Merge lp:~unity-team/libusermetrics/minimum-maximum-qml into lp:libusermetrics
- minimum-maximum-qml
- Merge into trunk
Proposed by
Pete Woods
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 141 |
Merged at revision: | 141 |
Proposed branch: | lp:~unity-team/libusermetrics/minimum-maximum-qml |
Merge into: | lp:libusermetrics |
Diff against target: |
538 lines (+159/-42) 15 files modified
po/en_GB.po (+11/-10) po/libusermetrics.pot (+11/-10) src/modules/UserMetrics/CMakeLists.txt (+4/-1) src/modules/UserMetrics/Metric.cpp (+44/-5) src/modules/UserMetrics/Metric.h (+21/-1) src/modules/UserMetrics/qmldir (+1/-0) tests/unit/qml/CMakeLists.txt (+7/-7) tests/unit/qml/UserMetricsTest/CMakeLists.txt (+4/-1) tests/unit/qml/UserMetricsTest/DBusQuery.cpp (+12/-2) tests/unit/qml/UserMetricsTest/MetricInfo.cpp (+11/-2) tests/unit/qml/UserMetricsTest/MetricInfo.h (+16/-1) tests/unit/qml/UserMetricsTest/TestPlugin.cpp (+2/-2) tests/unit/qml/UserMetricsTest/TestPlugin.h (+4/-0) tests/unit/qml/UserMetricsTest/qmldir (+1/-0) tests/unit/qml/tst_Metrics.qml (+10/-0) |
To merge this branch: | bzr merge lp:~unity-team/libusermetrics/minimum-maximum-qml |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Unity Team | Pending | ||
Review via email: mp+188788@code.launchpad.net |
Commit message
Support minimum and maximum properties in the QML API
Description of the change
Support minimum and maximum properties in the QML API
To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) : | # |
review:
Approve
(continuous-integration)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'po/en_GB.po' | |||
2 | --- po/en_GB.po 2013-10-01 10:22:38 +0000 | |||
3 | +++ po/en_GB.po 2013-10-02 09:46:27 +0000 | |||
4 | @@ -7,7 +7,7 @@ | |||
5 | 7 | msgstr "" | 7 | msgstr "" |
6 | 8 | "Project-Id-Version: libusermetrics\n" | 8 | "Project-Id-Version: libusermetrics\n" |
7 | 9 | "Report-Msgid-Bugs-To: \n" | 9 | "Report-Msgid-Bugs-To: \n" |
9 | 10 | "POT-Creation-Date: 2013-10-01 11:14+0100\n" | 10 | "POT-Creation-Date: 2013-10-02 10:29+0100\n" |
10 | 11 | "PO-Revision-Date: 2013-07-05 15:09+0100\n" | 11 | "PO-Revision-Date: 2013-07-05 15:09+0100\n" |
11 | 12 | "Last-Translator: Pete Woods <pete.woods@canonical.com>\n" | 12 | "Last-Translator: Pete Woods <pete.woods@canonical.com>\n" |
12 | 13 | "Language-Team: British English <en@li.org>\n" | 13 | "Language-Team: British English <en@li.org>\n" |
13 | @@ -25,7 +25,7 @@ | |||
14 | 25 | msgid "Attempt to create data set owned by another user" | 25 | msgid "Attempt to create data set owned by another user" |
15 | 26 | msgstr "Attempt to create data set owned by another user" | 26 | msgstr "Attempt to create data set owned by another user" |
16 | 27 | 27 | ||
18 | 28 | #: src/usermetricsservice/DBusUserMetrics.cpp:239 | 28 | #: src/usermetricsservice/DBusUserMetrics.cpp:250 |
19 | 29 | #, fuzzy | 29 | #, fuzzy |
20 | 30 | msgid "Attempt to create user data owned by another user" | 30 | msgid "Attempt to create user data owned by another user" |
21 | 31 | msgstr "Attempt to create user data owned by another user" | 31 | msgstr "Attempt to create user data owned by another user" |
22 | @@ -73,11 +73,11 @@ | |||
23 | 73 | #: src/usermetricsservice/DBusDataSource.cpp:190 | 73 | #: src/usermetricsservice/DBusDataSource.cpp:190 |
24 | 74 | #: src/usermetricsservice/DBusDataSource.cpp:216 | 74 | #: src/usermetricsservice/DBusDataSource.cpp:216 |
25 | 75 | #: src/usermetricsservice/DBusDataSource.cpp:234 | 75 | #: src/usermetricsservice/DBusDataSource.cpp:234 |
27 | 76 | #: src/usermetricsservice/DBusUserMetrics.cpp:177 | 76 | #: src/usermetricsservice/DBusUserMetrics.cpp:188 |
28 | 77 | msgid "Could not save data source" | 77 | msgid "Could not save data source" |
29 | 78 | msgstr "Couldn't save data source" | 78 | msgstr "Couldn't save data source" |
30 | 79 | 79 | ||
32 | 80 | #: src/usermetricsservice/DBusUserMetrics.cpp:257 | 80 | #: src/usermetricsservice/DBusUserMetrics.cpp:268 |
33 | 81 | msgid "Could not save user data" | 81 | msgid "Could not save user data" |
34 | 82 | msgstr "Couldn't save user data" | 82 | msgstr "Couldn't save user data" |
35 | 83 | 83 | ||
36 | @@ -98,23 +98,24 @@ | |||
37 | 98 | msgid "Data source not found" | 98 | msgid "Data source not found" |
38 | 99 | msgstr "Data source not found" | 99 | msgstr "Data source not found" |
39 | 100 | 100 | ||
41 | 101 | #: src/usermetricsservice/DBusUserMetrics.cpp:143 | 101 | #: src/usermetricsservice/DBusUserMetrics.cpp:142 |
42 | 102 | #: src/usermetricsservice/DBusUserMetrics.cpp:154 | ||
43 | 102 | msgid "Data source query failed" | 103 | msgid "Data source query failed" |
44 | 103 | msgstr "Data source query failed" | 104 | msgstr "Data source query failed" |
45 | 104 | 105 | ||
47 | 105 | #: src/modules/UserMetrics/Metric.cpp:28 | 106 | #: src/modules/UserMetrics/Metric.cpp:30 |
48 | 106 | msgid "Failed to connect to metrics service:" | 107 | msgid "Failed to connect to metrics service:" |
49 | 107 | msgstr "Failed to connect to metrics service:" | 108 | msgstr "Failed to connect to metrics service:" |
50 | 108 | 109 | ||
52 | 109 | #: src/modules/UserMetrics/Metric.cpp:115 | 110 | #: src/modules/UserMetrics/Metric.cpp:154 |
53 | 110 | msgid "Failed to increment metric:" | 111 | msgid "Failed to increment metric:" |
54 | 111 | msgstr "" | 112 | msgstr "" |
55 | 112 | 113 | ||
57 | 113 | #: src/modules/UserMetrics/Metric.cpp:102 | 114 | #: src/modules/UserMetrics/Metric.cpp:141 |
58 | 114 | msgid "Failed to register user metric:" | 115 | msgid "Failed to register user metric:" |
59 | 115 | msgstr "Failed to register user metric:" | 116 | msgstr "Failed to register user metric:" |
60 | 116 | 117 | ||
62 | 117 | #: src/modules/UserMetrics/Metric.cpp:127 | 118 | #: src/modules/UserMetrics/Metric.cpp:166 |
63 | 118 | msgid "Failed to update metric:" | 119 | msgid "Failed to update metric:" |
64 | 119 | msgstr "Failed to update metric:" | 120 | msgstr "Failed to update metric:" |
65 | 120 | 121 | ||
66 | @@ -151,7 +152,7 @@ | |||
67 | 151 | msgid "Usage: " | 152 | msgid "Usage: " |
68 | 152 | msgstr "Usage: " | 153 | msgstr "Usage: " |
69 | 153 | 154 | ||
71 | 154 | #: src/usermetricsservice/DBusUserMetrics.cpp:248 | 155 | #: src/usermetricsservice/DBusUserMetrics.cpp:259 |
72 | 155 | msgid "User data query failed" | 156 | msgid "User data query failed" |
73 | 156 | msgstr "User data query failed" | 157 | msgstr "User data query failed" |
74 | 157 | 158 | ||
75 | 158 | 159 | ||
76 | === modified file 'po/libusermetrics.pot' | |||
77 | --- po/libusermetrics.pot 2013-10-01 10:22:38 +0000 | |||
78 | +++ po/libusermetrics.pot 2013-10-02 09:46:27 +0000 | |||
79 | @@ -8,7 +8,7 @@ | |||
80 | 8 | msgstr "" | 8 | msgstr "" |
81 | 9 | "Project-Id-Version: libusermetrics\n" | 9 | "Project-Id-Version: libusermetrics\n" |
82 | 10 | "Report-Msgid-Bugs-To: \n" | 10 | "Report-Msgid-Bugs-To: \n" |
84 | 11 | "POT-Creation-Date: 2013-10-01 11:16+0100\n" | 11 | "POT-Creation-Date: 2013-10-02 10:29+0100\n" |
85 | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
86 | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
87 | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" | 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
88 | @@ -38,7 +38,7 @@ | |||
89 | 38 | #: src/usermetricsservice/DBusDataSource.cpp:190 | 38 | #: src/usermetricsservice/DBusDataSource.cpp:190 |
90 | 39 | #: src/usermetricsservice/DBusDataSource.cpp:216 | 39 | #: src/usermetricsservice/DBusDataSource.cpp:216 |
91 | 40 | #: src/usermetricsservice/DBusDataSource.cpp:234 | 40 | #: src/usermetricsservice/DBusDataSource.cpp:234 |
93 | 41 | #: src/usermetricsservice/DBusUserMetrics.cpp:177 | 41 | #: src/usermetricsservice/DBusUserMetrics.cpp:188 |
94 | 42 | msgid "Could not save data source" | 42 | msgid "Could not save data source" |
95 | 43 | msgstr "" | 43 | msgstr "" |
96 | 44 | 44 | ||
97 | @@ -46,19 +46,20 @@ | |||
98 | 46 | msgid "Unable to register user metrics object on DBus" | 46 | msgid "Unable to register user metrics object on DBus" |
99 | 47 | msgstr "" | 47 | msgstr "" |
100 | 48 | 48 | ||
102 | 49 | #: src/usermetricsservice/DBusUserMetrics.cpp:143 | 49 | #: src/usermetricsservice/DBusUserMetrics.cpp:142 |
103 | 50 | #: src/usermetricsservice/DBusUserMetrics.cpp:154 | ||
104 | 50 | msgid "Data source query failed" | 51 | msgid "Data source query failed" |
105 | 51 | msgstr "" | 52 | msgstr "" |
106 | 52 | 53 | ||
108 | 53 | #: src/usermetricsservice/DBusUserMetrics.cpp:239 | 54 | #: src/usermetricsservice/DBusUserMetrics.cpp:250 |
109 | 54 | msgid "Attempt to create user data owned by another user" | 55 | msgid "Attempt to create user data owned by another user" |
110 | 55 | msgstr "" | 56 | msgstr "" |
111 | 56 | 57 | ||
113 | 57 | #: src/usermetricsservice/DBusUserMetrics.cpp:248 | 58 | #: src/usermetricsservice/DBusUserMetrics.cpp:259 |
114 | 58 | msgid "User data query failed" | 59 | msgid "User data query failed" |
115 | 59 | msgstr "" | 60 | msgstr "" |
116 | 60 | 61 | ||
118 | 61 | #: src/usermetricsservice/DBusUserMetrics.cpp:257 | 62 | #: src/usermetricsservice/DBusUserMetrics.cpp:268 |
119 | 62 | msgid "Could not save user data" | 63 | msgid "Could not save user data" |
120 | 63 | msgstr "" | 64 | msgstr "" |
121 | 64 | 65 | ||
122 | @@ -107,19 +108,19 @@ | |||
123 | 107 | msgid "New data set could not be found" | 108 | msgid "New data set could not be found" |
124 | 108 | msgstr "" | 109 | msgstr "" |
125 | 109 | 110 | ||
127 | 110 | #: src/modules/UserMetrics/Metric.cpp:28 | 111 | #: src/modules/UserMetrics/Metric.cpp:30 |
128 | 111 | msgid "Failed to connect to metrics service:" | 112 | msgid "Failed to connect to metrics service:" |
129 | 112 | msgstr "" | 113 | msgstr "" |
130 | 113 | 114 | ||
132 | 114 | #: src/modules/UserMetrics/Metric.cpp:102 | 115 | #: src/modules/UserMetrics/Metric.cpp:141 |
133 | 115 | msgid "Failed to register user metric:" | 116 | msgid "Failed to register user metric:" |
134 | 116 | msgstr "" | 117 | msgstr "" |
135 | 117 | 118 | ||
137 | 118 | #: src/modules/UserMetrics/Metric.cpp:115 | 119 | #: src/modules/UserMetrics/Metric.cpp:154 |
138 | 119 | msgid "Failed to increment metric:" | 120 | msgid "Failed to increment metric:" |
139 | 120 | msgstr "" | 121 | msgstr "" |
140 | 121 | 122 | ||
142 | 122 | #: src/modules/UserMetrics/Metric.cpp:127 | 123 | #: src/modules/UserMetrics/Metric.cpp:166 |
143 | 123 | msgid "Failed to update metric:" | 124 | msgid "Failed to update metric:" |
144 | 124 | msgstr "" | 125 | msgstr "" |
145 | 125 | 126 | ||
146 | 126 | 127 | ||
147 | === modified file 'src/modules/UserMetrics/CMakeLists.txt' | |||
148 | --- src/modules/UserMetrics/CMakeLists.txt 2013-09-24 08:13:01 +0000 | |||
149 | +++ src/modules/UserMetrics/CMakeLists.txt 2013-10-02 09:46:27 +0000 | |||
150 | @@ -38,4 +38,7 @@ | |||
151 | 38 | install(FILES qmldir DESTINATION ${PLUGIN_DIR}) | 38 | install(FILES qmldir DESTINATION ${PLUGIN_DIR}) |
152 | 39 | 39 | ||
153 | 40 | # copy qmldir file to build dir so QML unit tests can use it to import the plugin | 40 | # copy qmldir file to build dir so QML unit tests can use it to import the plugin |
155 | 41 | file(COPY qmldir DESTINATION ${CMAKE_BINARY_DIR}/src/modules/UserMetrics) | 41 | configure_file( |
156 | 42 | qmldir | ||
157 | 43 | qmldir | ||
158 | 44 | ) | ||
159 | 42 | 45 | ||
160 | === modified file 'src/modules/UserMetrics/Metric.cpp' | |||
161 | --- src/modules/UserMetrics/Metric.cpp 2013-09-26 15:24:43 +0000 | |||
162 | +++ src/modules/UserMetrics/Metric.cpp 2013-10-02 09:46:27 +0000 | |||
163 | @@ -18,10 +18,12 @@ | |||
164 | 18 | #include <libusermetricscommon/Localisation.h> | 18 | #include <libusermetricscommon/Localisation.h> |
165 | 19 | 19 | ||
166 | 20 | #include <stdexcept> | 20 | #include <stdexcept> |
167 | 21 | #include <cmath> | ||
168 | 21 | #include <QDebug> | 22 | #include <QDebug> |
169 | 22 | 23 | ||
170 | 23 | Metric::Metric(QObject *parent) : | 24 | Metric::Metric(QObject *parent) : |
172 | 24 | QObject(parent), m_componentComplete(false) { | 25 | QObject(parent), m_componentComplete(false), m_minimum(NAN), m_maximum( |
173 | 26 | NAN) { | ||
174 | 25 | try { | 27 | try { |
175 | 26 | m_metricManager.reset(UserMetricsInput::MetricManager::getInstance()); | 28 | m_metricManager.reset(UserMetricsInput::MetricManager::getInstance()); |
176 | 27 | } catch (std::exception &e) { | 29 | } catch (std::exception &e) { |
177 | @@ -80,6 +82,30 @@ | |||
178 | 80 | } | 82 | } |
179 | 81 | } | 83 | } |
180 | 82 | 84 | ||
181 | 85 | double Metric::minimum() const { | ||
182 | 86 | return m_minimum; | ||
183 | 87 | } | ||
184 | 88 | |||
185 | 89 | void Metric::setMinimum(double minimum) { | ||
186 | 90 | if (m_minimum != minimum) { | ||
187 | 91 | m_minimum = minimum; | ||
188 | 92 | Q_EMIT minimumChanged(); | ||
189 | 93 | registerMetric(); | ||
190 | 94 | } | ||
191 | 95 | } | ||
192 | 96 | |||
193 | 97 | double Metric::maximum() const { | ||
194 | 98 | return m_maximum; | ||
195 | 99 | } | ||
196 | 100 | |||
197 | 101 | void Metric::setMaximum(double maximum) { | ||
198 | 102 | if (m_maximum != maximum) { | ||
199 | 103 | m_maximum = maximum; | ||
200 | 104 | Q_EMIT maximumChanged(); | ||
201 | 105 | registerMetric(); | ||
202 | 106 | } | ||
203 | 107 | } | ||
204 | 108 | |||
205 | 83 | void Metric::registerMetric() { | 109 | void Metric::registerMetric() { |
206 | 84 | if (!m_componentComplete) { | 110 | if (!m_componentComplete) { |
207 | 85 | return; | 111 | return; |
208 | @@ -94,10 +120,23 @@ | |||
209 | 94 | } | 120 | } |
210 | 95 | 121 | ||
211 | 96 | try { | 122 | try { |
216 | 97 | m_metric = m_metricManager->add( | 123 | UserMetricsInput::MetricParameters parameters(m_name); |
217 | 98 | UserMetricsInput::MetricParameters(m_name).formatString( | 124 | parameters.formatString(m_format); |
218 | 99 | m_format).emptyDataString(m_emptyFormat).textDomain( | 125 | |
219 | 100 | m_domain)); | 126 | if (!m_emptyFormat.isEmpty()) { |
220 | 127 | parameters.emptyDataString(m_emptyFormat); | ||
221 | 128 | } | ||
222 | 129 | if (!m_domain.isEmpty()) { | ||
223 | 130 | parameters.textDomain(m_domain); | ||
224 | 131 | } | ||
225 | 132 | if (!isnan(m_minimum)) { | ||
226 | 133 | parameters.minimum(m_minimum); | ||
227 | 134 | } | ||
228 | 135 | if (!isnan(m_maximum)) { | ||
229 | 136 | parameters.maximum(m_maximum); | ||
230 | 137 | } | ||
231 | 138 | |||
232 | 139 | m_metric = m_metricManager->add(parameters); | ||
233 | 101 | } catch (std::exception &e) { | 140 | } catch (std::exception &e) { |
234 | 102 | qWarning() << _("Failed to register user metric:") << m_name << "\"" | 141 | qWarning() << _("Failed to register user metric:") << m_name << "\"" |
235 | 103 | << m_format << "\": " << e.what(); | 142 | << m_format << "\": " << e.what(); |
236 | 104 | 143 | ||
237 | === modified file 'src/modules/UserMetrics/Metric.h' | |||
238 | --- src/modules/UserMetrics/Metric.h 2013-09-24 08:13:01 +0000 | |||
239 | +++ src/modules/UserMetrics/Metric.h 2013-10-02 09:46:27 +0000 | |||
240 | @@ -24,10 +24,14 @@ | |||
241 | 24 | class Metric: public QObject, public QQmlParserStatus { | 24 | class Metric: public QObject, public QQmlParserStatus { |
242 | 25 | Q_OBJECT | 25 | Q_OBJECT |
243 | 26 | 26 | ||
245 | 27 | Q_INTERFACES (QQmlParserStatus)Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) | 27 | Q_INTERFACES (QQmlParserStatus) |
246 | 28 | |||
247 | 29 | Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) | ||
248 | 28 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) | 30 | Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged) |
249 | 29 | Q_PROPERTY(QString emptyFormat READ emptyFormat WRITE setEmptyFormat NOTIFY emptyFormatChanged) | 31 | Q_PROPERTY(QString emptyFormat READ emptyFormat WRITE setEmptyFormat NOTIFY emptyFormatChanged) |
250 | 30 | Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) | 32 | Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged) |
251 | 33 | Q_PROPERTY(double minimum READ minimum WRITE setMinimum NOTIFY minimumChanged) | ||
252 | 34 | Q_PROPERTY(double maximum READ maximum WRITE setMaximum NOTIFY maximumChanged) | ||
253 | 31 | 35 | ||
254 | 32 | public: | 36 | public: |
255 | 33 | explicit Metric(QObject *parent = 0); | 37 | explicit Metric(QObject *parent = 0); |
256 | @@ -50,6 +54,14 @@ | |||
257 | 50 | 54 | ||
258 | 51 | void setDomain(const QString &domain); | 55 | void setDomain(const QString &domain); |
259 | 52 | 56 | ||
260 | 57 | double minimum() const; | ||
261 | 58 | |||
262 | 59 | void setMinimum(double minimum); | ||
263 | 60 | |||
264 | 61 | double maximum() const; | ||
265 | 62 | |||
266 | 63 | void setMaximum(double maximum); | ||
267 | 64 | |||
268 | 53 | void classBegin(); | 65 | void classBegin(); |
269 | 54 | 66 | ||
270 | 55 | void componentComplete(); | 67 | void componentComplete(); |
271 | @@ -68,6 +80,10 @@ | |||
272 | 68 | 80 | ||
273 | 69 | void domainChanged(); | 81 | void domainChanged(); |
274 | 70 | 82 | ||
275 | 83 | void minimumChanged(); | ||
276 | 84 | |||
277 | 85 | void maximumChanged(); | ||
278 | 86 | |||
279 | 71 | protected: | 87 | protected: |
280 | 72 | void registerMetric(); | 88 | void registerMetric(); |
281 | 73 | 89 | ||
282 | @@ -84,6 +100,10 @@ | |||
283 | 84 | QString m_emptyFormat; | 100 | QString m_emptyFormat; |
284 | 85 | 101 | ||
285 | 86 | QString m_domain; | 102 | QString m_domain; |
286 | 103 | |||
287 | 104 | double m_minimum; | ||
288 | 105 | |||
289 | 106 | double m_maximum; | ||
290 | 87 | }; | 107 | }; |
291 | 88 | 108 | ||
292 | 89 | #endif // MODULES_USERMETRICS_METRICSMANAGER_H | 109 | #endif // MODULES_USERMETRICS_METRICSMANAGER_H |
293 | 90 | 110 | ||
294 | === modified file 'src/modules/UserMetrics/qmldir' | |||
295 | --- src/modules/UserMetrics/qmldir 2013-09-17 11:03:34 +0000 | |||
296 | +++ src/modules/UserMetrics/qmldir 2013-10-02 09:46:27 +0000 | |||
297 | @@ -1,1 +1,2 @@ | |||
298 | 1 | module UserMetrics | ||
299 | 1 | plugin usermetrics-qml | 2 | plugin usermetrics-qml |
300 | 2 | 3 | ||
301 | === modified file 'tests/unit/qml/CMakeLists.txt' | |||
302 | --- tests/unit/qml/CMakeLists.txt 2013-09-18 15:13:02 +0000 | |||
303 | +++ tests/unit/qml/CMakeLists.txt 2013-10-02 09:46:27 +0000 | |||
304 | @@ -1,13 +1,13 @@ | |||
305 | 1 | |||
306 | 1 | add_executable(tst_QmlTests tst_QmlTests.cpp) | 2 | add_executable(tst_QmlTests tst_QmlTests.cpp) |
307 | 2 | qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest) | 3 | qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest) |
308 | 3 | target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES}) | 4 | target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES}) |
310 | 4 | add_test(tst_QmlTests ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${SOURCE_BINARY_DIR}/modules) | 5 | |
311 | 6 | add_test(tst_QmlTests | ||
312 | 7 | ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests | ||
313 | 8 | -input ${CMAKE_CURRENT_SOURCE_DIR} | ||
314 | 9 | -import ${SOURCE_BINARY_DIR}/modules | ||
315 | 10 | ) | ||
316 | 5 | set_tests_properties(tst_QmlTests PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal") | 11 | set_tests_properties(tst_QmlTests PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal") |
317 | 6 | 12 | ||
318 | 7 | # copy qml test files to build dir | ||
319 | 8 | file(GLOB qmlTestFiles RELATIVE ${CMAKE_SOURCE_DIR}/tests/unit/qml/ *qml) | ||
320 | 9 | foreach(qmlTestFile ${qmlTestFiles}) | ||
321 | 10 | file(COPY ${qmlTestFile} DESTINATION ${CMAKE_BINARY_DIR}/tests/unit/qml/) | ||
322 | 11 | endforeach(qmlTestFile) | ||
323 | 12 | |||
324 | 13 | add_subdirectory(UserMetricsTest) | 13 | add_subdirectory(UserMetricsTest) |
325 | 14 | 14 | ||
326 | === modified file 'tests/unit/qml/UserMetricsTest/CMakeLists.txt' | |||
327 | --- tests/unit/qml/UserMetricsTest/CMakeLists.txt 2013-09-23 14:12:23 +0000 | |||
328 | +++ tests/unit/qml/UserMetricsTest/CMakeLists.txt 2013-10-02 09:46:27 +0000 | |||
329 | @@ -22,4 +22,7 @@ | |||
330 | 22 | ) | 22 | ) |
331 | 23 | 23 | ||
332 | 24 | # copy qmldir file to build dir | 24 | # copy qmldir file to build dir |
334 | 25 | file(COPY qmldir DESTINATION ${CMAKE_BINARY_DIR}/tests/unit/qml/UserMetricsTest) | 25 | configure_file( |
335 | 26 | qmldir | ||
336 | 27 | qmldir | ||
337 | 28 | ) | ||
338 | 26 | 29 | ||
339 | === modified file 'tests/unit/qml/UserMetricsTest/DBusQuery.cpp' | |||
340 | --- tests/unit/qml/UserMetricsTest/DBusQuery.cpp 2013-09-26 11:35:49 +0000 | |||
341 | +++ tests/unit/qml/UserMetricsTest/DBusQuery.cpp 2013-10-02 09:46:27 +0000 | |||
342 | @@ -17,7 +17,7 @@ | |||
343 | 17 | #include <DBusQuery.h> | 17 | #include <DBusQuery.h> |
344 | 18 | #include <MetricInfo.h> | 18 | #include <MetricInfo.h> |
345 | 19 | 19 | ||
347 | 20 | #include <QDebug> | 20 | #include <cmath> |
348 | 21 | #include <QtDBus/QtDBus> | 21 | #include <QtDBus/QtDBus> |
349 | 22 | #include <libqtdbustest/QProcessDBusService.h> | 22 | #include <libqtdbustest/QProcessDBusService.h> |
350 | 23 | #include <libqtdbustest/DBusService.h> | 23 | #include <libqtdbustest/DBusService.h> |
351 | @@ -59,10 +59,20 @@ | |||
352 | 59 | if (dataSourceInterface.name().isEmpty()) { | 59 | if (dataSourceInterface.name().isEmpty()) { |
353 | 60 | return 0; | 60 | return 0; |
354 | 61 | } else { | 61 | } else { |
355 | 62 | double minimum(NAN); | ||
356 | 63 | double maximum(NAN); | ||
357 | 64 | QVariantMap options(dataSourceInterface.options()); | ||
358 | 65 | if (options.contains("minimum")) { | ||
359 | 66 | minimum = options["minimum"].toDouble(); | ||
360 | 67 | } | ||
361 | 68 | if (options.contains("maximum")) { | ||
362 | 69 | maximum = options["maximum"].toDouble(); | ||
363 | 70 | } | ||
364 | 71 | |||
365 | 62 | return new MetricInfo(dataSourceInterface.name(), | 72 | return new MetricInfo(dataSourceInterface.name(), |
366 | 63 | dataSourceInterface.formatString(), | 73 | dataSourceInterface.formatString(), |
367 | 64 | dataSourceInterface.emptyDataString(), | 74 | dataSourceInterface.emptyDataString(), |
369 | 65 | dataSourceInterface.textDomain(), this); | 75 | dataSourceInterface.textDomain(), minimum, maximum, this); |
370 | 66 | } | 76 | } |
371 | 67 | } | 77 | } |
372 | 68 | 78 | ||
373 | 69 | 79 | ||
374 | === modified file 'tests/unit/qml/UserMetricsTest/MetricInfo.cpp' | |||
375 | --- tests/unit/qml/UserMetricsTest/MetricInfo.cpp 2013-09-24 08:13:01 +0000 | |||
376 | +++ tests/unit/qml/UserMetricsTest/MetricInfo.cpp 2013-10-02 09:46:27 +0000 | |||
377 | @@ -17,9 +17,10 @@ | |||
378 | 17 | #include <MetricInfo.h> | 17 | #include <MetricInfo.h> |
379 | 18 | 18 | ||
380 | 19 | MetricInfo::MetricInfo(QString name, QString format, QString emptyFormat, | 19 | MetricInfo::MetricInfo(QString name, QString format, QString emptyFormat, |
382 | 20 | QString domain, QObject *parent) : | 20 | QString domain, double minimum, double maximum, QObject *parent) : |
383 | 21 | QObject(parent), m_name(name), m_format(format), m_emptyFormat( | 21 | QObject(parent), m_name(name), m_format(format), m_emptyFormat( |
385 | 22 | emptyFormat), m_domain(domain) { | 22 | emptyFormat), m_domain(domain), m_minimum(minimum), m_maximum( |
386 | 23 | maximum) { | ||
387 | 23 | } | 24 | } |
388 | 24 | 25 | ||
389 | 25 | MetricInfo::~MetricInfo() { | 26 | MetricInfo::~MetricInfo() { |
390 | @@ -40,3 +41,11 @@ | |||
391 | 40 | QString MetricInfo::domain() const { | 41 | QString MetricInfo::domain() const { |
392 | 41 | return m_domain; | 42 | return m_domain; |
393 | 42 | } | 43 | } |
394 | 44 | |||
395 | 45 | double MetricInfo::minimum() const { | ||
396 | 46 | return m_minimum; | ||
397 | 47 | } | ||
398 | 48 | |||
399 | 49 | double MetricInfo::maximum() const { | ||
400 | 50 | return m_maximum; | ||
401 | 51 | } | ||
402 | 43 | 52 | ||
403 | === modified file 'tests/unit/qml/UserMetricsTest/MetricInfo.h' | |||
404 | --- tests/unit/qml/UserMetricsTest/MetricInfo.h 2013-09-24 08:13:01 +0000 | |||
405 | +++ tests/unit/qml/UserMetricsTest/MetricInfo.h 2013-10-02 09:46:27 +0000 | |||
406 | @@ -26,10 +26,13 @@ | |||
407 | 26 | Q_PROPERTY(QString format READ format NOTIFY formatChanged) | 26 | Q_PROPERTY(QString format READ format NOTIFY formatChanged) |
408 | 27 | Q_PROPERTY(QString emptyFormat READ emptyFormat NOTIFY emptyFormatChanged) | 27 | Q_PROPERTY(QString emptyFormat READ emptyFormat NOTIFY emptyFormatChanged) |
409 | 28 | Q_PROPERTY(QString domain READ domain NOTIFY domainChanged) | 28 | Q_PROPERTY(QString domain READ domain NOTIFY domainChanged) |
410 | 29 | Q_PROPERTY(double minimum READ minimum NOTIFY minimumChanged) | ||
411 | 30 | Q_PROPERTY(double maximum READ maximum NOTIFY maximumChanged) | ||
412 | 29 | 31 | ||
413 | 30 | public: | 32 | public: |
414 | 31 | explicit MetricInfo(QString name, QString format, QString emptyFormat, | 33 | explicit MetricInfo(QString name, QString format, QString emptyFormat, |
416 | 32 | QString domain, QObject *parent = 0); | 34 | QString domain, double minimum, double maximum, |
417 | 35 | QObject *parent = 0); | ||
418 | 33 | 36 | ||
419 | 34 | virtual ~MetricInfo(); | 37 | virtual ~MetricInfo(); |
420 | 35 | 38 | ||
421 | @@ -42,6 +45,10 @@ | |||
422 | 42 | 45 | ||
423 | 43 | QString domain() const; | 46 | QString domain() const; |
424 | 44 | 47 | ||
425 | 48 | double minimum() const; | ||
426 | 49 | |||
427 | 50 | double maximum() const; | ||
428 | 51 | |||
429 | 45 | Q_SIGNALS: | 52 | Q_SIGNALS: |
430 | 46 | void nameChanged(); | 53 | void nameChanged(); |
431 | 47 | 54 | ||
432 | @@ -51,6 +58,10 @@ | |||
433 | 51 | 58 | ||
434 | 52 | void domainChanged(); | 59 | void domainChanged(); |
435 | 53 | 60 | ||
436 | 61 | void minimumChanged(); | ||
437 | 62 | |||
438 | 63 | void maximumChanged(); | ||
439 | 64 | |||
440 | 54 | private: | 65 | private: |
441 | 55 | QString m_name; | 66 | QString m_name; |
442 | 56 | 67 | ||
443 | @@ -60,6 +71,10 @@ | |||
444 | 60 | 71 | ||
445 | 61 | QString m_domain; | 72 | QString m_domain; |
446 | 62 | 73 | ||
447 | 74 | double m_minimum; | ||
448 | 75 | |||
449 | 76 | double m_maximum; | ||
450 | 77 | |||
451 | 63 | }; | 78 | }; |
452 | 64 | 79 | ||
453 | 65 | #endif // MODULES_USERMETRICSTEST_METRICINFO_H | 80 | #endif // MODULES_USERMETRICSTEST_METRICINFO_H |
454 | 66 | 81 | ||
455 | === modified file 'tests/unit/qml/UserMetricsTest/TestPlugin.cpp' | |||
456 | --- tests/unit/qml/UserMetricsTest/TestPlugin.cpp 2013-09-24 08:13:01 +0000 | |||
457 | +++ tests/unit/qml/UserMetricsTest/TestPlugin.cpp 2013-10-02 09:46:27 +0000 | |||
458 | @@ -16,7 +16,6 @@ | |||
459 | 16 | 16 | ||
460 | 17 | #include <QtQuick/QtQuick> | 17 | #include <QtQuick/QtQuick> |
461 | 18 | #include <TestPlugin.h> | 18 | #include <TestPlugin.h> |
462 | 19 | #include <DBusQuery.h> | ||
463 | 20 | #include <MetricInfo.h> | 19 | #include <MetricInfo.h> |
464 | 21 | 20 | ||
465 | 22 | void Components::registerTypes(const char *uri) { | 21 | void Components::registerTypes(const char *uri) { |
466 | @@ -27,6 +26,7 @@ | |||
467 | 27 | } | 26 | } |
468 | 28 | 27 | ||
469 | 29 | void Components::initializeEngine(QQmlEngine *engine, const char *uri) { | 28 | void Components::initializeEngine(QQmlEngine *engine, const char *uri) { |
470 | 29 | m_dbusQuery.reset(new DBusQuery()); | ||
471 | 30 | QQmlExtensionPlugin::initializeEngine(engine, uri); | 30 | QQmlExtensionPlugin::initializeEngine(engine, uri); |
473 | 31 | engine->rootContext()->setContextProperty("dbusQuery", new DBusQuery(this)); | 31 | engine->rootContext()->setContextProperty("dbusQuery", m_dbusQuery.data()); |
474 | 32 | } | 32 | } |
475 | 33 | 33 | ||
476 | === modified file 'tests/unit/qml/UserMetricsTest/TestPlugin.h' | |||
477 | --- tests/unit/qml/UserMetricsTest/TestPlugin.h 2013-09-23 14:32:44 +0000 | |||
478 | +++ tests/unit/qml/UserMetricsTest/TestPlugin.h 2013-10-02 09:46:27 +0000 | |||
479 | @@ -19,6 +19,7 @@ | |||
480 | 19 | 19 | ||
481 | 20 | #include <QtQml/QQmlExtensionPlugin> | 20 | #include <QtQml/QQmlExtensionPlugin> |
482 | 21 | #include <QtQml/QQmlEngine> | 21 | #include <QtQml/QQmlEngine> |
483 | 22 | #include <DBusQuery.h> | ||
484 | 22 | 23 | ||
485 | 23 | class Components : public QQmlExtensionPlugin | 24 | class Components : public QQmlExtensionPlugin |
486 | 24 | { | 25 | { |
487 | @@ -28,6 +29,9 @@ | |||
488 | 28 | public: | 29 | public: |
489 | 29 | void registerTypes(const char *uri); | 30 | void registerTypes(const char *uri); |
490 | 30 | void initializeEngine(QQmlEngine *engine, const char *uri); | 31 | void initializeEngine(QQmlEngine *engine, const char *uri); |
491 | 32 | |||
492 | 33 | protected: | ||
493 | 34 | QScopedPointer<DBusQuery> m_dbusQuery; | ||
494 | 31 | }; | 35 | }; |
495 | 32 | 36 | ||
496 | 33 | #endif // MODULES_USERMETRICSTEST_TESTPLUGIN_H | 37 | #endif // MODULES_USERMETRICSTEST_TESTPLUGIN_H |
497 | 34 | 38 | ||
498 | === modified file 'tests/unit/qml/UserMetricsTest/qmldir' | |||
499 | --- tests/unit/qml/UserMetricsTest/qmldir 2013-09-18 15:13:02 +0000 | |||
500 | +++ tests/unit/qml/UserMetricsTest/qmldir 2013-10-02 09:46:27 +0000 | |||
501 | @@ -1,1 +1,2 @@ | |||
502 | 1 | module UserMetricsTest | ||
503 | 1 | plugin usermetrics-qml-test | 2 | plugin usermetrics-qml-test |
504 | 2 | 3 | ||
505 | === modified file 'tests/unit/qml/tst_Metrics.qml' | |||
506 | --- tests/unit/qml/tst_Metrics.qml 2013-09-23 14:44:47 +0000 | |||
507 | +++ tests/unit/qml/tst_Metrics.qml 2013-10-02 09:46:27 +0000 | |||
508 | @@ -26,6 +26,7 @@ | |||
509 | 26 | property string originalFormat: "Test Metric" | 26 | property string originalFormat: "Test Metric" |
510 | 27 | property string originalEmptyFormat: "Nope, no data" | 27 | property string originalEmptyFormat: "Nope, no data" |
511 | 28 | property string originalDomain: "test-domain" | 28 | property string originalDomain: "test-domain" |
512 | 29 | property double originalMinimum: 0.0 | ||
513 | 29 | 30 | ||
514 | 30 | Metric { | 31 | Metric { |
515 | 31 | id: metric | 32 | id: metric |
516 | @@ -33,6 +34,7 @@ | |||
517 | 33 | format: originalFormat | 34 | format: originalFormat |
518 | 34 | emptyFormat: originalEmptyFormat | 35 | emptyFormat: originalEmptyFormat |
519 | 35 | domain: originalDomain | 36 | domain: originalDomain |
520 | 37 | minimum: originalMinimum | ||
521 | 36 | } | 38 | } |
522 | 37 | 39 | ||
523 | 38 | function test_metric() { | 40 | function test_metric() { |
524 | @@ -42,6 +44,14 @@ | |||
525 | 42 | compare(info.format, originalFormat, "Metric format was not set properly"); | 44 | compare(info.format, originalFormat, "Metric format was not set properly"); |
526 | 43 | compare(info.emptyFormat, originalEmptyFormat, "Metric emptyFormat was not set properly"); | 45 | compare(info.emptyFormat, originalEmptyFormat, "Metric emptyFormat was not set properly"); |
527 | 44 | compare(info.domain, originalDomain, "Metric domain was not set properly"); | 46 | compare(info.domain, originalDomain, "Metric domain was not set properly"); |
528 | 47 | compare(info.minimum, originalMinimum, "Metric minimum was not set properly"); | ||
529 | 48 | compare(info.maximum, NaN, "Metric maximum was not set properly"); | ||
530 | 49 | |||
531 | 50 | metric.minimum = 0.0 | ||
532 | 51 | metric.maximum = 10.0 | ||
533 | 52 | info = dbusQuery.queryMetricInfo(1); | ||
534 | 53 | compare(info.minimum, 0.0, "Metric minimum was not set properly"); | ||
535 | 54 | compare(info.maximum, 10.0, "Metric maximum was not set properly"); | ||
536 | 45 | 55 | ||
537 | 46 | // Test update and increment with integers and floating point data | 56 | // Test update and increment with integers and floating point data |
538 | 47 | metric.update(0); | 57 | metric.update(0); |