qCTKTestApplication.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   qCTK
00004 
00005   Copyright (c) Kitware Inc. 
00006   All rights reserved.
00007   Distributed under a BSD License. See LICENSE.txt file.
00008 
00009   This software is distributed "AS IS" WITHOUT ANY WARRANTY; without even
00010   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011   See the above copyright notice for more information.
00012 
00013 =========================================================================*/
00014 /*=========================================================================
00015 
00016   Program:   Visualization Toolkit
00017   Module:    $RCSfile: QTestApp.h,v $
00018 
00019   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00020   All rights reserved.
00021   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00022 
00023      This software is distributed WITHOUT ANY WARRANTY; without even
00024      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00025      PURPOSE.  See the above copyright notice for more information.
00026 
00027 =========================================================================*/
00028 /*-------------------------------------------------------------------------
00029   Copyright 2008 Sandia Corporation.
00030   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00031   the U.S. Government retains certain rights in this software.
00032 -------------------------------------------------------------------------*/
00033 
00034 #ifndef __qCTKTestApplication_h
00035 #define __qCTKTestApplication_h
00036 
00037 // QT includes
00038 #include <QApplication>
00039 #include <QVector>
00040 #include <QByteArray>
00041 #include <QTimer>
00042 
00044 #define QCTK_DECLARE_TEST(TEST_NAME)                \
00045 namespace                                           \
00046 {                                                   \
00047 class _TEST_NAME : public qCTKTestApplication       \
00048 {                                                   \
00049 public:                                             \
00050   _TEST_NAME(int _argc, char * _argv []):           \
00051     qCTKTestApplication(_argc, _argv){}             \
00052   virtual void runTest();                           \
00053 };                                                  \
00054                                                     \
00055 void _TEST_NAME::runTest()                          \
00056 
00058 #define QCTK_RUN_TEST(TEST_NAME)                      \
00059 }                                                     \
00060                                                       \
00061 int TEST_NAME(int _argc, char * _argv [] )            \
00062 {                                                     \
00063   _TEST_NAME app(_argc, _argv);                       \
00064   QTimer::singleShot(0, &app, SLOT(runTestSlot()));   \
00065   return _TEST_NAME::exec();                          \
00066 }
00067 
00069 #define QCTK_EXIT_TEST(_status)    \
00070   QCoreApplication::exit(_status); \
00071   return;
00072   
00073 #include "qCTKWidgetsExport.h"
00074   
00075 
00076 class QCTK_WIDGETS_EXPORT qCTKTestApplication : public QObject
00077 {
00078   Q_OBJECT
00079   
00080 public:
00081   qCTKTestApplication(int _argc, char** _argv);
00082   ~qCTKTestApplication();
00083 
00086   virtual void runTest();
00087   
00092   static int exec(bool reportErrorsOnExit=false);
00093 
00094   static void messageHandler(QtMsgType type, const char *msg);
00095 
00096   static void delay(int ms);
00097 
00098   static bool simulateEvent(QWidget* w, QEvent* e);
00099 
00100   static void keyUp(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00101 
00102   static void keyDown(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00103 
00104   static void keyClick(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00105 
00106   static void mouseDown(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00107                         Qt::KeyboardModifiers mod, int ms);
00108   
00109   static void mouseUp(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00110                       Qt::KeyboardModifiers mod, int ms);
00111   
00112   static void mouseMove(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00113                         Qt::KeyboardModifiers mod, int ms);
00114 
00115   static void mouseClick(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00116                          Qt::KeyboardModifiers mod, int ms);
00117 
00118   static void mouseDClick(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00119                           Qt::KeyboardModifiers mod, int ms);
00120 
00121 public slots:
00122 
00125   void runTestSlot(); 
00126 
00127 private:
00128   QApplication*     App;
00129   static int        Error;
00130   QList<QByteArray> Argv;
00131   QVector<char*>    Argvp;
00132   int               Argc;
00133 };
00134 
00135 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1