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:
parent
fe8600233c
commit
59dd370291
5 changed files with 103 additions and 90 deletions
|
@ -126,6 +126,7 @@ public class IndexIncludeTest extends IndexTestBase {
|
|||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
file.setContents(new ByteArrayInputStream( "int included; int CONTEXT;\n".getBytes()), false, false, NPM);
|
||||
file.setLocalTimeStamp(timestamp+1000);
|
||||
}
|
||||
}, NPM);
|
||||
assertTrue("Timestamp was not increased", file.getLocalTimeStamp() >= timestamp);
|
||||
|
|
|
@ -77,14 +77,16 @@ public class IndexListenerTest extends BaseTestCase {
|
|||
try {
|
||||
IFile file= TestSourceReader.createFile(fProject1.getProject(), "test.cpp", "int a;");
|
||||
synchronized (mutex) {
|
||||
mutex.wait(8000);
|
||||
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 {
|
||||
im.removeIndexerStateListener(listener);
|
||||
|
|
|
@ -24,6 +24,7 @@ public class IndexTests extends TestSuite {
|
|||
suite.addTest(IndexSearchTest.suite());
|
||||
suite.addTest(IndexIncludeTest.suite());
|
||||
suite.addTest(IndexBugsTests.suite());
|
||||
suite.addTest(EnclosingNamesTest.suite());
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,13 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.core.resources.IContainer;
|
||||
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.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
@ -201,19 +204,25 @@ public class TestSourceReader {
|
|||
* @throws Exception
|
||||
* @since 4.0
|
||||
*/
|
||||
public static IFile createFile(IContainer container, IPath filePath, String contents) throws CoreException {
|
||||
//Obtain file handle
|
||||
IFile file = container.getFile(filePath);
|
||||
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
//Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, new NullProgressMonitor());
|
||||
}
|
||||
else {
|
||||
file.create(stream, false, new NullProgressMonitor());
|
||||
}
|
||||
return file;
|
||||
public static IFile createFile(final IContainer container, final IPath filePath, final String contents) throws CoreException {
|
||||
final IWorkspace ws = ResourcesPlugin.getWorkspace();
|
||||
final IFile result[] = new IFile[1];
|
||||
ws.run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
//Obtain file handle
|
||||
IFile file = container.getFile(filePath);
|
||||
InputStream stream = new ByteArrayInputStream(contents.getBytes());
|
||||
//Create file input stream
|
||||
if (file.exists()) {
|
||||
file.setContents(stream, false, false, new NullProgressMonitor());
|
||||
}
|
||||
else {
|
||||
file.create(stream, false, new NullProgressMonitor());
|
||||
}
|
||||
result[0]= file;
|
||||
}
|
||||
}, null);
|
||||
return result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,58 +65,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
openCallHierarchy(editor);
|
||||
Tree tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
}
|
||||
|
||||
// {testStaticMethods}
|
||||
|
@ -149,58 +149,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
openCallHierarchy(editor);
|
||||
Tree tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("method(); // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("inline_method(); // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
}
|
||||
|
||||
|
||||
|
@ -238,58 +238,58 @@ public class BasicCppCallHierarchyTest extends CallHierarchyBaseTest {
|
|||
openCallHierarchy(editor);
|
||||
Tree tree = getCHTree(page);
|
||||
checkTreeNode(tree, 0, "MyClass::field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("static_field"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("field; // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("static_field; // r1"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("field; // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("static_field; // r2"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("field; // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
|
||||
editor.selectAndReveal(content.indexOf("static_field; // r3"), 2);
|
||||
openCallHierarchy(editor);
|
||||
checkTreeNode(tree, 0, "MyClass::static_field");
|
||||
checkTreeNode(tree, 0, 0, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::method()");
|
||||
checkTreeNode(tree, 0, 2, "func()");
|
||||
checkTreeNode(tree, 0, 0, "func()");
|
||||
checkTreeNode(tree, 0, 1, "MyClass::inline_method()");
|
||||
checkTreeNode(tree, 0, 2, "MyClass::method()");
|
||||
}
|
||||
|
||||
// {testAutomaticConstructor}
|
||||
|
|
Loading…
Add table
Reference in a new issue