1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the test suite of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef TESTQGEOPOSITIONINFOSOURCE_P_H
30 #define TESTQGEOPOSITIONINFOSOURCE_P_H
31 
32 #include <QtPositioning/qgeopositioninfosource.h>
33 
34 #ifdef TST_GEOCLUEMOCK_ENABLED
35 #include "geocluemock.h"
36 #include <QThread>
37 #endif
38 
39 #include <QTest>
40 #include <QObject>
41 
42 QT_BEGIN_NAMESPACE
43 class QGeoPositionInfoSource;
44 QT_END_NAMESPACE
45 
46 class TestQGeoPositionInfoSource : public QObject
47 {
48     Q_OBJECT
49 
50 public:
51     TestQGeoPositionInfoSource(QObject *parent = 0);
52 
53     static TestQGeoPositionInfoSource *createDefaultSourceTest();
54 
55 public slots:
56     void test_slot1();
57     void test_slot2();
58 
59 protected:
60     virtual QGeoPositionInfoSource *createTestSource() = 0;
61 
62     // MUST be called by subclasses if they override respective test slots
63     void base_initTestCase();
64     void base_init();
65     void base_cleanup();
66     void base_cleanupTestCase();
67 
68 private slots:
69     void initTestCase();
70     void init();
71     void cleanup();
72     void cleanupTestCase();
73 
74     void constructor_withParent();
75 
76     void constructor_noParent();
77 
78     void updateInterval();
79 
80     void setPreferredPositioningMethods();
81     void setPreferredPositioningMethods_data();
82 
83     void preferredPositioningMethods();
84 
85     void createDefaultSource();
86 
87     void setUpdateInterval();
88     void setUpdateInterval_data();
89 
90     void lastKnownPosition();
91     void lastKnownPosition_data();
92 
93     void minimumUpdateInterval();
94 
95     void startUpdates_testIntervals();
96     void startUpdates_testIntervalChangesWhileRunning();
97     void startUpdates_testDefaultInterval();
98     void startUpdates_testZeroInterval();
99     void startUpdates_moreThanOnce();
100 
101     void stopUpdates();
102     void stopUpdates_withoutStart();
103 
104     void requestUpdate();
105     void requestUpdate_data();
106 
107     void requestUpdate_validTimeout();
108     void requestUpdate_defaultTimeout();
109     void requestUpdate_timeoutLessThanMinimumInterval();
110     void requestUpdate_repeatedCalls();
111     void requestUpdate_overlappingCalls();
112 
113     void requestUpdateAfterStartUpdates_ZeroInterval();
114     void requestUpdateAfterStartUpdates_SmallInterval();
115     void requestUpdateBeforeStartUpdates_ZeroInterval();
116     void requestUpdateBeforeStartUpdates_SmallInterval();
117 
118     void removeSlotForRequestTimeout();
119     void removeSlotForPositionUpdated();
120 
121 private:
122     QGeoPositionInfoSource *m_source;
123     bool m_testingDefaultSource;
124     bool m_testSlot2Called;
125 };
126 
127 #endif
128