testFramework.h

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