##// END OF EJS Templates
Fixed the SKIP_IF_CANNOT_TEST_MOUSE_EVENTS on Qt5
Marek Rosa -
r2063:da4e011c304c
parent child
Show More
@@ -1,55 +1,70
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 2012 Digia Plc
4 4 ** All rights reserved.
5 5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 6 **
7 7 ** This file is part of the Qt Commercial Charts Add-on.
8 8 **
9 9 ** $QT_BEGIN_LICENSE$
10 10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 11 ** accordance with the Qt Commercial License Agreement provided with the
12 12 ** Software or, alternatively, in accordance with the terms contained in
13 13 ** a written agreement between you and Digia.
14 14 **
15 15 ** If you have questions regarding the use of this file, please use
16 16 ** contact form at http://qt.digia.com
17 17 ** $QT_END_LICENSE$
18 18 **
19 19 ****************************************************************************/
20 20
21 21 #ifndef TST_DEFINITIONS_H
22 22 #define TST_DEFINITIONS_H
23 23
24 24 #include <QtTest/QtTest>
25 25 #include <QPushButton>
26 26
27 27 #define TRY_COMPARE(actual, expected) { \
28 28 do { \
29 29 const int timeout(1000); \
30 30 const int waitStep(30); \
31 31 /* always wait before comparing to catch possible extra signals */ \
32 32 QTest::qWait(waitStep); \
33 33 for (int time(0); (actual != expected) && (time < timeout); time += waitStep) \
34 34 QTest::qWait(waitStep); \
35 35 QCOMPARE(actual, expected); \
36 36 } while (0); \
37 37 }
38 38
39 39 // Some bamboo clients have trouble passing mouse events to the test application.
40 40 // This can be used to skip those tests so that they don't show up as a failure
41 41 // in the test report.
42 #ifdef QT5_QUICK_1
43 #define SKIP_IF_CANNOT_TEST_MOUSE_EVENTS() { \
44 do { \
45 QPushButton b; \
46 b.resize(100, 100); \
47 b.show(); \
48 QTest::qWaitForWindowShown(&b); \
49 QSignalSpy spy(&b, SIGNAL(clicked())); \
50 QTest::mouseClick(&b, Qt::LeftButton, 0, b.rect().center()); \
51 if (spy.count() == 0) \
52 QSKIP("Cannot test mouse events in this environment"); \
53 } while (0); \
54 }
55 #else
42 56 #define SKIP_IF_CANNOT_TEST_MOUSE_EVENTS() { \
43 57 do { \
44 58 QPushButton b; \
45 59 b.resize(100, 100); \
46 60 b.show(); \
47 61 QTest::qWaitForWindowShown(&b); \
48 62 QSignalSpy spy(&b, SIGNAL(clicked())); \
49 63 QTest::mouseClick(&b, Qt::LeftButton, 0, b.rect().center()); \
50 64 if (spy.count() == 0) \
51 65 QSKIP("Cannot test mouse events in this environment", SkipAll); \
52 66 } while (0); \
53 67 }
68 #endif
54 69
55 70 #endif // TST_DEFINITIONS_H
General Comments 0
You need to be logged in to leave comments. Login now