00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "QmitkFunctionalityTest.h" 00019 00020 #include <CppUnit/TestSuite.h> 00021 #include <CppUnit/TestCaller.h> 00022 00023 #include "QmitkMockFunctionality.h" 00024 00025 QmitkFunctionalityTest::QmitkFunctionalityTest(const std::string& testName) 00026 : berry::UITestCase(testName) 00027 { 00028 00029 } 00030 00031 CppUnit::Test* QmitkFunctionalityTest::Suite() 00032 { 00033 CppUnit::TestSuite* suite = new CppUnit::TestSuite("QmitkFunctionalityTest"); 00034 00035 CppUnit_addTest(suite, QmitkFunctionalityTest, TestOpenAndClose); 00036 00037 return suite; 00038 } 00039 00040 void QmitkFunctionalityTest::DoSetUp() 00041 { 00042 UITestCase::DoSetUp(); 00043 fWindow = OpenTestWindow(); 00044 fPage = fWindow->GetActivePage(); 00045 } 00046 00047 void QmitkFunctionalityTest::DoTearDown() 00048 { 00049 fPage = 0; 00050 fWindow = 0; 00051 UITestCase::DoTearDown(); 00052 } 00053 00054 void QmitkFunctionalityTest::TestOpenAndClose() 00055 { 00056 this->IgnoreLeakingObjects(); 00057 00058 berry::CallHistory::Pointer history; 00059 std::vector<std::string> callOrder; 00060 { 00061 // Open a functionality. 00062 QmitkMockFunctionality::Pointer part = fPage->ShowView(QmitkMockFunctionality::ID).Cast<QmitkMockFunctionality> (); 00063 history = part->GetCallHistory(); 00064 00065 //callOrder.push_back("SetInitializationData"); 00066 //callOrder.push_back("Init"); 00067 callOrder.push_back("CreateQtPartControl"); 00068 callOrder.push_back("SetFocus"); 00069 00070 assert(history->VerifyOrder(callOrder)); 00071 00072 // Close the part. 00073 fPage->HideView(part.Cast<berry::IViewPart>()); 00074 } 00075 00076 //callOrder.push_back("WidgetDisposed"); 00077 callOrder.push_back("FunctionalityDestructor"); 00078 assert(history->VerifyOrder(callOrder)); 00079 } 00080 00081 void QmitkFunctionalityTest::TestOpenAndWindowClose() 00082 { 00083 this->IgnoreLeakingObjects(); 00084 00085 berry::CallHistory::Pointer history; 00086 std::vector<std::string> callOrder; 00087 { 00088 // Open a new window 00089 berry::IWorkbenchWindow::Pointer newWindow = OpenTestWindow(); 00090 00091 // Open a part. 00092 QmitkMockFunctionality::Pointer part = newWindow->GetActivePage()->ShowView(QmitkMockFunctionality::ID).Cast<QmitkMockFunctionality> ();; 00093 history = part->GetCallHistory(); 00094 00095 //callOrder.push_back("SetInitializationData"); 00096 //callOrder.push_back("Init"); 00097 callOrder.push_back("CreateQtPartControl"); 00098 callOrder.push_back("SetFocus"); 00099 00100 assert(history->VerifyOrder(callOrder)); 00101 00102 // Close the window. 00103 newWindow->Close(); 00104 } 00105 00106 //callOrder.push_back("WidgetDisposed"); 00107 callOrder.push_back("FunctionalityDestructor"); 00108 assert(history->VerifyOrder(callOrder)); 00109 }