Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
berryUITestCase.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 BlueBerry Platform
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef BERRYUITESTCASE_H_
18 #define BERRYUITESTCASE_H_
19 
20 #include <berryTestCase.h>
21 
22 #include <berryIWindowListener.h>
23 #include <berryIWorkbench.h>
24 #include <berryIWorkbenchPage.h>
25 
26 #include <org_blueberry_uitest_Export.h>
27 
28 #include <list>
29 
30 namespace berry
31 {
32 
39 class BERRY_UITEST_EXPORT UITestCase: public TestCase
40 {
41 
42 public:
43 
50  static IAdaptable* GetPageInput();
51 
52  UITestCase(const QString& testName);
53 
60  virtual void DoSetUp();
61 
69  virtual void DoTearDown();
70 
74  void failexc(const QString& message, const std::exception& e,
75  long lineNumber = -1,
76  const QString& fileName = "unknown");
77 
81  IWorkbenchWindow::Pointer OpenTestWindow();
82 
86  IWorkbenchWindow::Pointer OpenTestWindow(const QString& perspectiveId);
87 
91  void CloseAllTestWindows();
92 
96  IWorkbenchPage::Pointer OpenTestPage(const IWorkbenchWindow::Pointer& win);
97 
101  QList<IWorkbenchPage::Pointer> OpenTestPage(
102  const IWorkbenchWindow::Pointer& win, int pageTotal);
103 
107  void CloseAllPages(const IWorkbenchWindow::Pointer& window);
108 
109 protected:
110 
117  void Trace(const QString& msg);
118 
124  void setUp();
125 
131  void tearDown();
132 
133  static void ProcessEvents();
134 
138  void ManageWindows(bool manage);
139 
146  IWorkbench* GetWorkbench();
147 
149  {
150 
151  private:
152  bool enabled;
153  QList<IWorkbenchWindow::Pointer>& testWindows;
154 
155  public:
156 
157  TestWindowListener(QList<IWorkbenchWindow::Pointer>& testWindows);
158 
159  void SetEnabled(bool enabled);
160 
161  void WindowActivated(const IWorkbenchWindow::Pointer& window);
162 
163  void WindowDeactivated(const IWorkbenchWindow::Pointer& window);
164 
165  void WindowClosed(const IWorkbenchWindow::Pointer& window);
166 
167  void WindowOpened(const IWorkbenchWindow::Pointer& window);
168  };
169 
171 
172 private:
173 
174  QList<IWorkbenchWindow::Pointer> testWindows;
175 
176  QScopedPointer<TestWindowListener> windowListener;
177 
178  static void Indent(std::ostream& output, unsigned int indent);
179 
180  //static void Write(IStatus status, unsigned int indent);
181 
186  void AddWindowListener();
187 
191  void RemoveWindowListener();
192 
201  void WaitOnShell(Shell::Pointer shell);
202 
203 };
204 
205 #define failuimsg(msg, exc) \
206  (this->failexc(msg, exc, __LINE__, __FILE__))
207 
208 }
209 
210 #endif /* BERRYUITESTCASE_H_ */
IWorkbench * fWorkbench