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