mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 292229 - Refactor the content assist test suite to make adding new flags easier
Change-Id: I06bd3590e037e0761a62c454dec497d3043e7e08
This commit is contained in:
parent
d9fd9df16e
commit
c5f3bbb55a
10 changed files with 86 additions and 87 deletions
|
@ -60,7 +60,14 @@ import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants;
|
||||||
|
|
||||||
public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
public static enum CompareType { ID, DISPLAY, REPLACEMENT, CONTEXT, INFORMATION }
|
public static enum CompareType { ID, DISPLAY, REPLACEMENT, CONTEXT, INFORMATION }
|
||||||
|
|
||||||
|
protected final static int IS_COMPLETION = 0x01;
|
||||||
|
protected final static int IS_TEMPLATE = 0x02;
|
||||||
|
protected final static int FILTER_RESULTS = 0x04;
|
||||||
|
protected final static int ALLOW_EXTRA_RESULTS = 0x08;
|
||||||
|
|
||||||
|
protected final static int DEFAULT_FLAGS = FILTER_RESULTS;
|
||||||
|
|
||||||
protected class ContentAssistResult {
|
protected class ContentAssistResult {
|
||||||
long startTime;
|
long startTime;
|
||||||
long endTime;
|
long endTime;
|
||||||
|
@ -158,8 +165,13 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
return new ContentAssistResult(startTime, endTime, results);
|
return new ContentAssistResult(startTime, endTime, results);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertContentAssistResults(int offset, int length, String[] expected, boolean isCompletion,
|
protected void assertContentAssistResults(int offset, int length, String[] expected, int flags,
|
||||||
boolean isTemplate, boolean filterResults, CompareType compareType) throws Exception {
|
CompareType compareType) throws Exception {
|
||||||
|
boolean isCompletion = (flags & IS_COMPLETION) != 0;
|
||||||
|
boolean isTemplate = (flags & IS_TEMPLATE) != 0;
|
||||||
|
boolean filterResults = (flags & FILTER_RESULTS) != 0;
|
||||||
|
boolean allowExtraResults = (flags & ALLOW_EXTRA_RESULTS) != 0;
|
||||||
|
|
||||||
ContentAssistResult r = invokeContentAssist(offset, length, isCompletion, isTemplate, filterResults);
|
ContentAssistResult r = invokeContentAssist(offset, length, isCompletion, isTemplate, filterResults);
|
||||||
|
|
||||||
String[] resultStrings= toStringArray(r.results, compareType);
|
String[] resultStrings= toStringArray(r.results, compareType);
|
||||||
|
@ -196,14 +208,17 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
|
|
||||||
if (!allFound) {
|
if (!allFound) {
|
||||||
assertEquals("Missing results!", toString(expected), toString(resultStrings));
|
assertEquals("Missing results!", toString(expected), toString(resultStrings));
|
||||||
} else if (doCheckExtraResults()) {
|
} else if (!allowExtraResults) {
|
||||||
assertEquals("Extra results!", toString(expected), toString(resultStrings));
|
assertEquals("Extra results!", toString(expected), toString(resultStrings));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertContentAssistResults(int offset, int length, Map<String, String[][]> expected,
|
protected void assertContentAssistResults(int offset, int length, Map<String, String[][]> expected,
|
||||||
boolean isCompletion, boolean isTemplate, boolean filterResults, CompareType compareType)
|
int flags, CompareType compareType)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
boolean isCompletion = (flags & IS_COMPLETION) != 0;
|
||||||
|
boolean isTemplate = (flags & IS_TEMPLATE) != 0;
|
||||||
|
boolean filterResults = (flags & FILTER_RESULTS) != 0;
|
||||||
ContentAssistResult r = invokeContentAssist(offset, length, isCompletion, isTemplate, filterResults);
|
ContentAssistResult r = invokeContentAssist(offset, length, isCompletion, isTemplate, filterResults);
|
||||||
Map<String, String[][]> resultMap = toMap(r.results, compareType);
|
Map<String, String[][]> resultMap = toMap(r.results, compareType);
|
||||||
|
|
||||||
|
@ -272,16 +287,11 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
return resultsMap;
|
return resultsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertContentAssistResults(int offset, int length, String[] expected, boolean isCompletion,
|
protected void assertContentAssistResults(int offset, String[] expected,
|
||||||
boolean isTemplate, CompareType compareType) throws Exception {
|
int flags, CompareType compareType) throws Exception {
|
||||||
assertContentAssistResults(offset, length, expected, isCompletion, isTemplate, true, compareType);
|
assertContentAssistResults(offset, 0, expected, flags, compareType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertContentAssistResults(int offset, String[] expected, boolean isCompletion,
|
|
||||||
CompareType compareType) throws Exception {
|
|
||||||
assertContentAssistResults(offset, 0, expected, isCompletion, false, compareType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter out template and keyword proposals.
|
* Filter out template and keyword proposals.
|
||||||
*
|
*
|
||||||
|
@ -380,13 +390,6 @@ public abstract class AbstractContentAssistTest extends BaseUITestCase {
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Override to relax checking of extra results
|
|
||||||
*/
|
|
||||||
protected boolean doCheckExtraResults() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the content of the editor buffer
|
* Returns the content of the editor buffer
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -56,11 +56,12 @@ public class CPPParameterGuessingTests extends AbstractContentAssistTest {
|
||||||
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
||||||
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = IS_COMPLETION;
|
||||||
|
|
||||||
protected void assertParametersGuesses(Map<String, String[][]> expected)
|
protected void assertParametersGuesses(Map<String, String[][]> expected)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
assertContentAssistResults(getBuffer().length() - 1, 0, expected, true,
|
assertContentAssistResults(getBuffer().length() - 1, 0, expected, DEFAULT_FLAGS, CompareType.REPLACEMENT);
|
||||||
false, false, CompareType.REPLACEMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(){
|
// void foo(){
|
||||||
|
|
|
@ -50,10 +50,11 @@ public class CParameterGuessingTests extends AbstractContentAssistTest {
|
||||||
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
||||||
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = IS_COMPLETION;
|
||||||
|
|
||||||
protected void assertParametersGuesses(Map<String, String[][]> expected) throws Exception {
|
protected void assertParametersGuesses(Map<String, String[][]> expected) throws Exception {
|
||||||
assertContentAssistResults(getBuffer().length() - 1, 0, expected, true, false, false,
|
assertContentAssistResults(getBuffer().length() - 1, 0, expected, DEFAULT_FLAGS, CompareType.REPLACEMENT);
|
||||||
CompareType.REPLACEMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo(){
|
// void foo(){
|
||||||
|
|
|
@ -89,8 +89,10 @@ public abstract class CompletionProposalsBaseTest extends AbstractContentAssistT
|
||||||
return bodyFile;
|
return bodyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected final static int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION;
|
||||||
|
|
||||||
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
||||||
assertContentAssistResults(offset, expected, true, compareType);
|
assertContentAssistResults(offset, expected, DEFAULT_FLAGS, compareType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompletionProposals() throws Exception {
|
public void testCompletionProposals() throws Exception {
|
||||||
|
|
|
@ -22,7 +22,6 @@ public class CompletionTestBase extends AbstractContentAssistTest {
|
||||||
private static final String CURSOR_LOCATION_TAG = "/*cursor*/";
|
private static final String CURSOR_LOCATION_TAG = "/*cursor*/";
|
||||||
|
|
||||||
protected int fCursorOffset;
|
protected int fCursorOffset;
|
||||||
private boolean fCheckExtraResults= true;
|
|
||||||
protected IProject fProject;
|
protected IProject fProject;
|
||||||
|
|
||||||
public CompletionTestBase(String name) {
|
public CompletionTestBase(String name) {
|
||||||
|
@ -44,30 +43,15 @@ public class CompletionTestBase extends AbstractContentAssistTest {
|
||||||
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
assertNotNull(createFile(project, HEADER_FILE_NAME, headerContent));
|
||||||
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
return createFile(project, SOURCE_FILE_NAME, sourceContent.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION;
|
||||||
|
|
||||||
/*
|
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
||||||
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest#doCheckExtraResults()
|
assertContentAssistResults(offset, expected, DEFAULT_FLAGS, compareType);
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected boolean doCheckExtraResults() {
|
|
||||||
return fCheckExtraResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setCheckExtraResults(boolean check) {
|
|
||||||
fCheckExtraResults= check;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertMinimumCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
protected void assertMinimumCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
||||||
setCheckExtraResults(false);
|
assertContentAssistResults(offset, expected, DEFAULT_FLAGS | ALLOW_EXTRA_RESULTS, compareType);
|
||||||
try {
|
|
||||||
assertCompletionResults(offset, expected, compareType);
|
|
||||||
} finally {
|
|
||||||
setCheckExtraResults(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
|
||||||
assertContentAssistResults(offset, expected, true, compareType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertCompletionResults(String[] expected) throws Exception {
|
protected void assertCompletionResults(String[] expected) throws Exception {
|
||||||
|
@ -75,7 +59,7 @@ public class CompletionTestBase extends AbstractContentAssistTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertParameterHint(String[] expected) throws Exception {
|
protected void assertParameterHint(String[] expected) throws Exception {
|
||||||
assertContentAssistResults(fCursorOffset, expected, false, CONTEXT);
|
assertContentAssistResults(fCursorOffset, expected, AbstractContentAssistTest.DEFAULT_FLAGS, CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertDotReplacedWithArrow() throws Exception {
|
protected void assertDotReplacedWithArrow() throws Exception {
|
||||||
|
|
|
@ -624,7 +624,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// }
|
// }
|
||||||
public void testAliasTemplate_418479() throws Exception {
|
public void testAliasTemplate_418479() throws Exception {
|
||||||
final String[] expected = { "D", "E" };
|
final String[] expected = { "D", "E" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//using namespace ns;void gfunc(){NSC/*cursor*/
|
//using namespace ns;void gfunc(){NSC/*cursor*/
|
||||||
|
@ -1212,9 +1212,9 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// Waldo::~/*cursor*/
|
// Waldo::~/*cursor*/
|
||||||
public void testDestructorDefinition_456293() throws Exception {
|
public void testDestructorDefinition_456293() throws Exception {
|
||||||
final String[] expectedDisplay = { "~Waldo(void)" };
|
final String[] expectedDisplay = { "~Waldo(void)" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
final String[] expectedReplacement = { "Waldo" };
|
final String[] expectedReplacement = { "Waldo" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedReplacement, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expectedReplacement, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <typename T> struct vector {
|
// template <typename T> struct vector {
|
||||||
|
@ -1294,7 +1294,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// template <typen/*cursor*/
|
// template <typen/*cursor*/
|
||||||
public void testTemplateDeclaration_397288() throws Exception {
|
public void testTemplateDeclaration_397288() throws Exception {
|
||||||
final String[] expected= { "typename" };
|
final String[] expected= { "typename" };
|
||||||
assertContentAssistResults(fCursorOffset, 0, expected, true, false, false, REPLACEMENT);
|
assertContentAssistResults(fCursorOffset, expected, IS_COMPLETION, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// class Base {
|
// class Base {
|
||||||
|
@ -1314,7 +1314,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// };
|
// };
|
||||||
public void testShadowingBaseClassMember_407807() throws Exception {
|
public void testShadowingBaseClassMember_407807() throws Exception {
|
||||||
final String[] expected = { "Cat", "meow(void)" };
|
final String[] expected = { "Cat", "meow(void)" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct Cat {
|
// struct Cat {
|
||||||
|
@ -1334,7 +1334,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// }
|
// }
|
||||||
public void testPreprocessorProvidedMacro_412463() throws Exception {
|
public void testPreprocessorProvidedMacro_412463() throws Exception {
|
||||||
final String[] expected = { "Cat", "meow(void)" };
|
final String[] expected = { "Cat", "meow(void)" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct Cat {
|
// struct Cat {
|
||||||
|
@ -1352,14 +1352,14 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// int x = __CDT_PARSER__;
|
// int x = __CDT_PARSER__;
|
||||||
public void testPredefinedMacro_412463() throws Exception {
|
public void testPredefinedMacro_412463() throws Exception {
|
||||||
final String[] expected = { "Cat", "meow(void)" };
|
final String[] expected = { "Cat", "meow(void)" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void foo() { Spec/*cursor*/
|
// void foo() { Spec/*cursor*/
|
||||||
public void testTemplateSpecialization() throws Exception {
|
public void testTemplateSpecialization() throws Exception {
|
||||||
setCommaAfterFunctionParameter(CCorePlugin.INSERT);
|
setCommaAfterFunctionParameter(CCorePlugin.INSERT);
|
||||||
final String[] expected = { "Specialization<typename T1, typename T2>" };
|
final String[] expected = { "Specialization<typename T1, typename T2>" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expected, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct Wrapper {
|
// struct Wrapper {
|
||||||
|
@ -1374,7 +1374,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// };
|
// };
|
||||||
public void testTemplateInstanceMemberAccess_459047() throws Exception {
|
public void testTemplateInstanceMemberAccess_459047() throws Exception {
|
||||||
final String[] expected = { "test(void)" };
|
final String[] expected = { "test(void)" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <int T>
|
// template <int T>
|
||||||
|
@ -1393,7 +1393,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// A<0>::AA<0>::Type<B>::/*cursor*/
|
// A<0>::AA<0>::Type<B>::/*cursor*/
|
||||||
public void testNestedTemplateSpecialization_460341() throws Exception {
|
public void testNestedTemplateSpecialization_460341() throws Exception {
|
||||||
final String[] expected = { "i" };
|
final String[] expected = { "i" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, ID);
|
assertCompletionResults(fCursorOffset, expected, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template <typename T>
|
// template <typename T>
|
||||||
|
@ -1417,7 +1417,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
public void testTemplateArgumentList() throws Exception {
|
public void testTemplateArgumentList() throws Exception {
|
||||||
setCommaAfterFunctionParameter(CCorePlugin.INSERT);
|
setCommaAfterFunctionParameter(CCorePlugin.INSERT);
|
||||||
final String[] expected = { "Specialization<typename T1, typename T2>" };
|
final String[] expected = { "Specialization<typename T1, typename T2>" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expected, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T,typename U>
|
// template<typename T,typename U>
|
||||||
|
@ -1436,14 +1436,14 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// class TestTemplateSelfReference : TestTemplate<T,U>::/*cursor*/
|
// class TestTemplateSelfReference : TestTemplate<T,U>::/*cursor*/
|
||||||
public void testTemplateSelfReference_bug456101() throws Exception {
|
public void testTemplateSelfReference_bug456101() throws Exception {
|
||||||
final String[] expected = { "NestedClass" };
|
final String[] expected = { "NestedClass" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expected, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
// class TestTemplateSelfReference : TClass<T>::/*cursor*/
|
// class TestTemplateSelfReference : TClass<T>::/*cursor*/
|
||||||
public void testTemplateSelfReferencePDOM_bug456101() throws Exception {
|
public void testTemplateSelfReferencePDOM_bug456101() throws Exception {
|
||||||
final String[] expected = { "NestedClass" };
|
final String[] expected = { "NestedClass" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expected, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace N {
|
// namespace N {
|
||||||
|
@ -1452,9 +1452,9 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// using N::fo/*cursor*/;
|
// using N::fo/*cursor*/;
|
||||||
public void testUsingCompletionWithFollowingSemicolon() throws Exception {
|
public void testUsingCompletionWithFollowingSemicolon() throws Exception {
|
||||||
final String[] expected = { "foo" };
|
final String[] expected = { "foo" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
|
||||||
final String[] expectedInformation = { "null" };
|
final String[] expectedInformation = { "null" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedInformation, true, CONTEXT);
|
assertCompletionResults(fCursorOffset, expectedInformation, CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace N {
|
// namespace N {
|
||||||
|
@ -1463,7 +1463,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// using N::Tp/*cursor*/;
|
// using N::Tp/*cursor*/;
|
||||||
public void testUsingCompletionWithoutTemplateArguments() throws Exception {
|
public void testUsingCompletionWithoutTemplateArguments() throws Exception {
|
||||||
final String[] expected = { "Tpl" };
|
final String[] expected = { "Tpl" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// namespace N {
|
// namespace N {
|
||||||
|
@ -1472,13 +1472,13 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
// using N::Tp/*cursor*/
|
// using N::Tp/*cursor*/
|
||||||
public void testUsingCompletionWithoutTemplateArgumentsButSemicolon() throws Exception {
|
public void testUsingCompletionWithoutTemplateArgumentsButSemicolon() throws Exception {
|
||||||
final String[] expected = { "Tpl;" };
|
final String[] expected = { "Tpl;" };
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expected, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// using Alias = C/*cursor*/
|
// using Alias = C/*cursor*/
|
||||||
public void testAliasDeclarationCompletion() throws Exception {
|
public void testAliasDeclarationCompletion() throws Exception {
|
||||||
final String[] expectedID = { "C1", "C2", "C3" };
|
final String[] expectedID = { "C1", "C2", "C3" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedID, true, ID);
|
assertCompletionResults(fCursorOffset, expectedID, ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void default_argument(int i = 23) {
|
// void default_argument(int i = 23) {
|
||||||
|
@ -1488,9 +1488,9 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(true);
|
setDisplayDefaultedParameters(true);
|
||||||
setDisplayDefaultArguments(true);
|
setDisplayDefaultArguments(true);
|
||||||
final String[] expectedDisplay = { "default_argument(int i = 23) : void" };
|
final String[] expectedDisplay = { "default_argument(int i = 23) : void" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
final String[] expectedReplacement = { "default_argument(i)" };
|
final String[] expectedReplacement = { "default_argument(i)" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedReplacement, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expectedReplacement, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void default_argument(int i = 23) {
|
// void default_argument(int i = 23) {
|
||||||
|
@ -1500,7 +1500,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(true);
|
setDisplayDefaultedParameters(true);
|
||||||
setDisplayDefaultArguments(false);
|
setDisplayDefaultArguments(false);
|
||||||
final String[] expectedDisplay = { "default_argument(int i) : void" };
|
final String[] expectedDisplay = { "default_argument(int i) : void" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void default_argument(int i = 23) {
|
// void default_argument(int i = 23) {
|
||||||
|
@ -1510,7 +1510,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(false);
|
setDisplayDefaultedParameters(false);
|
||||||
setDisplayDefaultArguments(false);
|
setDisplayDefaultArguments(false);
|
||||||
final String[] expectedDisplay = { "default_argument() : void" };
|
final String[] expectedDisplay = { "default_argument() : void" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T = int>
|
// template<typename T = int>
|
||||||
|
@ -1520,9 +1520,9 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(true);
|
setDisplayDefaultedParameters(true);
|
||||||
setDisplayDefaultArguments(true);
|
setDisplayDefaultArguments(true);
|
||||||
final String[] expectedDisplay = { "default_argument<typename T = int>" };
|
final String[] expectedDisplay = { "default_argument<typename T = int>" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
final String[] expectedReplacement = { "default_argument<>" };
|
final String[] expectedReplacement = { "default_argument<>" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedReplacement, true, REPLACEMENT);
|
assertCompletionResults(fCursorOffset, expectedReplacement, REPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T = int>
|
// template<typename T = int>
|
||||||
|
@ -1532,7 +1532,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(true);
|
setDisplayDefaultedParameters(true);
|
||||||
setDisplayDefaultArguments(false);
|
setDisplayDefaultArguments(false);
|
||||||
final String[] expectedDisplay = { "default_argument<typename T>" };
|
final String[] expectedDisplay = { "default_argument<typename T>" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T = int>
|
// template<typename T = int>
|
||||||
|
@ -1542,7 +1542,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(false);
|
setDisplayDefaultedParameters(false);
|
||||||
setDisplayDefaultArguments(false);
|
setDisplayDefaultArguments(false);
|
||||||
final String[] expectedDisplay = { "default_argument<>" };
|
final String[] expectedDisplay = { "default_argument<>" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// template<typename T>
|
// template<typename T>
|
||||||
|
@ -1554,7 +1554,7 @@ public class CompletionTests extends CompletionTestBase {
|
||||||
setDisplayDefaultedParameters(true);
|
setDisplayDefaultedParameters(true);
|
||||||
setDisplayDefaultArguments(true);
|
setDisplayDefaultArguments(true);
|
||||||
final String[] expectedDisplay = { "other_tpl<typename T1, typename T2 = tpl<T1>>" };
|
final String[] expectedDisplay = { "other_tpl<typename T1, typename T2 = tpl<T1>>" };
|
||||||
assertContentAssistResults(fCursorOffset, expectedDisplay, true, DISPLAY);
|
assertCompletionResults(fCursorOffset, expectedDisplay, DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
// struct A {
|
// struct A {
|
||||||
|
|
|
@ -185,8 +185,10 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
|
||||||
return sourceFile;
|
return sourceFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION;
|
||||||
|
|
||||||
protected void assertCompletionResults(String[] expected) throws Exception {
|
protected void assertCompletionResults(String[] expected) throws Exception {
|
||||||
assertContentAssistResults(fCursorOffset, expected, true, CompareType.ID);
|
assertContentAssistResults(fCursorOffset, expected, DEFAULT_FLAGS, CompareType.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void test() {
|
//void test() {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class ParameterHintTests extends AbstractContentAssistTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertParameterHints(String[] expected) throws Exception {
|
protected void assertParameterHints(String[] expected) throws Exception {
|
||||||
assertContentAssistResults(getBuffer().length() - 1, expected, false, CompareType.CONTEXT);
|
assertContentAssistResults(getBuffer().length() - 1, expected, DEFAULT_FLAGS, CompareType.CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void foo(){aFunc(
|
//void foo(){aFunc(
|
||||||
|
|
|
@ -65,9 +65,11 @@ public class ShowCamelCasePreferenceTest extends AbstractContentAssistTest {
|
||||||
ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES);
|
ContentAssistPreference.SHOW_CAMEL_CASE_MATCHES);
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION;
|
||||||
|
|
||||||
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
protected void assertCompletionResults(int offset, String[] expected, CompareType compareType) throws Exception {
|
||||||
assertContentAssistResults(offset, expected, true, compareType);
|
assertContentAssistResults(offset, expected, DEFAULT_FLAGS, compareType);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertCompletionResults(String[] expected) throws Exception {
|
protected void assertCompletionResults(String[] expected) throws Exception {
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.eclipse.jface.text.templates.persistence.TemplateStore;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.tests.text.contentassist2.AbstractContentAssistTest.CompareType;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
import org.eclipse.cdt.internal.corext.template.c.CContextType;
|
||||||
|
|
||||||
|
@ -102,8 +103,11 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
CUIPlugin.getDefault().getTemplateStore().add(data);
|
CUIPlugin.getDefault().getTemplateStore().add(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static final int DEFAULT_FLAGS = AbstractContentAssistTest.DEFAULT_FLAGS | IS_COMPLETION | IS_TEMPLATE;
|
||||||
|
|
||||||
|
protected void assertCompletionResults(String[] expected) throws Exception {
|
||||||
|
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, DEFAULT_FLAGS, CompareType.ID);
|
||||||
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
///*sel-start*/test foo bar/*sel-end*/
|
///*sel-start*/test foo bar/*sel-end*/
|
||||||
|
@ -114,7 +118,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP
|
TEMPLATE_NAME_LINE_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -127,7 +131,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP
|
TEMPLATE_NAME_LINE_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -139,7 +143,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_WORD_SELECTION_DISP
|
TEMPLATE_NAME_WORD_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -151,7 +155,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_WORD_SELECTION_DISP
|
TEMPLATE_NAME_WORD_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -164,7 +168,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_WORD_SELECTION_DISP
|
TEMPLATE_NAME_WORD_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -175,7 +179,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP
|
TEMPLATE_NAME_LINE_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -188,7 +192,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
final String[] expected= {
|
final String[] expected= {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP
|
TEMPLATE_NAME_LINE_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -201,7 +205,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP,
|
TEMPLATE_NAME_LINE_SELECTION_DISP,
|
||||||
TEMPLATE_NAME_WORD_SELECTION_DISP
|
TEMPLATE_NAME_WORD_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
//void func() {
|
//void func() {
|
||||||
|
@ -214,7 +218,7 @@ public class TemplateProposalTest extends AbstractContentAssistTest {
|
||||||
TEMPLATE_NAME_LINE_SELECTION_DISP,
|
TEMPLATE_NAME_LINE_SELECTION_DISP,
|
||||||
TEMPLATE_NAME_WORD_SELECTION_DISP
|
TEMPLATE_NAME_WORD_SELECTION_DISP
|
||||||
};
|
};
|
||||||
assertContentAssistResults(fSelectionOffset, fSelectionLength, expected, true, true, CompareType.ID);
|
assertCompletionResults(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue