mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
a test for up/down arrows in autopopup
This commit is contained in:
+46
-1
@@ -16,9 +16,10 @@
|
||||
package com.intellij.codeInsight.completion
|
||||
|
||||
import com.intellij.codeInsight.lookup.Lookup
|
||||
import com.intellij.codeInsight.lookup.LookupManager
|
||||
import com.intellij.openapi.actionSystem.IdeActions
|
||||
import com.intellij.openapi.command.CommandProcessor
|
||||
import com.intellij.codeInsight.lookup.LookupManager
|
||||
import com.intellij.ide.ui.UISettings
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -388,4 +389,48 @@ class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
|
||||
assert !lookup
|
||||
}
|
||||
|
||||
void testArrow(boolean up, boolean cycleScrolling, boolean lookupAbove, int index) {
|
||||
myFixture.configureByText("a.java", """
|
||||
class A {
|
||||
{ ArrayIndexOutOfBoundsException <caret> }
|
||||
}
|
||||
""")
|
||||
|
||||
type 'o'
|
||||
assert lookup
|
||||
assert !lookup.focused
|
||||
assert lookup.items.size() == 2
|
||||
|
||||
UISettings.instance.CYCLE_SCROLLING = cycleScrolling
|
||||
|
||||
try {
|
||||
edt { myFixture.performEditorAction(up ? IdeActions.ACTION_EDITOR_MOVE_CARET_UP : IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN) }
|
||||
if (lookup) {
|
||||
assert lookup.focused
|
||||
assert index >= 0
|
||||
assert lookup.items[index] == lookup.currentItem
|
||||
edt { lookup.hide() }
|
||||
} else {
|
||||
assert index == -1
|
||||
}
|
||||
type '\b'
|
||||
}
|
||||
finally {
|
||||
UISettings.instance.CYCLE_SCROLLING = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void testArrows(boolean cycleScrolling, boolean lookupAbove, int indexDown, indexUp) {
|
||||
testArrow true, cycleScrolling, lookupAbove, indexUp
|
||||
testArrow false, cycleScrolling, lookupAbove, indexDown
|
||||
}
|
||||
|
||||
public void testVerticalArrows() {
|
||||
testArrows false, false, 0, -1
|
||||
testArrows false, true, 0, -1
|
||||
testArrows true, false, 0, 1
|
||||
testArrows true, true, 0, 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
int shiftLow = layeredPane.getHeight() - (layeredPanePoint.y + dim.height);
|
||||
int shiftHigh = layeredPanePoint.y - dim.height;
|
||||
if (!isPositionedAboveCaret()) {
|
||||
myPositionedAbove = shiftLow < 0 && shiftLow < shiftHigh ? Boolean.TRUE : Boolean.FALSE;
|
||||
myPositionedAbove = shiftLow < 0 && shiftLow < shiftHigh;
|
||||
}
|
||||
if (isPositionedAboveCaret()) {
|
||||
layeredPanePoint.y -= dim.height + myEditor.getLineHeight();
|
||||
@@ -927,6 +927,11 @@ public class LookupImpl extends LightweightHint implements Lookup, Disposable {
|
||||
return myEditor;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void setPositionedAbove(boolean positionedAbove) {
|
||||
myPositionedAbove = positionedAbove;
|
||||
}
|
||||
|
||||
public boolean isPositionedAboveCaret(){
|
||||
return myPositionedAbove != null && myPositionedAbove.booleanValue();
|
||||
}
|
||||
|
||||
+6
@@ -67,6 +67,7 @@ import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
import com.intellij.openapi.extensions.ExtensionPoint;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
@@ -1143,6 +1144,11 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
final File tempFile = FileUtil.createTempFile(new File(getTempDirPath()), prefix, "." + StringUtil.getShortName(fileName), true);
|
||||
vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempFile);
|
||||
}
|
||||
final Document document = FileDocumentManager.getInstance().getCachedDocument(vFile);
|
||||
if (document != null) {
|
||||
FileDocumentManager.getInstance().saveDocument(document);
|
||||
}
|
||||
|
||||
VfsUtil.saveText(vFile, text);
|
||||
configureInner(vFile, SelectionAndCaretMarkupLoader.fromFile(vFile, getProject()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user