From dad0cb33cd4e7c9e08d809c7af4ad04e71ff4c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norbert=20Pl=F6tt?= Date: Tue, 18 Jul 2006 10:25:38 +0000 Subject: [PATCH] More content assist tests, ported to CCompletionProcessor2 --- .../CompletionProposalsBaseTest.java | 2 +- .../CompletionTest_ConstructorReference.java | 103 ++++++++++++++++++ ...onTest_MemberReference_Arrow_NoPrefix.java | 95 ++++++++++++++++ .../CompletionTest_NamespaceRef_NoPrefix.java | 94 ++++++++++++++++ .../CompletionTest_NamespaceRef_Prefix.java | 94 ++++++++++++++++ ...pletionTest_NewTypeReference_NoPrefix.java | 93 ++++++++++++++++ ...mpletionTest_ScopedReference_NoPrefix.java | 93 ++++++++++++++++ ...tionTest_ScopedReference_NonCodeScope.java | 99 +++++++++++++++++ ...CompletionTest_ScopedReference_Prefix.java | 96 ++++++++++++++++ .../CompletionTest_TypeDef_NoPrefix.java | 96 ++++++++++++++++ .../CompletionTest_TypeDef_Prefix.java | 96 ++++++++++++++++ ...pletionTest_VariableType_NestedPrefix.java | 99 +++++++++++++++++ 12 files changed, 1059 insertions(+), 1 deletion(-) create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java create mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionProposalsBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionProposalsBaseTest.java index 19600cc66da..388f3cb314a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionProposalsBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionProposalsBaseTest.java @@ -139,7 +139,7 @@ public abstract class CompletionProposalsBaseTest extends TestCase{ // check the completion node ASTCompletionNode currentCompletionNode = completionProcessor.getCurrentCompletionNode(); - assertNotNull(currentCompletionNode); + assertNotNull("null completion node!", currentCompletionNode); IASTName[] names = currentCompletionNode.getNames(); IASTName currentName = names[0]; IBinding binding = currentName.getBinding(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java new file mode 100644 index 00000000000..1230a16c875 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ConstructorReference.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + + + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * @author hamer + * + * Testing Constructor_Reference + * Bug# + * + */ +public class CompletionTest_ConstructorReference extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart35.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "xOtherClass(char*)", + "xOtherClass(int)" + }; + + public CompletionTest_ConstructorReference(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_ConstructorReference.class.getName()); + suite.addTest(new CompletionTest_ConstructorReference("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("( ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.ui.tests.text.contentassist.CompletionProposalsBaseTest#getFunctionOrConstructorName() + */ + protected String getFunctionOrConstructorName() { + return "xOtherClass"; + } + +} + diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java new file mode 100644 index 00000000000..03ec25c80d8 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_MemberReference_Arrow_NoPrefix.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Member_Reference, with NO prefix + * After an -> + * + */ + +public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionProposalsBaseTest{ + private final String fileName = "CompletionTestStart10.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "aField : int", + "xAClassField : float", + "aMethod(void) int", + "xAClassMethod(int x) void" + }; + + public CompletionTest_MemberReference_Arrow_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_MemberReference_Arrow_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_MemberReference_Arrow_NoPrefix("testCompletionProposals")); + return suite; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(" c-> ") + 4; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java new file mode 100644 index 00000000000..de3b6c2a296 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_NoPrefix.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Namespace_Reference, with no prefix + * Bug#50471 : Wrong completion kind after the "using" keyword + * + */ +public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart32.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "aNamespace", + "xNamespace" + }; + + public CompletionTest_NamespaceRef_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_NamespaceRef_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_NamespaceRef_NoPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("namespace ") + 10; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java new file mode 100644 index 00000000000..376eb110488 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NamespaceRef_Prefix.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Namespace_Reference, with prefix + * Bug#50471 : Wrong completion kind after the "using" keyword + * + */ +public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart33.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = "a"; + private final String[] expectedResults = { + "aNamespace" + }; + + public CompletionTest_NamespaceRef_Prefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_NamespaceRef_Prefix.class.getName()); + suite.addTest(new CompletionTest_NamespaceRef_Prefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("namespace a ") + 11; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java new file mode 100644 index 00000000000..7db5b336f7b --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_NewTypeReference_NoPrefix.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Class_Reference, with prefix + * Bug#50711 : Wrong completion kind in a new expression + * + */ +public class CompletionTest_NewTypeReference_NoPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart29.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + }; + + public CompletionTest_NewTypeReference_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_NewTypeReference_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_NewTypeReference_NoPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(" ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java new file mode 100644 index 00000000000..08f10b7d827 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NoPrefix.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Scoped_Reference, with no prefix + * Bug#50152: Wrong context sent after a "::" + * + */ +public class CompletionTest_ScopedReference_NoPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart30.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "aNamespaceFunction(void) void" + }; + + public CompletionTest_ScopedReference_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_ScopedReference_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_ScopedReference_NoPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(":: ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java new file mode 100644 index 00000000000..d6801fa34a6 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_NonCodeScope.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Scoped_Reference, with no prefix + * Bug#50152: Wrong context sent after a "::" + * + */ +public class CompletionTest_ScopedReference_NonCodeScope extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart39.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "Foo", + "x : int", + "bar(void) void", + "fum(void) void" + }; + /* FIXME: Unexpected results; run with tracing to reproduce +Result: y : int + */ + + public CompletionTest_ScopedReference_NonCodeScope(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_ScopedReference_NonCodeScope.class.getName()); + suite.addTest(new CompletionTest_ScopedReference_NonCodeScope("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(":: ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java new file mode 100644 index 00000000000..0e10a247041 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_ScopedReference_Prefix.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Scoped_Reference, with a prefix + * Bug#50152: Wrong context sent after a "::" + * + */ +public class CompletionTest_ScopedReference_Prefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart31.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = "a"; + private final String[] expectedResults = { + "aNamespaceFunction(void) void" + }; + /* FIXME: Addtional result which should not be there. Run with tracing to reproduce: +Result: author - author name + */ + + public CompletionTest_ScopedReference_Prefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_ScopedReference_Prefix.class.getName()); + suite.addTest(new CompletionTest_ScopedReference_Prefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf("::a ") + 3; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java new file mode 100644 index 00000000000..cd9b55302a4 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_NoPrefix.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + + + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Typedef as a possible returned type. + * Bug#52948 + * + */ +public class CompletionTest_TypeDef_NoPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart37.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = "m"; + private final String[] expectedResults = { + "myType" + }; + + public CompletionTest_TypeDef_NoPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_TypeDef_NoPrefix.class.getName()); + suite.addTest(new CompletionTest_TypeDef_NoPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(" m ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java new file mode 100644 index 00000000000..32edfafd8a5 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_TypeDef_Prefix.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; + + + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Typedef as a possible returned type. + * Bug#52948 + * + */ +public class CompletionTest_TypeDef_Prefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart37.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = "m"; + private final String[] expectedResults = { + "myType" + }; + + public CompletionTest_TypeDef_Prefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_TypeDef_Prefix.class.getName()); + suite.addTest(new CompletionTest_TypeDef_Prefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(" m ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java new file mode 100644 index 00000000000..24c790ef5ad --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_VariableType_NestedPrefix.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004, 2006 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Rational Software - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.ui.tests.text.contentassist2; +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.parser.ast.IASTCompletionNode.CompletionKind; + +/** + * @author hamer + * + * Testing Scoped_Reference, with no prefix + * Bug#50152: Wrong context sent after a "::" + * + */ +public class CompletionTest_VariableType_NestedPrefix extends CompletionProposalsBaseTest{ + + private final String fileName = "CompletionTestStart38.cpp"; + private final String fileFullPath ="resources/contentassist/" + fileName; + private final String headerFileName = "CompletionTestStart.h"; + private final String headerFileFullPath ="resources/contentassist/" + headerFileName; + private final String expectedPrefix = ""; + private final String[] expectedResults = { + "Foo", + "DEF", + "bar(void) void", + "fum(void) void", + "x : int" + }; +/* FIXME: Unexpected result. Rerun with tracing to reproduce +Result: y : int + */ + public CompletionTest_VariableType_NestedPrefix(String name) { + super(name); + } + + public static Test suite() { + TestSuite suite= new TestSuite(CompletionTest_VariableType_NestedPrefix.class.getName()); + suite.addTest(new CompletionTest_VariableType_NestedPrefix("testCompletionProposals")); + return suite; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition() + */ + protected int getCompletionPosition() { + return getBuffer().indexOf(":: ") + 2; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedPrefix() + */ + protected String getExpectedPrefix() { + return expectedPrefix; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getExpectedResultsValues() + */ + protected String[] getExpectedResultsValues() { + return expectedResults; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileName() + */ + protected String getFileName() { + return fileName; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getFileFullPath() + */ + protected String getFileFullPath() { + return fileFullPath; + } + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileFullPath() + */ + protected String getHeaderFileFullPath() { + return headerFileFullPath; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getHeaderFileName() + */ + protected String getHeaderFileName() { + return headerFileName; + } + +}