|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 test suite of the Qt Toolkit. |
|
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 #include <qcoreapplication.h> |
|
42 #include <qdebug.h> |
|
43 #include <qsharedpointer.h> |
|
44 |
|
45 #include <QtTest/QtTest> |
|
46 |
|
47 #include <QtDBus> |
|
48 |
|
49 #include "interface.h" |
|
50 #include "pinger.h" |
|
51 |
|
52 typedef QSharedPointer<com::trolltech::QtDBus::Pinger> Pinger; |
|
53 |
|
54 class tst_QDBusAbstractInterface: public QObject |
|
55 { |
|
56 Q_OBJECT |
|
57 Interface targetObj; |
|
58 |
|
59 Pinger getPinger(QString service = "", const QString &path = "/") |
|
60 { |
|
61 QDBusConnection con = QDBusConnection::sessionBus(); |
|
62 if (!con.isConnected()) |
|
63 return Pinger(); |
|
64 if (service.isEmpty() && !service.isNull()) |
|
65 service = con.baseService(); |
|
66 return Pinger(new com::trolltech::QtDBus::Pinger(service, path, con)); |
|
67 } |
|
68 |
|
69 public: |
|
70 tst_QDBusAbstractInterface(); |
|
71 |
|
72 private slots: |
|
73 void initTestCase(); |
|
74 |
|
75 void makeVoidCall(); |
|
76 void makeStringCall(); |
|
77 void makeComplexCall(); |
|
78 void makeMultiOutCall(); |
|
79 |
|
80 void makeAsyncVoidCall(); |
|
81 void makeAsyncStringCall(); |
|
82 void makeAsyncComplexCall(); |
|
83 void makeAsyncMultiOutCall(); |
|
84 |
|
85 void stringPropRead(); |
|
86 void stringPropWrite(); |
|
87 void variantPropRead(); |
|
88 void variantPropWrite(); |
|
89 void complexPropRead(); |
|
90 void complexPropWrite(); |
|
91 |
|
92 void stringPropDirectRead(); |
|
93 void stringPropDirectWrite(); |
|
94 void variantPropDirectRead(); |
|
95 void variantPropDirectWrite(); |
|
96 void complexPropDirectRead(); |
|
97 void complexPropDirectWrite(); |
|
98 |
|
99 void getVoidSignal_data(); |
|
100 void getVoidSignal(); |
|
101 void getStringSignal_data(); |
|
102 void getStringSignal(); |
|
103 void getComplexSignal_data(); |
|
104 void getComplexSignal(); |
|
105 |
|
106 void createErrors_data(); |
|
107 void createErrors(); |
|
108 |
|
109 void callErrors_data(); |
|
110 void callErrors(); |
|
111 void asyncCallErrors_data(); |
|
112 void asyncCallErrors(); |
|
113 |
|
114 void propertyReadErrors_data(); |
|
115 void propertyReadErrors(); |
|
116 void propertyWriteErrors_data(); |
|
117 void propertyWriteErrors(); |
|
118 void directPropertyReadErrors_data(); |
|
119 void directPropertyReadErrors(); |
|
120 void directPropertyWriteErrors_data(); |
|
121 void directPropertyWriteErrors(); |
|
122 }; |
|
123 |
|
124 tst_QDBusAbstractInterface::tst_QDBusAbstractInterface() |
|
125 { |
|
126 // register the meta types |
|
127 qDBusRegisterMetaType<RegisteredType>(); |
|
128 qRegisterMetaType<UnregisteredType>(); |
|
129 } |
|
130 |
|
131 void tst_QDBusAbstractInterface::initTestCase() |
|
132 { |
|
133 // register the object |
|
134 QDBusConnection con = QDBusConnection::sessionBus(); |
|
135 QVERIFY(con.isConnected()); |
|
136 con.registerObject("/", &targetObj, QDBusConnection::ExportScriptableContents); |
|
137 } |
|
138 |
|
139 void tst_QDBusAbstractInterface::makeVoidCall() |
|
140 { |
|
141 Pinger p = getPinger(); |
|
142 QVERIFY2(p, "Not connected to D-Bus"); |
|
143 |
|
144 QDBusReply<void> r = p->voidMethod(); |
|
145 QVERIFY(r.isValid()); |
|
146 } |
|
147 |
|
148 void tst_QDBusAbstractInterface::makeStringCall() |
|
149 { |
|
150 Pinger p = getPinger(); |
|
151 QVERIFY2(p, "Not connected to D-Bus"); |
|
152 |
|
153 QDBusReply<QString> r = p->stringMethod(); |
|
154 QVERIFY(r.isValid()); |
|
155 QCOMPARE(r.value(), targetObj.stringMethod()); |
|
156 } |
|
157 |
|
158 void tst_QDBusAbstractInterface::makeComplexCall() |
|
159 { |
|
160 Pinger p = getPinger(); |
|
161 QVERIFY2(p, "Not connected to D-Bus"); |
|
162 |
|
163 QDBusReply<RegisteredType> r = p->complexMethod(); |
|
164 QVERIFY(r.isValid()); |
|
165 QCOMPARE(r.value(), targetObj.complexMethod()); |
|
166 } |
|
167 |
|
168 void tst_QDBusAbstractInterface::makeMultiOutCall() |
|
169 { |
|
170 Pinger p = getPinger(); |
|
171 QVERIFY2(p, "Not connected to D-Bus"); |
|
172 |
|
173 int value; |
|
174 QDBusReply<QString> r = p->multiOutMethod(value); |
|
175 QVERIFY(r.isValid()); |
|
176 |
|
177 int expectedValue; |
|
178 QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue)); |
|
179 QCOMPARE(value, expectedValue); |
|
180 } |
|
181 |
|
182 void tst_QDBusAbstractInterface::makeAsyncVoidCall() |
|
183 { |
|
184 Pinger p = getPinger(); |
|
185 QVERIFY2(p, "Not connected to D-Bus"); |
|
186 |
|
187 QDBusPendingReply<void> r = p->voidMethod(); |
|
188 r.waitForFinished(); |
|
189 QVERIFY(r.isValid()); |
|
190 } |
|
191 |
|
192 void tst_QDBusAbstractInterface::makeAsyncStringCall() |
|
193 { |
|
194 Pinger p = getPinger(); |
|
195 QVERIFY2(p, "Not connected to D-Bus"); |
|
196 |
|
197 QDBusPendingReply<QString> r = p->stringMethod(); |
|
198 r.waitForFinished(); |
|
199 QVERIFY(r.isValid()); |
|
200 QCOMPARE(r.value(), targetObj.stringMethod()); |
|
201 } |
|
202 |
|
203 void tst_QDBusAbstractInterface::makeAsyncComplexCall() |
|
204 { |
|
205 Pinger p = getPinger(); |
|
206 QVERIFY2(p, "Not connected to D-Bus"); |
|
207 |
|
208 QDBusPendingReply<RegisteredType> r = p->complexMethod(); |
|
209 r.waitForFinished(); |
|
210 QVERIFY(r.isValid()); |
|
211 QCOMPARE(r.value(), targetObj.complexMethod()); |
|
212 } |
|
213 |
|
214 void tst_QDBusAbstractInterface::makeAsyncMultiOutCall() |
|
215 { |
|
216 Pinger p = getPinger(); |
|
217 QVERIFY2(p, "Not connected to D-Bus"); |
|
218 |
|
219 QDBusPendingReply<QString, int> r = p->multiOutMethod(); |
|
220 r.waitForFinished(); |
|
221 QVERIFY(r.isValid()); |
|
222 |
|
223 int expectedValue; |
|
224 QCOMPARE(r.value(), targetObj.multiOutMethod(expectedValue)); |
|
225 QCOMPARE(r.argumentAt<1>(), expectedValue); |
|
226 } |
|
227 |
|
228 void tst_QDBusAbstractInterface::stringPropRead() |
|
229 { |
|
230 Pinger p = getPinger(); |
|
231 QVERIFY2(p, "Not connected to D-Bus"); |
|
232 |
|
233 QString expectedValue = targetObj.m_stringProp = "This is a test"; |
|
234 QVariant v = p->property("stringProp"); |
|
235 QVERIFY(v.isValid()); |
|
236 QCOMPARE(v.toString(), expectedValue); |
|
237 } |
|
238 |
|
239 void tst_QDBusAbstractInterface::stringPropWrite() |
|
240 { |
|
241 Pinger p = getPinger(); |
|
242 QVERIFY2(p, "Not connected to D-Bus"); |
|
243 |
|
244 QString expectedValue = "This is a value"; |
|
245 QVERIFY(p->setProperty("stringProp", expectedValue)); |
|
246 QCOMPARE(targetObj.m_stringProp, expectedValue); |
|
247 } |
|
248 |
|
249 void tst_QDBusAbstractInterface::variantPropRead() |
|
250 { |
|
251 Pinger p = getPinger(); |
|
252 QVERIFY2(p, "Not connected to D-Bus"); |
|
253 |
|
254 QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(QVariant(42)); |
|
255 QVariant v = p->property("variantProp"); |
|
256 QVERIFY(v.isValid()); |
|
257 QDBusVariant value = v.value<QDBusVariant>(); |
|
258 QCOMPARE(value.variant().userType(), expectedValue.variant().userType()); |
|
259 QCOMPARE(value.variant(), expectedValue.variant()); |
|
260 } |
|
261 |
|
262 void tst_QDBusAbstractInterface::variantPropWrite() |
|
263 { |
|
264 Pinger p = getPinger(); |
|
265 QVERIFY2(p, "Not connected to D-Bus"); |
|
266 |
|
267 QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); |
|
268 QVERIFY(p->setProperty("variantProp", qVariantFromValue(expectedValue))); |
|
269 QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); |
|
270 } |
|
271 |
|
272 void tst_QDBusAbstractInterface::complexPropRead() |
|
273 { |
|
274 Pinger p = getPinger(); |
|
275 QVERIFY2(p, "Not connected to D-Bus"); |
|
276 |
|
277 RegisteredType expectedValue = targetObj.m_complexProp = RegisteredType("This is a test"); |
|
278 QVariant v = p->property("complexProp"); |
|
279 QVERIFY(v.userType() == qMetaTypeId<RegisteredType>()); |
|
280 QCOMPARE(v.value<RegisteredType>(), targetObj.m_complexProp); |
|
281 } |
|
282 |
|
283 void tst_QDBusAbstractInterface::complexPropWrite() |
|
284 { |
|
285 Pinger p = getPinger(); |
|
286 QVERIFY2(p, "Not connected to D-Bus"); |
|
287 |
|
288 RegisteredType expectedValue = RegisteredType("This is a value"); |
|
289 QVERIFY(p->setProperty("complexProp", qVariantFromValue(expectedValue))); |
|
290 QCOMPARE(targetObj.m_complexProp, expectedValue); |
|
291 } |
|
292 |
|
293 void tst_QDBusAbstractInterface::stringPropDirectRead() |
|
294 { |
|
295 Pinger p = getPinger(); |
|
296 QVERIFY2(p, "Not connected to D-Bus"); |
|
297 |
|
298 QString expectedValue = targetObj.m_stringProp = "This is a test"; |
|
299 QCOMPARE(p->stringProp(), expectedValue); |
|
300 } |
|
301 |
|
302 void tst_QDBusAbstractInterface::stringPropDirectWrite() |
|
303 { |
|
304 Pinger p = getPinger(); |
|
305 QVERIFY2(p, "Not connected to D-Bus"); |
|
306 |
|
307 QString expectedValue = "This is a value"; |
|
308 p->setStringProp(expectedValue); |
|
309 QCOMPARE(targetObj.m_stringProp, expectedValue); |
|
310 } |
|
311 |
|
312 void tst_QDBusAbstractInterface::variantPropDirectRead() |
|
313 { |
|
314 Pinger p = getPinger(); |
|
315 QVERIFY2(p, "Not connected to D-Bus"); |
|
316 |
|
317 QDBusVariant expectedValue = targetObj.m_variantProp = QDBusVariant(42); |
|
318 QCOMPARE(p->variantProp().variant(), expectedValue.variant()); |
|
319 } |
|
320 |
|
321 void tst_QDBusAbstractInterface::variantPropDirectWrite() |
|
322 { |
|
323 Pinger p = getPinger(); |
|
324 QVERIFY2(p, "Not connected to D-Bus"); |
|
325 |
|
326 QDBusVariant expectedValue = QDBusVariant(Q_INT64_C(-47)); |
|
327 p->setVariantProp(expectedValue); |
|
328 QCOMPARE(targetObj.m_variantProp.variant().userType(), expectedValue.variant().userType()); |
|
329 QCOMPARE(targetObj.m_variantProp.variant(), expectedValue.variant()); |
|
330 } |
|
331 |
|
332 void tst_QDBusAbstractInterface::complexPropDirectRead() |
|
333 { |
|
334 Pinger p = getPinger(); |
|
335 QVERIFY2(p, "Not connected to D-Bus"); |
|
336 |
|
337 RegisteredType expectedValue = targetObj.m_complexProp = RegisteredType("This is a test"); |
|
338 QCOMPARE(p->complexProp(), targetObj.m_complexProp); |
|
339 } |
|
340 |
|
341 void tst_QDBusAbstractInterface::complexPropDirectWrite() |
|
342 { |
|
343 Pinger p = getPinger(); |
|
344 QVERIFY2(p, "Not connected to D-Bus"); |
|
345 |
|
346 RegisteredType expectedValue = RegisteredType("This is a value"); |
|
347 p->setComplexProp(expectedValue); |
|
348 QCOMPARE(targetObj.m_complexProp, expectedValue); |
|
349 } |
|
350 |
|
351 void tst_QDBusAbstractInterface::getVoidSignal_data() |
|
352 { |
|
353 QTest::addColumn<QString>("service"); |
|
354 QTest::addColumn<QString>("path"); |
|
355 |
|
356 QTest::newRow("specific") << QDBusConnection::sessionBus().baseService() << "/"; |
|
357 QTest::newRow("service-wildcard") << QString() << "/"; |
|
358 QTest::newRow("path-wildcard") << QDBusConnection::sessionBus().baseService() << QString(); |
|
359 QTest::newRow("full-wildcard") << QString() << QString(); |
|
360 } |
|
361 |
|
362 void tst_QDBusAbstractInterface::getVoidSignal() |
|
363 { |
|
364 QFETCH(QString, service); |
|
365 QFETCH(QString, path); |
|
366 Pinger p = getPinger(service, path); |
|
367 QVERIFY2(p, "Not connected to D-Bus"); |
|
368 |
|
369 // we need to connect the signal somewhere in order for D-Bus to enable the rules |
|
370 QTestEventLoop::instance().connect(p.data(), SIGNAL(voidSignal()), SLOT(exitLoop())); |
|
371 QSignalSpy s(p.data(), SIGNAL(voidSignal())); |
|
372 |
|
373 emit targetObj.voidSignal(); |
|
374 QTestEventLoop::instance().enterLoop(2); |
|
375 QVERIFY(!QTestEventLoop::instance().timeout()); |
|
376 |
|
377 QVERIFY(s.size() == 1); |
|
378 QVERIFY(s.at(0).size() == 0); |
|
379 } |
|
380 |
|
381 void tst_QDBusAbstractInterface::getStringSignal_data() |
|
382 { |
|
383 getVoidSignal_data(); |
|
384 } |
|
385 |
|
386 void tst_QDBusAbstractInterface::getStringSignal() |
|
387 { |
|
388 QFETCH(QString, service); |
|
389 QFETCH(QString, path); |
|
390 Pinger p = getPinger(service, path); |
|
391 QVERIFY2(p, "Not connected to D-Bus"); |
|
392 |
|
393 // we need to connect the signal somewhere in order for D-Bus to enable the rules |
|
394 QTestEventLoop::instance().connect(p.data(), SIGNAL(stringSignal(QString)), SLOT(exitLoop())); |
|
395 QSignalSpy s(p.data(), SIGNAL(stringSignal(QString))); |
|
396 |
|
397 QString expectedValue = "Good morning"; |
|
398 emit targetObj.stringSignal(expectedValue); |
|
399 QTestEventLoop::instance().enterLoop(2); |
|
400 QVERIFY(!QTestEventLoop::instance().timeout()); |
|
401 |
|
402 QVERIFY(s.size() == 1); |
|
403 QVERIFY(s[0].size() == 1); |
|
404 QCOMPARE(s[0][0].userType(), int(QVariant::String)); |
|
405 QCOMPARE(s[0][0].toString(), expectedValue); |
|
406 } |
|
407 |
|
408 void tst_QDBusAbstractInterface::getComplexSignal_data() |
|
409 { |
|
410 getVoidSignal_data(); |
|
411 } |
|
412 |
|
413 void tst_QDBusAbstractInterface::getComplexSignal() |
|
414 { |
|
415 QFETCH(QString, service); |
|
416 QFETCH(QString, path); |
|
417 Pinger p = getPinger(service, path); |
|
418 QVERIFY2(p, "Not connected to D-Bus"); |
|
419 |
|
420 // we need to connect the signal somewhere in order for D-Bus to enable the rules |
|
421 QTestEventLoop::instance().connect(p.data(), SIGNAL(complexSignal(RegisteredType)), SLOT(exitLoop())); |
|
422 QSignalSpy s(p.data(), SIGNAL(complexSignal(RegisteredType))); |
|
423 |
|
424 RegisteredType expectedValue("Good evening"); |
|
425 emit targetObj.complexSignal(expectedValue); |
|
426 QTestEventLoop::instance().enterLoop(2); |
|
427 QVERIFY(!QTestEventLoop::instance().timeout()); |
|
428 |
|
429 QVERIFY(s.size() == 1); |
|
430 QVERIFY(s[0].size() == 1); |
|
431 QCOMPARE(s[0][0].userType(), qMetaTypeId<RegisteredType>()); |
|
432 QCOMPARE(s[0][0].value<RegisteredType>(), expectedValue); |
|
433 } |
|
434 |
|
435 void tst_QDBusAbstractInterface::createErrors_data() |
|
436 { |
|
437 QTest::addColumn<QString>("service"); |
|
438 QTest::addColumn<QString>("path"); |
|
439 QTest::addColumn<QString>("errorName"); |
|
440 |
|
441 QTest::newRow("invalid-service") << "this isn't valid" << "/" << "com.trolltech.QtDBus.Error.InvalidService"; |
|
442 QTest::newRow("invalid-path") << QDBusConnection::sessionBus().baseService() << "this isn't valid" |
|
443 << "com.trolltech.QtDBus.Error.InvalidObjectPath"; |
|
444 } |
|
445 |
|
446 void tst_QDBusAbstractInterface::createErrors() |
|
447 { |
|
448 QFETCH(QString, service); |
|
449 QFETCH(QString, path); |
|
450 Pinger p = getPinger(service, path); |
|
451 QVERIFY2(p, "Not connected to D-Bus"); |
|
452 |
|
453 QVERIFY(!p->isValid()); |
|
454 QTEST(p->lastError().name(), "errorName"); |
|
455 } |
|
456 |
|
457 void tst_QDBusAbstractInterface::callErrors_data() |
|
458 { |
|
459 createErrors_data(); |
|
460 QTest::newRow("service-wildcard") << QString() << "/" << "com.trolltech.QtDBus.Error.InvalidService"; |
|
461 QTest::newRow("path-wildcard") << QDBusConnection::sessionBus().baseService() << QString() |
|
462 << "com.trolltech.QtDBus.Error.InvalidObjectPath"; |
|
463 QTest::newRow("full-wildcard") << QString() << QString() << "com.trolltech.QtDBus.Error.InvalidService"; |
|
464 } |
|
465 |
|
466 void tst_QDBusAbstractInterface::callErrors() |
|
467 { |
|
468 QFETCH(QString, service); |
|
469 QFETCH(QString, path); |
|
470 Pinger p = getPinger(service, path); |
|
471 QVERIFY2(p, "Not connected to D-Bus"); |
|
472 |
|
473 // we shouldn't be able to make this call: |
|
474 QDBusReply<QString> r = p->stringMethod(); |
|
475 QVERIFY(!r.isValid()); |
|
476 QTEST(r.error().name(), "errorName"); |
|
477 QCOMPARE(p->lastError().name(), r.error().name()); |
|
478 } |
|
479 |
|
480 void tst_QDBusAbstractInterface::asyncCallErrors_data() |
|
481 { |
|
482 callErrors_data(); |
|
483 } |
|
484 |
|
485 void tst_QDBusAbstractInterface::asyncCallErrors() |
|
486 { |
|
487 QFETCH(QString, service); |
|
488 QFETCH(QString, path); |
|
489 Pinger p = getPinger(service, path); |
|
490 QVERIFY2(p, "Not connected to D-Bus"); |
|
491 |
|
492 // we shouldn't be able to make this call: |
|
493 QDBusPendingReply<QString> r = p->stringMethod(); |
|
494 QVERIFY(r.isError()); |
|
495 QTEST(r.error().name(), "errorName"); |
|
496 QCOMPARE(p->lastError().name(), r.error().name()); |
|
497 } |
|
498 |
|
499 void tst_QDBusAbstractInterface::propertyReadErrors_data() |
|
500 { |
|
501 callErrors_data(); |
|
502 } |
|
503 |
|
504 void tst_QDBusAbstractInterface::propertyReadErrors() |
|
505 { |
|
506 QFETCH(QString, service); |
|
507 QFETCH(QString, path); |
|
508 Pinger p = getPinger(service, path); |
|
509 QVERIFY2(p, "Not connected to D-Bus"); |
|
510 |
|
511 // we shouldn't be able to get this value: |
|
512 QVariant v = p->property("stringProp"); |
|
513 QVERIFY(v.isNull()); |
|
514 QVERIFY(!v.isValid()); |
|
515 QTEST(p->lastError().name(), "errorName"); |
|
516 } |
|
517 |
|
518 void tst_QDBusAbstractInterface::propertyWriteErrors_data() |
|
519 { |
|
520 callErrors_data(); |
|
521 } |
|
522 |
|
523 void tst_QDBusAbstractInterface::propertyWriteErrors() |
|
524 { |
|
525 QFETCH(QString, service); |
|
526 QFETCH(QString, path); |
|
527 Pinger p = getPinger(service, path); |
|
528 QVERIFY2(p, "Not connected to D-Bus"); |
|
529 |
|
530 // we shouldn't be able to get this value: |
|
531 if (p->isValid()) |
|
532 QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError)); |
|
533 QVERIFY(!p->setProperty("stringProp", "")); |
|
534 QTEST(p->lastError().name(), "errorName"); |
|
535 } |
|
536 |
|
537 void tst_QDBusAbstractInterface::directPropertyReadErrors_data() |
|
538 { |
|
539 callErrors_data(); |
|
540 } |
|
541 |
|
542 void tst_QDBusAbstractInterface::directPropertyReadErrors() |
|
543 { |
|
544 QFETCH(QString, service); |
|
545 QFETCH(QString, path); |
|
546 Pinger p = getPinger(service, path); |
|
547 QVERIFY2(p, "Not connected to D-Bus"); |
|
548 |
|
549 // we shouldn't be able to get this value: |
|
550 QString v = p->stringProp(); |
|
551 QVERIFY(v.isNull()); |
|
552 QTEST(p->lastError().name(), "errorName"); |
|
553 } |
|
554 |
|
555 void tst_QDBusAbstractInterface::directPropertyWriteErrors_data() |
|
556 { |
|
557 callErrors_data(); |
|
558 } |
|
559 |
|
560 void tst_QDBusAbstractInterface::directPropertyWriteErrors() |
|
561 { |
|
562 QFETCH(QString, service); |
|
563 QFETCH(QString, path); |
|
564 Pinger p = getPinger(service, path); |
|
565 QVERIFY2(p, "Not connected to D-Bus"); |
|
566 |
|
567 // we shouldn't be able to get this value: |
|
568 // but there's no direct way of verifying that the setting failed |
|
569 if (p->isValid()) |
|
570 QCOMPARE(int(p->lastError().type()), int(QDBusError::NoError)); |
|
571 p->setStringProp(""); |
|
572 QTEST(p->lastError().name(), "errorName"); |
|
573 } |
|
574 |
|
575 QTEST_MAIN(tst_QDBusAbstractInterface) |
|
576 #include "tst_qdbusabstractinterface.moc" |