1
/*******************************************************************************
2
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* Markus Schorn - initial API and implementation
10
*******************************************************************************/
12
package org.eclipse.cdt.ui.tests.includebrowser;
14
import org.eclipse.core.resources.IFile;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.NullProgressMonitor;
17
import org.eclipse.swt.widgets.Tree;
18
import org.eclipse.ui.IWorkbenchPage;
19
import org.eclipse.ui.PartInitException;
20
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.cdt.core.CCorePlugin;
23
import org.eclipse.cdt.core.dom.IPDOMManager;
24
import org.eclipse.cdt.core.index.IIndex;
25
import org.eclipse.cdt.core.model.CoreModelUtil;
26
import org.eclipse.cdt.core.model.ICProject;
27
import org.eclipse.cdt.core.model.ITranslationUnit;
28
import org.eclipse.cdt.core.testplugin.CProjectHelper;
29
import org.eclipse.cdt.ui.CUIPlugin;
30
import org.eclipse.cdt.ui.tests.BaseUITestCase;
32
import org.eclipse.cdt.internal.ui.includebrowser.IBViewPart;
34
public class IncludeBrowserBaseTest extends BaseUITestCase {
35
protected static final int INDEXER_WAIT_TIME = 8000;
36
protected static IProgressMonitor NPM= new NullProgressMonitor();
38
private ICProject fCProject;
39
protected IIndex fIndex;
42
public IncludeBrowserBaseTest(String name) {
46
protected void setUp() throws Exception {
48
fCProject= CProjectHelper.createCCProject("__ibTest__", "bin", IPDOMManager.ID_FAST_INDEXER);
51
CCorePlugin.getIndexManager().reindex(fCProject);
52
fIndex= CCorePlugin.getIndexManager().getIndex(fCProject);
55
protected void tearDown() throws Exception {
56
if (fCProject != null) {
57
CProjectHelper.delete(fCProject);
62
protected ICProject getProject() {
66
protected IBViewPart openIncludeBrowser(IFile file) throws PartInitException {
67
IBViewPart result = doOpenIncludeBrowser(file);
72
protected IBViewPart openIncludeBrowser(IFile file, boolean includedBy) throws PartInitException {
73
IBViewPart result = doOpenIncludeBrowser(file);
74
result.onSetDirection(includedBy);
79
private IBViewPart doOpenIncludeBrowser(IFile file) throws PartInitException {
80
ITranslationUnit tu= CoreModelUtil.findTranslationUnit(file);
82
fail(file.getFullPath().toString() + " is no translation unit!");
84
IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
85
IBViewPart result= (IBViewPart)page.showView(CUIPlugin.ID_INCLUDE_BROWSER);
90
protected Tree getIBTree() {
91
IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
93
IBViewPart ib= (IBViewPart)page.findView(CUIPlugin.ID_INCLUDE_BROWSER);
95
Tree tree= ib.getTreeViewer().getTree();