From e6968d589b154d16813d50982e6c2777242476eb Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 16 Feb 2010 16:04:34 +0000 Subject: [PATCH] Fix testcases. --- .../callhierarchy/CallHierarchyBugs.java | 5 ++-- .../rename/RenameRegressionTests.java | 13 ++++----- .../tests/refactoring/rename/RenameTests.java | 10 ++++++- .../CompletionTests_PlainC.java | 3 +-- .../selection/BaseSelectionTestsIndexer.java | 27 +++++++++---------- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java index 639a75938aa..f9c28a5788c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/callhierarchy/CallHierarchyBugs.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 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 @@ -474,7 +474,8 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest { openCallHierarchy(editor, false); Tree chTree= checkTreeNode(ch, 0, "Base::dosomething()").getParent(); - checkTreeNode(chTree, 0, 0, "Base::dosomething()"); + TreeItem item= checkTreeNode(chTree, 0, 0, "Base::dosomething()"); + expandTreeItem(item); checkTreeNode(chTree, 0, 1, "Derived::dosomething()"); checkTreeNode(chTree, 0, 2, null); } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java index aa1810f2ad6..3f544a8eed6 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameRegressionTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2009 IBM Corporation and others. + * Copyright (c) 2004, 2010 IBM Corporation 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 @@ -417,9 +417,9 @@ public class RenameRegressionTests extends RenameTests { IFile file = importFile( "t.cpp", contents ); //$NON-NLS-1$ int offset = contents.indexOf( "v/*vp1*/" ) ; //$NON-NLS-1$ Change changes = getRefactorChanges(file, offset, "ooga" ); //$NON-NLS-1$ - //dervied method is not renamed; only a warning to rename derived or base class methods - assertTotalChanges( 1, changes ); + assertTotalChanges( 2, changes ); assertChange( changes, file, contents.indexOf("v/*vp1*/"), 1, "ooga" ); //$NON-NLS-1$//$NON-NLS-2$ + assertChange( changes, file, contents.indexOf("v(){}"), 1, "ooga" ); //$NON-NLS-1$//$NON-NLS-2$ } // defect is input for new name is not allowed @@ -605,10 +605,11 @@ public class RenameRegressionTests extends RenameTests { //vp1 implicit virtual method int offset = contents.indexOf( "v/*vp1*/" ) ; //$NON-NLS-1$ Change changes = getRefactorChanges(file, offset, "v1" ); //$NON-NLS-1$ - assertTotalChanges( 3, changes ); - assertChange( changes, file, contents.indexOf("v()"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ + assertTotalChanges( 4, changes ); + assertChange( changes, file, contents.indexOf("v();"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ + assertChange( changes, file, contents.indexOf("v(){}"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ assertChange( changes, file, contents.indexOf("v/*vp1*/"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ - assertChange( changes, file, contents.indexOf("v(){"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ + assertChange( changes, file, contents.indexOf("v(){i++;}"), 1, "v1" ); //$NON-NLS-1$//$NON-NLS-2$ } public void testMethod_45() throws Exception { StringWriter writer = new StringWriter(); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java index 458e85708fe..938d873e7c2 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/rename/RenameTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2008 Wind River Systems, Inc. + * Copyright (c) 2005, 2010 Wind River Systems, Inc. * 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 @@ -152,4 +152,12 @@ public class RenameTests extends RefactoringTests { } assertTrue(im.joinIndexer(10000, NPM)); } + + @Override + protected IFile importFile(String fileName, String contents) + throws Exception { + IFile result= super.importFile(fileName, contents); + waitForIndexer(); + return result; + } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java index 39b50460fc4..46fa6d653c8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTests_PlainC.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2010 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 @@ -358,7 +358,6 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest { "AMacro(x)", "DEBUG", "XMacro(x, y)", - "_Pragma(arg)", "__CDT_PARSER__", "__DATE__", "__FILE__", diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java index b9a527775c6..fa78b4384d3 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/selection/BaseSelectionTestsIndexer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2009 IBM Corporation and others. + * Copyright (c) 2005, 2010 IBM Corporation 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 @@ -82,8 +82,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { OpenDeclarationsAction.sIsJUnitTest= true; IWorkbenchPage page= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewReference[] refs= page.getViewReferences(); - for (int i = 0; i < refs.length; i++) { - IViewReference viewReference = refs[i]; + for (IViewReference viewReference : refs) { page.setPartState(viewReference, IWorkbenchPage.STATE_RESTORED); } } @@ -97,8 +96,8 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { message.append(status.getMessage()); if (status.isMultiStatus()) { IStatus children[] = status.getChildren(); - for (int i = 0; i < children.length; i++) { - message.append(getMessage(children[i])); + for (IStatus element : children) { + message.append(getMessage(element)); } } message.append("]"); //$NON-NLS-1$ @@ -112,9 +111,9 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { InputStream stream = new ByteArrayInputStream(contents.getBytes()); //Create file input stream if (file.exists()) - file.setContents(stream, false, false, monitor); + file.setContents(stream, true, false, monitor); else - file.create(stream, false, monitor); + file.create(stream, true, monitor); fileManager.addFile(file); @@ -140,12 +139,12 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { //Create file input stream if (file.exists()) { long timestamp= file.getLocalTimeStamp(); - file.setContents(stream, false, false, monitor); + file.setContents(stream, true, false, monitor); if (file.getLocalTimeStamp() == timestamp) { file.setLocalTimeStamp(timestamp+1000); } } else { - file.create(stream, false, monitor); + file.create(stream, true, monitor); } fileManager.addFile(file); @@ -170,9 +169,9 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { InputStream stream = new ByteArrayInputStream(contents.getBytes()); //Create file input stream if (file.exists()) - file.setContents(stream, false, false, monitor); + file.setContents(stream, true, false, monitor); else - file.create(stream, false, monitor); + file.create(stream, true, monitor); fileManager.addFile(file); @@ -204,7 +203,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart part = null; try { - part = page.openEditor(new FileEditorInput(file), getEditorID(), true); //$NON-NLS-1$ + part = page.openEditor(new FileEditorInput(file), getEditorID(), true); } catch (PartInitException e) { assertFalse(true); } @@ -255,7 +254,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart part = null; try { - part = page.openEditor(new FileEditorInput(file), getEditorID()); //$NON-NLS-1$ + part = page.openEditor(new FileEditorInput(file), getEditorID()); } catch (PartInitException e) { assertFalse(true); } @@ -289,7 +288,7 @@ public class BaseSelectionTestsIndexer extends BaseUITestCase { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IEditorPart part = null; try { - part = page.openEditor(new FileEditorInput(file), getEditorID()); //$NON-NLS-1$ + part = page.openEditor(new FileEditorInput(file), getEditorID()); } catch (PartInitException e) { assertFalse(true); }