diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java similarity index 57% rename from core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java rename to core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 3cbce55784e..bfe2fe20c62 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -9,9 +9,8 @@ * Markus Schorn - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.ui.tests; +package org.eclipse.cdt.core.testplugin.util; -import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.Vector; @@ -23,22 +22,6 @@ import junit.framework.TestFailure; import junit.framework.TestResult; import junit.framework.TestSuite; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.swt.widgets.Display; - -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; -import org.eclipse.cdt.core.index.IIndex; -import org.eclipse.cdt.core.index.IIndexFile; -import org.eclipse.cdt.core.model.CModelException; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICProject; -import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.cdt.core.testplugin.util.TestSourceReader; -import org.eclipse.cdt.ui.testplugin.CTestPlugin; - public class BaseTestCase extends TestCase { private boolean fExpectFailure= false; private int fBugnumber= 0; @@ -128,57 +111,4 @@ public class BaseTestCase extends TestCase { fExpectFailure= true; fBugnumber= bugnumber; } - - /** - * Reads a section in comments form the source of the given class. Fully - * equivalent to readTaggedComment(getClass(), tag) - * @since 4.0 - */ - protected String readTaggedComment(final String tag) throws IOException { - return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), getClass(), tag); - } - - protected IFile createFile(IContainer container, String fileName, String contents) throws Exception { - return TestSourceReader.createFile(container, new Path(fileName), contents); - } - - protected IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException { - ICElement elem= project.findElement(file.getFullPath()); - if (elem instanceof ITranslationUnit) { - ITranslationUnit tu= (ITranslationUnit) elem; - if (tu != null) { - return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); - } - } - fail("Could not create ast for " + file.getFullPath()); - return null; - } - - protected void waitForIndexer(IIndex index, IFile file, int maxmillis) throws Exception { - long endTime= System.currentTimeMillis() + maxmillis; - do { - index.acquireReadLock(); - try { - IIndexFile pfile= index.getFile(file.getLocation()); - // mstodo check timestamp - if (pfile != null) { - return; - } - } - finally { - index.releaseReadLock(); - } - - Thread.sleep(50); - } while (System.currentTimeMillis() < endTime); - throw new Exception("Indexer did not complete in time!"); - } - - protected void runEventQueue(int time) { - long endTime= System.currentTimeMillis()+time; - do { - while (Display.getCurrent().readAndDispatch()); - } - while(System.currentTimeMillis() < endTime); - } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java new file mode 100644 index 00000000000..03b60be5c31 --- /dev/null +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/BaseUITestCase.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2006 Wind River Systems, Inc. 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: + * Markus Schorn - initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.ui.tests; + +import java.io.IOException; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.swt.widgets.Display; + +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexFile; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.TestSourceReader; +import org.eclipse.cdt.ui.testplugin.CTestPlugin; + +public class BaseUITestCase extends BaseTestCase { + private boolean fExpectFailure= false; + private int fBugnumber= 0; + + public BaseUITestCase() { + super(); + } + + public BaseUITestCase(String name) { + super(name); + } + + /** + * Reads a section in comments form the source of the given class. Fully + * equivalent to readTaggedComment(getClass(), tag) + * @since 4.0 + */ + protected String readTaggedComment(final String tag) throws IOException { + return TestSourceReader.readTaggedComment(CTestPlugin.getDefault().getBundle(), getClass(), tag); + } + + protected IFile createFile(IContainer container, String fileName, String contents) throws Exception { + return TestSourceReader.createFile(container, new Path(fileName), contents); + } + + protected IASTTranslationUnit createIndexBasedAST(IIndex index, ICProject project, IFile file) throws CModelException, CoreException { + ICElement elem= project.findElement(file.getFullPath()); + if (elem instanceof ITranslationUnit) { + ITranslationUnit tu= (ITranslationUnit) elem; + if (tu != null) { + return tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); + } + } + fail("Could not create ast for " + file.getFullPath()); + return null; + } + + protected void waitForIndexer(IIndex index, IFile file, int maxmillis) throws Exception { + long endTime= System.currentTimeMillis() + maxmillis; + do { + index.acquireReadLock(); + try { + IIndexFile pfile= index.getFile(file.getLocation()); + // mstodo check timestamp + if (pfile != null) { + return; + } + } + finally { + index.releaseReadLock(); + } + + Thread.sleep(50); + } while (System.currentTimeMillis() < endTime); + throw new Exception("Indexer did not complete in time!"); + } + + protected void runEventQueue(int time) { + long endTime= System.currentTimeMillis()+time; + do { + while (Display.getCurrent().readAndDispatch()); + } + while(System.currentTimeMillis() < endTime); + } +} diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java index 79ab95181f2..6d09d8f24c7 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBaseTest.java @@ -25,13 +25,13 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.tests.BaseTestCase; +import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.callhierarchy.CHViewPart; import org.eclipse.cdt.internal.ui.callhierarchy.CallHierarchyUI; import org.eclipse.cdt.internal.ui.editor.CEditor; -public class CallHierarchyBaseTest extends BaseTestCase { +public class CallHierarchyBaseTest extends BaseUITestCase { private ICProject fCProject; protected IIndex fIndex; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java index 77c98ce74e9..c7de741f011 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist/ContentAssistTests.java @@ -39,7 +39,7 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.ui.tests.BaseTestCase; +import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.ui.text.ICHelpInvocationContext; import org.eclipse.cdt.internal.ui.CHelpProviderManager; @@ -50,7 +50,7 @@ import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2; /** * @author aniefer */ -public class ContentAssistTests extends BaseTestCase { +public class ContentAssistTests extends BaseUITestCase { private NullProgressMonitor monitor= new NullProgressMonitor(); static IProject project; static boolean disabledHelpContributions = false; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java index 790b7c659a7..23dd9625b10 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/ResolveBindingTests.java @@ -31,9 +31,9 @@ import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.cdt.ui.tests.BaseTestCase; +import org.eclipse.cdt.ui.tests.BaseUITestCase; -public class ResolveBindingTests extends BaseTestCase { +public class ResolveBindingTests extends BaseUITestCase { private static final int WAIT_FOR_INDEXER = 5000; private ICProject fCProject; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java index 17db537c39a..63838c2a6e0 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/viewsupport/AsyncViewerTest.java @@ -23,13 +23,13 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.PlatformUI; -import org.eclipse.cdt.ui.tests.BaseTestCase; +import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeContentProvider; import org.eclipse.cdt.internal.ui.viewsupport.AsyncTreeWorkInProgressNode; import org.eclipse.cdt.internal.ui.viewsupport.ExtendedTreeViewer; -public class AsyncViewerTest extends BaseTestCase { +public class AsyncViewerTest extends BaseUITestCase { private class Node { private String fLabel; private Node[] fChildren;