From 3d474b9327409ffe5d9ba08f84801ddceac1ffa3 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 15 Feb 2012 18:37:02 -0800 Subject: [PATCH] Converted Hide Method refactoring test to the new framework. --- .../resources/refactoring/HideMethod.rts | 1422 ---------------- .../refactoring/HideMethodHistory.rts | 45 - .../refactoring/RefactoringTestBase.java | 24 +- .../refactoring/RefactoringTestSuite.java | 4 +- .../hidemethod/HideMethodRefactoringTest.java | 1487 ++++++++++++++++- .../hidemethod/HideMethodTestSuite.java | 34 - 6 files changed, 1491 insertions(+), 1525 deletions(-) delete mode 100644 core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts delete mode 100644 core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts delete mode 100644 core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts deleted file mode 100644 index 31440b3d883..00000000000 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethod.rts +++ /dev/null @@ -1,1422 +0,0 @@ -//!HideMethodSimple -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodLineComment -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - //Comment - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - //Comment - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodBlockComment -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*Comment*/ - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /*Comment*/ - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodLineCommentBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*///Comment - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); //Comment -}; - -#endif /*A_H_*/ -//!HideMethodBlockCommentBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*//*Comment*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); /*Comment*/ -}; - -#endif /*A_H_*/ -//!HideMethodLineCommentWithSpace -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - - //Comment - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - //Comment - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodBlockCommentWithSpace -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - - /*Comment*/ - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /*Comment*/ - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodLineCommentWithSpaceBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*///Comment - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); //Comment -}; - -#endif /*A_H_*/ -//!HideMethodBlockCommentWithSpaceBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*//*Comment*/ - - std::string toString(); - -private: - int i; -}; -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); /*Comment*/ -}; -#endif /*A_H_*/ -//!HideMethodBigBlockComment -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /* - * Comment - */ - /*$*/void method2();/*$$*/ - std::string toString(); - -private: - int i; -}; -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /* - * Comment - */ - void method2(); -}; -#endif /*A_H_*/ -//!HideMethodBigBlockCommentBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*$*/void method2();/*$$*/ /* - * Comment - */ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); /* - * Comment - */ -}; - -#endif /*A_H_*/ -//!HideMethodBigBlockCommentBeforeAndBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /* - * Davor - */ - /*$*/void method2();/*$$*/ /* - * Comment - */ - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /* - * Davor - */ - void method2(); /* - * Comment - */ -}; - -#endif /*A_H_*/ -//!HideMethodMixedCommentBeforeAndAfter -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*123*/ - /*$*/void method2();/*$$*///TEST - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /*123*/ - void method2(); //TEST -}; - -#endif /*A_H_*/ -//!HideMethodBlockCommentBeforeAndBehind -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - /*123*/ - /*$*/void method2();/*$$*//*TEST*/ - std::string toString(); - -private: - int i; -}; -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - /*123*/ - void method2(); /*TEST*/ -}; -#endif /*A_H_*/ -//!HideMethodNoChange -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -errors=1 -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -private: - /*$*/void method2();/*$$*/ -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -private: - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethod2MethodsDifferentLine -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - /*$*/void method1();/*$$*/ - void method2(); -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - void method2(); - -private: - void method1(); -}; - -#endif /*A_H_*/ -//!HideMethod2MethodsSameLine -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - /*$*/void method1();/*$$*/void method2(); -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - void method2(); - -private: - void method1(); -}; - -#endif /*A_H_*/ -//!HideMethod2MethodsDifferentLineWithComment -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - //Comment - /*$*/void method1();/*$$*/ - void method2(); -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - void method2(); - -private: - //Comment - void method1(); -}; - -#endif /*A_H_*/ -//!HideMethod2MethodsSameLineWithComment -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - //Comment - /*$*/void method1();/*$$*/void method2(); -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - void method2(); - -private: - //Comment - void method1(); -}; - -#endif /*A_H_*/ -//!HideMethodSimple ImplementationFile -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - void method2(); - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -void A::/*$*/method2/*$$*/() -{ -} -//!HideMethodSimple ImplementationFile with Comments BUG #60 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - //TEST 1 - void method2(); //TEST 2 - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - //TEST 1 - void method2(); //TEST 2 -}; - -#endif /*A_H_*/ -//@A.cpp -#include "A.h" - -void A::/*$*/method2/*$$*/() -{ -} - -//!HideMethod with references 1 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=HideMethod.h -//@HideMethod.h -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/method2/*$$*/(); - - void method3() { - method2(); - } -}; - -#endif /* HIDEMETHOD_H_ */ -//= -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - - void method3() { - method2(); - } - -private: - void method2(); -}; - -#endif /* HIDEMETHOD_H_ */ -//!HideMethod with references 2 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=HideMethod.h -//@HideMethod.h -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/method2/*$$*/(); - void method3(); -}; - -#endif /* HIDEMETHOD_H_ */ -//= -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void method3(); - -private: - void method2(); -}; - -#endif /* HIDEMETHOD_H_ */ -//@HideMethod.cpp -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::method2() { - //do nothing -} - -void HideMethod::method3() { - method2(); -} -//= -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::method2() { - //do nothing -} - -void HideMethod::method3() { - method2(); -} -//!HideMethod with references 3 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=HideMethod.h -warnings=1 -//@HideMethod.h -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/method2/*$$*/(); - void method3(); -}; - -class test{ -public: - void call() { - HideMethod hm; - hm.method2(); - } -}; - -#endif /* HIDEMETHOD_H_ */ -//= -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void method3(); - -private: - void method2(); -}; - -class test{ -public: - void call() { - HideMethod hm; - hm.method2(); - } -}; - -#endif /* HIDEMETHOD_H_ */ -//!HideMethod with references 4 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=HideMethod.h -warnings=1 -//@HideMethod.h -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void /*$*/method2/*$$*/(); - void method3(); -}; - -#endif /* HIDEMETHOD_H_ */ -//= -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void method3(); - -private: - void method2(); -}; - -#endif /* HIDEMETHOD_H_ */ -//@HideMethod.cpp -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub - -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::method2() { - //do nothing -} - -void HideMethod::method3() { - //do nothing -} - -int main() { - HideMethod hm; - hm.method2(); -} -//= -//@HideMethod.cpp -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub - -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::method2() { - //do nothing -} - -void HideMethod::method3() { - //do nothing -} - -int main() { - HideMethod hm; - hm.method2(); -} -//!HideMethod with CPP file selection -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=HideMethod.h -//@HideMethod.h -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void method2(); - void method3(); -}; - -#endif /* HIDEMETHOD_H_ */ -//= -#ifndef HIDEMETHOD_H_ -#define HIDEMETHOD_H_ - -class HideMethod { -public: - HideMethod(); - virtual ~HideMethod(); - void method3(); - -private: - void method2(); -}; - -#endif /* HIDEMETHOD_H_ */ -//@HideMethod.cpp -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::/*$*/method2/*$$*/() { - //do nothing -} - -void HideMethod::method3() { - method2(); -} -//= -#include "HideMethod.h" - -HideMethod::HideMethod() { - // TODO Auto-generated constructor stub -} - -HideMethod::~HideMethod() { - // TODO Auto-generated destructor stub -} - -void HideMethod::method2() { - //do nothing -} - -void HideMethod::method3() { - method2(); -} -//!HideMethodChangeToDefaultVisibility Class1 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - /*$*/void method2();/*$$*/ -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - -private: - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethodChangeToDefaultVisibility Class2 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -errors=1 -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { - /*$*/void method2();/*$$*/ -}; - -#endif /*A_H_*/ - -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { - void method2(); -}; - -#endif /*A_H_*/ - -//!HideMethodChangeToDefaultVisibility Struct -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -struct A { - /*$*/void method2();/*$$*/ -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -struct A { -private: - void method2(); -}; - -#endif /*A_H_*/ -//!HideMethod CheckIfPrivateBug 1 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.cpp -//@A.cpp -struct other { - bool value() { return true; } -}; - -class Class { -public: - void /*$*/set/*$$*/(bool b) {} - void test() { - other o; - this->set(o.value()); - } -}; - -//= -struct other { - bool value() { return true; } -}; - -class Class { -public: - void test() { - other o; - this->set(o.value()); - } - -private: - void set(bool b) { - } -}; - -//!HideMethod CheckIfPrivateBug 2 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.cpp -//@A.cpp -struct other { - bool value() { return true; } -}; - -class Class { -public: - void set(bool b) { - } - - void test() { - other o; - this->/*$*/set/*$$*/(o.value()); - } -}; - -//= -struct other { - bool value() { return true; } -}; - -class Class { -public: - void test() { - other o; - this->set(o.value()); - } - -private: - void set(bool b) { - } -}; - -//!HideMethod CheckIfPrivateBug 3 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.cpp -warnings=1 -//@A.cpp -struct other { - bool /*$*/value/*$$*/() { return true; } -}; - -class Class { -public: - void set(bool b) {} - void test() { - other o; - this->set(o.value()); - } -}; - -//= -struct other { -private: - bool value() { - return true; - } -}; - -class Class { -public: - void set(bool b) {} - void test() { - other o; - this->set(o.value()); - } -}; - -//!HideMethod CheckIfPrivateBug 4 -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.cpp -//@A.cpp -struct other { - bool value() { return true; } -}; - -class Class { -public: - void set(bool b) { - } - - void /*$*/test/*$$*/() { - other o; - this->set(o.value()); - } -}; - -//= -struct other { - bool value() { return true; } -}; - -class Class { -public: - void set(bool b) { - } - -private: - void test() { - other o; - this->set(o.value()); - } -}; - -//!HideMethod Main -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.cpp -fatalerror=true -//@A.cpp -int /*$*/main/*$$*/() { - int i = 2; - i++; - return 0; -} - -//= -int main() { - int i = 2; - i++; - return 0; -} - -//!HideMethod empty public sections -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -class Class { -public: - void /*$*/to_move()/*$$*/; - -private: - void just_private(); -}; -//= -class Class { -public: - -private: - void just_private(); - void to_move(); -}; -//!HideMethod several private sections -//#org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest -//@.config -filename=A.h -//@A.h -class Class { -public: - void /*$*/to_move()/*$$*/; - -private: - void just_private(); - -private: -}; -//= -class Class { -public: - -private: - void just_private(); - void to_move(); - -private: -}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts deleted file mode 100644 index 35d7d9cbcf9..00000000000 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/HideMethodHistory.rts +++ /dev/null @@ -1,45 +0,0 @@ -//!HideMethodSimple -//#org.eclipse.cdt.ui.tests.refactoring.RefactoringHistoryTest -//@A.h -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - void method2(); - std::string toString(); - -private: - int i; -}; - -#endif /*A_H_*/ -//= -#ifndef A_H_ -#define A_H_ - -#include - -class A { -public: - A(); - std::string toString(); - -private: - int i; - - void method2(); -}; - -#endif /*A_H_*/ -//@refScript.xml - - - - diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java index b98a640d0cb..e170939a855 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestBase.java @@ -59,8 +59,16 @@ public abstract class RefactoringTestBase extends BaseTestCase { private static final int INDEXER_TIMEOUT_SEC = 360; protected static final NullProgressMonitor NULL_PROGRESS_MONITOR = new NullProgressMonitor(); + /** Allows empty files to be created during test setup. */ protected boolean createEmptyFiles = true; + /** See {@link PreferenceConstants.CLASS_MEMBER_ASCENDING_VISIBILITY_ORDER} */ protected boolean ascendingVisibilityOrder; + /** Expected counts of errors, warnings and info messages */ + protected int expectedInitialErrors; + protected int expectedInitialWarnings; + protected int expectedFinalWarnings; + protected int expectedFinalInfos; + private boolean cpp = true; private ICProject cproject; private final Set testFiles = new LinkedHashSet(); @@ -170,12 +178,24 @@ public abstract class RefactoringTestBase extends BaseTestCase { assertStatusFatalError(initialStatus); return; } + if (expectedInitialErrors != 0) { + assertStatusError(initialStatus, expectedInitialErrors); + } else if (expectedInitialWarnings != 0) { + assertStatusWarning(initialStatus, expectedInitialWarnings); + } else { + assertStatusOk(initialStatus); + } - assertStatusOk(initialStatus); if (withUserInput) simulateUserInput(); RefactoringStatus finalStatus = refactoring.checkFinalConditions(NULL_PROGRESS_MONITOR); - assertStatusOk(finalStatus); + if (expectedFinalWarnings != 0) { + assertStatusWarning(finalStatus, expectedFinalWarnings); + } else if (expectedFinalInfos != 0) { + assertStatusInfo(finalStatus, expectedFinalInfos); + } else { + assertStatusOk(finalStatus); + } Change change = refactoring.createChange(NULL_PROGRESS_MONITOR); change.perform(NULL_PROGRESS_MONITOR); } finally { diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java index c0a5fbcac4c..1a24b1a7b3a 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/RefactoringTestSuite.java @@ -20,7 +20,7 @@ import org.eclipse.cdt.ui.tests.refactoring.extractconstant.ExtractConstantRefac import org.eclipse.cdt.ui.tests.refactoring.extractfunction.ExtractFunctionRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.extractlocalvariable.ExtractLocalVariableRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest; -import org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodTestSuite; +import org.eclipse.cdt.ui.tests.refactoring.hidemethod.HideMethodRefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodTestSuite; import org.eclipse.cdt.ui.tests.refactoring.rename.RenameRegressionTests; import org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToogleRefactoringTest; @@ -37,7 +37,7 @@ public class RefactoringTestSuite extends TestSuite { suite.addTest(RenameRegressionTests.suite()); suite.addTest(ExtractFunctionRefactoringTest.suite()); suite.addTest(ExtractConstantRefactoringTest.suite()); - suite.addTest(HideMethodTestSuite.suite()); + suite.addTest(HideMethodRefactoringTest.suite()); suite.addTest(GenerateGettersAndSettersTest.suite()); suite.addTest(ImplementMethodTestSuite.suite()); suite.addTest(ExtractLocalVariableRefactoringTest.suite()); diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java index fb7aee5b765..d739b058ceb 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodRefactoringTest.java @@ -12,38 +12,1485 @@ *******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.hidemethod; -import java.util.Collection; -import java.util.Properties; +import junit.framework.Test; -import org.eclipse.core.resources.IFile; import org.eclipse.ltk.core.refactoring.Refactoring; -import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; -import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; +import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestBase; import org.eclipse.cdt.internal.ui.refactoring.hidemethod.HideMethodRefactoring; /** - * @author Guido Zgraggen IFS + * Tests for Extract Local Variable refactoring. */ -public class HideMethodRefactoringTest extends RefactoringTest { - - public HideMethodRefactoringTest(String name, Collection files) { - super(name, files); +public class HideMethodRefactoringTest extends RefactoringTestBase { + + public HideMethodRefactoringTest() { + super(); + } + + public HideMethodRefactoringTest(String name) { + super(name); + } + + public static Test suite() { + return suite(HideMethodRefactoringTest.class); } @Override - protected void runTest() throws Throwable { - IFile refFile = project.getFile(fileWithSelection); - Refactoring refactoring = new HideMethodRefactoring(refFile,selection, null, cproject); - executeRefactoring(refactoring); - compareFiles(fileMap); + protected Refactoring createRefactoring() { + return new HideMethodRefactoring(getSelectedFile(), getSelection(), null, getCProject()); } - @Override - protected void configureRefactoring(Properties refactoringProperties) { - fatalError = Boolean.valueOf(refactoringProperties.getProperty("fatalerror", "false")).booleanValue(); //$NON-NLS-1$//$NON-NLS-2$ - finalWarnings = new Integer(refactoringProperties.getProperty("warnings", "0")).intValue(); //$NON-NLS-1$//$NON-NLS-2$ - initialErrors = new Integer(refactoringProperties.getProperty("errors", "0")).intValue(); //$NON-NLS-1$//$NON-NLS-2$ + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testSimple() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // //Comment + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // //Comment + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testLineComment() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*Comment*/ + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /*Comment*/ + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testBlockComment() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*///Comment + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); //Comment + //}; + // + //#endif /*A_H_*/ + public void testLineCommentBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*//*Comment*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); /*Comment*/ + //}; + // + //#endif /*A_H_*/ + public void testBlockCommentBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // + // //Comment + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // //Comment + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testLineCommentWithSpace() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // + // /*Comment*/ + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /*Comment*/ + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testBlockCommentWithSpace() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*///Comment + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); //Comment + //}; + // + //#endif /*A_H_*/ + public void testLineCommentWithSpaceBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*//*Comment*/ + // + // std::string toString(); + // + //private: + // int i; + //}; + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); /*Comment*/ + //}; + //#endif /*A_H_*/ + public void testBlockCommentWithSpaceBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /* + // * Comment + // */ + // /*$*/void method2();/*$$*/ + // std::string toString(); + // + //private: + // int i; + //}; + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /* + // * Comment + // */ + // void method2(); + //}; + //#endif /*A_H_*/ + public void testBigBlockComment() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*$*/void method2();/*$$*/ /* + // * Comment + // */ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); /* + // * Comment + // */ + //}; + // + //#endif /*A_H_*/ + public void testBigBlockCommentBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /* + // * Davor + // */ + // /*$*/void method2();/*$$*/ /* + // * Comment + // */ + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /* + // * Davor + // */ + // void method2(); /* + // * Comment + // */ + //}; + // + //#endif /*A_H_*/ + public void testBigBlockCommentBeforeAndBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*123*/ + // /*$*/void method2();/*$$*///TEST + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /*123*/ + // void method2(); //TEST + //}; + // + //#endif /*A_H_*/ + public void testMixedCommentBeforeAndAfter() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // /*123*/ + // /*$*/void method2();/*$$*//*TEST*/ + // std::string toString(); + // + //private: + // int i; + //}; + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // /*123*/ + // void method2(); /*TEST*/ + //}; + //#endif /*A_H_*/ + public void testBlockCommentBeforeAndBehind() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //private: + // /*$*/void method2();/*$$*/ + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //private: + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testNoChange() throws Exception { + expectedInitialErrors = 1; + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // /*$*/void method1();/*$$*/ + // void method2(); + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // void method2(); + // + //private: + // void method1(); + //}; + // + //#endif /*A_H_*/ + public void testTwoMethodsDifferentLine() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // /*$*/void method1();/*$$*/void method2(); + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // void method2(); + // + //private: + // void method1(); + //}; + // + //#endif /*A_H_*/ + public void testTwoMethodsSameLine() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // //Comment + // /*$*/void method1();/*$$*/ + // void method2(); + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // void method2(); + // + //private: + // //Comment + // void method1(); + //}; + // + //#endif /*A_H_*/ + public void testTwoMethodsDifferentLineWithComment() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // //Comment + // /*$*/void method1();/*$$*/void method2(); + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // void method2(); + // + //private: + // //Comment + // void method1(); + //}; + // + //#endif /*A_H_*/ + public void testTwoMethodsSameLineWithComment() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // void method2(); + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //void A::/*$*/method2/*$$*/() + //{ + //} + public void testSimpleImplementationFile() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // //TEST 1 + // void method2(); //TEST 2 + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // //TEST 1 + // void method2(); //TEST 2 + //}; + // + //#endif /*A_H_*/ + + //A.cpp + //#include "A.h" + // + //void A::/*$*/method2/*$$*/() + //{ + //} + public void testSimpleImplementationFileWithCommentsBUG60() throws Exception { + assertRefactoringSuccess(); + } + + //HideMethod.h + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void /*$*/method2/*$$*/(); + // + // void method3() { + // method2(); + // } + //}; + // + //#endif /* HIDEMETHOD_H_ */ + //==================== + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // + // void method3() { + // method2(); + // } + // + //private: + // void method2(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + public void testReferences1() throws Exception { + assertRefactoringSuccess(); + } + + //HideMethod.h + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void /*$*/method2/*$$*/(); + // void method3(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + //==================== + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void method3(); + // + //private: + // void method2(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + + //HideMethod.cpp + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::method2() { + // //do nothing + //} + // + //void HideMethod::method3() { + // method2(); + //} + //==================== + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::method2() { + // //do nothing + //} + // + //void HideMethod::method3() { + // method2(); + //} + public void testReferences2() throws Exception { + assertRefactoringSuccess(); + } + + //HideMethod.h + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void /*$*/method2/*$$*/(); + // void method3(); + //}; + // + //class test{ + //public: + // void call() { + // HideMethod hm; + // hm.method2(); + // } + //}; + // + //#endif /* HIDEMETHOD_H_ */ + //==================== + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void method3(); + // + //private: + // void method2(); + //}; + // + //class test{ + //public: + // void call() { + // HideMethod hm; + // hm.method2(); + // } + //}; + // + //#endif /* HIDEMETHOD_H_ */ + public void testReferences3() throws Exception { + expectedFinalWarnings = 1; + assertRefactoringSuccess(); + } + + //HideMethod.h + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void /*$*/method2/*$$*/(); + // void method3(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + //==================== + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void method3(); + // + //private: + // void method2(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + + //HideMethod.cpp + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::method2() { + // //do nothing + //} + // + //void HideMethod::method3() { + // //do nothing + //} + // + //int main() { + // HideMethod hm; + // hm.method2(); + //} + //==================== + + //HideMethod.cpp + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::method2() { + // //do nothing + //} + // + //void HideMethod::method3() { + // //do nothing + //} + // + //int main() { + // HideMethod hm; + // hm.method2(); + //} + public void testReferences4() throws Exception { + expectedFinalWarnings = 1; + assertRefactoringSuccess(); + } + + //HideMethod.h + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void method2(); + // void method3(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + //==================== + //#ifndef HIDEMETHOD_H_ + //#define HIDEMETHOD_H_ + // + //class HideMethod { + //public: + // HideMethod(); + // virtual ~HideMethod(); + // void method3(); + // + //private: + // void method2(); + //}; + // + //#endif /* HIDEMETHOD_H_ */ + + //HideMethod.cpp + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::/*$*/method2/*$$*/() { + // //do nothing + //} + // + //void HideMethod::method3() { + // method2(); + //} + //==================== + //#include "HideMethod.h" + // + //HideMethod::HideMethod() { + //} + // + //HideMethod::~HideMethod() { + //} + // + //void HideMethod::method2() { + // //do nothing + //} + // + //void HideMethod::method3() { + // method2(); + //} + public void testCPPFileSelection() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // /*$*/void method2();/*$$*/ + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // + //private: + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testChangeToDefaultVisibilityClass1() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + // /*$*/void method2();/*$$*/ + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testChangeToDefaultVisibilityClass2() throws Exception { + expectedInitialErrors = 1; + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //struct A { + // /*$*/void method2();/*$$*/ + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //struct A { + //private: + // void method2(); + //}; + // + //#endif /*A_H_*/ + public void testChangeToDefaultVisibilityStruct() throws Exception { + assertRefactoringSuccess(); + } + + //A.cpp + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void /*$*/set/*$$*/(bool b) {} + // void test() { + // other o; + // this->set(o.value()); + // } + //}; + //==================== + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void test() { + // other o; + // this->set(o.value()); + // } + // + //private: + // void set(bool b) { + // } + //}; + public void testCheckIfPrivateBug1() throws Exception { + assertRefactoringSuccess(); + } + + //A.cpp + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void set(bool b) { + // } + // + // void test() { + // other o; + // this->/*$*/set/*$$*/(o.value()); + // } + //}; + //==================== + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void test() { + // other o; + // this->set(o.value()); + // } + // + //private: + // void set(bool b) { + // } + //}; + public void testCheckIfPrivateBug2() throws Exception { + assertRefactoringSuccess(); + } + + //A.cpp + //struct other { + // bool /*$*/value/*$$*/() { return true; } + //}; + // + //class Class { + //public: + // void set(bool b) {} + // void test() { + // other o; + // this->set(o.value()); + // } + //}; + //==================== + //struct other { + //private: + // bool value() { + // return true; + // } + //}; + // + //class Class { + //public: + // void set(bool b) {} + // void test() { + // other o; + // this->set(o.value()); + // } + //}; + public void testCheckIfPrivateBug3() throws Exception { + expectedFinalWarnings = 1; + assertRefactoringSuccess(); + } + + //A.cpp + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void set(bool b) { + // } + // + // void /*$*/test/*$$*/() { + // other o; + // this->set(o.value()); + // } + //}; + //==================== + //struct other { + // bool value() { return true; } + //}; + // + //class Class { + //public: + // void set(bool b) { + // } + // + //private: + // void test() { + // other o; + // this->set(o.value()); + // } + //}; + public void testCheckIfPrivateBug4() throws Exception { + assertRefactoringSuccess(); + } + + //A.cpp + //int /*$*/main/*$$*/() { + // int i = 2; + // i++; + // return 0; + //} + //==================== + //int main() { + // int i = 2; + // i++; + // return 0; + //} + public void testStandaloneFunction() throws Exception { + assertRefactoringFailure(); + } + + //A.h + //class Class { + //public: + // void /*$*/to_move()/*$$*/; + // + //private: + // void just_private(); + //}; + //==================== + //class Class { + //public: + // + //private: + // void just_private(); + // void to_move(); + //}; + public void testEmptyPublicSections() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //class Class { + //public: + // void /*$*/to_move()/*$$*/; + // + //private: + // void just_private(); + // + //private: + //}; + //==================== + //class Class { + //public: + // + //private: + // void just_private(); + // void to_move(); + // + //private: + //}; + public void testSeveralPrivateSections() throws Exception { + assertRefactoringSuccess(); + } + + //A.h + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // void method2(); + // std::string toString(); + // + //private: + // int i; + //}; + // + //#endif /*A_H_*/ + //==================== + //#ifndef A_H_ + //#define A_H_ + // + //#include + // + //class A { + //public: + // A(); + // std::string toString(); + // + //private: + // int i; + // + // void method2(); + //}; + // + //#endif /*A_H_*/ + + //refScript.xml + // + // + // + // + public void testHistorySimple() throws Exception { + assertRefactoringSuccess(); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java deleted file mode 100644 index 9f087c51285..00000000000 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/hidemethod/HideMethodTestSuite.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Google, 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: - * Tom Ball (Google) - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.ui.tests.refactoring.hidemethod; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.eclipse.cdt.ui.tests.refactoring.RefactoringTester; - -/** - * Test suite to run just the Hide Method unit tests. - * - * @author Tom Ball - */ -public class HideMethodTestSuite extends TestSuite { - - @SuppressWarnings("nls") - public static Test suite() throws Exception { - TestSuite suite = new HideMethodTestSuite(); - suite.addTest(RefactoringTester.suite("HideMethodRefactoringTests", - "resources/refactoring/HideMethod.rts")); - suite.addTest(RefactoringTester.suite("HideMethodRefactoringHistoryTests", - "resources/refactoring/HideMethodHistory.rts")); - return suite; - } -}