1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Reworked contentassist2 test cases and add them to the automated suite

This commit is contained in:
Anton Leherbauer 2007-01-09 10:39:05 +00:00
parent c94c4ae67a
commit 00cf81d291
41 changed files with 415 additions and 242 deletions

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.ui.tests.callhierarchy.CallHierarchyTestSuite;
import org.eclipse.cdt.ui.tests.includebrowser.IncludeBrowserTestSuite;
import org.eclipse.cdt.ui.tests.text.TextTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite;
import org.eclipse.cdt.ui.tests.text.selection.SelectionTestSuite;
import org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite;
@ -56,12 +57,12 @@ public class AutomatedSuite extends TestSuite {
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist
addTest(ContentAssistTestSuite.suite());
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist2
addTest(ContentAssist2TestSuite.suite());
// tests from the refactoring plugin
addTest(RenameRegressionTests.suite());
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist2
// commented out because they are failing pretty badly
// addTest(ContentAssist2TestSuite.suite());
// tests from package org.eclipse.cdt.ui.tests.text.selection
addTest(SelectionTestSuite.suite());
}

View file

@ -8,7 +8,6 @@
* Contributors:
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests;
import java.io.IOException;
@ -30,8 +29,6 @@ import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
public class BaseUITestCase extends BaseTestCase {
private boolean fExpectFailure= false;
private int fBugnumber= 0;
public BaseUITestCase() {
super();

View file

@ -0,0 +1,218 @@
/*******************************************************************************
* 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
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.templates.TemplateProposal;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.KeywordSetKey;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.ui.tests.text.EditorTestHelper;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
/**
*
* @since 4.0
*/
public abstract class AbstractCompletionTest extends BaseUITestCase {
private ICProject fCProject;
protected IFile fCFile;
private ITextEditor fEditor;
private final static Set fgAllKeywords= new HashSet();
static {
Set cKeywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.C);
Set cppKeywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
fgAllKeywords.addAll(cKeywords);
fgAllKeywords.addAll(cppKeywords);
}
public AbstractCompletionTest(String name) {
super(name);
}
protected void setUp() throws Exception {
super.setUp();
fCProject= CProjectHelper.createCCProject(getName(), "unused", IPDOMManager.ID_FAST_INDEXER);
fCFile= setUpProjectContent(fCProject.getProject());
assertNotNull(fCFile);
fEditor= (ITextEditor)EditorTestHelper.openInEditor(fCFile, true);
assertNotNull(fEditor);
EditorTestHelper.joinBackgroundActivities((AbstractTextEditor)fEditor);
}
/**
* Setup the project's content.
* @param project
* @return the file to be opened in the editor
* @throws Exception
*/
protected abstract IFile setUpProjectContent(IProject project) throws Exception;
protected void tearDown() throws Exception {
EditorTestHelper.closeEditor(fEditor);
fEditor= null;
CProjectHelper.delete(fCProject);
fCProject= null;
fCFile= null;
super.tearDown();
}
protected void assertCompletionResults(int offset, String[] expected, boolean compareIdString) throws Exception {
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("\n\n\n\n\nTesting "+this.getClass().getName());
}
CCompletionProcessor2 completionProcessor = new CCompletionProcessor2(fEditor);
// call the CompletionProcessor
ISourceViewer sourceViewer= EditorTestHelper.getSourceViewer((AbstractTextEditor)fEditor);
long startTime= System.currentTimeMillis();
ICompletionProposal[] results = completionProcessor.computeCompletionProposals(sourceViewer, offset);
long endTime= System.currentTimeMillis();
assertTrue(results != null);
results= filterProposals(results);
checkCompletionNode(completionProcessor.getCurrentCompletionNode());
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("Time (ms): " + (endTime-startTime));
for (int i = 0; i < results.length; i++) {
ICompletionProposal proposal = results[i];
System.out.println("Result: " + proposal.getDisplayString());
}
}
boolean allFound = true ; // for the time being, let's be optimistic
for (int i = 0; i< expected.length; i++){
boolean found = false;
for(int j = 0; j< results.length; j++){
ICompletionProposal proposal = results[j];
String displayString = proposal.getDisplayString();
if(expected[i].equals(displayString)){
found = true;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("Lookup success for " + expected[i]);
}
break;
}
}
if (!found) {
allFound = false ;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println( "Lookup failed for " + expected[i]); //$NON-NLS-1$
}
}
}
String[] resultStrings= toStringArray(results, compareIdString);
Arrays.sort(expected);
Arrays.sort(resultStrings);
if (!allFound) {
assertEquals("Missing results!", toString(expected), toString(resultStrings));
} else if (doCheckExtraResults()) {
assertEquals("Extra results!", toString(expected), toString(resultStrings));
}
}
/**
* Perform additional checks on the ASTCompletionNode.
*
* @param currentCompletionNode
*/
protected void checkCompletionNode(ASTCompletionNode currentCompletionNode) {
// no-op by default
}
private String toString(String[] strings) {
StringBuffer buf= new StringBuffer();
for(int i=0; i< strings.length; i++){
buf.append(strings[i]).append('\n');
}
return buf.toString();
}
private String[] toStringArray(ICompletionProposal[] proposals, boolean useIdString) {
String[] strings= new String[proposals.length];
for(int i=0; i< proposals.length; i++){
ICompletionProposal proposal = proposals[i];
if (proposal instanceof ICCompletionProposal && useIdString) {
strings[i]= ((ICCompletionProposal)proposal).getIdString();
} else {
strings[i]= proposal.getDisplayString();
}
}
return strings;
}
/**
* Override to relax checking of extra results
*/
protected boolean doCheckExtraResults() {
return true ;
}
/**
* Filter out template and keyword proposals.
* @param results
* @return filtered proposals
*/
private ICompletionProposal[] filterProposals(ICompletionProposal[] results) {
List filtered= new ArrayList();
for (int i = 0; i < results.length; i++) {
ICompletionProposal proposal = results[i];
if (proposal instanceof TemplateProposal) {
continue;
}
if (proposal instanceof ICCompletionProposal) {
// check for keywords proposal
if (fgAllKeywords.contains(proposal.getDisplayString())) {
continue;
}
}
filtered.add(proposal);
}
return (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
}
/**
* @return the content of the editor buffer
*/
protected String getBuffer() {
return EditorTestHelper.getDocument(fEditor).get();
}
}

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Rational Software - Initial API and implementation
* IBM Rational Software - Initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.ui.tests.text.contentassist2;
@ -17,199 +18,92 @@ package org.eclipse.cdt.ui.tests.text.contentassist2;
*
*/
import java.io.FileInputStream;
import junit.framework.TestCase;
import java.io.FileNotFoundException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
public abstract class CompletionProposalsBaseTest extends AbstractCompletionTest {
private boolean fFailingTest;
public abstract class CompletionProposalsBaseTest extends TestCase{
protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
private final String projectName = "TestProject1"; //$NON-NLS-1$
private final String projectType = "bin"; //$NON-NLS-1$
private ICProject fCProject;
private IFile fCFile;
private IFile fHeaderFile;
private NullProgressMonitor monitor;
private ITranslationUnit tu = null;
private String buffer = EMPTY_STRING;
private Document document = null;
public CompletionProposalsBaseTest(String name) {
super(name);
}
/*
* Derived classes have to provide these test parameters
* @see junit.framework.TestCase#getName()
*/
public String getName() {
if (fFailingTest) {
return "[Failing] " + super.getName();
}
return super.getName();
}
/*
* @see org.eclipse.cdt.core.testplugin.util.BaseTestCase#setExpectFailure(int)
*/
public void setExpectFailure(int bugnumber) {
super.setExpectFailure(bugnumber);
fFailingTest= true;
}
/*
* Derived classes have to provide the file locations
*/
protected abstract String getFileName();
protected abstract String getFileFullPath();
protected abstract String getHeaderFileName();
protected abstract String getHeaderFileFullPath();
/*
* Derived classes have to provide these test parameters
*/
protected abstract int getCompletionPosition();
protected abstract String getExpectedPrefix();
protected abstract String[] getExpectedResultsValues();
protected String getFunctionOrConstructorName() { return EMPTY_STRING; }
/**
* Override to relax checking of extra results
*/
protected boolean doCheckExtraResults() {
return true ;
}
protected void setUp() throws Exception {
monitor = new NullProgressMonitor();
fCProject= CProjectHelper.createCProject(projectName, projectType, IPDOMManager.ID_NO_INDEXER);
fHeaderFile = fCProject.getProject().getFile(getHeaderFileName());
protected IFile setUpProjectContent(IProject project) throws FileNotFoundException {
IFile headerFile = project.getFile(getHeaderFileName());
String fileName = getFileName();
fCFile = fCProject.getProject().getFile(fileName);
if ( (!fCFile.exists()) &&( !fHeaderFile.exists() )) {
IFile bodyFile = project.getFile(fileName);
if ( (!bodyFile.exists()) &&( !headerFile.exists() )) {
IProgressMonitor monitor= new NullProgressMonitor();
try{
FileInputStream headerFileIn = new FileInputStream(
CTestPlugin.getDefault().getFileInPlugin(new Path(getHeaderFileFullPath())));
fHeaderFile.create(headerFileIn,false, monitor);
headerFile.create(headerFileIn,false, monitor);
FileInputStream bodyFileIn = new FileInputStream(
CTestPlugin.getDefault().getFileInPlugin(new Path(getFileFullPath())));
fCFile.create(bodyFileIn,false, monitor);
bodyFile.create(bodyFileIn,false, monitor);
} catch (CoreException e) {
e.printStackTrace();
}
}
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
}
return bodyFile;
}
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures= description.getNatureIds();
String[] newNatures= new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= natureId;
description.setNatureIds(newNatures);
proj.setDescription(description, monitor);
}
protected void tearDown() {
CProjectHelper.delete(fCProject);
}
public void testCompletionProposals() throws Exception {
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("\n\n\n\n\nTesting "+this.getClass().getName());
}
// setup the translation unit, the buffer and the document
ITranslationUnit tu = (ITranslationUnit)CoreModel.getDefault().create(fCFile);
buffer = tu.getBuffer().getContents();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
FileEditorInput editorInput = new FileEditorInput(fCFile);
IEditorPart editorPart = page.openEditor(editorInput, "org.eclipse.cdt.ui.editor.CEditor");
CEditor editor = (CEditor) editorPart ;
IAction completionAction = editor.getAction("ContentAssistProposal");
CCompletionProcessor2 completionProcessor = new CCompletionProcessor2(editorPart);
// call the CompletionProcessor
ICompletionProposal[] results = completionProcessor.computeCompletionProposals(editor.getCSourceViewer(), getCompletionPosition()); // (document, pos, wc, null);
assertTrue(results != null);
if (CTestPlugin.getDefault().isDebugging()) {
for (int i = 0; i < results.length; i++) {
ICompletionProposal proposal = results[i];
System.out.println("Result: " + proposal.getDisplayString());
}
}
// check the completion node
ASTCompletionNode currentCompletionNode = completionProcessor.getCurrentCompletionNode();
assertNotNull("null completion node!", currentCompletionNode);
IASTName[] names = currentCompletionNode.getNames();
IASTName currentName = names[0];
IBinding binding = currentName.getBinding();
String prefix = currentCompletionNode.getPrefix();
assertEquals(getExpectedPrefix(), prefix);
String[] expected = getExpectedResultsValues();
String[] expected = getExpectedResultsValues();
assertCompletionResults(getCompletionPosition(), expected, false);
boolean allFound = true ; // for the time being, let's be optimistic
for (int i = 0; i< expected.length; i++){
boolean found = false;
for(int j = 0; j< results.length; j++){
ICompletionProposal proposal = results[j];
String displayString = proposal.getDisplayString();
if(expected[i].equals(displayString)){
found = true;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println("Lookup success for " + expected[i]);
}
break;
}
}
if (!found) {
allFound = false ;
if (CTestPlugin.getDefault().isDebugging()) {
System.out.println( "Lookup failed for " + expected[i]); //$NON-NLS-1$
}
}
}
assertTrue("Not enough results!", results.length >= expected.length);
if (doCheckExtraResults()) {
assertEquals("Extra results! Run with tracing to see details!", expected.length, results.length);
}
assertTrue("Some expected results were not found!", allFound);
}
}
/*
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractCompletionTest#checkCompletionNode(org.eclipse.cdt.core.dom.ast.ASTCompletionNode)
*/
protected void checkCompletionNode(ASTCompletionNode currentCompletionNode) {
assertNotNull("null completion node!", currentCompletionNode);
// check the completion node
String prefix = currentCompletionNode.getPrefix();
assertEquals(getExpectedPrefix(), prefix);
}
/**
* @return Returns the buffer.
*/
public String getBuffer() {
return buffer;
}
/**
* @return Returns the document.
*/
public Document getDocument() {
return document;
}
/**
* @return Returns the tu.
*/
public ITranslationUnit getTranslationUnit() {
return tu;
}
}

View file

@ -28,10 +28,21 @@ public class CompletionTest_ArgumentType_NoPrefix extends CompletionProposalsBa
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"aClass",
"anotherClass",
"aNamespace",
"anEnumeration",
"AStruct",
"xOtherClass",
"xNamespace",
"xEnumeration",
"XStruct"
};
public CompletionTest_ArgumentType_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -27,10 +27,22 @@ public class CompletionTest_ArgumentType_NoPrefix2 extends CompletionProposalsB
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"aClass",
"anotherClass",
"aNamespace",
"anEnumeration",
"AStruct",
"xOtherClass",
"xNamespace",
"xEnumeration",
"XStruct",
"ClassA"
};
public CompletionTest_ArgumentType_NoPrefix2(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -31,6 +31,7 @@ public class CompletionTest_ArgumentType_Prefix extends CompletionProposalsBase
"anotherClass",
"aNamespace",
"anEnumeration",
// missing proposal:
"AStruct"
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
Result: aFirstEnum
@ -38,13 +39,15 @@ Result: aFunction(void) bool
Result: anotherFunction(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/
};
public CompletionTest_ArgumentType_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -31,6 +31,7 @@ public class CompletionTest_ArgumentType_Prefix2 extends CompletionProposalsBas
"anotherClass",
"aNamespace",
"anEnumeration",
// missing proposal:
"AStruct"
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
Result: aFirstEnum
@ -38,13 +39,15 @@ Result: aFunction(void) bool
Result: anotherFunction(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/
};
public CompletionTest_ArgumentType_Prefix2(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -36,6 +36,8 @@ public class CompletionTest_ClassReference_NoPrefix extends CompletionProposals
public CompletionTest_ClassReference_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -38,13 +38,14 @@ public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBa
Result: anotherFunction(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/
};
public CompletionTest_ClassReference_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -36,6 +36,8 @@ public class CompletionTest_ConstructorReference extends CompletionProposalsBas
public CompletionTest_ConstructorReference(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -29,11 +29,13 @@ public class CompletionTest_ExceptionReference_NoPrefix extends CompletionPropo
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"..."
"..." // TODO
};
public CompletionTest_ExceptionReference_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -33,6 +33,7 @@ public class CompletionTest_ExceptionReference_Prefix extends CompletionProposa
"anotherClass",
"aNamespace",
"anEnumeration",
// missing proposal:
"AStruct"
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
Result: aFirstEnum
@ -42,13 +43,15 @@ Result: anotherFunction(void) void
Result: anotherMethod(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/
};
public CompletionTest_ExceptionReference_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -26,10 +26,13 @@ public class CompletionTest_FieldType_NoPrefix extends CompletionProposalsBaseT
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"<aType>" // TODO
};
public CompletionTest_FieldType_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -27,10 +27,13 @@ public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBase
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"<aType>" // TODO
};
public CompletionTest_FieldType_NoPrefix2(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -30,6 +30,7 @@ public class CompletionTest_FieldType_Prefix extends CompletionProposalsBaseTes
"aThirdClass",
"aNamespace",
"anEnumeration",
// missing proposal:
"AStruct"
/* FIXME: Additional results which should not be returned. Run with tracing enabled to reproduce:
Result: aFirstEnum
@ -37,13 +38,15 @@ Result: aFunction(void) bool
Result: anotherFunction(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/
};
public CompletionTest_FieldType_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -27,21 +27,22 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTe
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
// Should be
// "aMacro(x)",
// "Debug",
// "xMacro(x,y)"
"aMacro(x)",
"Debug",
"xMacro(x,y)"
};
public CompletionTest_MacroRef_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_MacroRef_NoPrefix.class.getName());
suite.addTest(new CompletionTest_MacroRef_NoPrefix("testCompletionProposals"));
return suite;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()

View file

@ -27,12 +27,13 @@ public class CompletionTest_MacroRef_Prefix extends CompletionProposalsBaseTest
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "D";
private final String[] expectedResults = {
// Should be
// "Debug"
"Debug"
};
public CompletionTest_MacroRef_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -31,10 +31,14 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionPr
"xAClassField : float",
"aMethod(void) int",
"xAClassMethod(int x) void"
/* "aClass" FIXME: Surplus result: aClass is currently returned as a result, but this is not syntactically correct.
Completion processing needs to be fixed, putting this here as a reminder. */
};
public CompletionTest_MemberReference_Arrow_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -34,6 +34,8 @@ public class CompletionTest_MemberReference_Arrow_Prefix extends CompletionProp
public CompletionTest_MemberReference_Arrow_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -19,30 +19,28 @@ import junit.framework.TestSuite;
* Complex Context: Function return value: foo()->a(CTRL+SPACE)
*
*/
public class CompletionFailedTest_MemberReference_Arrow_Prefix2 extends CompletionProposalsBaseTest{
public class CompletionTest_MemberReference_Arrow_Prefix2 extends CompletionProposalsBaseTest{
private final String fileName = "CompletionTestStart7.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 = {
"aClass",
// FIXME: additional result
// "aClass",
"aField : int",
"aMethod(void) int"
};
/* Additional results which should not be found. Run with trace activated to reproduce:
* Result: author - author name
* is a template --> relax extra results checking
*/
public CompletionFailedTest_MemberReference_Arrow_Prefix2(String name) {
public CompletionTest_MemberReference_Arrow_Prefix2(String name) {
super(name) ;
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionFailedTest_MemberReference_Arrow_Prefix2.class.getName());
suite.addTest(new CompletionFailedTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
TestSuite suite= new TestSuite(CompletionTest_MemberReference_Arrow_Prefix2.class.getName());
suite.addTest(new CompletionTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
return suite;
}
/* (non-Javadoc)
@ -93,11 +91,4 @@ public class CompletionFailedTest_MemberReference_Arrow_Prefix2 extends Complet
return headerFileName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return false ;
}
}

View file

@ -37,6 +37,8 @@ public class CompletionTest_MemberReference_Dot_NoPrefix extends CompletionProp
public CompletionTest_MemberReference_Dot_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -28,10 +28,14 @@ public class CompletionTest_MemberReference_Dot_Prefix extends CompletionPropos
private final String[] expectedResults = {
"aField : int",
"aMethod(void) int",
/* "aClass" FIXME: Surplus result: aClass is currently returned as a result, but this is not syntactically correct.
Completion processing needs to be fixed, putting this here as a reminder. */
};
public CompletionTest_MemberReference_Dot_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -33,6 +33,8 @@ public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBa
public CompletionTest_NamespaceRef_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -29,10 +29,13 @@ public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBase
private final String expectedPrefix = "a";
private final String[] expectedResults = {
"aNamespace"
/* FIXME: extra results */
};
public CompletionTest_NamespaceRef_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -28,10 +28,17 @@ public class CompletionTest_NewTypeReference_NoPrefix extends CompletionProposa
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"aClass",
"anotherClass",
"AStruct",
"xOtherClass",
"XStruct"
};
public CompletionTest_NewTypeReference_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -30,6 +30,7 @@ public class CompletionTest_NewTypeReference_Prefix extends CompletionProposals
private final String[] expectedResults = {
"aClass",
"anotherClass",
// missing proposal:
"AStruct"
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
Result: aFirstEnum
@ -39,12 +40,14 @@ Result: anotherFunction(void) void
Result: anotherMethod(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/ };
public CompletionTest_NewTypeReference_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -38,6 +38,8 @@ Result: y : int
public CompletionTest_ScopedReference_NonCodeScope(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -30,19 +30,6 @@ public class CompletionTest_ScopedReference_Prefix extends CompletionProposalsB
"aNamespaceFunction(void) void"
};
/* FIXME: Addtional result which should not be there. Run with tracing to reproduce:
Result: author - author name
*/
/* (non-Javadoc)
* Relax result checking here because the "a" prefix finds the template for "author"
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return false ;
}
public CompletionTest_ScopedReference_Prefix(String name) {
super(name);
}

View file

@ -34,6 +34,8 @@ public class CompletionTest_SingleName_Method_NoPrefix extends CompletionPropos
public CompletionTest_SingleName_Method_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -38,22 +38,15 @@ public class CompletionTest_SingleName_Method_Prefix extends CompletionProposa
"aFirstEnum",
"aSecondEnum",
"aThirdEnum",
// missing proposals:
"AStruct",
"AMacro(x)"
};
/* (non-Javadoc)
* Relax result checking here because the "a" prefix also finds the template for "author"
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return false ;
}
public CompletionTest_SingleName_Method_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -64,6 +64,8 @@ public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBase
public CompletionTest_SingleName_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -35,14 +35,14 @@ public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseT
"aFirstEnum",
"aSecondEnum",
"aThirdEnum",
// missing proposal:
"AMacro(x)"
/* FIXME: Additional results which should not be there. Run with tracing to reproduce:
* Result: author - author name
*/
};
public CompletionTest_SingleName_Prefix2(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
setExpectFailure(109724);
}
public static Test suite() {

View file

@ -34,15 +34,6 @@ public class CompletionTest_TypeDef_NoPrefix extends CompletionProposalsBaseTes
};
/* (non-Javadoc)
* Relax checking here because the "m" prefix also finds the templates for "main" and "mutable"
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return false ;
}
public CompletionTest_TypeDef_NoPrefix(String name) {
super(name);
}

View file

@ -34,16 +34,6 @@ public class CompletionTest_TypeDef_Prefix extends CompletionProposalsBaseTest{
};
/* (non-Javadoc)
* Checking for prefix "m" finds also the template for "main" and "mutable".
* --> we relax extra results checking in this case.
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
*/
protected boolean doCheckExtraResults() {
return false ;
}
public CompletionTest_TypeDef_Prefix(String name) {
super(name);
}

View file

@ -53,6 +53,8 @@ Result: xVariable : int
public CompletionTest_TypeRef_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -38,12 +38,13 @@ Result: anotherClass
Result: anotherFunction(void) void
Result: aSecondEnum
Result: aThirdEnum
Result: author - author name
Result: aVariable : int
*/ };
public CompletionTest_TypeRef_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -38,6 +38,8 @@ Result: y : int
*/
public CompletionTest_VariableType_NestedPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(88787);
}
public static Test suite() {

View file

@ -25,10 +25,21 @@ public class CompletionTest_VariableType_NoPrefix extends CompletionProposalsBa
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
private final String expectedPrefix = "";
private final String[] expectedResults = {
"aClass",
"anotherClass",
"aNamespace",
"anEnumeration",
"AStruct",
"xOtherClass",
"xNamespace",
"xEnumeration",
"XStruct",
};
public CompletionTest_VariableType_NoPrefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
setExpectFailure(151207);
}
public static Test suite() {

View file

@ -29,18 +29,30 @@ public class CompletionTest_VariableType_Prefix extends CompletionProposalsBase
"anotherClass",
"aNamespace",
"anEnumeration",
// missing proposal:
"AStruct"
/* Superfluous proposals:
"aFirstEnum",
"aFunction(void) bool",
"aSecondEnum",
"aThirdEnum",
"aVariable : int",
"anotherFunction(void) void"
*/
};
public CompletionTest_VariableType_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
// and https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
setExpectFailure(109724);
}
public static Test suite() {
TestSuite suite= new TestSuite(CompletionTest_VariableType_Prefix.class.getName());
suite.addTest(new CompletionTest_VariableType_Prefix("testCompletionProposals"));
return suite;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.codeassist.tests.CompletionProposalsTest#getCompletionPosition()
*/

View file

@ -25,7 +25,7 @@ public class ContentAssist2TestSuite extends TestSuite {
public ContentAssist2TestSuite() {
super("Tests in package org.eclipse.cdt.ui.tests.text.contentassist2");
addTest(CompletionFailedTest_MemberReference_Arrow_Prefix2.suite());
addTest(CompletionTest_MemberReference_Arrow_Prefix2.suite());
addTest(CompletionTest_ArgumentType_NoPrefix.suite());
addTest(CompletionTest_ArgumentType_NoPrefix2.suite());
addTest(CompletionTest_ArgumentType_Prefix.suite());