CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkEventTranslatorPlayerWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Kitware Inc.
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 #ifndef __ctkEventTranslatorPlayerWidget_h
21 #define __ctkEventTranslatorPlayerWidget_h
22 
23 // Qt includes
24 #include <QDateTime>
25 #include <QMainWindow>
26 
27 // CTK includes
28 #if !defined(NO_SYMBOL_EXPORT)
29 # include "ctkQtTestingExport.h"
30 #else
31 # define CTK_QTTESTING_EXPORT
32 #endif
33 class ctkCallback;
34 class ctkEventTranslatorPlayerWidgetPrivate;
35 
36 // QtTesting includes
37 class pqTestUtility;
38 class pqWidgetEventPlayer;
39 class pqWidgetEventTranslator;
40 
41 //-----------------------------------------------------------------------------
42 #define CTKCOMPARE(actual, expected) \
43 do \
44 {\
45  if (!ctkEventTranslatorPlayerWidget::compare(actual, expected, #actual, #expected, __FILE__, __LINE__))\
46  { \
47  return;\
48  } \
49 } while (0)
50 
51 //-----------------------------------------------------------------------------
52 class CTK_QTTESTING_EXPORT ctkEventTranslatorPlayerWidget
53  : public QMainWindow
54 {
55  Q_OBJECT
56 public:
57  typedef QMainWindow Superclass;
60 
61  void addTestCase(QWidget* widget, QString fileName, void(*newCallback)(void* data));
62  void addTestCase(QDialog* dialog, QString fileName, void(*newCallback)(void* data));
63 
64  void setTestUtility(pqTestUtility* newTestUtility);
65  pqTestUtility* testUtility() const;
66 
67  void addWidgetEventPlayer(pqWidgetEventPlayer* player);
68  void addWidgetEventTranslator(pqWidgetEventTranslator* translator);
69 
70  static const char* enumValueToKey(QObject* object, const char* enumName, int value);
71 
72  static bool compare(const double& actual, const double& expected,
73  const char* actualName, const char* expectedName, const char * function, int line);
74  static bool compare(const int& actual, const int& expected,
75  const char* actualName, const char* expectedName, const char * function, int line);
76  static bool compare(const QString& actual,const QString& expected,
77  const char* actualName, const char* expectedName, const char * function, int line);
78  static bool compare(const QStringList& actual,const QStringList& expected,
79  const char* actualName, const char* expectedName, const char * function, int line);
80  static bool compare(const QDateTime& actual,const QDateTime& expected,
81  const char* actualName, const char* expectedName, const char * function, int line);
82  static bool compare(const QColor& actual,const QColor& expected,
83  const char* actualName, const char* expectedName, const char * function, int line);
84  static bool compare(const QImage& actual,const QImage& expected,
85  const char* actualName, const char* expectedName, const char * function, int line);
86 
87 public slots:
88  void play();
89 
90 protected slots:
91  void record(int currentTestCase);
92  bool play(int currentTestCase);
93  void popupDialog();
94  void onClickedPlayback(bool);
95  void onClickedRecord(bool);
96  void switchTestCase(int testCase);
97 
98 signals:
99  void startPlayerBack(QWidget* widget);
100  void playerDone(QWidget* widget);
101  void recordDone(QWidget* widget);
102 
103 protected:
104  QScopedPointer< ctkEventTranslatorPlayerWidgetPrivate > d_ptr;
105 private:
106  Q_DECLARE_PRIVATE(ctkEventTranslatorPlayerWidget);
107  Q_DISABLE_COPY(ctkEventTranslatorPlayerWidget);
108 
109  struct InfoTestCase {
110  QWidget* Widget;
111  ctkCallback* Callback;
112  QString FileName;
113  bool Dialog;
114  };
115 
116 };
117 
118 #endif
static bool compare(const QColor &actual, const QColor &expected, const char *actualName, const char *expectedName, const char *function, int line)
void switchTestCase(int testCase)
void addTestCase(QWidget *widget, QString fileName, void(*newCallback)(void *data))
void addWidgetEventPlayer(pqWidgetEventPlayer *player)
void recordDone(QWidget *widget)
static bool compare(const double &actual, const double &expected, const char *actualName, const char *expectedName, const char *function, int line)
pqTestUtility * testUtility() const
static bool compare(const QStringList &actual, const QStringList &expected, const char *actualName, const char *expectedName, const char *function, int line)
bool play(int currentTestCase)
static const char * enumValueToKey(QObject *object, const char *enumName, int value)
static bool compare(const int &actual, const int &expected, const char *actualName, const char *expectedName, const char *function, int line)
void startPlayerBack(QWidget *widget)
static bool compare(const QString &actual, const QString &expected, const char *actualName, const char *expectedName, const char *function, int line)
void addWidgetEventTranslator(pqWidgetEventTranslator *translator)
void playerDone(QWidget *widget)
void addTestCase(QDialog *dialog, QString fileName, void(*newCallback)(void *data))
void record(int currentTestCase)
void setTestUtility(pqTestUtility *newTestUtility)
QScopedPointer< ctkEventTranslatorPlayerWidgetPrivate > d_ptr
static bool compare(const QDateTime &actual, const QDateTime &expected, const char *actualName, const char *expectedName, const char *function, int line)
static bool compare(const QImage &actual, const QImage &expected, const char *actualName, const char *expectedName, const char *function, int line)