diff options
Diffstat (limited to 'core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java')
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java index 49fc46dab96..9d5d147179c 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/implementmethod/ImplementMethodRefactoringTest.java @@ -8,6 +8,7 @@ * * Contributors: * Institute for Software - initial API and implementation + * Marc-Andre Laperle *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.implementmethod; @@ -18,10 +19,12 @@ import org.eclipse.core.resources.IFile; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; -import org.eclipse.cdt.internal.ui.refactoring.CRefactoring; +import org.eclipse.cdt.internal.ui.refactoring.CRefactoring2; import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRefactoring; /** @@ -30,6 +33,7 @@ import org.eclipse.cdt.internal.ui.refactoring.implementmethod.ImplementMethodRe public class ImplementMethodRefactoringTest extends RefactoringTest { protected int finalWarnings; private int initialWarnings; + private int infos; public ImplementMethodRefactoringTest(String name, Collection<TestSourceFile> files) { super(name, files); @@ -38,37 +42,36 @@ public class ImplementMethodRefactoringTest extends RefactoringTest { @Override protected void runTest() throws Throwable { IFile refFile = project.getFile(fileName); - CRefactoring refactoring = new ImplementMethodRefactoring(refFile, selection, null, cproject); - - try { - refactoring.lockIndex(); - RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); + ICElement element = CoreModel.getDefault().create(refFile); + CRefactoring2 refactoring = new ImplementMethodRefactoring(element, selection, cproject, astCache); + RefactoringStatus checkInitialConditions = refactoring.checkInitialConditions(NULL_PROGRESS_MONITOR); - if(initialWarnings == 0) { - assertConditionsOk(checkInitialConditions); - } else { - assertConditionsFatalError(checkInitialConditions, initialWarnings); - return; - } + if (initialWarnings == 0) { + assertConditionsOk(checkInitialConditions); + } else { + assertConditionsFatalError(checkInitialConditions, initialWarnings); + return; + } - refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); - RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); - if (finalWarnings == 0) { - Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); - assertConditionsOk(finalConditions); - createChange.perform(NULL_PROGRESS_MONITOR); - } else { - assertConditionsWarning(finalConditions, finalWarnings); - } - compareFiles(fileMap); - } finally { - refactoring.unlockIndex(); + RefactoringStatus finalConditions = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); + Change createChange = refactoring.createChange(NULL_PROGRESS_MONITOR); + + if (finalWarnings > 0) { + assertConditionsWarning(finalConditions, finalWarnings); + } else if (infos > 0) { + assertConditionsInfo(finalConditions, infos); + } else { + assertConditionsOk(finalConditions); } + + createChange.perform(NULL_PROGRESS_MONITOR); + compareFiles(fileMap); } @Override protected void configureRefactoring(Properties refactoringProperties) { finalWarnings = new Integer(refactoringProperties.getProperty("finalWarnings", "0")).intValue(); //$NON-NLS-1$//$NON-NLS-2$ initialWarnings = Integer.parseInt(refactoringProperties.getProperty("initialWarnings", "0")); //$NON-NLS-1$//$NON-NLS-2$ + infos = Integer.parseInt(refactoringProperties.getProperty("infos", "0")); //$NON-NLS-1$//$NON-NLS-2$ } } |