1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 10:46:02 +02:00

Fixes a few testcases

This commit is contained in:
Markus Schorn 2006-11-17 13:38:40 +00:00
parent fe8600233c
commit 59dd370291
5 changed files with 103 additions and 90 deletions

View file

@ -126,6 +126,7 @@ public class IndexIncludeTest extends IndexTestBase {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException { public void run(IProgressMonitor monitor) throws CoreException {
file.setContents(new ByteArrayInputStream( "int included; int CONTEXT;\n".getBytes()), false, false, NPM); file.setContents(new ByteArrayInputStream( "int included; int CONTEXT;\n".getBytes()), false, false, NPM);
file.setLocalTimeStamp(timestamp+1000);
} }
}, NPM); }, NPM);
assertTrue("Timestamp was not increased", file.getLocalTimeStamp() >= timestamp); assertTrue("Timestamp was not increased", file.getLocalTimeStamp() >= timestamp);

View file

@ -77,14 +77,16 @@ public class IndexListenerTest extends BaseTestCase {
try { try {
IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;"); IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
synchronized (mutex) { synchronized (mutex) {
mutex.wait(8000);
if (state[0]+state[1] < 2) { if (state[0]+state[1] < 2) {
mutex.wait(1000); mutex.wait(8000);
if (state[0]+state[1] < 2) {
mutex.wait(2000);
}
} }
assertEquals(1, state[0]);
assertEquals(1, state[1]);
assertEquals(0, state[2]);
} }
assertEquals(1, state[0]);
assertEquals(1, state[1]);
assertEquals(0, state[2]);
} }
finally { finally {
im.removeIndexerStateListener(listener); im.removeIndexerStateListener(listener);

View file

@ -24,6 +24,7 @@ public class IndexTests extends TestSuite {
suite.addTest(IndexSearchTest.suite()); suite.addTest(IndexSearchTest.suite());
suite.addTest(IndexIncludeTest.suite()); suite.addTest(IndexIncludeTest.suite());
suite.addTest(IndexBugsTests.suite()); suite.addTest(IndexBugsTests.suite());
suite.addTest(EnclosingNamesTest.suite());
return suite; return suite;
} }

View file

@ -35,10 +35,13 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
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.osgi.framework.Bundle; import org.osgi.framework.Bundle;
@ -201,19 +204,25 @@ public class TestSourceReader {
* @throws Exception * @throws Exception
* @since 4.0 * @since 4.0
*/ */
public static IFile createFile(IContainer container, IPath filePath, String contents) throws CoreException { public static IFile createFile(final IContainer container, final IPath filePath, final String contents) throws CoreException {
//Obtain file handle final IWorkspace ws = ResourcesPlugin.getWorkspace();
IFile file = container.getFile(filePath); final IFile result[] = new IFile[1];
ws.run(new IWorkspaceRunnable() {
InputStream stream = new ByteArrayInputStream(contents.getBytes()); public void run(IProgressMonitor monitor) throws CoreException {
//Create file input stream //Obtain file handle
if (file.exists()) { IFile file = container.getFile(filePath);
file.setContents(stream, false, false, new NullProgressMonitor()); InputStream stream = new ByteArrayInputStream(contents.getBytes());
} //Create file input stream
else { if (file.exists()) {
file.create(stream, false, new NullProgressMonitor()); file.setContents(stream, false, false, new NullProgressMonitor());
} }
return file; else {
file.create(stream, false, new NullProgressMonitor());
}
result[0]= file;
}
}, null);
return result[0];
} }
/** /**

View file

@ -65,58 +65,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
openCallHierarchy(editor); openCallHierarchy(editor);
Tree tree = getCHTree(page); Tree tree = getCHTree(page);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method"), 2); editor.selectAndReveal(content.indexOf("inline_method"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r1"), 2); editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r2"), 2); editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r3"), 2); editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
} }
// {testStaticMethods} // {testStaticMethods}
@ -149,58 +149,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
openCallHierarchy(editor); openCallHierarchy(editor);
Tree tree = getCHTree(page); Tree tree = getCHTree(page);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method"), 2); editor.selectAndReveal(content.indexOf("inline_method"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r1"), 2); editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r2"), 2); editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("method(); // r3"), 2); editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::method()"); checkTreeNode(tree, 0, "MyClass::method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2); editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, "MyClass::inline_method()");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
} }
@ -238,58 +238,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
openCallHierarchy(editor); openCallHierarchy(editor);
Tree tree = getCHTree(page); Tree tree = getCHTree(page);
checkTreeNode(tree, 0, "MyClass::field"); checkTreeNode(tree, 0, "MyClass::field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("static_field"), 2); editor.selectAndReveal(content.indexOf("static_field"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::static_field"); checkTreeNode(tree, 0, "MyClass::static_field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("field; // r1"), 2); editor.selectAndReveal(content.indexOf("field; // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::field"); checkTreeNode(tree, 0, "MyClass::field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("static_field; // r1"), 2); editor.selectAndReveal(content.indexOf("static_field; // r1"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::static_field"); checkTreeNode(tree, 0, "MyClass::static_field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("field; // r2"), 2); editor.selectAndReveal(content.indexOf("field; // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::field"); checkTreeNode(tree, 0, "MyClass::field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("static_field; // r2"), 2); editor.selectAndReveal(content.indexOf("static_field; // r2"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::static_field"); checkTreeNode(tree, 0, "MyClass::static_field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("field; // r3"), 2); editor.selectAndReveal(content.indexOf("field; // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::field"); checkTreeNode(tree, 0, "MyClass::field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
editor.selectAndReveal(content.indexOf("static_field; // r3"), 2); editor.selectAndReveal(content.indexOf("static_field; // r3"), 2);
openCallHierarchy(editor); openCallHierarchy(editor);
checkTreeNode(tree, 0, "MyClass::static_field"); checkTreeNode(tree, 0, "MyClass::static_field");
checkTreeNode(tree, 0, 0, "MyClass::inline_method()"); checkTreeNode(tree, 0, 0, "func()");
checkTreeNode(tree, 0, 1, "MyClass::method()"); checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
checkTreeNode(tree, 0, 2, "func()"); checkTreeNode(tree, 0, 2, "MyClass::method()");
} }
// {testAutomaticConstructor} // {testAutomaticConstructor}