Merge lp:~zsombi/ubuntu-ui-toolkit/serviceproperties-warnings into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1413
Merged at revision: 1411
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/serviceproperties-warnings
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 189 lines (+94/-20)
3 files modified
modules/Ubuntu/Components/plugin/ucserviceproperties.cpp (+10/-5)
tests/unit/runtest.sh (+0/-1)
tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp (+84/-14)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/serviceproperties-warnings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Cris Dywan Pending
Review via email: mp+250273@code.launchpad.net

Commit message

Turning warnings to be reported in the error property. SHOW_SERVICEPROPERTIES_WARNINGS environment variable set will display them in the console.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote :

Very nice! Thanks a lot!

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 'modules/Ubuntu/Components/plugin/ucserviceproperties.cpp'
2--- modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 2015-02-04 07:14:04 +0000
3+++ modules/Ubuntu/Components/plugin/ucserviceproperties.cpp 2015-02-19 10:00:30 +0000
4@@ -41,11 +41,16 @@
5
6 void UCServicePropertiesPrivate::warning(const QString &message)
7 {
8- QByteArray suppressWarnings = qgetenv("SUPPRESS_SERVICEPROPERTIES_WARNINGS");
9- if ((suppressWarnings == "yes") || (suppressWarnings == "1")) {
10- return;
11- }
12- qmlInfo(q_ptr) << message;
13+ // append warning messages to the error string
14+ if (error.isEmpty()) {
15+ setError(message);
16+ } else {
17+ setError(QString("%1\n%2").arg(error).arg(message));
18+ }
19+ QString env = qgetenv("SHOW_SERVICEPROPERTIES_WARNINGS");
20+ if (!env.isEmpty() && (env == "1" || env.toLower() == "true")) {
21+ qmlInfo(q_ptr) << message;
22+ }
23 }
24
25 void UCServicePropertiesPrivate::setError(const QString &msg)
26
27=== modified file 'tests/unit/runtest.sh'
28--- tests/unit/runtest.sh 2015-02-18 15:39:38 +0000
29+++ tests/unit/runtest.sh 2015-02-19 10:00:30 +0000
30@@ -63,7 +63,6 @@
31
32 QML2_IMPORT_PATH=${_IMPORT_PATH} UBUNTU_UI_TOOLKIT_THEMES_PATH=${_THEMES_PATH} \
33 ALARM_BACKEND=memory \
34- SUPPRESS_SERVICEPROPERTIES_WARNINGS=yes \
35 $_CMD $_ARGS 2>&1 | grep -v 'QFontDatabase: Cannot find font directory'
36 # Note: Get first command before the pipe, $? would be ambiguous
37 RESULT=${PIPESTATUS[0]}
38
39=== modified file 'tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp'
40--- tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 2014-12-03 12:55:58 +0000
41+++ tests/unit_x11/tst_serviceproperties/tst_serviceproperties.cpp 2015-02-19 10:00:30 +0000
42@@ -62,6 +62,12 @@
43 }
44 }
45
46+ void cleanup()
47+ {
48+ // restore env var setting
49+ qputenv("SHOW_SERVICEPROPERTIES_WARNINGS", QByteArray());
50+ }
51+
52 void test_change_property()
53 {
54 if (!error.isEmpty()) {
55@@ -85,40 +91,100 @@
56 spy.wait(400);
57 }
58
59+ void test_environment_variable_data()
60+ {
61+ QTest::addColumn<QByteArray>("value");
62+ QTest::addColumn<bool>("warning");
63+
64+ QTest::newRow("empty string, no warning") << QByteArray() << false;
65+ QTest::newRow("0 integer, no warning") << QByteArray("0") << false;
66+ QTest::newRow("boolean false, no warning") << QByteArray("false") << false;
67+ QTest::newRow("boolean FALSE, no warning") << QByteArray("false") << false;
68+ QTest::newRow("1 integer, warning") << QByteArray("1") << true;
69+ QTest::newRow("boolean true, warning") << QByteArray("true") << true;
70+ QTest::newRow("boolean TRUE, warning") << QByteArray("true") << true;
71+ QTest::newRow("positive integer, no warning") << QByteArray("5") << false;
72+ QTest::newRow("invalid integral value, no warning") << QByteArray("whatever") << false;
73+ }
74+
75+ void test_environment_variable()
76+ {
77+ if (!error.isEmpty()) {
78+ QSKIP(qPrintable(error));
79+ }
80+ QFETCH(QByteArray, value);
81+ QFETCH(bool, warning);
82+ qputenv("SHOW_SERVICEPROPERTIES_WARNINGS", value);
83+ if (warning) {
84+ ignoreWarning("InvalidPropertyWatcher.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'");
85+ }
86+ QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher.qml"));
87+ UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>());
88+ QVERIFY(watcher);
89+ // error should contain the warning
90+ QCOMPARE(watcher->property("error").toString(), QString("No such property 'ThisIsAnInvalidPropertyToWatch'"));
91+ }
92+
93+ void test_invalid_property_data()
94+ {
95+ QTest::addColumn<bool>("warning");
96+
97+ QTest::newRow("Without warning") << false;
98+ QTest::newRow("With warning") << true;
99+ }
100 void test_invalid_property()
101 {
102 if (!error.isEmpty()) {
103 QSKIP(qPrintable(error));
104 }
105- ignoreWarning("InvalidPropertyWatcher.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'");
106+ QFETCH(bool, warning);
107+ qputenv("SHOW_SERVICEPROPERTIES_WARNINGS", warning ? "1" : "0");
108+ if (warning) {
109+ ignoreWarning("InvalidPropertyWatcher.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'");
110+ }
111 QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher.qml"));
112 UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>());
113 QVERIFY(watcher);
114- // error should not be set
115- QCOMPARE(watcher->property("error").toString(), QString());
116- }
117-
118+ // error should contain the warning
119+ QCOMPARE(watcher->property("error").toString(), QString("No such property 'ThisIsAnInvalidPropertyToWatch'"));
120+ }
121+
122+ void test_one_valid_one_invalid_property_data()
123+ {
124+ QTest::addColumn<bool>("warning");
125+
126+ QTest::newRow("Without warning") << false;
127+ QTest::newRow("With warning") << true;
128+ }
129 void test_one_valid_one_invalid_property()
130 {
131 if (!error.isEmpty()) {
132 QSKIP(qPrintable(error));
133 }
134- ignoreWarning("InvalidPropertyWatcher2.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'");
135+ QFETCH(bool, warning);
136+ qputenv("SHOW_SERVICEPROPERTIES_WARNINGS", warning ? "1" : "0");
137+ if (warning) {
138+ ignoreWarning("InvalidPropertyWatcher2.qml", 22, 5, "QML ServiceProperties: No such property 'ThisIsAnInvalidPropertyToWatch'");
139+ }
140 QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("InvalidPropertyWatcher2.qml"));
141 UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>());
142 QVERIFY(watcher);
143- // error should not be set
144- QCOMPARE(watcher->property("error").toString(), QString());
145+ // error should contain the wearning
146+ QCOMPARE(watcher->property("error").toString(), QString("No such property 'ThisIsAnInvalidPropertyToWatch'"));
147 }
148
149 void test_change_connection_props_data()
150 {
151 QTest::addColumn<QString>("property");
152 QTest::addColumn<QString>("value");
153+ QTest::addColumn<bool>("warning");
154
155- QTest::newRow("Changing servcie") << "service" << "anything.else";
156- QTest::newRow("Changing interface") << "serviceInterface" << "anything.else";
157- QTest::newRow("Changing adaptor") << "adaptorInterface" << "anything.else";
158+ QTest::newRow("Changing servcie, no warning") << "service" << "anything.else" << false;
159+ QTest::newRow("Changing servcie, with warning") << "service" << "anything.else" << true;
160+ QTest::newRow("Changing interface, no warning") << "serviceInterface" << "anything.else" << false;
161+ QTest::newRow("Changing interface, with warning") << "serviceInterface" << "anything.else" << true;
162+ QTest::newRow("Changing adaptor, no warning") << "adaptorInterface" << "anything.else" << false;
163+ QTest::newRow("Changing adaptor, with warning") << "adaptorInterface" << "anything.else" << true;
164 }
165 void test_change_connection_props()
166 {
167@@ -128,15 +194,19 @@
168 if (!error.isEmpty()) {
169 QSKIP(qPrintable(error));
170 }
171- ignoreWarning("IncomingCallVibrateWatcher.qml", 22, 5, "QML ServiceProperties: Changing connection parameters forbidden.");
172+ QFETCH(bool, warning);
173+ qputenv("SHOW_SERVICEPROPERTIES_WARNINGS", warning ? "1" : "0");
174+ if (warning) {
175+ ignoreWarning("IncomingCallVibrateWatcher.qml", 22, 5, "QML ServiceProperties: Changing connection parameters forbidden.");
176+ }
177 QScopedPointer<UbuntuTestCase> test(new UbuntuTestCase("IncomingCallVibrateWatcher.qml"));
178 UCServiceProperties *watcher = static_cast<UCServiceProperties*>(test->rootObject()->property("service").value<QObject*>());
179 QVERIFY(watcher);
180
181 // try to change the property
182 watcher->setProperty(property.toLocal8Bit().constData(), value);
183- // no error should be reported
184- QCOMPARE(watcher->property("error").toString(), QString());
185+ // error shoudl also have the warning
186+ QCOMPARE(watcher->property("error").toString(), QString("Changing connection parameters forbidden."));
187 }
188
189 };

Subscribers

People subscribed via source and target branches