QTest Namespace Reference


Detailed Description

The QTest namespace contains all the functions and declarations that are related to the QTestLib tool.

QtTest

Please refer to the {QTestLib Manual} documentation for information on how to write unit tests.


Classes

struct  TestFunction
struct  QTestDataSetter
struct  IgnoreResultList

Enumerations

enum  
enum  SkipMode
enum  TestFailMode
enum  KeyAction
enum  MouseAction

Functions

Qt::Key asciiToKey (char ascii)
char keyToAscii (Qt::Key key)
static const char * incidentType2String (QAbstractTestLogger::IncidentTypes type)
static const char * messageType2String (QAbstractTestLogger::MessageTypes type)
static void outputMessage (const char *str)
static void printMessage (const char *type, const char *msg, const char *file=0, int line=0)
static void qPrintMessage (const QByteArray &ba)
static QByteArray memberName (const QMetaMethod &member)
static void qSignalDumperCallback (QObject *caller, int method_index, void **argv)
static void qSignalDumperCallbackSlot (QObject *caller, int method_index, void **argv)
static void qSignalDumperCallbackEndSignal (QObject *caller, int)
template<>
char * toString (const QLatin1String &str)
template<>
char * toString (const QString &str)
template<>
char * toString (const QTime &time)
template<>
char * toString (const QDate &date)
template<>
char * toString (const QDateTime &dateTime)
template<>
char * toString (const QChar &c)
template<>
char * toString (const QPoint &p)
template<>
char * toString (const QSize &s)
template<>
char * toString (const QRect &s)
template<>
char * toString (const QPointF &p)
template<>
char * toString (const QSizeF &s)
template<>
char * toString (const QRectF &s)
template<>
bool qCompare (QString const &t1, QLatin1String const &t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare (QLatin1String const &t1, QString const &t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare (QStringList const &t1, QStringList const &t2, const char *actual, const char *expected, const char *file, int line)
template<typename T>
bool qCompare (QFlags< T > const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line)
template<typename T>
bool qCompare (QFlags< T > const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line)
int Q_TESTLIB_EXPORT qt_snprintf (char *str, int size, const char *format,...)
template<>
bool qCompare (QIcon const &t1, QIcon const &t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare (QPixmap const &t1, QPixmap const &t2, const char *actual, const char *expected, const char *file, int line)
bool Q_TESTLIB_EXPORT defaultKeyVerbose ()
int defaultEventDelay ()
int Q_TESTLIB_EXPORT defaultMouseDelay ()
int Q_TESTLIB_EXPORT defaultKeyDelay ()
static bool isValidSlot (const QMetaMethod &sl)
static void qPrintTestSlots ()
static int qToInt (char *str)
static void qParseArgs (int argc, char *argv[])
static bool qInvokeTestMethod (const char *slotName, const char *data=0)
void * fetchData (QTestData *data, const char *tagName, int typeId)
int qExec (QObject *testObject, int argc, char **argv)
void qFail (const char *statementStr, const char *file, int line)
bool qVerify (bool statement, const char *statementStr, const char *description, const char *file, int line)
void qSkip (const char *message, QTest::SkipMode mode, const char *file, int line)
bool qExpectFail (const char *dataIndex, const char *comment, QTest::TestFailMode mode, const char *file, int line)
void qWarn (const char *message)
void ignoreMessage (QtMsgType type, const char *message)
void * qData (const char *tagName, int typeId)
void * qGlobalData (const char *tagName, int typeId)
void * qElementData (const char *tagName, int metaTypeId)
void addColumnInternal (int id, const char *name)
QTestDatanewRow (const char *dataTag)
const char * currentTestFunction ()
const char * currentDataTag ()
bool currentTestFailed ()
void qSleep (int ms)
QObjecttestObject ()
bool compare_helper (bool success, const char *msg, const char *file, int line)
bool compare_helper (bool success, const char *msg, char *val1, char *val2, const char *actual, const char *expected, const char *file, int line)
char * toString (const char *str)
char * toString (const void *p)
bool compare_string_helper (const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
template<typename T>
char * toString (const T &)
template<typename T>
void addColumn (const char *name, T *=0)
template<typename T>
bool qCompare (T const &t1, T const &t2, const char *actual, const char *expected, const char *file, int line)
template<>
Q_TESTLIB_EXPORT bool qCompare< float > (float const &t1, float const &t2, const char *actual, const char *expected, const char *file, int line)
template<>
Q_TESTLIB_EXPORT bool qCompare< double > (double const &t1, double const &t2, const char *actual, const char *expected, const char *file, int line)
bool compare_ptr_helper (const void *t1, const void *t2, const char *actual, const char *expected, const char *file, int line)
template<typename T1, typename T2>
bool qCompare (T1 const &, T2 const &, const char *, const char *, const char *, int)
template<typename T>
bool qCompare (const T *t1, const T *t2, const char *actual, const char *expected, const char *file, int line)
template<typename T>
bool qCompare (T *t1, T *t2, const char *actual, const char *expected, const char *file, int line)
template<typename T1, typename T2>
bool qCompare (const T1 *t1, const T2 *t2, const char *actual, const char *expected, const char *file, int line)
template<typename T1, typename T2>
bool qCompare (T1 *t1, T2 *t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare< char > (const char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare< char > (char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare (char *t1, const char *t2, const char *actual, const char *expected, const char *file, int line)
template<>
bool qCompare (const char *t1, char *t2, const char *actual, const char *expected, const char *file, int line)
template<class T>
bool qTest (const T &actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line)
static void simulateEvent (QWidget *widget, bool press, int code, Qt::KeyboardModifiers modifier, QString text, bool repeat, int delay=-1)
static void sendKeyEvent (KeyAction action, QWidget *widget, Qt::Key code, QString text, Qt::KeyboardModifiers modifier, int delay=-1)
static void sendKeyEvent (KeyAction action, QWidget *widget, Qt::Key code, char ascii, Qt::KeyboardModifiers modifier, int delay=-1)
static void keyEvent (KeyAction action, QWidget *widget, char ascii, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyEvent (KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyClicks (QWidget *widget, const QString &sequence, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyPress (QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyRelease (QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyClick (QWidget *widget, char key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyPress (QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyRelease (QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static void keyClick (QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier=Qt::NoModifier, int delay=-1)
static bool handleIgnoredMessage (QtMsgType type, const char *msg)
static void messageHandler (QtMsgType type, const char *msg)
static void mouseEvent (MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
void mousePress (QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=0, QPoint pos=QPoint(), int delay=-1)
void mouseRelease (QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=0, QPoint pos=QPoint(), int delay=-1)
void mouseClick (QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=0, QPoint pos=QPoint(), int delay=-1)
void mouseDClick (QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey=0, QPoint pos=QPoint(), int delay=-1)
void mouseMove (QWidget *widget, QPoint pos=QPoint(), int delay=-1)
static void qWait (int ms)
static const char * xmlMessageType2String (QAbstractTestLogger::MessageTypes type)
static const char * xmlIncidentType2String (QAbstractTestLogger::IncidentTypes type)
static bool isEmpty (const char *str)
static const char * incidentFormatString (bool noDescription, bool noTag)
static const char * messageFormatString (bool noDescription, bool noTag)

Variables

static FILE * stream = 0
static int iLevel = 0
static int ignoreLevel = 0
static bool skipCurrentTest = false
static QObjectcurrentTestObject = 0
QTest::TestFunction testFuncs [512]
static int lastTestFuncIdx = -1
static int keyDelay = -1
static int mouseDelay = -1
static int eventDelay = -1
static int keyVerbose = -1
static IgnoreResultListignoreResultList = 0
static QTestLog::LogMode logMode = QTestLog::Plain
static int verbosity = 0
static int maxWarnings = 2002
static QAbstractTestLoggertestLogger = 0
static const char * outFile = 0
static QtMsgHandler oldMessageHandler
static QTestDatacurrentTestData = 0
static QTestDatacurrentGlobalTestData = 0
static const char * currentTestFunc = 0
static const char * currentTestObjectName = 0
static bool failed = false
static bool dataFailed = false
static QTestResult::TestLocation location = QTestResult::NoWhere
static int fails = 0
static int passes = 0
static int skips = 0
static const char * expectFailComment = 0
static int expectFailMode = 0


Enumeration Type Documentation

anonymous enum

Definition at line 44 of file qsignaldumper.cpp.

00044 { IndentSpacesCount = 4 };

enum QTest::KeyAction

This enum describes possible actions for key handling.

Press The key is pressed. Release The key is released. Click The key is clicked (pressed and released).

Definition at line 46 of file qtestkeyboard.h.

00046 { Press, Release, Click };

enum QTest::MouseAction

This enum describes possible actions for mouse handling.

MousePress A mouse button is pressed. MouseRelease A mouse button is released. MouseClick A mouse button is clicked (pressed and released). MouseDClick A mouse button is double clicked (pressed and released twice). MouseMove The mouse pointer has moved.

Definition at line 47 of file qtestmouse.h.

enum QTest::SkipMode

This enum describes the modes for skipping tests during execution of the test data.

SkipSingle Skips the current entry in the test table; continues execution of all the other entries in the table.

SkipAll Skips all the entries in the test table; the test won't be executed further.

See also:
QSKIP()

Definition at line 52 of file qtest_global.h.

00052 { SkipSingle = 1, SkipAll = 2 };

enum QTest::TestFailMode

This enum describes the modes for handling an expected failure of the QVERIFY() or QCOMPARE() macros.

Abort Aborts the execution of the test. Use this mode when it doesn't make sense to execute the test any further after the expected failure.

Continue Continues execution of the test after the expected failure.

See also:
QEXPECT_FAIL()

Definition at line 53 of file qtest_global.h.

00053 { Abort = 1, Continue = 2 };


Function Documentation

template<typename T>
void QTest::addColumn ( const char *  name,
T *  dummy = 0 
) [inline]

Adds a column with type {T} to the current test data. name is the name of the column. dummy is a workaround for buggy compilers and can be ignored.

To populate the column with values, newRow() can be used. Use QFETCH() to fetch the data in the actual test.

Example:

    void myTestFunction_data() {
        QTest::addColumn<int>("intval");
        QTest::addColumn<QString>("str");
        QTest::addColumn<double>("dbl");

        QTest::newRow("row1") << 1 << "hello" << 1.5;
    }

To add custom types to the testdata, the type must be registered with QMetaType via Q_DECLARE_METATYPE().

{Note:} This macro can only be used in a test's data function that is invoked by the test framework.

See {Chapter 2: Data Driven Testing}{Data Driven Testing} for a more extensive example.

See also:
QTest::newRow(), QFETCH(), QMetaType

Definition at line 141 of file qtestcase.h.

References addColumnInternal().

00142     {
00143         addColumnInternal(qMetaTypeId<T>(), name);
00144     }

Here is the call graph for this function:

Q_TESTLIB_EXPORT void QTest::addColumnInternal ( int  id,
const char *  name 
)

Definition at line 1254 of file qtestcase.cpp.

References QTestTable::addColumn(), QTestTable::currentTestTable(), and QTEST_ASSERT_X.

Referenced by addColumn().

01255 {
01256     QTestTable *tbl = QTestTable::currentTestTable();
01257     QTEST_ASSERT_X(tbl, "QTest::addColumn()", "Cannot add testdata outside of a _data slot.");
01258 
01259     tbl->addColumn(id, name);
01260 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT Qt::Key QTest::asciiToKey ( char  ascii  ) 

Definition at line 34 of file qasciikey.cpp.

References Qt::Key_0, Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_A, Qt::Key_Aacute, Qt::Key_Acircumflex, Qt::Key_acute, Qt::Key_Adiaeresis, Qt::Key_AE, Qt::Key_Agrave, Qt::Key_Ampersand, Qt::Key_Apostrophe, Qt::Key_Aring, Qt::Key_AsciiCircum, Qt::Key_AsciiTilde, Qt::Key_Asterisk, Qt::Key_At, Qt::Key_Atilde, Qt::Key_B, Qt::Key_Backslash, Qt::Key_Backspace, Qt::Key_Backtab, Qt::Key_Bar, Qt::Key_BraceLeft, Qt::Key_BraceRight, Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_brokenbar, Qt::Key_C, Qt::Key_Ccedilla, Qt::Key_cedilla, Qt::Key_cent, Qt::Key_Colon, Qt::Key_Comma, Qt::Key_copyright, Qt::Key_currency, Qt::Key_D, Qt::Key_degree, Qt::Key_diaeresis, Qt::Key_division, Qt::Key_Dollar, Qt::Key_E, Qt::Key_Eacute, Qt::Key_Ecircumflex, Qt::Key_Ediaeresis, Qt::Key_Egrave, Qt::Key_Equal, Qt::Key_Escape, Qt::Key_ETH, Qt::Key_Exclam, Qt::Key_exclamdown, Qt::Key_F, Qt::Key_G, Qt::Key_Greater, Qt::Key_guillemotleft, Qt::Key_guillemotright, Qt::Key_H, Qt::Key_hyphen, Qt::Key_I, Qt::Key_Iacute, Qt::Key_Icircumflex, Qt::Key_Idiaeresis, Qt::Key_Igrave, Qt::Key_J, Qt::Key_K, Qt::Key_L, Qt::Key_Less, Qt::Key_M, Qt::Key_macron, Qt::Key_masculine, Qt::Key_Minus, Qt::Key_mu, Qt::Key_multiply, Qt::Key_N, Qt::Key_nobreakspace, Qt::Key_notsign, Qt::Key_Ntilde, Qt::Key_NumberSign, Qt::Key_O, Qt::Key_Oacute, Qt::Key_Ocircumflex, Qt::Key_Odiaeresis, Qt::Key_Ograve, Qt::Key_onehalf, Qt::Key_onequarter, Qt::Key_onesuperior, Qt::Key_Ooblique, Qt::Key_ordfeminine, Qt::Key_Otilde, Qt::Key_P, Qt::Key_paragraph, Qt::Key_ParenLeft, Qt::Key_ParenRight, Qt::Key_Percent, Qt::Key_Period, Qt::Key_periodcentered, Qt::Key_Plus, Qt::Key_plusminus, Qt::Key_Q, Qt::Key_Question, Qt::Key_questiondown, Qt::Key_QuoteDbl, Qt::Key_QuoteLeft, Qt::Key_R, Qt::Key_registered, Qt::Key_Return, Qt::Key_S, Qt::Key_section, Qt::Key_Semicolon, Qt::Key_Slash, Qt::Key_Space, Qt::Key_ssharp, Qt::Key_sterling, Qt::Key_T, Qt::Key_Tab, Qt::Key_THORN, Qt::Key_threequarters, Qt::Key_threesuperior, Qt::Key_twosuperior, Qt::Key_U, Qt::Key_Uacute, Qt::Key_Ucircumflex, Qt::Key_Udiaeresis, Qt::Key_Ugrave, Qt::Key_Underscore, Qt::Key_V, Qt::Key_W, Qt::Key_X, Qt::Key_Y, Qt::Key_Yacute, Qt::Key_ydiaeresis, Qt::Key_yen, Qt::Key_Z, and QTEST_ASSERT.

Referenced by keyEvent().

00035 {
00036     switch ((unsigned char)ascii) {
00037     case 0x08: return Qt::Key_Backspace;
00038     case 0x09: return Qt::Key_Tab;
00039     case 0x0b: return Qt::Key_Backtab;
00040     case 0x0d: return Qt::Key_Return;
00041     case 0x1b: return Qt::Key_Escape;
00042     case 0x20: return Qt::Key_Space;
00043     case 0x21: return Qt::Key_Exclam;
00044     case 0x22: return Qt::Key_QuoteDbl;
00045     case 0x23: return Qt::Key_NumberSign;
00046     case 0x24: return Qt::Key_Dollar;
00047     case 0x25: return Qt::Key_Percent;
00048     case 0x26: return Qt::Key_Ampersand;
00049     case 0x27: return Qt::Key_Apostrophe;
00050     case 0x28: return Qt::Key_ParenLeft;
00051     case 0x29: return Qt::Key_ParenRight;
00052     case 0x2a: return Qt::Key_Asterisk;
00053     case 0x2b: return Qt::Key_Plus;
00054     case 0x2c: return Qt::Key_Comma;
00055     case 0x2d: return Qt::Key_Minus;
00056     case 0x2e: return Qt::Key_Period;
00057     case 0x2f: return Qt::Key_Slash;
00058     case 0x30: return Qt::Key_0;
00059     case 0x31: return Qt::Key_1;
00060     case 0x32: return Qt::Key_2;
00061     case 0x33: return Qt::Key_3;
00062     case 0x34: return Qt::Key_4;
00063     case 0x35: return Qt::Key_5;
00064     case 0x36: return Qt::Key_6;
00065     case 0x37: return Qt::Key_7;
00066     case 0x38: return Qt::Key_8;
00067     case 0x39: return Qt::Key_9;
00068     case 0x3a: return Qt::Key_Colon;
00069     case 0x3b: return Qt::Key_Semicolon;
00070     case 0x3c: return Qt::Key_Less;
00071     case 0x3d: return Qt::Key_Equal;
00072     case 0x3e: return Qt::Key_Greater;
00073     case 0x3f: return Qt::Key_Question;
00074     case 0x40: return Qt::Key_At;
00075     case 0x41: return Qt::Key_A;
00076     case 0x42: return Qt::Key_B;
00077     case 0x43: return Qt::Key_C;
00078     case 0x44: return Qt::Key_D;
00079     case 0x45: return Qt::Key_E;
00080     case 0x46: return Qt::Key_F;
00081     case 0x47: return Qt::Key_G;
00082     case 0x48: return Qt::Key_H;
00083     case 0x49: return Qt::Key_I;
00084     case 0x4a: return Qt::Key_J;
00085     case 0x4b: return Qt::Key_K;
00086     case 0x4c: return Qt::Key_L;
00087     case 0x4d: return Qt::Key_M;
00088     case 0x4e: return Qt::Key_N;
00089     case 0x4f: return Qt::Key_O;
00090     case 0x50: return Qt::Key_P;
00091     case 0x51: return Qt::Key_Q;
00092     case 0x52: return Qt::Key_R;
00093     case 0x53: return Qt::Key_S;
00094     case 0x54: return Qt::Key_T;
00095     case 0x55: return Qt::Key_U;
00096     case 0x56: return Qt::Key_V;
00097     case 0x57: return Qt::Key_W;
00098     case 0x58: return Qt::Key_X;
00099     case 0x59: return Qt::Key_Y;
00100     case 0x5a: return Qt::Key_Z;
00101     case 0x5b: return Qt::Key_BracketLeft;
00102     case 0x5c: return Qt::Key_Backslash;
00103     case 0x5d: return Qt::Key_BracketRight;
00104     case 0x5e: return Qt::Key_AsciiCircum;
00105     case 0x5f: return Qt::Key_Underscore;
00106     case 0x60: return Qt::Key_QuoteLeft;
00107     case 0x61: return Qt::Key_A;
00108     case 0x62: return Qt::Key_B;
00109     case 0x63: return Qt::Key_C;
00110     case 0x64: return Qt::Key_D;
00111     case 0x65: return Qt::Key_E;
00112     case 0x66: return Qt::Key_F;
00113     case 0x67: return Qt::Key_G;
00114     case 0x68: return Qt::Key_H;
00115     case 0x69: return Qt::Key_I;
00116     case 0x6a: return Qt::Key_J;
00117     case 0x6b: return Qt::Key_K;
00118     case 0x6c: return Qt::Key_L;
00119     case 0x6d: return Qt::Key_M;
00120     case 0x6e: return Qt::Key_N;
00121     case 0x6f: return Qt::Key_O;
00122     case 0x70: return Qt::Key_P;
00123     case 0x71: return Qt::Key_Q;
00124     case 0x72: return Qt::Key_R;
00125     case 0x73: return Qt::Key_S;
00126     case 0x74: return Qt::Key_T;
00127     case 0x75: return Qt::Key_U;
00128     case 0x76: return Qt::Key_V;
00129     case 0x77: return Qt::Key_W;
00130     case 0x78: return Qt::Key_X;
00131     case 0x79: return Qt::Key_Y;
00132     case 0x7a: return Qt::Key_Z;
00133     case 0x7b: return Qt::Key_BraceLeft;
00134     case 0x7c: return Qt::Key_Bar;
00135     case 0x7d: return Qt::Key_BraceRight;
00136     case 0x7e: return Qt::Key_AsciiTilde;
00137 
00138     // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06
00139     case 0xa0: return Qt::Key_nobreakspace;
00140     case 0xa1: return Qt::Key_exclamdown;
00141     case 0xa2: return Qt::Key_cent;
00142     case 0xa3: return Qt::Key_sterling;
00143     case 0xa4: return Qt::Key_currency;
00144     case 0xa5: return Qt::Key_yen;
00145     case 0xa6: return Qt::Key_brokenbar;
00146     case 0xa7: return Qt::Key_section;
00147     case 0xa8: return Qt::Key_diaeresis;
00148     case 0xa9: return Qt::Key_copyright;
00149     case 0xaa: return Qt::Key_ordfeminine;
00150     case 0xab: return Qt::Key_guillemotleft;
00151     case 0xac: return Qt::Key_notsign;
00152     case 0xad: return Qt::Key_hyphen;
00153     case 0xae: return Qt::Key_registered;
00154     case 0xaf: return Qt::Key_macron;
00155     case 0xb0: return Qt::Key_degree;
00156     case 0xb1: return Qt::Key_plusminus;
00157     case 0xb2: return Qt::Key_twosuperior;
00158     case 0xb3: return Qt::Key_threesuperior;
00159     case 0xb4: return Qt::Key_acute;
00160     case 0xb5: return Qt::Key_mu;
00161     case 0xb6: return Qt::Key_paragraph;
00162     case 0xb7: return Qt::Key_periodcentered;
00163     case 0xb8: return Qt::Key_cedilla;
00164     case 0xb9: return Qt::Key_onesuperior;
00165     case 0xba: return Qt::Key_masculine;
00166     case 0xbb: return Qt::Key_guillemotright;
00167     case 0xbc: return Qt::Key_onequarter;
00168     case 0xbd: return Qt::Key_onehalf;
00169     case 0xbe: return Qt::Key_threequarters;
00170     case 0xbf: return Qt::Key_questiondown;
00171     case 0xc0: return Qt::Key_Agrave;
00172     case 0xc1: return Qt::Key_Aacute;
00173     case 0xc2: return Qt::Key_Acircumflex;
00174     case 0xc3: return Qt::Key_Atilde;
00175     case 0xc4: return Qt::Key_Adiaeresis;
00176     case 0xc5: return Qt::Key_Aring;
00177     case 0xc6: return Qt::Key_AE;
00178     case 0xc7: return Qt::Key_Ccedilla;
00179     case 0xc8: return Qt::Key_Egrave;
00180     case 0xc9: return Qt::Key_Eacute;
00181     case 0xca: return Qt::Key_Ecircumflex;
00182     case 0xcb: return Qt::Key_Ediaeresis;
00183     case 0xcc: return Qt::Key_Igrave;
00184     case 0xcd: return Qt::Key_Iacute;
00185     case 0xce: return Qt::Key_Icircumflex;
00186     case 0xcf: return Qt::Key_Idiaeresis;
00187     case 0xd0: return Qt::Key_ETH;
00188     case 0xd1: return Qt::Key_Ntilde;
00189     case 0xd2: return Qt::Key_Ograve;
00190     case 0xd3: return Qt::Key_Oacute;
00191     case 0xd4: return Qt::Key_Ocircumflex;
00192     case 0xd5: return Qt::Key_Otilde;
00193     case 0xd6: return Qt::Key_Odiaeresis;
00194     case 0xd7: return Qt::Key_multiply;
00195     case 0xd8: return Qt::Key_Ooblique;
00196     case 0xd9: return Qt::Key_Ugrave;
00197     case 0xda: return Qt::Key_Uacute;
00198     case 0xdb: return Qt::Key_Ucircumflex;
00199     case 0xdc: return Qt::Key_Udiaeresis;
00200     case 0xdd: return Qt::Key_Yacute;
00201     case 0xde: return Qt::Key_THORN;
00202     case 0xdf: return Qt::Key_ssharp;
00203     case 0xe5: return Qt::Key_Aring;
00204     case 0xe6: return Qt::Key_AE;
00205     case 0xf7: return Qt::Key_division;
00206     case 0xf8: return Qt::Key_Ooblique;
00207     case 0xff: return Qt::Key_ydiaeresis;
00208     default: QTEST_ASSERT(false); return Qt::Key(0);
00209     }
00210 }

Q_TESTLIB_EXPORT bool QTest::compare_helper ( bool  success,
const char *  msg,
char *  val1,
char *  val2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
)

Definition at line 1409 of file qtestcase.cpp.

References QTestResult::compare().

01411 {
01412     return QTestResult::compare(success, msg, val1, val2, actual, expected, file, line);
01413 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT bool QTest::compare_helper ( bool  success,
const char *  msg,
const char *  file,
int  line 
)

Definition at line 1402 of file qtestcase.cpp.

References QTestResult::compare().

Referenced by compare_ptr_helper(), compare_string_helper(), and qCompare().

01403 {
01404     return QTestResult::compare(success, msg, file, line);
01405 }

Here is the call graph for this function:

bool QTest::compare_ptr_helper ( const void *  t1,
const void *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 165 of file qtestcase.h.

References compare_helper(), and toString().

Referenced by qCompare().

00167     {
00168         return (t1 == t2)
00169             ? compare_helper(true, "COMPARE()", file, line)
00170             : compare_helper(false, "Compared pointers are not the same",
00171                              toString(t1), toString(t2), actual, expected, file, line);
00172     }

Here is the call graph for this function:

Q_TESTLIB_EXPORT bool QTest::compare_string_helper ( const char *  t1,
const char *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
)

Definition at line 1483 of file qtestcase.cpp.

References compare_helper(), qstrcmp(), and toString().

Referenced by qCompare().

01485 {
01486     return (qstrcmp(t1, t2) == 0)
01487             ? compare_helper(true, "COMPARE()", file, line)
01488             : compare_helper(false, "Compared strings are not the same",
01489                              toString(t1), toString(t2), actual, expected, file, line);
01490 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT const char * QTest::currentDataTag (  ) 

Returns the name of the current test data. If the test doesn't have any assigned testdata, the function returns 0.

Definition at line 1349 of file qtestcase.cpp.

References QTestResult::currentDataTag().

01350 {
01351     return QTestResult::currentDataTag();
01352 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT bool QTest::currentTestFailed (  ) 

Returns true if the current test function failed, otherwise false.

Definition at line 1357 of file qtestcase.cpp.

References QTestResult::currentTestFailed().

01358 {
01359     return QTestResult::currentTestFailed();
01360 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT const char * QTest::currentTestFunction (  ) 

Returns the name of the test function that is currently executed.

Example:

    void MyTestClass::cleanup()
    {
        if (qstrcmp(currentTestFunction(), "myDatabaseTest") == 0) {
            // clean up all database connections
            closeAllDatabases();
        }
    }

Definition at line 1340 of file qtestcase.cpp.

References QTestResult::currentTestFunction().

01341 {
01342     return QTestResult::currentTestFunction();
01343 }

Here is the call graph for this function:

int QTest::defaultEventDelay (  ) 

Definition at line 730 of file qtestcase.cpp.

References constData(), eventDelay, and qgetenv().

Referenced by defaultKeyDelay(), and defaultMouseDelay().

00731 {
00732     if (eventDelay == -1) {
00733         if (qgetenv("QTEST_EVENT_DELAY").constData())
00734             eventDelay = atoi(::qgetenv("QTEST_EVENT_DELAY"));
00735         else
00736             eventDelay = 0;
00737     }
00738     return eventDelay;
00739 }

Here is the call graph for this function:

int Q_TESTLIB_EXPORT QTest::defaultKeyDelay (  ) 

Definition at line 752 of file qtestcase.cpp.

References constData(), defaultEventDelay(), keyDelay, and qgetenv().

Referenced by simulateEvent().

00753 {
00754     if (keyDelay == -1) {
00755         if (::qgetenv("QTEST_KEYEVENT_DELAY").constData())
00756             keyDelay = atoi(qgetenv("QTEST_KEYEVENT_DELAY").constData());
00757         else
00758             keyDelay = defaultEventDelay();
00759     }
00760     return keyDelay;
00761 }

Here is the call graph for this function:

bool Q_TESTLIB_EXPORT QTest::defaultKeyVerbose (  ) 

Definition at line 722 of file qtestcase.cpp.

References constData(), keyVerbose, and qgetenv().

00723 {
00724     if (keyVerbose == -1) {
00725         keyVerbose = ::qgetenv("QTEST_KEYEVENT_VERBOSE").constData() ? 1 : 0;
00726     }
00727     return keyVerbose == 1;
00728 }

Here is the call graph for this function:

int Q_TESTLIB_EXPORT QTest::defaultMouseDelay (  ) 

Definition at line 741 of file qtestcase.cpp.

References constData(), defaultEventDelay(), mouseDelay, and qgetenv().

Referenced by mouseEvent().

00742 {
00743     if (mouseDelay == -1) {
00744         if (::qgetenv("QTEST_MOUSEEVENT_DELAY").constData())
00745             mouseDelay = atoi((::qgetenv("QTEST_MOUSEEVENT_DELAY")));
00746         else
00747             mouseDelay = defaultEventDelay();
00748     }
00749     return mouseDelay;
00750 }

Here is the call graph for this function:

void* QTest::fetchData ( QTestData data,
const char *  tagName,
int  typeId 
)

Definition at line 1017 of file qtestcase.cpp.

References data, QTEST_ASSERT, QTEST_ASSERT_X, and QMetaType::typeName().

Referenced by qData(), and qGlobalData().

01018 {
01019     QTEST_ASSERT(typeId);
01020     QTEST_ASSERT_X(data, "QTest::fetchData()", "Test data requested, but no testdata available .");
01021     QTEST_ASSERT(data->parent());
01022 
01023     int idx = data->parent()->indexOf(tagName);
01024 
01025     if (idx == -1 || idx >= data->dataCount()) {
01026         qFatal("QFETCH: Requested testdata '%s' not available, check your _data function.",
01027                 tagName);
01028     }
01029 
01030     if (typeId != data->parent()->elementTypeId(idx)) {
01031         qFatal("Requested type '%s' does not match available type '%s'.",
01032                QMetaType::typeName(typeId),
01033                QMetaType::typeName(data->parent()->elementTypeId(idx)));
01034     }
01035 
01036     return data->data(idx);
01037 }

Here is the call graph for this function:

static bool QTest::handleIgnoredMessage ( QtMsgType  type,
const char *  msg 
) [static]

Definition at line 74 of file qtestlog.cpp.

References ignoreResultList, QTest::IgnoreResultList::msg, QTest::IgnoreResultList::next, and QTest::IgnoreResultList::type.

Referenced by messageHandler().

00075     {
00076         IgnoreResultList *last = 0;
00077         IgnoreResultList *list = ignoreResultList;
00078         while (list) {
00079             if (list->type == type && strcmp(msg, list->msg) == 0) {
00080                 // remove the item from the list
00081                 if (last)
00082                     last->next = list->next;
00083                 else if (list->next)
00084                     ignoreResultList = list->next;
00085                 else
00086                     ignoreResultList = 0;
00087 
00088                 delete list;
00089                 return true;
00090             }
00091 
00092             last = list;
00093             list = list->next;
00094         }
00095         return false;
00096     }

Q_TESTLIB_EXPORT void QTest::ignoreMessage ( QtMsgType  type,
const char *  message 
)

Ignores messages created by qDebug() or qWarning(). If the message with the corresponding type is outputted, it will be removed from the test log. If the test finished and the message was not outputted, a test failure is appended to the test log.

{Note:} Invoking this function will only ignore one message. If the message you want to ignore is outputted twice, you have to call ignoreMessage() twice, too.

Example:

    QDir dir;

    QTest::ignoreMessage(QtWarningMsg, "QDir::mkdir: Empty or null file name(s)");
    dir.mkdir("");

The example above tests that QDir::mkdir() outputs the right warning when invoked with an invalid file name.

Definition at line 1217 of file qtestcase.cpp.

References QTestResult::ignoreMessage().

01218 {
01219     QTestResult::ignoreMessage(type, message);
01220 }

Here is the call graph for this function:

static const char* QTest::incidentFormatString ( bool  noDescription,
bool  noTag 
) [static]

Definition at line 133 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addIncident().

00134 {
00135     if (noDescription) {
00136         if (noTag)
00137             return "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n";
00138         else
00139             return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
00140                    "    <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
00141                    "</Incident>\n";
00142     } else {
00143         if (noTag)
00144             return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
00145                    "    <Description><![CDATA[%s%s%s%s]]></Description>\n"
00146                    "</Incident>\n";
00147         else
00148             return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
00149                    "    <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
00150                    "    <Description><![CDATA[%s]]></Description>\n"
00151                    "</Incident>\n";
00152     }
00153 }

static const char* QTest::incidentType2String ( QAbstractTestLogger::IncidentTypes  type  )  [static]

Definition at line 77 of file qplaintestlogger.cpp.

References COLORED_MSG, QAbstractTestLogger::Fail, QByteArray::isEmpty(), QAbstractTestLogger::Pass, qgetenv(), QAbstractTestLogger::XFail, and QAbstractTestLogger::XPass.

Referenced by QPlainTestLogger::addIncident().

00078     {
00079         static bool colored = (!qgetenv("QTEST_COLORED").isEmpty());
00080         switch (type) {
00081         case QAbstractTestLogger::Pass:
00082             return COLORED_MSG(0, 32, "PASS   "); //green
00083         case QAbstractTestLogger::XFail:
00084             return COLORED_MSG(1, 32, "XFAIL  "); //light green
00085         case QAbstractTestLogger::Fail:
00086             return COLORED_MSG(0, 31, "FAIL!  "); //red
00087         case QAbstractTestLogger::XPass:
00088             return COLORED_MSG(0, 31, "XPASS  "); //red, too
00089         }
00090         return "??????";
00091     }

Here is the call graph for this function:

static bool QTest::isEmpty ( const char *  str  )  [inline, static]

Definition at line 128 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addIncident(), and QXmlTestLogger::addMessage().

00129 {
00130     return !str || !str[0];
00131 }

static bool QTest::isValidSlot ( const QMetaMethod sl  )  [static]

Definition at line 763 of file qtestcase.cpp.

References QMetaMethod::access(), QList< T >::isEmpty(), len, QMetaMethod::methodType(), QMetaMethod::parameterTypes(), QMetaMethod::Private, qstrlen(), QMetaMethod::signature(), QMetaMethod::Slot, and QMetaMethod::typeName().

Referenced by qExec(), qParseArgs(), and qPrintTestSlots().

00764 {
00765     if (sl.access() != QMetaMethod::Private || !sl.parameterTypes().isEmpty()
00766         || qstrlen(sl.typeName()) || sl.methodType() != QMetaMethod::Slot)
00767         return false;
00768     const char *sig = sl.signature();
00769     int len = qstrlen(sig);
00770     if (len < 2)
00771         return false;
00772     if (sig[len - 2] != '(' || sig[len - 1] != ')')
00773         return false;
00774     if (len > 7 && strcmp(sig + (len - 7), "_data()") == 0)
00775         return false;
00776     if (strcmp(sig, "initTestCase()") == 0 || strcmp(sig, "cleanupTestCase()") == 0
00777         || strcmp(sig, "cleanup()") == 0 || strcmp(sig, "init()") == 0)
00778         return false;
00779     return true;
00780 }

Here is the call graph for this function:

static void QTest::keyClick ( QWidget widget,
Qt::Key  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 163 of file qtestkeyboard.h.

References Click, and keyEvent().

00164     { keyEvent(Click, widget, key, modifier, delay); }

Here is the call graph for this function:

static void QTest::keyClick ( QWidget widget,
char  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 157 of file qtestkeyboard.h.

References Click, and keyEvent().

00158     { keyEvent(Click, widget, key, modifier, delay); }

Here is the call graph for this function:

void QTest::keyClicks ( QWidget widget,
const QString sequence,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Simulates clicking a sequence of keys on a widget. Optionally, a keyboard modifier can be specified as well as a delay (in milliseconds) of the test before each key click.

Example:

    QTest::keyClicks(myWidget, "hello world");

The example above simulates clicking the sequence of keys representing "hello world" on myWidget without any keyboard modifiers and without delay of the test.

See also:
QTest::keyClick()

Definition at line 146 of file qtestkeyboard.h.

References QString::at(), Click, i, keyEvent(), QString::length(), and QChar::toLatin1().

Referenced by QTestKeyClicksEvent::simulate(), and TestGui::testGui().

00148     {
00149         for (int i=0; i < sequence.length(); i++)
00150             keyEvent(Click, widget, sequence.at(i).toLatin1(), modifier, delay);
00151     }

Here is the call graph for this function:

static void QTest::keyEvent ( KeyAction  action,
QWidget widget,
Qt::Key  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 142 of file qtestkeyboard.h.

References keyToAscii(), and sendKeyEvent().

Referenced by QCalendarPopup::event(), QDesignerActions::eventFilter(), QGraphicsScene::keyPressEvent(), and QGraphicsScene::keyReleaseEvent().

00144     { sendKeyEvent(action, widget, key, keyToAscii(key), modifier, delay); }

Here is the call graph for this function:

static void QTest::keyEvent ( KeyAction  action,
QWidget widget,
char  ascii,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 139 of file qtestkeyboard.h.

References asciiToKey(), and sendKeyEvent().

Referenced by keyClick(), keyClicks(), keyPress(), keyRelease(), and QTestKeyEvent::simulate().

00141     { sendKeyEvent(action, widget, asciiToKey(ascii), ascii, modifier, delay); }

Here is the call graph for this function:

static void QTest::keyPress ( QWidget widget,
Qt::Key  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 159 of file qtestkeyboard.h.

References keyEvent(), and Press.

00160     { keyEvent(Press, widget, key, modifier, delay); }

Here is the call graph for this function:

static void QTest::keyPress ( QWidget widget,
char  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 153 of file qtestkeyboard.h.

References keyEvent(), and Press.

00154     { keyEvent(Press, widget, key, modifier, delay); }

Here is the call graph for this function:

static void QTest::keyRelease ( QWidget widget,
Qt::Key  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 161 of file qtestkeyboard.h.

References keyEvent(), and Release.

00162     { keyEvent(Release, widget, key, modifier, delay); }

Here is the call graph for this function:

static void QTest::keyRelease ( QWidget widget,
char  key,
Qt::KeyboardModifiers  modifier = Qt::NoModifier,
int  delay = -1 
) [inline, static]

Definition at line 155 of file qtestkeyboard.h.

References keyEvent(), and Release.

00156     { keyEvent(Release, widget, key, modifier, delay); }

Here is the call graph for this function:

Q_TESTLIB_EXPORT char QTest::keyToAscii ( Qt::Key  key  ) 

Definition at line 219 of file qasciikey.cpp.

References Qt::Key_0, Qt::Key_1, Qt::Key_2, Qt::Key_3, Qt::Key_4, Qt::Key_5, Qt::Key_6, Qt::Key_7, Qt::Key_8, Qt::Key_9, Qt::Key_A, Qt::Key_Aacute, Qt::Key_Acircumflex, Qt::Key_acute, Qt::Key_Adiaeresis, Qt::Key_AE, Qt::Key_Agrave, Qt::Key_Alt, Qt::Key_Ampersand, Qt::Key_Apostrophe, Qt::Key_Aring, Qt::Key_AsciiCircum, Qt::Key_AsciiTilde, Qt::Key_Asterisk, Qt::Key_At, Qt::Key_Atilde, Qt::Key_B, Qt::Key_Back, Qt::Key_Backslash, Qt::Key_Backspace, Qt::Key_Backtab, Qt::Key_Bar, Qt::Key_BassBoost, Qt::Key_BassDown, Qt::Key_BassUp, Qt::Key_BraceLeft, Qt::Key_BraceRight, Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_brokenbar, Qt::Key_C, Qt::Key_CapsLock, Qt::Key_Ccedilla, Qt::Key_cedilla, Qt::Key_cent, Qt::Key_Clear, Qt::Key_Colon, Qt::Key_Comma, Qt::Key_Control, Qt::Key_copyright, Qt::Key_currency, Qt::Key_D, Qt::Key_degree, Qt::Key_Delete, Qt::Key_diaeresis, Qt::Key_Direction_L, Qt::Key_Direction_R, Qt::Key_division, Qt::Key_Dollar, Qt::Key_Down, Qt::Key_E, Qt::Key_Eacute, Qt::Key_Ecircumflex, Qt::Key_Ediaeresis, Qt::Key_Egrave, Qt::Key_End, Qt::Key_Enter, Qt::Key_Equal, Qt::Key_Escape, Qt::Key_ETH, Qt::Key_Exclam, Qt::Key_exclamdown, Qt::Key_F, Qt::Key_F1, Qt::Key_F10, Qt::Key_F11, Qt::Key_F12, Qt::Key_F13, Qt::Key_F14, Qt::Key_F15, Qt::Key_F16, Qt::Key_F17, Qt::Key_F18, Qt::Key_F19, Qt::Key_F2, Qt::Key_F20, Qt::Key_F21, Qt::Key_F22, Qt::Key_F23, Qt::Key_F24, Qt::Key_F25, Qt::Key_F26, Qt::Key_F27, Qt::Key_F28, Qt::Key_F29, Qt::Key_F3, Qt::Key_F30, Qt::Key_F31, Qt::Key_F32, Qt::Key_F33, Qt::Key_F34, Qt::Key_F35, Qt::Key_F4, Qt::Key_F5, Qt::Key_F6, Qt::Key_F7, Qt::Key_F8, Qt::Key_F9, Qt::Key_Favorites, Qt::Key_Forward, Qt::Key_G, Qt::Key_Greater, Qt::Key_guillemotleft, Qt::Key_guillemotright, Qt::Key_H, Qt::Key_Help, Qt::Key_Home, Qt::Key_HomePage, Qt::Key_Hyper_L, Qt::Key_Hyper_R, Qt::Key_hyphen, Qt::Key_I, Qt::Key_Iacute, Qt::Key_Icircumflex, Qt::Key_Idiaeresis, Qt::Key_Igrave, Qt::Key_Insert, Qt::Key_J, Qt::Key_K, Qt::Key_L, Qt::Key_Launch0, Qt::Key_Launch1, Qt::Key_Launch2, Qt::Key_Launch3, Qt::Key_Launch4, Qt::Key_Launch5, Qt::Key_Launch6, Qt::Key_Launch7, Qt::Key_Launch8, Qt::Key_Launch9, Qt::Key_LaunchA, Qt::Key_LaunchB, Qt::Key_LaunchC, Qt::Key_LaunchD, Qt::Key_LaunchE, Qt::Key_LaunchF, Qt::Key_LaunchMail, Qt::Key_LaunchMedia, Qt::Key_Left, Qt::Key_Less, Qt::Key_M, Qt::Key_macron, Qt::Key_masculine, Qt::Key_MediaNext, Qt::Key_MediaPlay, Qt::Key_MediaPrevious, Qt::Key_MediaRecord, Qt::Key_MediaStop, Qt::Key_Menu, Qt::Key_Meta, Qt::Key_Minus, Qt::Key_mu, Qt::Key_multiply, Qt::Key_N, Qt::Key_nobreakspace, Qt::Key_notsign, Qt::Key_Ntilde, Qt::Key_NumberSign, Qt::Key_NumLock, Qt::Key_O, Qt::Key_Oacute, Qt::Key_Ocircumflex, Qt::Key_Odiaeresis, Qt::Key_Ograve, Qt::Key_onehalf, Qt::Key_onequarter, Qt::Key_onesuperior, Qt::Key_Ooblique, Qt::Key_OpenUrl, Qt::Key_ordfeminine, Qt::Key_Otilde, Qt::Key_P, Qt::Key_PageDown, Qt::Key_PageUp, Qt::Key_paragraph, Qt::Key_ParenLeft, Qt::Key_ParenRight, Qt::Key_Pause, Qt::Key_Percent, Qt::Key_Period, Qt::Key_periodcentered, Qt::Key_Plus, Qt::Key_plusminus, Qt::Key_Print, Qt::Key_Q, Qt::Key_Question, Qt::Key_questiondown, Qt::Key_QuoteDbl, Qt::Key_QuoteLeft, Qt::Key_R, Qt::Key_Refresh, Qt::Key_registered, Qt::Key_Return, Qt::Key_Right, Qt::Key_S, Qt::Key_ScrollLock, Qt::Key_Search, Qt::Key_section, Qt::Key_Semicolon, Qt::Key_Shift, Qt::Key_Slash, Qt::Key_Space, Qt::Key_ssharp, Qt::Key_Standby, Qt::Key_sterling, Qt::Key_Stop, Qt::Key_Super_L, Qt::Key_Super_R, Qt::Key_SysReq, Qt::Key_T, Qt::Key_Tab, Qt::Key_THORN, Qt::Key_threequarters, Qt::Key_threesuperior, Qt::Key_TrebleDown, Qt::Key_TrebleUp, Qt::Key_twosuperior, Qt::Key_U, Qt::Key_Uacute, Qt::Key_Ucircumflex, Qt::Key_Udiaeresis, Qt::Key_Ugrave, Qt::Key_Underscore, Qt::Key_Up, Qt::Key_V, Qt::Key_VolumeDown, Qt::Key_VolumeMute, Qt::Key_VolumeUp, Qt::Key_W, Qt::Key_X, Qt::Key_Y, Qt::Key_Yacute, Qt::Key_ydiaeresis, Qt::Key_yen, Qt::Key_Z, and QTEST_ASSERT.

Referenced by keyEvent().

00220 {
00221     switch (key) {
00222     case Qt::Key_Backspace: return 0x8; //BS
00223     case Qt::Key_Tab: return 0x09; // HT
00224     case Qt::Key_Backtab: return 0x0b; // VT
00225     case Qt::Key_Enter:
00226     case Qt::Key_Return: return 0x0d; // CR
00227     case Qt::Key_Escape: return 0x1b; // ESC
00228     case Qt::Key_Space: return 0x20;        // 7 bit printable ASCII
00229     case Qt::Key_Exclam: return 0x21;
00230     case Qt::Key_QuoteDbl: return 0x22;
00231     case Qt::Key_NumberSign: return 0x23;
00232     case Qt::Key_Dollar: return 0x24;
00233     case Qt::Key_Percent: return 0x25;
00234     case Qt::Key_Ampersand: return 0x26;
00235     case Qt::Key_Apostrophe: return 0x27;
00236     case Qt::Key_ParenLeft: return 0x28;
00237     case Qt::Key_ParenRight: return 0x29;
00238     case Qt::Key_Asterisk: return 0x2a;
00239     case Qt::Key_Plus: return 0x2b;
00240     case Qt::Key_Comma: return 0x2c;
00241     case Qt::Key_Minus: return 0x2d;
00242     case Qt::Key_Period: return 0x2e;
00243     case Qt::Key_Slash: return 0x2f;
00244     case Qt::Key_0: return 0x30;
00245     case Qt::Key_1: return 0x31;
00246     case Qt::Key_2: return 0x32;
00247     case Qt::Key_3: return 0x33;
00248     case Qt::Key_4: return 0x34;
00249     case Qt::Key_5: return 0x35;
00250     case Qt::Key_6: return 0x36;
00251     case Qt::Key_7: return 0x37;
00252     case Qt::Key_8: return 0x38;
00253     case Qt::Key_9: return 0x39;
00254     case Qt::Key_Colon: return 0x3a;
00255     case Qt::Key_Semicolon: return 0x3b;
00256     case Qt::Key_Less: return 0x3c;
00257     case Qt::Key_Equal: return 0x3d;
00258     case Qt::Key_Greater: return 0x3e;
00259     case Qt::Key_Question: return 0x3f;
00260     case Qt::Key_At: return 0x40;
00261     case Qt::Key_A: return 0x61; // 0x41 == 'A', 0x61 == 'a'
00262     case Qt::Key_B: return 0x62;
00263     case Qt::Key_C: return 0x63;
00264     case Qt::Key_D: return 0x64;
00265     case Qt::Key_E: return 0x65;
00266     case Qt::Key_F: return 0x66;
00267     case Qt::Key_G: return 0x67;
00268     case Qt::Key_H: return 0x68;
00269     case Qt::Key_I: return 0x69;
00270     case Qt::Key_J: return 0x6a;
00271     case Qt::Key_K: return 0x6b;
00272     case Qt::Key_L: return 0x6c;
00273     case Qt::Key_M: return 0x6d;
00274     case Qt::Key_N: return 0x6e;
00275     case Qt::Key_O: return 0x6f;
00276     case Qt::Key_P: return 0x70;
00277     case Qt::Key_Q: return 0x71;
00278     case Qt::Key_R: return 0x72;
00279     case Qt::Key_S: return 0x73;
00280     case Qt::Key_T: return 0x74;
00281     case Qt::Key_U: return 0x75;
00282     case Qt::Key_V: return 0x76;
00283     case Qt::Key_W: return 0x77;
00284     case Qt::Key_X: return 0x78;
00285     case Qt::Key_Y: return 0x79;
00286     case Qt::Key_Z: return 0x7a;
00287     case Qt::Key_BracketLeft: return 0x5b;
00288     case Qt::Key_Backslash: return 0x5c;
00289     case Qt::Key_BracketRight: return 0x5d;
00290     case Qt::Key_AsciiCircum: return 0x5e;
00291     case Qt::Key_Underscore: return 0x5f;
00292     case Qt::Key_QuoteLeft: return 0x60;
00293 
00294     case Qt::Key_BraceLeft: return 0x7b;
00295     case Qt::Key_Bar: return 0x7c;
00296     case Qt::Key_BraceRight: return 0x7d;
00297     case Qt::Key_AsciiTilde: return 0x7e;
00298 
00299     case Qt::Key_Delete: return 0;
00300     case Qt::Key_Insert: return 0; // = 0x1006,
00301     case Qt::Key_Pause: return 0; // = 0x1008,
00302     case Qt::Key_Print: return 0; // = 0x1009,
00303     case Qt::Key_SysReq: return 0; // = 0x100a,
00304 
00305     case Qt::Key_Clear: return 0; // = 0x100b,
00306 
00307     case Qt::Key_Home: return 0; // = 0x1010,        // cursor movement
00308     case Qt::Key_End: return 0; // = 0x1011,
00309     case Qt::Key_Left: return 0; // = 0x1012,
00310     case Qt::Key_Up: return 0; // = 0x1013,
00311     case Qt::Key_Right: return 0; // = 0x1014,
00312     case Qt::Key_Down: return 0; // = 0x1015,
00313     case Qt::Key_PageUp: return 0; // = 0x1016,
00314     case Qt::Key_PageDown: return 0; // = 0x1017,
00315     case Qt::Key_Shift: return 0; // = 0x1020,        // modifiers
00316     case Qt::Key_Control: return 0; // = 0x1021,
00317     case Qt::Key_Meta: return 0; // = 0x1022,
00318     case Qt::Key_Alt: return 0; // = 0x1023,
00319     case Qt::Key_CapsLock: return 0; // = 0x1024,
00320     case Qt::Key_NumLock: return 0; // = 0x1025,
00321     case Qt::Key_ScrollLock: return 0; // = 0x1026,
00322     case Qt::Key_F1: return 0; // = 0x1030,        // function keys
00323     case Qt::Key_F2: return 0; // = 0x1031,
00324     case Qt::Key_F3: return 0; // = 0x1032,
00325     case Qt::Key_F4: return 0; // = 0x1033,
00326     case Qt::Key_F5: return 0; // = 0x1034,
00327     case Qt::Key_F6: return 0; // = 0x1035,
00328     case Qt::Key_F7: return 0; // = 0x1036,
00329     case Qt::Key_F8: return 0; // = 0x1037,
00330     case Qt::Key_F9: return 0; // = 0x1038,
00331     case Qt::Key_F10: return 0; // = 0x1039,
00332     case Qt::Key_F11: return 0; // = 0x103a,
00333     case Qt::Key_F12: return 0; // = 0x103b,
00334     case Qt::Key_F13: return 0; // = 0x103c,
00335     case Qt::Key_F14: return 0; // = 0x103d,
00336     case Qt::Key_F15: return 0; // = 0x103e,
00337     case Qt::Key_F16: return 0; // = 0x103f,
00338     case Qt::Key_F17: return 0; // = 0x1040,
00339     case Qt::Key_F18: return 0; // = 0x1041,
00340     case Qt::Key_F19: return 0; // = 0x1042,
00341     case Qt::Key_F20: return 0; // = 0x1043,
00342     case Qt::Key_F21: return 0; // = 0x1044,
00343     case Qt::Key_F22: return 0; // = 0x1045,
00344     case Qt::Key_F23: return 0; // = 0x1046,
00345     case Qt::Key_F24: return 0; // = 0x1047,
00346     case Qt::Key_F25: return 0; // = 0x1048,        // F25 .. F35 only on X11
00347     case Qt::Key_F26: return 0; // = 0x1049,
00348     case Qt::Key_F27: return 0; // = 0x104a,
00349     case Qt::Key_F28: return 0; // = 0x104b,
00350     case Qt::Key_F29: return 0; // = 0x104c,
00351     case Qt::Key_F30: return 0; // = 0x104d,
00352     case Qt::Key_F31: return 0; // = 0x104e,
00353     case Qt::Key_F32: return 0; // = 0x104f,
00354     case Qt::Key_F33: return 0; // = 0x1050,
00355     case Qt::Key_F34: return 0; // = 0x1051,
00356     case Qt::Key_F35: return 0; // = 0x1052,
00357     case Qt::Key_Super_L: return 0; // = 0x1053,        // extra keys
00358     case Qt::Key_Super_R: return 0; // = 0x1054,
00359     case Qt::Key_Menu: return 0; // = 0x1055,
00360     case Qt::Key_Hyper_L: return 0; // = 0x1056,
00361     case Qt::Key_Hyper_R: return 0; // = 0x1057,
00362     case Qt::Key_Help: return 0; // = 0x1058,
00363     case Qt::Key_Direction_L: return 0; // = 0x1059,
00364     case Qt::Key_Direction_R: return 0; // = 0x1060,
00365 
00366     // Latin 1 codes adapted from X: keysymdef.h,v 1.21 94/08/28 16:17:06
00367     case Qt::Key_nobreakspace: return char(0xa0);
00368     case Qt::Key_exclamdown: return char(0xa1);
00369     case Qt::Key_cent: return char(0xa2);
00370     case Qt::Key_sterling: return char(0xa3);
00371     case Qt::Key_currency: return char(0xa4);
00372     case Qt::Key_yen: return char(0xa5);
00373     case Qt::Key_brokenbar: return char(0xa6);
00374     case Qt::Key_section: return char(0xa7);
00375     case Qt::Key_diaeresis: return char(0xa8);
00376     case Qt::Key_copyright: return char(0xa9);
00377     case Qt::Key_ordfeminine: return char(0xaa);
00378     case Qt::Key_guillemotleft: return char(0xab); // left angle quotation mar
00379     case Qt::Key_notsign: return char(0xac);
00380     case Qt::Key_hyphen: return char(0xad);
00381     case Qt::Key_registered: return char(0xae);
00382     case Qt::Key_macron: return char(0xaf);
00383     case Qt::Key_degree: return char(0xb0);
00384     case Qt::Key_plusminus: return char(0xb1);
00385     case Qt::Key_twosuperior: return char(0xb2);
00386     case Qt::Key_threesuperior: return char(0xb3);
00387     case Qt::Key_acute: return char(0xb4);
00388     case Qt::Key_mu: return char(0xb5);
00389     case Qt::Key_paragraph: return char(0xb6);
00390     case Qt::Key_periodcentered: return char(0xb7);
00391     case Qt::Key_cedilla: return char(0xb8);
00392     case Qt::Key_onesuperior: return char(0xb9);
00393     case Qt::Key_masculine: return char(0xba);
00394     case Qt::Key_guillemotright: return char(0xbb); // right angle quotation mar
00395     case Qt::Key_onequarter: return char(0xbc);
00396     case Qt::Key_onehalf: return char(0xbd);
00397     case Qt::Key_threequarters: return char(0xbe);
00398     case Qt::Key_questiondown: return char(0xbf);
00399     case Qt::Key_Agrave: return char(0xc0);
00400     case Qt::Key_Aacute: return char(0xc1);
00401     case Qt::Key_Acircumflex: return char(0xc2);
00402     case Qt::Key_Atilde: return char(0xc3);
00403     case Qt::Key_Adiaeresis: return char(0xc4);
00404     case Qt::Key_Aring: return char(0xe5);
00405     case Qt::Key_AE: return char(0xe6);
00406     case Qt::Key_Ccedilla: return char(0xc7);
00407     case Qt::Key_Egrave: return char(0xc8);
00408     case Qt::Key_Eacute: return char(0xc9);
00409     case Qt::Key_Ecircumflex: return char(0xca);
00410     case Qt::Key_Ediaeresis: return char(0xcb);
00411     case Qt::Key_Igrave: return char(0xcc);
00412     case Qt::Key_Iacute: return char(0xcd);
00413     case Qt::Key_Icircumflex: return char(0xce);
00414     case Qt::Key_Idiaeresis: return char(0xcf);
00415     case Qt::Key_ETH: return char(0xd0);
00416     case Qt::Key_Ntilde: return char(0xd1);
00417     case Qt::Key_Ograve: return char(0xd2);
00418     case Qt::Key_Oacute: return char(0xd3);
00419     case Qt::Key_Ocircumflex: return char(0xd4);
00420     case Qt::Key_Otilde: return char(0xd5);
00421     case Qt::Key_Odiaeresis: return char(0xd6);
00422     case Qt::Key_multiply: return char(0xd7);
00423     case Qt::Key_Ooblique: return char(0xf8);
00424     case Qt::Key_Ugrave: return char(0xd9);
00425     case Qt::Key_Uacute: return char(0xda);
00426     case Qt::Key_Ucircumflex: return char(0xdb);
00427     case Qt::Key_Udiaeresis: return char(0xdc);
00428     case Qt::Key_Yacute: return char(0xdd);
00429     case Qt::Key_THORN: return char(0xde);
00430     case Qt::Key_ssharp: return char(0xdf);
00431     case Qt::Key_division: return char(0xf7);
00432     case Qt::Key_ydiaeresis: return char(0xff);
00433 
00434     // multimedia/internet keys - ignored by default - see QKeyEvent c'tor
00435 
00436     case Qt::Key_Back : return 0; // = 0x1061,
00437     case Qt::Key_Forward : return 0; // = 0x1062,
00438     case Qt::Key_Stop : return 0; // = 0x1063,
00439     case Qt::Key_Refresh : return 0; // = 0x1064,
00440 
00441     case Qt::Key_VolumeDown: return 0; // = 0x1070,
00442     case Qt::Key_VolumeMute : return 0; // = 0x1071,
00443     case Qt::Key_VolumeUp: return 0; // = 0x1072,
00444     case Qt::Key_BassBoost: return 0; // = 0x1073,
00445     case Qt::Key_BassUp: return 0; // = 0x1074,
00446     case Qt::Key_BassDown: return 0; // = 0x1075,
00447     case Qt::Key_TrebleUp: return 0; // = 0x1076,
00448     case Qt::Key_TrebleDown: return 0; // = 0x1077,
00449 
00450     case Qt::Key_MediaPlay : return 0; // = 0x1080,
00451     case Qt::Key_MediaStop : return 0; // = 0x1081,
00452     case Qt::Key_MediaPrevious : return 0; // = 0x1082,
00453     case Qt::Key_MediaNext : return 0; // = 0x1083,
00454     case Qt::Key_MediaRecord: return 0; // = 0x1084,
00455 
00456     case Qt::Key_HomePage : return 0; // = 0x1090,
00457     case Qt::Key_Favorites : return 0; // = 0x1091,
00458     case Qt::Key_Search : return 0; // = 0x1092,
00459     case Qt::Key_Standby: return 0; // = 0x1093,
00460     case Qt::Key_OpenUrl: return 0; // = 0x1094,
00461 
00462     case Qt::Key_LaunchMail : return 0; // = 0x10a0,
00463     case Qt::Key_LaunchMedia: return 0; // = 0x10a1,
00464     case Qt::Key_Launch0 : return 0; // = 0x10a2,
00465     case Qt::Key_Launch1 : return 0; // = 0x10a3,
00466     case Qt::Key_Launch2 : return 0; // = 0x10a4,
00467     case Qt::Key_Launch3 : return 0; // = 0x10a5,
00468     case Qt::Key_Launch4 : return 0; // = 0x10a6,
00469     case Qt::Key_Launch5 : return 0; // = 0x10a7,
00470     case Qt::Key_Launch6 : return 0; // = 0x10a8,
00471     case Qt::Key_Launch7 : return 0; // = 0x10a9,
00472     case Qt::Key_Launch8 : return 0; // = 0x10aa,
00473     case Qt::Key_Launch9 : return 0; // = 0x10ab,
00474     case Qt::Key_LaunchA : return 0; // = 0x10ac,
00475     case Qt::Key_LaunchB : return 0; // = 0x10ad,
00476     case Qt::Key_LaunchC : return 0; // = 0x10ae,
00477     case Qt::Key_LaunchD : return 0; // = 0x10af,
00478     case Qt::Key_LaunchE : return 0; // = 0x10b0,
00479     case Qt::Key_LaunchF : return 0; // = 0x10b1,
00480 
00481     default: QTEST_ASSERT(false); return 0;
00482     }
00483 }

static QByteArray QTest::memberName ( const QMetaMethod member  )  [static]

Definition at line 46 of file qsignaldumper.cpp.

References QByteArray::indexOf(), QByteArray::left(), and QMetaMethod::signature().

Referenced by QDBusConnectionPrivate::activateCall(), QDBusUtil::isValidMemberName(), qSignalDumperCallback(), and QDBusConnectionPrivate::relaySignal().

00047 {
00048     QByteArray ba = member.signature();
00049     return ba.left(ba.indexOf('('));
00050 }

Here is the call graph for this function:

static const char* QTest::messageFormatString ( bool  noDescription,
bool  noTag 
) [static]

Definition at line 155 of file qxmltestlogger.cpp.

Referenced by QXmlTestLogger::addMessage().

00156 {
00157     if (noDescription) {
00158         if (noTag)
00159             return "<Message type=\"%s\" file=\"%s\" line=\"%d\" />\n";
00160         else
00161             return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
00162                    "    <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
00163                    "</Message>\n";
00164     } else {
00165         if (noTag)
00166             return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
00167                    "    <Description><![CDATA[%s%s%s%s]]></Description>\n"
00168                    "</Message>\n";
00169         else
00170             return "<Message type=\"%s\" file=\"%s\" line=\"%d\">\n"
00171                    "    <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
00172                    "    <Description><![CDATA[%s]]></Description>\n"
00173                    "</Message>\n";
00174     }
00175 }

static void QTest::messageHandler ( QtMsgType  type,
const char *  msg 
) [static]

Definition at line 98 of file qtestlog.cpp.

References QAbstractTestLogger::addMessage(), QBasicAtomic::deref(), handleIgnoredMessage(), maxWarnings, oldMessageHandler, QAbstractTestLogger::QDebug, QAbstractTestLogger::QFatal, qInstallMsgHandler(), QAbstractTestLogger::QSystem, QTEST_ASSERT, QAbstractTestLogger::QWarning, and testLogger.

Referenced by QTestLog::startLogging().

00099     {
00100         static QAtomic counter = QTest::maxWarnings;
00101 
00102         if (!msg || !QTest::testLogger) {
00103             // if this goes wrong, something is seriously broken.
00104             qInstallMsgHandler(oldMessageHandler);
00105             QTEST_ASSERT(msg);
00106             QTEST_ASSERT(QTest::testLogger);
00107         }
00108 
00109         if (handleIgnoredMessage(type, msg))
00110             // the message is expected, so just swallow it.
00111             return;
00112 
00113         if (type != QtFatalMsg) {
00114             if (counter <= 0)
00115                 return;
00116 
00117             if (!counter.deref()) {
00118                 QTest::testLogger->addMessage(QAbstractTestLogger::QSystem,
00119                         "Maximum amount of warnings exceeded.");
00120                 return;
00121             }
00122         }
00123 
00124         switch (type) {
00125         case QtDebugMsg:
00126             QTest::testLogger->addMessage(QAbstractTestLogger::QDebug, msg);
00127             break;
00128         case QtCriticalMsg:
00129             QTest::testLogger->addMessage(QAbstractTestLogger::QSystem, msg);
00130             break;
00131         case QtWarningMsg:
00132             QTest::testLogger->addMessage(QAbstractTestLogger::QWarning, msg);
00133             break;
00134         case QtFatalMsg:
00135             QTest::testLogger->addMessage(QAbstractTestLogger::QFatal, msg);
00136             break;
00137         }
00138     }

Here is the call graph for this function:

static const char* QTest::messageType2String ( QAbstractTestLogger::MessageTypes  type  )  [static]

Definition at line 95 of file qplaintestlogger.cpp.

References COLORED_MSG, QAbstractTestLogger::Info, QByteArray::isEmpty(), QAbstractTestLogger::QDebug, QAbstractTestLogger::QFatal, qgetenv(), QAbstractTestLogger::QSystem, QAbstractTestLogger::QWarning, QAbstractTestLogger::Skip, and QAbstractTestLogger::Warn.

Referenced by QPlainTestLogger::addMessage(), and QPlainTestLogger::enterTestFunction().

00096     {
00097         static bool colored = (!qgetenv("QTEST_COLORED").isEmpty());
00098         switch (type) {
00099         case QAbstractTestLogger::Skip:
00100             return COLORED_MSG(0, 37, "SKIP   "); //white
00101         case QAbstractTestLogger::Warn:
00102             return COLORED_MSG(0, 33, "WARNING"); // yellow
00103         case QAbstractTestLogger::QWarning:
00104             return COLORED_MSG(1, 33, "QWARN  ");
00105         case QAbstractTestLogger::QDebug:
00106             return COLORED_MSG(1, 33, "QDEBUG ");
00107         case QAbstractTestLogger::QSystem:
00108             return COLORED_MSG(1, 33, "QSYSTEM");
00109         case QAbstractTestLogger::QFatal:
00110             return COLORED_MSG(0, 31, "QFATAL "); // red
00111         case QAbstractTestLogger::Info:
00112             return "INFO   "; // no coloring
00113         }
00114         return "??????";
00115     }

Here is the call graph for this function:

void QTest::mouseClick ( QWidget widget,
Qt::MouseButton  button,
Qt::KeyboardModifiers  modifier = 0,
QPoint  pos = QPoint(),
int  delay = -1 
) [inline]

Simulates clicking a mouse button with an optional modifier on a widget. The position of the click is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before pressing and before releasing the button.

See also:
QTest::mousePress(), QTest::mouseRelease()

Definition at line 105 of file qtestmouse.h.

References MouseClick, and mouseEvent().

00107     { mouseEvent(MouseClick, widget, button, stateKey, pos, delay); }

Here is the call graph for this function:

void QTest::mouseDClick ( QWidget widget,
Qt::MouseButton  button,
Qt::KeyboardModifiers  modifier = 0,
QPoint  pos = QPoint(),
int  delay = -1 
) [inline]

Simulates double clicking a mouse button with an optional modifier on a widget. The position of the click is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before each press and release.

See also:
QTest::mouseClick()

Definition at line 108 of file qtestmouse.h.

References MouseDClick, and mouseEvent().

00110     { mouseEvent(MouseDClick, widget, button, stateKey, pos, delay); }

Here is the call graph for this function:

void QTest::mouseEvent ( MouseAction  action,
QWidget widget,
Qt::MouseButton  button,
Qt::KeyboardModifiers  stateKey,
QPoint  pos,
int  delay = -1 
) [static]

Definition at line 49 of file qtestmouse.h.

References QRect::center(), defaultMouseDelay(), QPoint::isNull(), Qt::KeyboardModifierMask, Qt::LeftButton, QWidget::mapToGlobal(), QEvent::MouseButtonDblClick, Qt::MouseButtonMask, QEvent::MouseButtonPress, QEvent::MouseButtonRelease, MouseClick, MouseDClick, MouseMove, MousePress, MouseRelease, Qt::NoButton, Q_TESTLIB_EXPORT, qApp, QTEST_ASSERT, qWait(), qWarn(), QWidget::rect(), QCursor::setPos(), and QEvent::User.

Referenced by BookDelegate::editorEvent(), QGraphicsScene::event(), Calculator::eventFilter(), QDesignerTabWidget::eventFilter(), mouseClick(), mouseDClick(), QGraphicsView::mouseDoubleClickEvent(), QGraphicsScene::mouseDoubleClickEvent(), mouseMove(), QGraphicsScene::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), mousePress(), QGraphicsView::mousePressEvent(), QGraphicsScene::mousePressEvent(), QGraphicsScenePrivate::mousePressEventHandler(), mouseRelease(), QGraphicsView::mouseReleaseEvent(), QGraphicsScene::mouseReleaseEvent(), QGraphicsItemPrivate::remapItemPos(), QGraphicsViewPrivate::replayLastMouseEvent(), QGraphicsScenePrivate::sendMouseEvent(), and QTestMouseEvent::simulate().

00051     {
00052         QTEST_ASSERT(widget);
00053         extern int Q_TESTLIB_EXPORT defaultMouseDelay();
00054 
00055         if (delay == -1 || delay < defaultMouseDelay())
00056             delay = defaultMouseDelay();
00057         if(delay > 0)
00058             QTest::qWait(delay);
00059 
00060         if (pos.isNull())
00061             pos = widget->rect().center();
00062 
00063         if (action == MouseClick) {
00064             mouseEvent(MousePress, widget, button, stateKey, pos);
00065             mouseEvent(MouseRelease, widget, button, stateKey, pos);
00066             return;
00067         }
00068 
00069         QTEST_ASSERT(button == Qt::NoButton || button & Qt::MouseButtonMask);
00070         QTEST_ASSERT(stateKey == 0 || stateKey & Qt::KeyboardModifierMask);
00071 
00072         stateKey &= Qt::KeyboardModifierMask;
00073 
00074         QMouseEvent me(QEvent::User, QPoint(), Qt::LeftButton, button, stateKey);
00075         switch (action)
00076         {
00077             case MousePress:
00078                 me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
00079                 break;
00080             case MouseRelease:
00081                 me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
00082                 break;
00083             case MouseDClick:
00084                 me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
00085                 break;
00086             case MouseMove:
00087                 QCursor::setPos(widget->mapToGlobal(pos));
00088                 qApp->processEvents();
00089                 return;
00090             default:
00091                 QTEST_ASSERT(false);
00092         }
00093         reinterpret_cast<QSpontaneKeyEvent *>(&me)->setSpontaneous();
00094         if (!qApp->notify(widget, &me))
00095             QTest::qWarn("Mouse event not accepted by receiving widget");
00096 
00097     }

Here is the call graph for this function:

void QTest::mouseMove ( QWidget widget,
QPoint  pos = QPoint(),
int  delay = -1 
) [inline]

Moves the mouse pointer to a widget. If pos is not specified, the mouse pointer moves to the center of the widget. If a delay (in milliseconds) is given, the test will wait before moving the mouse pointer.

Definition at line 111 of file qtestmouse.h.

References mouseEvent(), MouseMove, and Qt::NoButton.

00112     { mouseEvent(MouseMove, widget, Qt::NoButton, 0, pos, delay); }

Here is the call graph for this function:

void QTest::mousePress ( QWidget widget,
Qt::MouseButton  button,
Qt::KeyboardModifiers  modifier = 0,
QPoint  pos = QPoint(),
int  delay = -1 
) [inline]

Simulates pressing a mouse button with an optional modifier on a widget. The position is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before the press.

See also:
QTest::mouseRelease(), QTest::mouseClick()

Definition at line 99 of file qtestmouse.h.

References mouseEvent(), and MousePress.

Referenced by QGraphicsScenePrivate::mousePressEventHandler().

00101     { mouseEvent(MousePress, widget, button, stateKey, pos, delay); }

Here is the call graph for this function:

void QTest::mouseRelease ( QWidget widget,
Qt::MouseButton  button,
Qt::KeyboardModifiers  modifier = 0,
QPoint  pos = QPoint(),
int  delay = -1 
) [inline]

Simulates releasing a mouse button with an optional modifier on a widget. The position of the release is defined by pos; the default position is the center of the widget. If delay is specified, the test will wait for the specified amount of milliseconds before releasing the button.

See also:
QTest::mousePress(), QTest::mouseClick()

Definition at line 102 of file qtestmouse.h.

References mouseEvent(), and MouseRelease.

00104     { mouseEvent(MouseRelease, widget, button, stateKey, pos, delay); }

Here is the call graph for this function:

Q_TESTLIB_EXPORT QTestData & QTest::newRow ( const char *  dataTag  ) 

Appends a new row to the current test data. dataTag is the name of the testdata that will appear in the test output. Returns a QTestData reference that can be used to stream in data.

Example:

    void myTestFunction_data()
    {
        QTest::addColumn<QString>("aString");
        QTest::newRow("just hello") << QString("hello");
        QTest::newRow("a null string") << QString();
    }

{Note:} This macro can only be used in a test's data function that is invoked by the test framework.

See {Chapter 2: Data Driven Testing}{Data Driven Testing} for a more extensive example.

See also:
addColumn(), QFETCH()

Definition at line 1285 of file qtestcase.cpp.

References QTestTable::currentTestTable(), QTestTable::newData(), and QTEST_ASSERT_X.

Referenced by QListModel::ensureSorted(), QTreeModel::ensureSorted(), QTableModel::ensureSorted(), QTextControlPrivate::gotoNextTableCell(), QTextControlPrivate::gotoPreviousTableCell(), QAbstractItemView::keyboardSearch(), QTableView::moveCursor(), TestGui::testGui_data(), TestQString::toUpper_data(), and QTableModel::updateRowIndexes().

01286 {
01287     QTestTable *tbl = QTestTable::currentTestTable();
01288     QTEST_ASSERT_X(tbl, "QTest::addColumn()", "Cannot add testdata outside of a _data slot.");
01289 
01290     return *tbl->newData(dataTag);
01291 }

Here is the call graph for this function:

static void QTest::outputMessage ( const char *  str  )  [static]

Definition at line 117 of file qplaintestlogger.cpp.

References QAbstractTestLogger::outputString().

Referenced by printMessage(), QPlainTestLogger::startLogging(), and QPlainTestLogger::stopLogging().

00118     {
00119 #ifdef Q_OS_WIN
00120         EnterCriticalSection(&outputCriticalSection);
00121         // OutputDebugString is not threadsafe
00122         OutputDebugStringA(str);
00123         LeaveCriticalSection(&outputCriticalSection);
00124 #endif
00125         QAbstractTestLogger::outputString(str);
00126     }

Here is the call graph for this function:

static void QTest::printMessage ( const char *  type,
const char *  msg,
const char *  file = 0,
int  line = 0 
) [static]

Definition at line 128 of file qplaintestlogger.cpp.

References buf, QTestResult::currentDataTag(), QTestResult::currentGlobalDataTag(), QTestResult::currentTestFunction(), QTestResult::currentTestObjectName(), filler, outputMessage(), qt_snprintf(), and QTEST_ASSERT.

Referenced by QPlainTestLogger::addIncident(), QPlainTestLogger::addMessage(), and QPlainTestLogger::enterTestFunction().

00129     {
00130         QTEST_ASSERT(type);
00131         QTEST_ASSERT(msg);
00132 
00133         char buf[1024];
00134 
00135         const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
00136             : "UnknownTestFunc";
00137         const char *tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
00138         const char *gtag = QTestResult::currentGlobalDataTag()
00139                          ? QTestResult::currentGlobalDataTag()
00140                          : "";
00141         const char *filler = (tag[0] && gtag[0]) ? ":" : "";
00142         if (file) {
00143             QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n"
00144 #ifdef Q_OS_WIN
00145                           "%s(%d) : failure location\n"
00146 #else
00147                           "   Loc: [%s(%d)]\n"
00148 #endif
00149                           , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
00150                           msg[0] ? " " : "", msg, file, line);
00151         } else {
00152             QTest::qt_snprintf(buf, sizeof(buf), "%s: %s::%s(%s%s%s)%s%s\n",
00153                     type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
00154                     msg[0] ? " " : "", msg);
00155         }
00156         memcpy(buf, type, strlen(type));
00157         outputMessage(buf);
00158     }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( const char *  t1,
char *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 263 of file qtestcase.h.

References compare_string_helper().

00265     {
00266         return compare_string_helper(t1, t2, actual, expected, file, line);
00267     }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( char *  t1,
const char *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 255 of file qtestcase.h.

References compare_string_helper().

00257     {
00258         return compare_string_helper(t1, t2, actual, expected, file, line);
00259     }

Here is the call graph for this function:

template<typename T1, typename T2>
bool QTest::qCompare ( T1 *  t1,
T2 *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 217 of file qtestcase.h.

References compare_ptr_helper().

00219     {
00220         return compare_ptr_helper(const_cast<const T1 *>(t1),
00221                 static_cast<const T1 *>(const_cast<const T2 *>(t2)), actual, expected, file, line);
00222     }

Here is the call graph for this function:

template<typename T1, typename T2>
bool QTest::qCompare ( const T1 *  t1,
const T2 *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 211 of file qtestcase.h.

References compare_ptr_helper().

00213     {
00214         return compare_ptr_helper(t1, static_cast<const T1 *>(t2), actual, expected, file, line);
00215     }

Here is the call graph for this function:

template<typename T>
bool QTest::qCompare ( T *  t1,
T *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 204 of file qtestcase.h.

References compare_ptr_helper().

00206     {
00207         return compare_ptr_helper(t1, t2, actual, expected, file, line);
00208     }

Here is the call graph for this function:

template<typename T>
bool QTest::qCompare ( const T *  t1,
const T *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 198 of file qtestcase.h.

References compare_ptr_helper().

00200     {
00201         return compare_ptr_helper(t1, t2, actual, expected, file, line);
00202     }

Here is the call graph for this function:

template<typename T1, typename T2>
bool QTest::qCompare ( T1 const &  ,
T2 const &  ,
const char *  ,
const char *  ,
const char *  ,
int   
)

template<typename T>
bool QTest::qCompare ( T const &  t1,
T const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 148 of file qtestcase.h.

References compare_helper().

00150     {
00151         return (t1 == t2)
00152             ? compare_helper(true, "COMPARE()", file, line)
00153             : compare_helper(false, "Compared values are not the same",
00154                              toString<T>(t1), toString<T>(t2), actual, expected, file, line);
00155     }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( QPixmap const &  t1,
QPixmap const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 56 of file qtest_gui.h.

References qCompare(), and QPixmap::toImage().

00058 {
00059     return qCompare(t1.toImage(), t2.toImage(), actual, expected, file, line);
00060 }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( QIcon const &  t1,
QIcon const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 47 of file qtest_gui.h.

References QTEST_ASSERT.

00049 {
00050     QTEST_ASSERT(sizeof(QIcon) == sizeof(void *));
00051     return qCompare<void *>(*reinterpret_cast<void * const *>(&t1),
00052                    *reinterpret_cast<void * const *>(&t2), actual, expected, file, line);
00053 }

template<typename T>
bool QTest::qCompare ( QFlags< T > const &  t1,
int const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 164 of file qtest.h.

References qCompare().

00166 {
00167     return qCompare(int(t1), t2, actual, expected, file, line);
00168 }

Here is the call graph for this function:

template<typename T>
bool QTest::qCompare ( QFlags< T > const &  t1,
T const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 157 of file qtest.h.

References qCompare().

00159 {
00160     return qCompare(int(t1), int(t2), actual, expected, file, line);
00161 }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( QStringList const &  t1,
QStringList const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 131 of file qtest.h.

References QList< T >::at(), compare_helper(), QByteArray::constData(), QList< T >::count(), i, qMin(), qt_snprintf(), and QString::toLatin1().

00133 {
00134     char msg[1024];
00135     msg[0] = '\0';
00136     bool isOk = true;
00137     if (t1.count() != t2.count()) {
00138         qt_snprintf(msg, 1024, "Compared QStringLists have different sizes.\n"
00139                     "   Actual (%s) size  : '%d'\n"
00140                     "   Expected (%s) size: '%d'", actual, t1.count(), expected, t2.count());
00141         isOk = false;
00142     }
00143     const int min = qMin(t1.count(), t2.count());
00144     for (int i = 0; i < min; ++i) {
00145         if (t1.at(i) != t2.at(i)) {
00146             qt_snprintf(msg, 1024, "Compared QStringLists differ at index %d.\n"
00147                         "   Actual (%s) : '%s'\n"
00148                         "   Expected (%s) : '%s'", i, actual, t1.at(i).toLatin1().constData(),
00149                         expected, t2.at(i).toLatin1().constData());
00150             isOk = false;
00151         }
00152     }
00153     return compare_helper(isOk, msg, file, line);
00154 }

Here is the call graph for this function:

template<>
bool QTest::qCompare ( QLatin1String const &  t1,
QString const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 124 of file qtest.h.

00126 {
00127     return qCompare<QString>(QString(t1), t2, actual, expected, file, line);
00128 }

template<>
bool QTest::qCompare ( QString const &  t1,
QLatin1String const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

Definition at line 116 of file qtest.h.

Referenced by qCompare(), and qTest().

00118 {
00119     return qCompare<QString>(t1, QString(t2), actual, expected, file, line);
00120 }

template<>
bool QTest::qCompare< char > ( char *  t1,
char *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

template<>
bool QTest::qCompare< char > ( const char *  t1,
const char *  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
) [inline]

template<>
bool QTest::qCompare< double > ( double const &  t1,
double const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
)

template<>
bool QTest::qCompare< float > ( float const &  t1,
float const &  t2,
const char *  actual,
const char *  expected,
const char *  file,
int  line 
)

Q_TESTLIB_EXPORT void * QTest::qData ( const char *  tagName,
int  typeId 
)

Definition at line 1224 of file qtestcase.cpp.

References QTestResult::currentTestData(), and fetchData().

01225 {
01226     return fetchData(QTestResult::currentTestData(), tagName, typeId);
01227 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT void * QTest::qElementData ( const char *  tagName,
int  metaTypeId 
)

Definition at line 1238 of file qtestcase.cpp.

References QTestResult::currentTestData(), data, and QTEST_ASSERT.

Referenced by qTest().

01239 {
01240     QTEST_ASSERT(tagName);
01241     QTestData *data = QTestResult::currentTestData();
01242     QTEST_ASSERT(data);
01243     QTEST_ASSERT(data->parent());
01244 
01245     int idx = data->parent()->indexOf(tagName);
01246     QTEST_ASSERT(idx != -1);
01247     QTEST_ASSERT(data->parent()->elementTypeId(idx) == metaTypeId);
01248 
01249     return data->data(data->parent()->indexOf(tagName));
01250 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT int QTest::qExec ( QObject testObject,
int  argc = 0,
char **  argv = 0 
)

Executes tests declared in testObject. In addition, the private slots {initTestCase()}, {cleanupTestCase()}, {init()} and {cleanup()} are executed if they exist. See {Creating a test} for more details.

Optionally, the command line arguments argc and argv can be provided. For a list of recognized arguments, read {QTestLib Command Line Arguments}.

For stand-alone tests, the convenience macro QTEST_MAIN() can be used to declare a main method that parses the command line arguments and executes the tests.

The following example will run all tests in MyFirstTestObject and {MySecondTestObject}:

    MyFirstTestObject test1;
    QTest::qExec(&test1);

    MySecondTestObject test2;
    QTest::qExec(&test2);

Note: This function is not reentrant, only one test can run at a time. A test that was executed with qExec() can't run another test via qExec() and threads are not allowed to call qExec() simultaneously.

See also:
QTEST_MAIN()

Definition at line 1070 of file qtestcase.cpp.

References QTestResult::addFailure(), QMetaObject::className(), QTestTable::clearGlobalTestTable(), QTestResult::currentTestFunction(), currentTestObject, QTest::TestFunction::data, QTestResult::DataFunc, Qt::DirectConnection, QTestResult::failCount(), QTestResult::finishedCurrentTestFunction(), QTestResult::Func, QTest::TestFunction::function, QTestTable::globalTestTable(), i, QMetaObject::invokeMethod(), isValidSlot(), lastTestFuncIdx, QMetaObject::method(), QMetaObject::methodCount(), qInvokeTestMethod(), qParseArgs(), QTEST_ASSERT, QTestResult::reset(), QTestResult::setCurrentTestFunction(), QTestResult::setCurrentTestLocation(), QTestResult::setCurrentTestObject(), QMetaMethod::signature(), skipCurrentTest, QTestLog::startLogging(), QTestLog::stopLogging(), testFuncs, and testObject().

01071 {
01072 #ifndef QT_NO_EXCEPTIONS
01073     try {
01074 #endif
01075 
01076 #if defined(Q_OS_WIN)
01077     SetErrorMode(SetErrorMode(0) | SEM_NOGPFAULTERRORBOX);
01078 #endif
01079 
01080     QTestResult::reset();
01081 
01082     QTEST_ASSERT(testObject);
01083     QTEST_ASSERT(!currentTestObject);
01084     currentTestObject = testObject;
01085 
01086     const QMetaObject *metaObject = testObject->metaObject();
01087     QTEST_ASSERT(metaObject);
01088 
01089     QTestResult::setCurrentTestObject(metaObject->className());
01090     qParseArgs(argc, argv);
01091 
01092     QTestLog::startLogging();
01093 
01094     QTestResult::setCurrentTestFunction("initTestCase");
01095     QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
01096     QTestTable::globalTestTable();
01097     QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection);
01098 
01099     if (!QTest::skipCurrentTest) {
01100         QTestResult::setCurrentTestLocation(QTestResult::Func);
01101         QMetaObject::invokeMethod(testObject, "initTestCase");
01102         QTestResult::finishedCurrentTestFunction();
01103 
01104         if (lastTestFuncIdx >= 0) {
01105             for (int i = 0; i <= lastTestFuncIdx; ++i) {
01106                 if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
01107                                        testFuncs[i].data))
01108                     break;
01109             }
01110         } else {
01111             int methodCount = metaObject->methodCount();
01112             for (int i = 0; i < methodCount; ++i) {
01113                 QMetaMethod slotMethod = metaObject->method(i);
01114                 if (!isValidSlot(slotMethod))
01115                     continue;
01116                 if (!qInvokeTestMethod(slotMethod.signature()))
01117                     break;
01118             }
01119         }
01120 
01121         QTestResult::setCurrentTestFunction("cleanupTestCase");
01122         QMetaObject::invokeMethod(testObject, "cleanupTestCase");
01123     }
01124     QTestResult::finishedCurrentTestFunction();
01125     QTestResult::setCurrentTestFunction(0);
01126     QTestTable::clearGlobalTestTable();
01127 
01128 #ifndef QT_NO_EXCEPTIONS
01129     } catch (...) {
01130         QTestResult::addFailure("Caught unhandled exception", __FILE__, __LINE__);
01131         if (QTestResult::currentTestFunction()) {
01132             QTestResult::finishedCurrentTestFunction();
01133             QTestResult::setCurrentTestFunction(0);
01134         }
01135 
01136         QTestLog::stopLogging();
01137 #ifdef Q_OS_WIN
01138         // rethrow exception to make debugging easier
01139         throw;
01140 #endif
01141         return -1;
01142     }
01143 #endif
01144 
01145     QTestLog::stopLogging();
01146     currentTestObject = 0;
01147 #if defined(QTEST_NOEXITCODE) || defined(QT_BUILD_INTERNAL)
01148     return 0;
01149 #else
01150     return QTestResult::failCount();
01151 #endif
01152 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT bool QTest::qExpectFail ( const char *  dataIndex,
const char *  comment,
QTest::TestFailMode  mode,
const char *  file,
int  line 
)

Definition at line 1183 of file qtestcase.cpp.

References QTestResult::expectFail().

01185 {
01186     return QTestResult::expectFail(dataIndex, comment, mode, file, line);
01187 }

Here is the call graph for this function:

Q_TESTLIB_EXPORT void QTest::qFail ( const char *  statementStr,
const char *  file,
int  line 
)

Definition at line 1156 of file qtestcase.cpp.

References QTestResult::addFailure().

01157 {