00001
00002
00003
00004
00005 #ifndef BALL_VIEW_WIDGETS_TESTFRAMEWORK_H
00006 #define BALL_VIEW_WIDGETS_TESTFRAMEWORK_H
00007
00008 #ifndef BALL_VIEW_WIDGETS_DOCKWIDGET_H
00009 # include <BALL/VIEW/WIDGETS/dockWidget.h>
00010 #endif
00011
00012 #ifndef BALL_SYSTEM_FILE_H
00013 # include <BALL/SYSTEM/file.h>
00014 #endif
00015
00016 #ifndef BALL_SYSTEM_TIMER_H
00017 # include <BALL/SYSTEM/timer.h>
00018 #endif
00019
00020 #include <QtCore/QThread>
00021
00022 class QAction;
00023
00024 namespace BALL
00025 {
00026 namespace VIEW
00027 {
00058 class BALL_VIEW_EXPORT TestFramework
00059 : public QWidget,
00060 public ModularWidget
00061 {
00062 Q_OBJECT
00063
00064 class MyMouseEvent
00065 : public QMouseEvent
00066 {
00067 public:
00068
00069 MyMouseEvent(Type type, const QPoint & position, Qt::MouseButton button,
00070 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
00071 : QMouseEvent(type, position, button, buttons, modifiers) {}
00072 };
00073
00074 class MyEventThread
00075 : public QThread
00076 {
00077 public:
00078
00079 MyEventThread();
00080
00081 virtual void run();
00082
00083 TestFramework* tf;
00084 MainControl* mc;
00085 };
00086
00087 friend class MyEventThread;
00088
00089 public:
00090
00091 BALL_EMBEDDABLE(TestFramework,DockWidget)
00092
00093
00094 TestFramework(QWidget *parent = 0, const char *name = 0);
00095
00097 virtual ~TestFramework();
00098
00099
00100 virtual void initializeWidget(MainControl& main_control);
00101
00103 void setFilename(const String& filename);
00104
00106 void checkMenu(MainControl& main_control);
00107
00109 virtual bool canHandle(const String& fileformat) const;
00110
00112 virtual bool openFile(const String& filename);
00113
00114 public slots:
00115
00117 void startTest();
00118
00120 void stopTest();
00121
00123 void runTest();
00124
00126 void abortTest();
00127
00129 void saveFile();
00130
00132 void loadFile();
00133
00135 virtual bool eventFilter(QObject*, QEvent* e);
00136
00138 virtual void timeOut();
00139
00141 void switchRecordMove();
00142
00143 protected:
00144
00145 virtual bool event(QEvent* e);
00146
00147 void storeEvent(QEvent& e);
00148
00149 void processEvent_();
00150
00151 QAction* start_recording, *stop_recording, *run_test, *abort_test,
00152 *save_file, *load_file, *switch_move;
00153 QAction* action_;
00154
00155 File outfile_;
00156 File infile_;
00157 String filename_;
00158 Timer timer_, runtime_;
00159 list<String>lines_;
00160 QWidget* widget_, *last_widget_;
00161 float time_;
00162 bool event_busy_;
00163 Index x_, y_;
00164 int modifiers_, type_, our_type_, button_, buttons_;
00165 bool test_running_, recording_;
00166 String last_event_string_, last_names_, shortcut_;
00167 String python_line_;
00168 String expected_result_;
00169 MyEventThread thread_;
00170 Size errors_;
00171 QEvent* last_event_;
00172 bool is_command_line_;
00173 float max_run_time_;
00174 Position line_nr_;
00175 };
00176
00177 } }
00178
00179 #endif // BALL_VIEW_WIDGETS_TESTFRAMEWORK_H