1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Fix for 184466: UI Jobs refer to deleted projects in the ui tests

This commit is contained in:
Anton Leherbauer 2007-05-07 09:50:27 +00:00
parent b808918b1e
commit f303c6143a
9 changed files with 46 additions and 12 deletions

View file

@ -20,6 +20,11 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
@ -108,4 +113,23 @@ public class BaseUITestCase extends BaseTestCase {
item.getParent().notifyListeners(SWT.Expand, event); item.getParent().notifyListeners(SWT.Expand, event);
runEventQueue(0); runEventQueue(0);
} }
protected void closeEditor(IEditorPart editor) {
IWorkbenchPartSite site;
IWorkbenchPage page;
if (editor != null && (site= editor.getSite()) != null && (page= site.getPage()) != null) {
page.closeEditor(editor, false);
}
}
protected void closeAllEditors() {
IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
for (int i= 0; i < windows.length; i++) {
IWorkbenchPage[] pages= windows[i].getPages();
for (int j= 0; j < pages.length; j++) {
IWorkbenchPage page= pages[j];
page.closeAllEditors(false);
}
}
}
} }

View file

@ -55,6 +55,7 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
closeAllEditors();
if (fCProject != null) { if (fCProject != null) {
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others. * Copyright (c) 2000, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -53,7 +53,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IViewReference; import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
@ -162,9 +161,7 @@ public class EditorTestHelper {
for (int i= 0; i < windows.length; i++) { for (int i= 0; i < windows.length; i++) {
IWorkbenchPage[] pages= windows[i].getPages(); IWorkbenchPage[] pages= windows[i].getPages();
for (int j= 0; j < pages.length; j++) { for (int j= 0; j < pages.length; j++) {
IEditorReference[] editorReferences= pages[j].getEditorReferences(); pages[j].closeAllEditors(false);
for (int k= 0; k < editorReferences.length; k++)
closeEditor(editorReferences[k].getEditor(false));
} }
} }
} }

View file

@ -108,6 +108,7 @@ public class ContentAssistTests extends BaseUITestCase {
} }
public void cleanupProject() throws Exception { public void cleanupProject() throws Exception {
closeAllEditors();
try{ try{
project.delete( true, false, monitor ); project.delete( true, false, monitor );
project = null; project = null;
@ -120,6 +121,8 @@ public class ContentAssistTests extends BaseUITestCase {
if( project == null || !project.exists() ) if( project == null || !project.exists() )
return; return;
closeAllEditors();
IResource [] members = project.members(); IResource [] members = project.members();
for( int i = 0; i < members.length; i++ ){ for( int i = 0; i < members.length; i++ ){
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$ if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -61,6 +61,7 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
closeAllEditors();
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
super.tearDown(); super.tearDown();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -50,7 +50,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
@ -64,7 +64,7 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
* *
* @author dsteffle * @author dsteffle
*/ */
public class CPPSelectionTestsNoIndexer extends BaseTestCase { public class CPPSelectionTestsNoIndexer extends BaseUITestCase {
private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$ private static final String INDEX_FILE_ID = "2946365241"; //$NON-NLS-1$
static NullProgressMonitor monitor; static NullProgressMonitor monitor;
@ -116,6 +116,7 @@ public class CPPSelectionTestsNoIndexer extends BaseTestCase {
} }
public void cleanupProject() throws Exception { public void cleanupProject() throws Exception {
closeAllEditors();
try{ try{
project.delete( true, false, monitor ); project.delete( true, false, monitor );
project = null; project = null;
@ -128,6 +129,8 @@ public class CPPSelectionTestsNoIndexer extends BaseTestCase {
if( project == null || !project.exists() ) if( project == null || !project.exists() )
return; return;
closeAllEditors();
IResource [] members = project.members(); IResource [] members = project.members();
for( int i = 0; i < members.length; i++ ){ for( int i = 0; i < members.length; i++ ){
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$ if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -57,6 +57,7 @@ public abstract class CSelectionTestsAnyIndexer extends BaseSelectionTestsIndexe
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
closeAllEditors();
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
super.tearDown(); super.tearDown();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -16,7 +16,6 @@ import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
@ -48,6 +47,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.FileManager; import org.eclipse.cdt.core.testplugin.FileManager;
import org.eclipse.cdt.ui.tests.BaseUITestCase;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.parser.ParserException; import org.eclipse.cdt.internal.core.parser.ParserException;
@ -61,7 +61,7 @@ import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
* *
* @author dsteffle * @author dsteffle
*/ */
public class CSelectionTestsNoIndexer extends TestCase { public class CSelectionTestsNoIndexer extends BaseUITestCase {
private static final String INDEX_FILE_ID = "2324852323"; //$NON-NLS-1$ private static final String INDEX_FILE_ID = "2324852323"; //$NON-NLS-1$
static NullProgressMonitor monitor; static NullProgressMonitor monitor;
@ -107,6 +107,7 @@ public class CSelectionTestsNoIndexer extends TestCase {
} }
public void cleanupProject() throws Exception { public void cleanupProject() throws Exception {
closeAllEditors();
CProjectHelper.delete(cPrj); CProjectHelper.delete(cPrj);
project= null; project= null;
} }
@ -115,6 +116,8 @@ public class CSelectionTestsNoIndexer extends TestCase {
if( project == null || !project.exists() ) if( project == null || !project.exists() )
return; return;
closeAllEditors();
IResource [] members = project.members(); IResource [] members = project.members();
for( int i = 0; i < members.length; i++ ){ for( int i = 0; i < members.length; i++ ){
if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$ if( members[i].getName().equals( ".project" ) || members[i].getName().equals( ".cdtproject" ) ) //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -60,6 +60,7 @@ public class TypeHierarchyBaseTest extends BaseUITestCase {
} }
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
closeAllEditors();
if (fCProject != null) { if (fCProject != null) {
CProjectHelper.delete(fCProject); CProjectHelper.delete(fCProject);
} }