|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QLOCATIONTESTUTILS_P_H |
|
43 #define QLOCATIONTESTUTILS_P_H |
|
44 |
|
45 #include <QString> |
|
46 #include <QTest> |
|
47 |
|
48 #define QTRY_COMPARE(a,e) \ |
|
49 for (int _i = 0; _i < 5000; _i += 100) { \ |
|
50 if ((a) == (e)) break; \ |
|
51 QTest::qWait(100); \ |
|
52 } \ |
|
53 QCOMPARE(a, e) |
|
54 |
|
55 #define QTRY_COMPARE_WITH_TIMEOUT(a,e,t) \ |
|
56 for (int _i = 0; _i < t; _i += 100) { \ |
|
57 if ((a) >= (e)) break; \ |
|
58 QTest::qWait(100); \ |
|
59 } \ |
|
60 QCOMPARE(a, e) |
|
61 |
|
62 #define QTRY_VERIFY_WITH_TIMEOUT(a,t) \ |
|
63 for (int _i = 0; _i < t; _i += 100) { \ |
|
64 if (a) break; \ |
|
65 QTest::qWait(100); \ |
|
66 } \ |
|
67 QVERIFY(a) |
|
68 |
|
69 #define QTRY_COMPARE_WITH_TIMEOUT_RANGE(a,e,t1,t2) { \ |
|
70 int _i; \ |
|
71 for (_i = 0; _i < t1; _i += 100) { \ |
|
72 if ((a) >= (e)) {char str[100]; sprintf(str, "Got signal earlier than expected, i = %d, n = %d", _i, e);QFAIL((const char *)str); break;} \ |
|
73 QTest::qWait(100); \ |
|
74 } \ |
|
75 for (; _i < t2; _i += 100) { \ |
|
76 if ((a) >= (e)) break; \ |
|
77 QTest::qWait(100); \ |
|
78 } } \ |
|
79 QCOMPARE(a, e) |
|
80 |
|
81 #if defined(Q_OS_WINCE) |
|
82 #define EXPECT_FAIL_WINCE_SEE_MOBILITY_337 { QEXPECT_FAIL("", "MOBILITY-337: This test will fail on the test farm for WinCE", Continue); } |
|
83 #else |
|
84 #define EXPECT_FAIL_WINCE_SEE_MOBILITY_337 |
|
85 #endif |
|
86 |
|
87 #if defined(Q_OS_WINCE) |
|
88 #define EXPECT_FAIL_WINCE_SEE_MOBILITY_337_ABORT { QEXPECT_FAIL("", "MOBILITY-337: This test will fail on the test farm for WinCE", Abort); } |
|
89 #else |
|
90 #define EXPECT_FAIL_WINCE_SEE_MOBILITY_337_ABORT |
|
91 #endif |
|
92 |
|
93 |
|
94 class QLocationTestUtils |
|
95 { |
|
96 public: |
|
97 static void uheap_mark(); |
|
98 static void uheap_mark_end(); |
|
99 |
|
100 static bool hasDefaultSource(); |
|
101 static bool hasDefaultMonitor(); |
|
102 |
|
103 static QString addNmeaChecksumAndBreaks(const QString &sentence); |
|
104 |
|
105 static QString createRmcSentence(const QDateTime &dt); |
|
106 static QString createGgaSentence(const QTime &time); |
|
107 static QString createGgaSentence(int lat, int lng, const QTime &time); |
|
108 static QString createZdaSentence(const QDateTime &dt); |
|
109 }; |
|
110 |
|
111 #endif |