Files
openide/java/java-tests/testSrc/com/intellij/codeInsight/completion/JavaAutoPopupTest.groovy
2010-10-28 21:19:35 +04:00

100 lines
2.7 KiB
Groovy

/*
* Copyright 2000-2010 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.completion
/**
* @author peter
*/
class JavaAutoPopupTest extends CompletionAutoPopupTestCase {
public void testNewItemsOnLongerPrefix() {
myFixture.configureByText("a.java", """
class Foo {
void foo(String iterable) {
<caret>
}
}
""")
type('i')
assertSameElements myFixture.lookupElementStrings, "if", "iterable", "int"
type('t')
assertOrderedEquals myFixture.lookupElementStrings, "iterable"
type('er')
assertOrderedEquals myFixture.lookupElementStrings, "iter", "iterable"
}
public void testRecalculateItemsOnBackspace() {
myFixture.configureByText("a.java", """
class Foo {
void foo(String iterable) {
int itaa;
ite<caret>
}
}
""")
type "r"
assertOrderedEquals myFixture.lookupElementStrings, "iter", "iterable"
type '\b'
assertOrderedEquals myFixture.lookupElementStrings, "iterable"
type '\b'
assertOrderedEquals myFixture.lookupElementStrings, "itaa", "iterable"
type "a"
assertOrderedEquals myFixture.lookupElementStrings, "itaa"
type '\b'
assertOrderedEquals myFixture.lookupElementStrings, "itaa", "iterable"
type "e"
assertOrderedEquals myFixture.lookupElementStrings, "iterable"
type "r"
assertOrderedEquals myFixture.lookupElementStrings, "iter", "iterable"
}
public void testNoAutopopupInTheMiddleOfIdentifier() {
myFixture.configureByText("a.java", """
class Foo {
String foo(String iterable) {
return it<caret>rable;
}
}
""")
type 'e'
assertNull lookup
}
public void testGenerallyFocusLookupInJavaMethod() {
myFixture.configureByText("a.java", """
class Foo {
String foo(String iterable) {
return it<caret>;
}
}
""")
type 'e'
assertTrue lookup.focused
}
public void testNoLookupFocusInJavaVariable() {
myFixture.configureByText("a.java", """
class Foo {
String foo(String st<caret>) {
}
}
""")
type 'r'
assertFalse lookup.focused
}
}