Merge lp:~unity-team/libusermetrics/minimum-maximum-qml into lp:libusermetrics

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
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
=== modified file 'po/en_GB.po'
--- po/en_GB.po 2013-10-01 10:22:38 +0000
+++ po/en_GB.po 2013-10-02 09:46:27 +0000
@@ -7,7 +7,7 @@
7msgstr ""7msgstr ""
8"Project-Id-Version: libusermetrics\n"8"Project-Id-Version: libusermetrics\n"
9"Report-Msgid-Bugs-To: \n"9"Report-Msgid-Bugs-To: \n"
10"POT-Creation-Date: 2013-10-01 11:14+0100\n"10"POT-Creation-Date: 2013-10-02 10:29+0100\n"
11"PO-Revision-Date: 2013-07-05 15:09+0100\n"11"PO-Revision-Date: 2013-07-05 15:09+0100\n"
12"Last-Translator: Pete Woods <pete.woods@canonical.com>\n"12"Last-Translator: Pete Woods <pete.woods@canonical.com>\n"
13"Language-Team: British English <en@li.org>\n"13"Language-Team: British English <en@li.org>\n"
@@ -25,7 +25,7 @@
25msgid "Attempt to create data set owned by another user"25msgid "Attempt to create data set owned by another user"
26msgstr "Attempt to create data set owned by another user"26msgstr "Attempt to create data set owned by another user"
2727
28#: src/usermetricsservice/DBusUserMetrics.cpp:23928#: src/usermetricsservice/DBusUserMetrics.cpp:250
29#, fuzzy29#, fuzzy
30msgid "Attempt to create user data owned by another user"30msgid "Attempt to create user data owned by another user"
31msgstr "Attempt to create user data owned by another user"31msgstr "Attempt to create user data owned by another user"
@@ -73,11 +73,11 @@
73#: src/usermetricsservice/DBusDataSource.cpp:19073#: src/usermetricsservice/DBusDataSource.cpp:190
74#: src/usermetricsservice/DBusDataSource.cpp:21674#: src/usermetricsservice/DBusDataSource.cpp:216
75#: src/usermetricsservice/DBusDataSource.cpp:23475#: src/usermetricsservice/DBusDataSource.cpp:234
76#: src/usermetricsservice/DBusUserMetrics.cpp:17776#: src/usermetricsservice/DBusUserMetrics.cpp:188
77msgid "Could not save data source"77msgid "Could not save data source"
78msgstr "Couldn't save data source"78msgstr "Couldn't save data source"
7979
80#: src/usermetricsservice/DBusUserMetrics.cpp:25780#: src/usermetricsservice/DBusUserMetrics.cpp:268
81msgid "Could not save user data"81msgid "Could not save user data"
82msgstr "Couldn't save user data"82msgstr "Couldn't save user data"
8383
@@ -98,23 +98,24 @@
98msgid "Data source not found"98msgid "Data source not found"
99msgstr "Data source not found"99msgstr "Data source not found"
100100
101#: src/usermetricsservice/DBusUserMetrics.cpp:143101#: src/usermetricsservice/DBusUserMetrics.cpp:142
102#: src/usermetricsservice/DBusUserMetrics.cpp:154
102msgid "Data source query failed"103msgid "Data source query failed"
103msgstr "Data source query failed"104msgstr "Data source query failed"
104105
105#: src/modules/UserMetrics/Metric.cpp:28106#: src/modules/UserMetrics/Metric.cpp:30
106msgid "Failed to connect to metrics service:"107msgid "Failed to connect to metrics service:"
107msgstr "Failed to connect to metrics service:"108msgstr "Failed to connect to metrics service:"
108109
109#: src/modules/UserMetrics/Metric.cpp:115110#: src/modules/UserMetrics/Metric.cpp:154
110msgid "Failed to increment metric:"111msgid "Failed to increment metric:"
111msgstr ""112msgstr ""
112113
113#: src/modules/UserMetrics/Metric.cpp:102114#: src/modules/UserMetrics/Metric.cpp:141
114msgid "Failed to register user metric:"115msgid "Failed to register user metric:"
115msgstr "Failed to register user metric:"116msgstr "Failed to register user metric:"
116117
117#: src/modules/UserMetrics/Metric.cpp:127118#: src/modules/UserMetrics/Metric.cpp:166
118msgid "Failed to update metric:"119msgid "Failed to update metric:"
119msgstr "Failed to update metric:"120msgstr "Failed to update metric:"
120121
@@ -151,7 +152,7 @@
151msgid "Usage: "152msgid "Usage: "
152msgstr "Usage: "153msgstr "Usage: "
153154
154#: src/usermetricsservice/DBusUserMetrics.cpp:248155#: src/usermetricsservice/DBusUserMetrics.cpp:259
155msgid "User data query failed"156msgid "User data query failed"
156msgstr "User data query failed"157msgstr "User data query failed"
157158
158159
=== modified file 'po/libusermetrics.pot'
--- po/libusermetrics.pot 2013-10-01 10:22:38 +0000
+++ po/libusermetrics.pot 2013-10-02 09:46:27 +0000
@@ -8,7 +8,7 @@
8msgstr ""8msgstr ""
9"Project-Id-Version: libusermetrics\n"9"Project-Id-Version: libusermetrics\n"
10"Report-Msgid-Bugs-To: \n"10"Report-Msgid-Bugs-To: \n"
11"POT-Creation-Date: 2013-10-01 11:16+0100\n"11"POT-Creation-Date: 2013-10-02 10:29+0100\n"
12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -38,7 +38,7 @@
38#: src/usermetricsservice/DBusDataSource.cpp:19038#: src/usermetricsservice/DBusDataSource.cpp:190
39#: src/usermetricsservice/DBusDataSource.cpp:21639#: src/usermetricsservice/DBusDataSource.cpp:216
40#: src/usermetricsservice/DBusDataSource.cpp:23440#: src/usermetricsservice/DBusDataSource.cpp:234
41#: src/usermetricsservice/DBusUserMetrics.cpp:17741#: src/usermetricsservice/DBusUserMetrics.cpp:188
42msgid "Could not save data source"42msgid "Could not save data source"
43msgstr ""43msgstr ""
4444
@@ -46,19 +46,20 @@
46msgid "Unable to register user metrics object on DBus"46msgid "Unable to register user metrics object on DBus"
47msgstr ""47msgstr ""
4848
49#: src/usermetricsservice/DBusUserMetrics.cpp:14349#: src/usermetricsservice/DBusUserMetrics.cpp:142
50#: src/usermetricsservice/DBusUserMetrics.cpp:154
50msgid "Data source query failed"51msgid "Data source query failed"
51msgstr ""52msgstr ""
5253
53#: src/usermetricsservice/DBusUserMetrics.cpp:23954#: src/usermetricsservice/DBusUserMetrics.cpp:250
54msgid "Attempt to create user data owned by another user"55msgid "Attempt to create user data owned by another user"
55msgstr ""56msgstr ""
5657
57#: src/usermetricsservice/DBusUserMetrics.cpp:24858#: src/usermetricsservice/DBusUserMetrics.cpp:259
58msgid "User data query failed"59msgid "User data query failed"
59msgstr ""60msgstr ""
6061
61#: src/usermetricsservice/DBusUserMetrics.cpp:25762#: src/usermetricsservice/DBusUserMetrics.cpp:268
62msgid "Could not save user data"63msgid "Could not save user data"
63msgstr ""64msgstr ""
6465
@@ -107,19 +108,19 @@
107msgid "New data set could not be found"108msgid "New data set could not be found"
108msgstr ""109msgstr ""
109110
110#: src/modules/UserMetrics/Metric.cpp:28111#: src/modules/UserMetrics/Metric.cpp:30
111msgid "Failed to connect to metrics service:"112msgid "Failed to connect to metrics service:"
112msgstr ""113msgstr ""
113114
114#: src/modules/UserMetrics/Metric.cpp:102115#: src/modules/UserMetrics/Metric.cpp:141
115msgid "Failed to register user metric:"116msgid "Failed to register user metric:"
116msgstr ""117msgstr ""
117118
118#: src/modules/UserMetrics/Metric.cpp:115119#: src/modules/UserMetrics/Metric.cpp:154
119msgid "Failed to increment metric:"120msgid "Failed to increment metric:"
120msgstr ""121msgstr ""
121122
122#: src/modules/UserMetrics/Metric.cpp:127123#: src/modules/UserMetrics/Metric.cpp:166
123msgid "Failed to update metric:"124msgid "Failed to update metric:"
124msgstr ""125msgstr ""
125126
126127
=== modified file 'src/modules/UserMetrics/CMakeLists.txt'
--- src/modules/UserMetrics/CMakeLists.txt 2013-09-24 08:13:01 +0000
+++ src/modules/UserMetrics/CMakeLists.txt 2013-10-02 09:46:27 +0000
@@ -38,4 +38,7 @@
38install(FILES qmldir DESTINATION ${PLUGIN_DIR})38install(FILES qmldir DESTINATION ${PLUGIN_DIR})
3939
40# copy qmldir file to build dir so QML unit tests can use it to import the plugin40# copy qmldir file to build dir so QML unit tests can use it to import the plugin
41file(COPY qmldir DESTINATION ${CMAKE_BINARY_DIR}/src/modules/UserMetrics)41configure_file(
42 qmldir
43 qmldir
44)
4245
=== modified file 'src/modules/UserMetrics/Metric.cpp'
--- src/modules/UserMetrics/Metric.cpp 2013-09-26 15:24:43 +0000
+++ src/modules/UserMetrics/Metric.cpp 2013-10-02 09:46:27 +0000
@@ -18,10 +18,12 @@
18#include <libusermetricscommon/Localisation.h>18#include <libusermetricscommon/Localisation.h>
1919
20#include <stdexcept>20#include <stdexcept>
21#include <cmath>
21#include <QDebug>22#include <QDebug>
2223
23Metric::Metric(QObject *parent) :24Metric::Metric(QObject *parent) :
24 QObject(parent), m_componentComplete(false) {25 QObject(parent), m_componentComplete(false), m_minimum(NAN), m_maximum(
26 NAN) {
25 try {27 try {
26 m_metricManager.reset(UserMetricsInput::MetricManager::getInstance());28 m_metricManager.reset(UserMetricsInput::MetricManager::getInstance());
27 } catch (std::exception &e) {29 } catch (std::exception &e) {
@@ -80,6 +82,30 @@
80 }82 }
81}83}
8284
85double Metric::minimum() const {
86 return m_minimum;
87}
88
89void Metric::setMinimum(double minimum) {
90 if (m_minimum != minimum) {
91 m_minimum = minimum;
92 Q_EMIT minimumChanged();
93 registerMetric();
94 }
95}
96
97double Metric::maximum() const {
98 return m_maximum;
99}
100
101void Metric::setMaximum(double maximum) {
102 if (m_maximum != maximum) {
103 m_maximum = maximum;
104 Q_EMIT maximumChanged();
105 registerMetric();
106 }
107}
108
83void Metric::registerMetric() {109void Metric::registerMetric() {
84 if (!m_componentComplete) {110 if (!m_componentComplete) {
85 return;111 return;
@@ -94,10 +120,23 @@
94 }120 }
95121
96 try {122 try {
97 m_metric = m_metricManager->add(123 UserMetricsInput::MetricParameters parameters(m_name);
98 UserMetricsInput::MetricParameters(m_name).formatString(124 parameters.formatString(m_format);
99 m_format).emptyDataString(m_emptyFormat).textDomain(125
100 m_domain));126 if (!m_emptyFormat.isEmpty()) {
127 parameters.emptyDataString(m_emptyFormat);
128 }
129 if (!m_domain.isEmpty()) {
130 parameters.textDomain(m_domain);
131 }
132 if (!isnan(m_minimum)) {
133 parameters.minimum(m_minimum);
134 }
135 if (!isnan(m_maximum)) {
136 parameters.maximum(m_maximum);
137 }
138
139 m_metric = m_metricManager->add(parameters);
101 } catch (std::exception &e) {140 } catch (std::exception &e) {
102 qWarning() << _("Failed to register user metric:") << m_name << "\""141 qWarning() << _("Failed to register user metric:") << m_name << "\""
103 << m_format << "\": " << e.what();142 << m_format << "\": " << e.what();
104143
=== modified file 'src/modules/UserMetrics/Metric.h'
--- src/modules/UserMetrics/Metric.h 2013-09-24 08:13:01 +0000
+++ src/modules/UserMetrics/Metric.h 2013-10-02 09:46:27 +0000
@@ -24,10 +24,14 @@
24class Metric: public QObject, public QQmlParserStatus {24class Metric: public QObject, public QQmlParserStatus {
25Q_OBJECT25Q_OBJECT
2626
27Q_INTERFACES (QQmlParserStatus)Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)27Q_INTERFACES (QQmlParserStatus)
28
29Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
28Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)30Q_PROPERTY(QString format READ format WRITE setFormat NOTIFY formatChanged)
29Q_PROPERTY(QString emptyFormat READ emptyFormat WRITE setEmptyFormat NOTIFY emptyFormatChanged)31Q_PROPERTY(QString emptyFormat READ emptyFormat WRITE setEmptyFormat NOTIFY emptyFormatChanged)
30Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged)32Q_PROPERTY(QString domain READ domain WRITE setDomain NOTIFY domainChanged)
33Q_PROPERTY(double minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
34Q_PROPERTY(double maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
3135
32public:36public:
33 explicit Metric(QObject *parent = 0);37 explicit Metric(QObject *parent = 0);
@@ -50,6 +54,14 @@
5054
51 void setDomain(const QString &domain);55 void setDomain(const QString &domain);
5256
57 double minimum() const;
58
59 void setMinimum(double minimum);
60
61 double maximum() const;
62
63 void setMaximum(double maximum);
64
53 void classBegin();65 void classBegin();
5466
55 void componentComplete();67 void componentComplete();
@@ -68,6 +80,10 @@
6880
69 void domainChanged();81 void domainChanged();
7082
83 void minimumChanged();
84
85 void maximumChanged();
86
71protected:87protected:
72 void registerMetric();88 void registerMetric();
7389
@@ -84,6 +100,10 @@
84 QString m_emptyFormat;100 QString m_emptyFormat;
85101
86 QString m_domain;102 QString m_domain;
103
104 double m_minimum;
105
106 double m_maximum;
87};107};
88108
89#endif // MODULES_USERMETRICS_METRICSMANAGER_H109#endif // MODULES_USERMETRICS_METRICSMANAGER_H
90110
=== modified file 'src/modules/UserMetrics/qmldir'
--- src/modules/UserMetrics/qmldir 2013-09-17 11:03:34 +0000
+++ src/modules/UserMetrics/qmldir 2013-10-02 09:46:27 +0000
@@ -1,1 +1,2 @@
1module UserMetrics
1plugin usermetrics-qml2plugin usermetrics-qml
23
=== modified file 'tests/unit/qml/CMakeLists.txt'
--- tests/unit/qml/CMakeLists.txt 2013-09-18 15:13:02 +0000
+++ tests/unit/qml/CMakeLists.txt 2013-10-02 09:46:27 +0000
@@ -1,13 +1,13 @@
1
1add_executable(tst_QmlTests tst_QmlTests.cpp)2add_executable(tst_QmlTests tst_QmlTests.cpp)
2qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest)3qt5_use_modules(tst_QmlTests Core Qml Quick Test QuickTest)
3target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES})4target_link_libraries(tst_QmlTests ${TPL_QT5_LIBRARIES})
4add_test(tst_QmlTests ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests -import ${SOURCE_BINARY_DIR}/modules)5
6add_test(tst_QmlTests
7 ${CMAKE_CURRENT_BINARY_DIR}/tst_QmlTests
8 -input ${CMAKE_CURRENT_SOURCE_DIR}
9 -import ${SOURCE_BINARY_DIR}/modules
10)
5set_tests_properties(tst_QmlTests PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")11set_tests_properties(tst_QmlTests PROPERTIES ENVIRONMENT "QT_QPA_PLATFORM=minimal")
612
7# copy qml test files to build dir
8file(GLOB qmlTestFiles RELATIVE ${CMAKE_SOURCE_DIR}/tests/unit/qml/ *qml)
9foreach(qmlTestFile ${qmlTestFiles})
10 file(COPY ${qmlTestFile} DESTINATION ${CMAKE_BINARY_DIR}/tests/unit/qml/)
11endforeach(qmlTestFile)
12
13add_subdirectory(UserMetricsTest)13add_subdirectory(UserMetricsTest)
1414
=== modified file 'tests/unit/qml/UserMetricsTest/CMakeLists.txt'
--- tests/unit/qml/UserMetricsTest/CMakeLists.txt 2013-09-23 14:12:23 +0000
+++ tests/unit/qml/UserMetricsTest/CMakeLists.txt 2013-10-02 09:46:27 +0000
@@ -22,4 +22,7 @@
22 )22 )
2323
24# copy qmldir file to build dir24# copy qmldir file to build dir
25file(COPY qmldir DESTINATION ${CMAKE_BINARY_DIR}/tests/unit/qml/UserMetricsTest)25configure_file(
26 qmldir
27 qmldir
28)
2629
=== modified file 'tests/unit/qml/UserMetricsTest/DBusQuery.cpp'
--- tests/unit/qml/UserMetricsTest/DBusQuery.cpp 2013-09-26 11:35:49 +0000
+++ tests/unit/qml/UserMetricsTest/DBusQuery.cpp 2013-10-02 09:46:27 +0000
@@ -17,7 +17,7 @@
17#include <DBusQuery.h>17#include <DBusQuery.h>
18#include <MetricInfo.h>18#include <MetricInfo.h>
1919
20#include <QDebug>20#include <cmath>
21#include <QtDBus/QtDBus>21#include <QtDBus/QtDBus>
22#include <libqtdbustest/QProcessDBusService.h>22#include <libqtdbustest/QProcessDBusService.h>
23#include <libqtdbustest/DBusService.h>23#include <libqtdbustest/DBusService.h>
@@ -59,10 +59,20 @@
59 if (dataSourceInterface.name().isEmpty()) {59 if (dataSourceInterface.name().isEmpty()) {
60 return 0;60 return 0;
61 } else {61 } else {
62 double minimum(NAN);
63 double maximum(NAN);
64 QVariantMap options(dataSourceInterface.options());
65 if (options.contains("minimum")) {
66 minimum = options["minimum"].toDouble();
67 }
68 if (options.contains("maximum")) {
69 maximum = options["maximum"].toDouble();
70 }
71
62 return new MetricInfo(dataSourceInterface.name(),72 return new MetricInfo(dataSourceInterface.name(),
63 dataSourceInterface.formatString(),73 dataSourceInterface.formatString(),
64 dataSourceInterface.emptyDataString(),74 dataSourceInterface.emptyDataString(),
65 dataSourceInterface.textDomain(), this);75 dataSourceInterface.textDomain(), minimum, maximum, this);
66 }76 }
67}77}
6878
6979
=== modified file 'tests/unit/qml/UserMetricsTest/MetricInfo.cpp'
--- tests/unit/qml/UserMetricsTest/MetricInfo.cpp 2013-09-24 08:13:01 +0000
+++ tests/unit/qml/UserMetricsTest/MetricInfo.cpp 2013-10-02 09:46:27 +0000
@@ -17,9 +17,10 @@
17#include <MetricInfo.h>17#include <MetricInfo.h>
1818
19MetricInfo::MetricInfo(QString name, QString format, QString emptyFormat,19MetricInfo::MetricInfo(QString name, QString format, QString emptyFormat,
20 QString domain, QObject *parent) :20 QString domain, double minimum, double maximum, QObject *parent) :
21 QObject(parent), m_name(name), m_format(format), m_emptyFormat(21 QObject(parent), m_name(name), m_format(format), m_emptyFormat(
22 emptyFormat), m_domain(domain) {22 emptyFormat), m_domain(domain), m_minimum(minimum), m_maximum(
23 maximum) {
23}24}
2425
25MetricInfo::~MetricInfo() {26MetricInfo::~MetricInfo() {
@@ -40,3 +41,11 @@
40QString MetricInfo::domain() const {41QString MetricInfo::domain() const {
41 return m_domain;42 return m_domain;
42}43}
44
45double MetricInfo::minimum() const {
46 return m_minimum;
47}
48
49double MetricInfo::maximum() const {
50 return m_maximum;
51}
4352
=== modified file 'tests/unit/qml/UserMetricsTest/MetricInfo.h'
--- tests/unit/qml/UserMetricsTest/MetricInfo.h 2013-09-24 08:13:01 +0000
+++ tests/unit/qml/UserMetricsTest/MetricInfo.h 2013-10-02 09:46:27 +0000
@@ -26,10 +26,13 @@
26Q_PROPERTY(QString format READ format NOTIFY formatChanged)26Q_PROPERTY(QString format READ format NOTIFY formatChanged)
27Q_PROPERTY(QString emptyFormat READ emptyFormat NOTIFY emptyFormatChanged)27Q_PROPERTY(QString emptyFormat READ emptyFormat NOTIFY emptyFormatChanged)
28Q_PROPERTY(QString domain READ domain NOTIFY domainChanged)28Q_PROPERTY(QString domain READ domain NOTIFY domainChanged)
29Q_PROPERTY(double minimum READ minimum NOTIFY minimumChanged)
30Q_PROPERTY(double maximum READ maximum NOTIFY maximumChanged)
2931
30public:32public:
31 explicit MetricInfo(QString name, QString format, QString emptyFormat,33 explicit MetricInfo(QString name, QString format, QString emptyFormat,
32 QString domain, QObject *parent = 0);34 QString domain, double minimum, double maximum,
35 QObject *parent = 0);
3336
34 virtual ~MetricInfo();37 virtual ~MetricInfo();
3538
@@ -42,6 +45,10 @@
4245
43 QString domain() const;46 QString domain() const;
4447
48 double minimum() const;
49
50 double maximum() const;
51
45Q_SIGNALS:52Q_SIGNALS:
46 void nameChanged();53 void nameChanged();
4754
@@ -51,6 +58,10 @@
5158
52 void domainChanged();59 void domainChanged();
5360
61 void minimumChanged();
62
63 void maximumChanged();
64
54private:65private:
55 QString m_name;66 QString m_name;
5667
@@ -60,6 +71,10 @@
6071
61 QString m_domain;72 QString m_domain;
6273
74 double m_minimum;
75
76 double m_maximum;
77
63};78};
6479
65#endif // MODULES_USERMETRICSTEST_METRICINFO_H80#endif // MODULES_USERMETRICSTEST_METRICINFO_H
6681
=== modified file 'tests/unit/qml/UserMetricsTest/TestPlugin.cpp'
--- tests/unit/qml/UserMetricsTest/TestPlugin.cpp 2013-09-24 08:13:01 +0000
+++ tests/unit/qml/UserMetricsTest/TestPlugin.cpp 2013-10-02 09:46:27 +0000
@@ -16,7 +16,6 @@
1616
17#include <QtQuick/QtQuick>17#include <QtQuick/QtQuick>
18#include <TestPlugin.h>18#include <TestPlugin.h>
19#include <DBusQuery.h>
20#include <MetricInfo.h>19#include <MetricInfo.h>
2120
22void Components::registerTypes(const char *uri) {21void Components::registerTypes(const char *uri) {
@@ -27,6 +26,7 @@
27}26}
2827
29void Components::initializeEngine(QQmlEngine *engine, const char *uri) {28void Components::initializeEngine(QQmlEngine *engine, const char *uri) {
29 m_dbusQuery.reset(new DBusQuery());
30 QQmlExtensionPlugin::initializeEngine(engine, uri);30 QQmlExtensionPlugin::initializeEngine(engine, uri);
31 engine->rootContext()->setContextProperty("dbusQuery", new DBusQuery(this));31 engine->rootContext()->setContextProperty("dbusQuery", m_dbusQuery.data());
32}32}
3333
=== modified file 'tests/unit/qml/UserMetricsTest/TestPlugin.h'
--- tests/unit/qml/UserMetricsTest/TestPlugin.h 2013-09-23 14:32:44 +0000
+++ tests/unit/qml/UserMetricsTest/TestPlugin.h 2013-10-02 09:46:27 +0000
@@ -19,6 +19,7 @@
1919
20#include <QtQml/QQmlExtensionPlugin>20#include <QtQml/QQmlExtensionPlugin>
21#include <QtQml/QQmlEngine>21#include <QtQml/QQmlEngine>
22#include <DBusQuery.h>
2223
23class Components : public QQmlExtensionPlugin24class Components : public QQmlExtensionPlugin
24{25{
@@ -28,6 +29,9 @@
28public:29public:
29 void registerTypes(const char *uri);30 void registerTypes(const char *uri);
30 void initializeEngine(QQmlEngine *engine, const char *uri);31 void initializeEngine(QQmlEngine *engine, const char *uri);
32
33protected:
34 QScopedPointer<DBusQuery> m_dbusQuery;
31};35};
3236
33#endif // MODULES_USERMETRICSTEST_TESTPLUGIN_H37#endif // MODULES_USERMETRICSTEST_TESTPLUGIN_H
3438
=== modified file 'tests/unit/qml/UserMetricsTest/qmldir'
--- tests/unit/qml/UserMetricsTest/qmldir 2013-09-18 15:13:02 +0000
+++ tests/unit/qml/UserMetricsTest/qmldir 2013-10-02 09:46:27 +0000
@@ -1,1 +1,2 @@
1module UserMetricsTest
1plugin usermetrics-qml-test2plugin usermetrics-qml-test
23
=== modified file 'tests/unit/qml/tst_Metrics.qml'
--- tests/unit/qml/tst_Metrics.qml 2013-09-23 14:44:47 +0000
+++ tests/unit/qml/tst_Metrics.qml 2013-10-02 09:46:27 +0000
@@ -26,6 +26,7 @@
26 property string originalFormat: "Test Metric"26 property string originalFormat: "Test Metric"
27 property string originalEmptyFormat: "Nope, no data"27 property string originalEmptyFormat: "Nope, no data"
28 property string originalDomain: "test-domain"28 property string originalDomain: "test-domain"
29 property double originalMinimum: 0.0
2930
30 Metric {31 Metric {
31 id: metric32 id: metric
@@ -33,6 +34,7 @@
33 format: originalFormat34 format: originalFormat
34 emptyFormat: originalEmptyFormat35 emptyFormat: originalEmptyFormat
35 domain: originalDomain36 domain: originalDomain
37 minimum: originalMinimum
36 }38 }
3739
38 function test_metric() {40 function test_metric() {
@@ -42,6 +44,14 @@
42 compare(info.format, originalFormat, "Metric format was not set properly");44 compare(info.format, originalFormat, "Metric format was not set properly");
43 compare(info.emptyFormat, originalEmptyFormat, "Metric emptyFormat was not set properly");45 compare(info.emptyFormat, originalEmptyFormat, "Metric emptyFormat was not set properly");
44 compare(info.domain, originalDomain, "Metric domain was not set properly");46 compare(info.domain, originalDomain, "Metric domain was not set properly");
47 compare(info.minimum, originalMinimum, "Metric minimum was not set properly");
48 compare(info.maximum, NaN, "Metric maximum was not set properly");
49
50 metric.minimum = 0.0
51 metric.maximum = 10.0
52 info = dbusQuery.queryMetricInfo(1);
53 compare(info.minimum, 0.0, "Metric minimum was not set properly");
54 compare(info.maximum, 10.0, "Metric maximum was not set properly");
4555
46 // Test update and increment with integers and floating point data56 // Test update and increment with integers and floating point data
47 metric.update(0);57 metric.update(0);

Subscribers

People subscribed via source and target branches

to all changes: