ctkTestApplication.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 /*=========================================================================
00021 
00022   Program:   Visualization Toolkit
00023   Module:    $RCSfile: QTestApp.h,v $
00024 
00025   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00026   All rights reserved.
00027   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00028 
00029      This software is distributed WITHOUT ANY WARRANTY; without even
00030      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00031      PURPOSE.  See the above copyright notice for more information.
00032 
00033 =========================================================================*/
00034 /*-------------------------------------------------------------------------
00035   Copyright 2008 Sandia Corporation.
00036   Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00037   the U.S. Government retains certain rights in this software.
00038 -------------------------------------------------------------------------*/
00039 
00040 #ifndef __ctkTestApplication_h
00041 #define __ctkTestApplication_h
00042 
00043 // Qt includes
00044 #include <QApplication>
00045 #include <QVector>
00046 #include <QByteArray>
00047 #include <QTimer>
00048 
00050 #define QCTK_DECLARE_TEST(TEST_NAME)                \
00051 namespace                                           \
00052 {                                                   \
00053 class _TEST_NAME : public ctkTestApplication       \
00054 {                                                   \
00055 public:                                             \
00056   _TEST_NAME(int _argc, char * _argv []):           \
00057     ctkTestApplication(_argc, _argv){}             \
00058   virtual void runTest();                           \
00059 };                                                  \
00060                                                     \
00061 void _TEST_NAME::runTest()                          \
00062 
00064 #define QCTK_RUN_TEST(TEST_NAME)                      \
00065 }                                                     \
00066                                                       \
00067 int TEST_NAME(int _argc, char * _argv [] )            \
00068 {                                                     \
00069   _TEST_NAME app(_argc, _argv);                       \
00070   QTimer::singleShot(0, &app, SLOT(runTestSlot()));   \
00071   return _TEST_NAME::exec();                          \
00072 }
00073 
00075 #define QCTK_EXIT_TEST(_status)    \
00076   QCoreApplication::exit(_status); \
00077   return;
00078   
00079 #include "CTKWidgetsExport.h"
00080   
00081 
00082 class CTK_WIDGETS_EXPORT ctkTestApplication : public QObject
00083 {
00084   Q_OBJECT
00085   
00086 public:
00087   ctkTestApplication(int _argc, char** _argv);
00088   ~ctkTestApplication();
00089 
00092   virtual void runTest();
00093   
00098   static int exec(bool reportErrorsOnExit=false);
00099 
00100   static void messageHandler(QtMsgType type, const char *msg);
00101 
00102   static void delay(int ms);
00103 
00104   static bool simulateEvent(QWidget* w, QEvent* e);
00105 
00106   static void keyUp(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00107 
00108   static void keyDown(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00109 
00110   static void keyClick(QWidget* w, Qt::Key key, Qt::KeyboardModifiers mod, int ms);
00111 
00112   static void mouseDown(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00113                         Qt::KeyboardModifiers mod, int ms);
00114   
00115   static void mouseUp(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00116                       Qt::KeyboardModifiers mod, int ms);
00117   
00118   static void mouseMove(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00119                         Qt::KeyboardModifiers mod, int ms);
00120 
00121   static void mouseClick(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00122                          Qt::KeyboardModifiers mod, int ms);
00123 
00124   static void mouseDClick(QWidget* w, QPoint pos, Qt::MouseButton btn, 
00125                           Qt::KeyboardModifiers mod, int ms);
00126 
00127 public slots:
00128 
00131   void runTestSlot(); 
00132 
00133 private:
00134   QApplication*     App;
00135   static int        Error;
00136   QList<QByteArray> Argv;
00137   QVector<char*>    Argvp;
00138   int               Argc;
00139 };
00140 
00141 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated on 21 May 2010 for CTK by  doxygen 1.6.1