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:
parent
c94c4ae67a
commit
00cf81d291
41 changed files with 415 additions and 242 deletions
|
@ -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.includebrowser.IncludeBrowserTestSuite;
|
||||||
import org.eclipse.cdt.ui.tests.text.TextTestSuite;
|
import org.eclipse.cdt.ui.tests.text.TextTestSuite;
|
||||||
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite;
|
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.text.selection.SelectionTestSuite;
|
||||||
import org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite;
|
import org.eclipse.cdt.ui.tests.viewsupport.ViewSupportTestSuite;
|
||||||
|
|
||||||
|
@ -56,11 +57,11 @@ public class AutomatedSuite extends TestSuite {
|
||||||
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist
|
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist
|
||||||
addTest(ContentAssistTestSuite.suite());
|
addTest(ContentAssistTestSuite.suite());
|
||||||
|
|
||||||
|
// tests from package org.eclipse.cdt.ui.tests.text.contentAssist2
|
||||||
|
addTest(ContentAssist2TestSuite.suite());
|
||||||
|
|
||||||
// tests from the refactoring plugin
|
// tests from the refactoring plugin
|
||||||
addTest(RenameRegressionTests.suite());
|
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
|
// tests from package org.eclipse.cdt.ui.tests.text.selection
|
||||||
addTest(SelectionTestSuite.suite());
|
addTest(SelectionTestSuite.suite());
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Markus Schorn - initial API and implementation
|
* Markus Schorn - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.ui.tests;
|
package org.eclipse.cdt.ui.tests;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -30,8 +29,6 @@ import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
import org.eclipse.cdt.ui.testplugin.CTestPlugin;
|
||||||
|
|
||||||
public class BaseUITestCase extends BaseTestCase {
|
public class BaseUITestCase extends BaseTestCase {
|
||||||
private boolean fExpectFailure= false;
|
|
||||||
private int fBugnumber= 0;
|
|
||||||
|
|
||||||
public BaseUITestCase() {
|
public BaseUITestCase() {
|
||||||
super();
|
super();
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
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 java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
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.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.ui.testplugin.CTestPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
public abstract class CompletionProposalsBaseTest extends AbstractCompletionTest {
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
private boolean fFailingTest;
|
||||||
|
|
||||||
public CompletionProposalsBaseTest(String name) {
|
public CompletionProposalsBaseTest(String name) {
|
||||||
super(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 getFileName();
|
||||||
protected abstract String getFileFullPath();
|
protected abstract String getFileFullPath();
|
||||||
protected abstract String getHeaderFileName();
|
protected abstract String getHeaderFileName();
|
||||||
protected abstract String getHeaderFileFullPath();
|
protected abstract String getHeaderFileFullPath();
|
||||||
|
/*
|
||||||
|
* Derived classes have to provide these test parameters
|
||||||
|
*/
|
||||||
protected abstract int getCompletionPosition();
|
protected abstract int getCompletionPosition();
|
||||||
protected abstract String getExpectedPrefix();
|
protected abstract String getExpectedPrefix();
|
||||||
protected abstract String[] getExpectedResultsValues();
|
protected abstract String[] getExpectedResultsValues();
|
||||||
protected String getFunctionOrConstructorName() { return EMPTY_STRING; }
|
|
||||||
|
|
||||||
/**
|
protected IFile setUpProjectContent(IProject project) throws FileNotFoundException {
|
||||||
* Override to relax checking of extra results
|
IFile headerFile = project.getFile(getHeaderFileName());
|
||||||
*/
|
|
||||||
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());
|
|
||||||
String fileName = getFileName();
|
String fileName = getFileName();
|
||||||
fCFile = fCProject.getProject().getFile(fileName);
|
IFile bodyFile = project.getFile(fileName);
|
||||||
if ( (!fCFile.exists()) &&( !fHeaderFile.exists() )) {
|
if ( (!bodyFile.exists()) &&( !headerFile.exists() )) {
|
||||||
|
IProgressMonitor monitor= new NullProgressMonitor();
|
||||||
try{
|
try{
|
||||||
FileInputStream headerFileIn = new FileInputStream(
|
FileInputStream headerFileIn = new FileInputStream(
|
||||||
CTestPlugin.getDefault().getFileInPlugin(new Path(getHeaderFileFullPath())));
|
CTestPlugin.getDefault().getFileInPlugin(new Path(getHeaderFileFullPath())));
|
||||||
fHeaderFile.create(headerFileIn,false, monitor);
|
headerFile.create(headerFileIn,false, monitor);
|
||||||
FileInputStream bodyFileIn = new FileInputStream(
|
FileInputStream bodyFileIn = new FileInputStream(
|
||||||
CTestPlugin.getDefault().getFileInPlugin(new Path(getFileFullPath())));
|
CTestPlugin.getDefault().getFileInPlugin(new Path(getFileFullPath())));
|
||||||
fCFile.create(bodyFileIn,false, monitor);
|
bodyFile.create(bodyFileIn,false, monitor);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fCProject.getProject().hasNature(CCProjectNature.CC_NATURE_ID)) {
|
return bodyFile;
|
||||||
addNatureToProject(fCProject.getProject(), CCProjectNature.CC_NATURE_ID, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
public void testCompletionProposals() throws Exception {
|
||||||
|
String[] expected = getExpectedResultsValues();
|
||||||
if (CTestPlugin.getDefault().isDebugging()) {
|
assertCompletionResults(getCompletionPosition(), expected, false);
|
||||||
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();
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* @return Returns the buffer.
|
* @see org.eclipse.cdt.ui.tests.text.contentassist2.AbstractCompletionTest#checkCompletionNode(org.eclipse.cdt.core.dom.ast.ASTCompletionNode)
|
||||||
*/
|
*/
|
||||||
public String getBuffer() {
|
protected void checkCompletionNode(ASTCompletionNode currentCompletionNode) {
|
||||||
return buffer;
|
assertNotNull("null completion node!", currentCompletionNode);
|
||||||
}
|
// check the completion node
|
||||||
|
String prefix = currentCompletionNode.getPrefix();
|
||||||
/**
|
assertEquals(getExpectedPrefix(), prefix);
|
||||||
* @return Returns the document.
|
|
||||||
*/
|
|
||||||
public Document getDocument() {
|
|
||||||
return document;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Returns the tu.
|
|
||||||
*/
|
|
||||||
public ITranslationUnit getTranslationUnit() {
|
|
||||||
return tu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,10 +28,21 @@ public class CompletionTest_ArgumentType_NoPrefix extends CompletionProposalsBa
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"aClass",
|
||||||
|
"anotherClass",
|
||||||
|
"aNamespace",
|
||||||
|
"anEnumeration",
|
||||||
|
"AStruct",
|
||||||
|
"xOtherClass",
|
||||||
|
"xNamespace",
|
||||||
|
"xEnumeration",
|
||||||
|
"XStruct"
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ArgumentType_NoPrefix(String name) {
|
public CompletionTest_ArgumentType_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -27,10 +27,22 @@ public class CompletionTest_ArgumentType_NoPrefix2 extends CompletionProposalsB
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"aClass",
|
||||||
|
"anotherClass",
|
||||||
|
"aNamespace",
|
||||||
|
"anEnumeration",
|
||||||
|
"AStruct",
|
||||||
|
"xOtherClass",
|
||||||
|
"xNamespace",
|
||||||
|
"xEnumeration",
|
||||||
|
"XStruct",
|
||||||
|
"ClassA"
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ArgumentType_NoPrefix2(String name) {
|
public CompletionTest_ArgumentType_NoPrefix2(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class CompletionTest_ArgumentType_Prefix extends CompletionProposalsBase
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
"aNamespace",
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
||||||
Result: aFirstEnum
|
Result: aFirstEnum
|
||||||
|
@ -38,13 +39,15 @@ Result: aFunction(void) bool
|
||||||
Result: anotherFunction(void) void
|
Result: anotherFunction(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ArgumentType_Prefix(String name) {
|
public CompletionTest_ArgumentType_Prefix(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -31,6 +31,7 @@ public class CompletionTest_ArgumentType_Prefix2 extends CompletionProposalsBas
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
"aNamespace",
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
||||||
Result: aFirstEnum
|
Result: aFirstEnum
|
||||||
|
@ -38,13 +39,15 @@ Result: aFunction(void) bool
|
||||||
Result: anotherFunction(void) void
|
Result: anotherFunction(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ArgumentType_Prefix2(String name) {
|
public CompletionTest_ArgumentType_Prefix2(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class CompletionTest_ClassReference_NoPrefix extends CompletionProposals
|
||||||
|
|
||||||
public CompletionTest_ClassReference_NoPrefix(String name) {
|
public CompletionTest_ClassReference_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -38,13 +38,14 @@ public class CompletionTest_ClassReference_Prefix extends CompletionProposalsBa
|
||||||
Result: anotherFunction(void) void
|
Result: anotherFunction(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ClassReference_Prefix(String name) {
|
public CompletionTest_ClassReference_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -36,6 +36,8 @@ public class CompletionTest_ConstructorReference extends CompletionProposalsBas
|
||||||
|
|
||||||
public CompletionTest_ConstructorReference(String name) {
|
public CompletionTest_ConstructorReference(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -29,11 +29,13 @@ public class CompletionTest_ExceptionReference_NoPrefix extends CompletionPropo
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"..."
|
"..." // TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ExceptionReference_NoPrefix(String name) {
|
public CompletionTest_ExceptionReference_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class CompletionTest_ExceptionReference_Prefix extends CompletionProposa
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
"aNamespace",
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
||||||
Result: aFirstEnum
|
Result: aFirstEnum
|
||||||
|
@ -42,13 +43,15 @@ Result: anotherFunction(void) void
|
||||||
Result: anotherMethod(void) void
|
Result: anotherMethod(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_ExceptionReference_Prefix(String name) {
|
public CompletionTest_ExceptionReference_Prefix(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -26,10 +26,13 @@ public class CompletionTest_FieldType_NoPrefix extends CompletionProposalsBaseT
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"<aType>" // TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_FieldType_NoPrefix(String name) {
|
public CompletionTest_FieldType_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -27,10 +27,13 @@ public class CompletionTest_FieldType_NoPrefix2 extends CompletionProposalsBase
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"<aType>" // TODO
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_FieldType_NoPrefix2(String name) {
|
public CompletionTest_FieldType_NoPrefix2(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class CompletionTest_FieldType_Prefix extends CompletionProposalsBaseTes
|
||||||
"aThirdClass",
|
"aThirdClass",
|
||||||
"aNamespace",
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
/* FIXME: Additional results which should not be returned. Run with tracing enabled to reproduce:
|
/* FIXME: Additional results which should not be returned. Run with tracing enabled to reproduce:
|
||||||
Result: aFirstEnum
|
Result: aFirstEnum
|
||||||
|
@ -37,13 +38,15 @@ Result: aFunction(void) bool
|
||||||
Result: anotherFunction(void) void
|
Result: anotherFunction(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_FieldType_Prefix(String name) {
|
public CompletionTest_FieldType_Prefix(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -27,14 +27,15 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTe
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
// Should be
|
"aMacro(x)",
|
||||||
// "aMacro(x)",
|
"Debug",
|
||||||
// "Debug",
|
"xMacro(x,y)"
|
||||||
// "xMacro(x,y)"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_MacroRef_NoPrefix(String name) {
|
public CompletionTest_MacroRef_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -27,12 +27,13 @@ public class CompletionTest_MacroRef_Prefix extends CompletionProposalsBaseTest
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "D";
|
private final String expectedPrefix = "D";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
// Should be
|
"Debug"
|
||||||
// "Debug"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_MacroRef_Prefix(String name) {
|
public CompletionTest_MacroRef_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -31,10 +31,14 @@ public class CompletionTest_MemberReference_Arrow_NoPrefix extends CompletionPr
|
||||||
"xAClassField : float",
|
"xAClassField : float",
|
||||||
"aMethod(void) int",
|
"aMethod(void) int",
|
||||||
"xAClassMethod(int x) void"
|
"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) {
|
public CompletionTest_MemberReference_Arrow_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class CompletionTest_MemberReference_Arrow_Prefix extends CompletionProp
|
||||||
|
|
||||||
public CompletionTest_MemberReference_Arrow_Prefix(String name) {
|
public CompletionTest_MemberReference_Arrow_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -19,30 +19,28 @@ import junit.framework.TestSuite;
|
||||||
* Complex Context: Function return value: foo()->a(CTRL+SPACE)
|
* 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 fileName = "CompletionTestStart7.cpp";
|
||||||
private final String fileFullPath ="resources/contentassist/" + fileName;
|
private final String fileFullPath ="resources/contentassist/" + fileName;
|
||||||
private final String headerFileName = "CompletionTestStart.h";
|
private final String headerFileName = "CompletionTestStart.h";
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "a";
|
private final String expectedPrefix = "a";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"aClass",
|
// FIXME: additional result
|
||||||
|
// "aClass",
|
||||||
"aField : int",
|
"aField : int",
|
||||||
"aMethod(void) int"
|
"aMethod(void) int"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Additional results which should not be found. Run with trace activated to reproduce:
|
public CompletionTest_MemberReference_Arrow_Prefix2(String name) {
|
||||||
* Result: author - author name
|
|
||||||
* is a template --> relax extra results checking
|
|
||||||
*/
|
|
||||||
|
|
||||||
public CompletionFailedTest_MemberReference_Arrow_Prefix2(String name) {
|
|
||||||
super(name) ;
|
super(name) ;
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite= new TestSuite(CompletionFailedTest_MemberReference_Arrow_Prefix2.class.getName());
|
TestSuite suite= new TestSuite(CompletionTest_MemberReference_Arrow_Prefix2.class.getName());
|
||||||
suite.addTest(new CompletionFailedTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
|
suite.addTest(new CompletionTest_MemberReference_Arrow_Prefix2("testCompletionProposals"));
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -93,11 +91,4 @@ public class CompletionFailedTest_MemberReference_Arrow_Prefix2 extends Complet
|
||||||
return headerFileName;
|
return headerFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.ui.tests.text.contentassist2.CompletionProposalsBaseTest#doCheckExtraResults()
|
|
||||||
*/
|
|
||||||
protected boolean doCheckExtraResults() {
|
|
||||||
return false ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,6 +37,8 @@ public class CompletionTest_MemberReference_Dot_NoPrefix extends CompletionProp
|
||||||
|
|
||||||
public CompletionTest_MemberReference_Dot_NoPrefix(String name) {
|
public CompletionTest_MemberReference_Dot_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -28,10 +28,14 @@ public class CompletionTest_MemberReference_Dot_Prefix extends CompletionPropos
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"aField : int",
|
"aField : int",
|
||||||
"aMethod(void) 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) {
|
public CompletionTest_MemberReference_Dot_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class CompletionTest_NamespaceRef_NoPrefix extends CompletionProposalsBa
|
||||||
|
|
||||||
public CompletionTest_NamespaceRef_NoPrefix(String name) {
|
public CompletionTest_NamespaceRef_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -29,10 +29,13 @@ public class CompletionTest_NamespaceRef_Prefix extends CompletionProposalsBase
|
||||||
private final String expectedPrefix = "a";
|
private final String expectedPrefix = "a";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"aNamespace"
|
"aNamespace"
|
||||||
|
/* FIXME: extra results */
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_NamespaceRef_Prefix(String name) {
|
public CompletionTest_NamespaceRef_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -28,10 +28,17 @@ public class CompletionTest_NewTypeReference_NoPrefix extends CompletionProposa
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"aClass",
|
||||||
|
"anotherClass",
|
||||||
|
"AStruct",
|
||||||
|
"xOtherClass",
|
||||||
|
"XStruct"
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_NewTypeReference_NoPrefix(String name) {
|
public CompletionTest_NewTypeReference_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -30,6 +30,7 @@ public class CompletionTest_NewTypeReference_Prefix extends CompletionProposals
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
"aClass",
|
"aClass",
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
/* FIXME: Additional results which should not be there. Run with trace enabled to reproduce:
|
||||||
Result: aFirstEnum
|
Result: aFirstEnum
|
||||||
|
@ -39,12 +40,14 @@ Result: anotherFunction(void) void
|
||||||
Result: anotherMethod(void) void
|
Result: anotherMethod(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/ };
|
*/ };
|
||||||
|
|
||||||
public CompletionTest_NewTypeReference_Prefix(String name) {
|
public CompletionTest_NewTypeReference_Prefix(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -38,6 +38,8 @@ Result: y : int
|
||||||
|
|
||||||
public CompletionTest_ScopedReference_NonCodeScope(String name) {
|
public CompletionTest_ScopedReference_NonCodeScope(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -30,19 +30,6 @@ public class CompletionTest_ScopedReference_Prefix extends CompletionProposalsB
|
||||||
"aNamespaceFunction(void) void"
|
"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) {
|
public CompletionTest_ScopedReference_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ public class CompletionTest_SingleName_Method_NoPrefix extends CompletionPropos
|
||||||
|
|
||||||
public CompletionTest_SingleName_Method_NoPrefix(String name) {
|
public CompletionTest_SingleName_Method_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -38,22 +38,15 @@ public class CompletionTest_SingleName_Method_Prefix extends CompletionProposa
|
||||||
"aFirstEnum",
|
"aFirstEnum",
|
||||||
"aSecondEnum",
|
"aSecondEnum",
|
||||||
"aThirdEnum",
|
"aThirdEnum",
|
||||||
|
// missing proposals:
|
||||||
"AStruct",
|
"AStruct",
|
||||||
"AMacro(x)"
|
"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) {
|
public CompletionTest_SingleName_Method_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
|
||||||
|
setExpectFailure(109724);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -64,6 +64,8 @@ public class CompletionTest_SingleName_NoPrefix extends CompletionProposalsBase
|
||||||
|
|
||||||
public CompletionTest_SingleName_NoPrefix(String name) {
|
public CompletionTest_SingleName_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -35,14 +35,14 @@ public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseT
|
||||||
"aFirstEnum",
|
"aFirstEnum",
|
||||||
"aSecondEnum",
|
"aSecondEnum",
|
||||||
"aThirdEnum",
|
"aThirdEnum",
|
||||||
|
// missing proposal:
|
||||||
"AMacro(x)"
|
"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) {
|
public CompletionTest_SingleName_Prefix2(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
|
||||||
|
setExpectFailure(109724);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -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) {
|
public CompletionTest_TypeDef_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
public CompletionTest_TypeDef_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,8 @@ Result: xVariable : int
|
||||||
|
|
||||||
public CompletionTest_TypeRef_NoPrefix(String name) {
|
public CompletionTest_TypeRef_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -38,12 +38,13 @@ Result: anotherClass
|
||||||
Result: anotherFunction(void) void
|
Result: anotherFunction(void) void
|
||||||
Result: aSecondEnum
|
Result: aSecondEnum
|
||||||
Result: aThirdEnum
|
Result: aThirdEnum
|
||||||
Result: author - author name
|
|
||||||
Result: aVariable : int
|
Result: aVariable : int
|
||||||
*/ };
|
*/ };
|
||||||
|
|
||||||
public CompletionTest_TypeRef_Prefix(String name) {
|
public CompletionTest_TypeRef_Prefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -38,6 +38,8 @@ Result: y : int
|
||||||
*/
|
*/
|
||||||
public CompletionTest_VariableType_NestedPrefix(String name) {
|
public CompletionTest_VariableType_NestedPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=88787
|
||||||
|
setExpectFailure(88787);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -25,10 +25,21 @@ public class CompletionTest_VariableType_NoPrefix extends CompletionProposalsBa
|
||||||
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
private final String headerFileFullPath ="resources/contentassist/" + headerFileName;
|
||||||
private final String expectedPrefix = "";
|
private final String expectedPrefix = "";
|
||||||
private final String[] expectedResults = {
|
private final String[] expectedResults = {
|
||||||
|
"aClass",
|
||||||
|
"anotherClass",
|
||||||
|
"aNamespace",
|
||||||
|
"anEnumeration",
|
||||||
|
"AStruct",
|
||||||
|
"xOtherClass",
|
||||||
|
"xNamespace",
|
||||||
|
"xEnumeration",
|
||||||
|
"XStruct",
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_VariableType_NoPrefix(String name) {
|
public CompletionTest_VariableType_NoPrefix(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
|
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
|
||||||
|
setExpectFailure(151207);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
|
|
|
@ -29,11 +29,23 @@ public class CompletionTest_VariableType_Prefix extends CompletionProposalsBase
|
||||||
"anotherClass",
|
"anotherClass",
|
||||||
"aNamespace",
|
"aNamespace",
|
||||||
"anEnumeration",
|
"anEnumeration",
|
||||||
|
// missing proposal:
|
||||||
"AStruct"
|
"AStruct"
|
||||||
|
/* Superfluous proposals:
|
||||||
|
"aFirstEnum",
|
||||||
|
"aFunction(void) bool",
|
||||||
|
"aSecondEnum",
|
||||||
|
"aThirdEnum",
|
||||||
|
"aVariable : int",
|
||||||
|
"anotherFunction(void) void"
|
||||||
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
public CompletionTest_VariableType_Prefix(String name) {
|
public CompletionTest_VariableType_Prefix(String name) {
|
||||||
super(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() {
|
public static Test suite() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class ContentAssist2TestSuite extends TestSuite {
|
||||||
public ContentAssist2TestSuite() {
|
public ContentAssist2TestSuite() {
|
||||||
super("Tests in package org.eclipse.cdt.ui.tests.text.contentassist2");
|
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_NoPrefix.suite());
|
||||||
addTest(CompletionTest_ArgumentType_NoPrefix2.suite());
|
addTest(CompletionTest_ArgumentType_NoPrefix2.suite());
|
||||||
addTest(CompletionTest_ArgumentType_Prefix.suite());
|
addTest(CompletionTest_ArgumentType_Prefix.suite());
|
||||||
|
|
Loading…
Add table
Reference in a new issue