mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Adds a base class for index tests.
This commit is contained in:
parent
234a13b0e1
commit
e57307c5b3
2 changed files with 58 additions and 25 deletions
|
@ -17,7 +17,6 @@ import java.util.regex.Pattern;
|
|||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||
|
@ -33,19 +32,14 @@ import org.eclipse.cdt.core.index.IIndexBinding;
|
|||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class IndexSearchTest extends BaseTestCase {
|
||||
public class IndexSearchTest extends IndexTestBase {
|
||||
|
||||
private static final IndexFilter INDEX_FILTER = new IndexFilter();
|
||||
private static final IProgressMonitor NPM= new NullProgressMonitor();
|
||||
|
@ -66,7 +60,7 @@ public class IndexSearchTest extends BaseTestCase {
|
|||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
if (fProject == null) {
|
||||
createProject();
|
||||
fProject= createProject(true);
|
||||
}
|
||||
fIndex= CCorePlugin.getIndexManager().getIndex(fProject);
|
||||
}
|
||||
|
@ -76,23 +70,6 @@ public class IndexSearchTest extends BaseTestCase {
|
|||
super.tearDown();
|
||||
}
|
||||
|
||||
|
||||
private void createProject() throws CoreException {
|
||||
// Create the project
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
fProject= CProjectHelper.createCProject("IndexSearchTest_" + System.currentTimeMillis(), null);
|
||||
|
||||
CCorePlugin.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_NO_INDEXER);
|
||||
CProjectHelper.importSourcesFromPlugin(fProject, CTestPlugin.getDefault().getBundle(), "resources/indexTests/search");
|
||||
}
|
||||
}, null);
|
||||
CCorePlugin.getPDOMManager().setIndexerId(fProject, IPDOMManager.ID_FAST_INDEXER);
|
||||
// wait until the indexer is done
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(5000, new NullProgressMonitor()));
|
||||
}
|
||||
|
||||
public void deleteProject() {
|
||||
if (fProject != null) {
|
||||
CProjectHelper.delete(fProject);
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*******************************************************************************
|
||||
* 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.internal.index.tests;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
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.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class IndexTestBase extends BaseTestCase {
|
||||
|
||||
public IndexTestBase(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected ICProject createProject(final boolean useCpp) throws CoreException {
|
||||
// Create the project
|
||||
final ICProject[] result= new ICProject[] {null};
|
||||
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
|
||||
workspace.run(new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
String name= "IndexSearchTest_" + System.currentTimeMillis();
|
||||
if (useCpp) {
|
||||
result[0]= CProjectHelper.createCCProject(name, null);
|
||||
}
|
||||
else {
|
||||
result[0]= CProjectHelper.createCProject(name, null);
|
||||
}
|
||||
|
||||
CCorePlugin.getPDOMManager().setIndexerId(result[0], IPDOMManager.ID_NO_INDEXER);
|
||||
CProjectHelper.importSourcesFromPlugin(result[0], CTestPlugin.getDefault().getBundle(), "resources/indexTests/search");
|
||||
}
|
||||
}, null);
|
||||
CCorePlugin.getPDOMManager().setIndexerId(result[0], IPDOMManager.ID_FAST_INDEXER);
|
||||
// wait until the indexer is done
|
||||
assertTrue(CCorePlugin.getIndexManager().joinIndexer(5000, new NullProgressMonitor()));
|
||||
return result[0];
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue