mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Moves BaseTestCase to cdt.core.tests
This commit is contained in:
parent
9f1cc8d372
commit
08a632ecc7
6 changed files with 106 additions and 79 deletions
|
@ -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 <code>readTaggedComment(getClass(), tag)</code>
|
||||
* @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);
|
||||
}
|
||||
}
|
|
@ -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 <code>readTaggedComment(getClass(), tag)</code>
|
||||
* @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);
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue