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#include <qcoreapplication.h>
29#include <qmetatype.h>
30#include <QtTest/QtTest>
31
32#include <QtDBus/QtDBus>
33#include <private/qdbusmetaobject_p.h>
34
35class tst_QDBusMetaObject: public QObject
36{
37 Q_OBJECT
38
39 QHash<QString, QDBusMetaObject *> map;
40public slots:
41 void init();
42
43private slots:
44 void initTestCase();
45 void types_data();
46 void types();
47 void methods_data();
48 void methods();
49 void _signals_data();
50 void _signals();
51 void properties_data();
52 void properties();
53};
54
55typedef QPair<QString,QString> StringPair;
56
57struct Struct1 { }; // (s)
58struct Struct4 // (ssa(ss)sayasx)
59{
60 QString m1;
61 QString m2;
62 QList<StringPair> m3;
63 QString m4;
64 QByteArray m5;
65 QStringList m6;
66 qlonglong m7;
67};
68
69Q_DECLARE_METATYPE(Struct1)
70Q_DECLARE_METATYPE(Struct4)
71Q_DECLARE_METATYPE(StringPair)
72
73Q_DECLARE_METATYPE(const QMetaObject*)
74
75QT_BEGIN_NAMESPACE
76QDBusArgument &operator<<(QDBusArgument &arg, const Struct1 &)
77{
78 arg.beginStructure();
79 arg << QString();
80 arg.endStructure();
81 return arg;
82}
83
84QDBusArgument &operator<<(QDBusArgument &arg, const StringPair &s)
85{
86 arg.beginStructure();
87 arg << s.first << s.second;
88 arg.endStructure();
89 return arg;
90}
91
92QDBusArgument &operator<<(QDBusArgument &arg, const Struct4 &s)
93{
94 arg.beginStructure();
95 arg << s.m1 << s.m2 << s.m3 << s.m4 << s.m5 << s.m6 << s.m7;
96 arg.endStructure();
97 return arg;
98}
99
100const QDBusArgument &operator>>(const QDBusArgument &arg, Struct1 &)
101{ return arg; }
102const QDBusArgument &operator>>(const QDBusArgument &arg, Struct4 &)
103{ return arg; }
104const QDBusArgument &operator>>(const QDBusArgument &arg, StringPair &)
105{ return arg; }
106QT_END_NAMESPACE
107
108void tst_QDBusMetaObject::initTestCase()
109{
110 qDBusRegisterMetaType<Struct1>();
111 qDBusRegisterMetaType<Struct4>();
112 qDBusRegisterMetaType<StringPair>();
113
114 qDBusRegisterMetaType<QList<Struct1> >();
115 qDBusRegisterMetaType<QList<Struct4> >();
116}
117
118void tst_QDBusMetaObject::init()
119{
120 qDeleteAll(c: map);
121 map.clear();
122}
123
124// test classes
125class TypesTest1: public QObject
126{
127 Q_OBJECT
128
129signals:
130 void signal(uchar);
131};
132const char TypesTest1_xml[] =
133 "<signal name=\"signal\"><arg type=\"y\"/></signal>";
134
135class TypesTest2: public QObject
136{
137 Q_OBJECT
138
139signals:
140 void signal(bool);
141};
142const char TypesTest2_xml[] =
143 "<signal name=\"signal\"><arg type=\"b\"/></signal>";
144
145class TypesTest3: public QObject
146{
147 Q_OBJECT
148
149signals:
150 void signal(short);
151};
152const char TypesTest3_xml[] =
153 "<signal name=\"signal\"><arg type=\"n\"/></signal>";
154
155class TypesTest4: public QObject
156{
157 Q_OBJECT
158
159signals:
160 void signal(ushort);
161};
162const char TypesTest4_xml[] =
163 "<signal name=\"signal\"><arg type=\"q\"/></signal>";
164
165class TypesTest5: public QObject
166{
167 Q_OBJECT
168
169signals:
170 void signal(int);
171};
172const char TypesTest5_xml[] =
173 "<signal name=\"signal\"><arg type=\"i\"/></signal>";
174
175class TypesTest6: public QObject
176{
177 Q_OBJECT
178
179signals:
180 void signal(uint);
181};
182const char TypesTest6_xml[] =
183 "<signal name=\"signal\"><arg type=\"u\"/></signal>";
184
185class TypesTest7: public QObject
186{
187 Q_OBJECT
188
189signals:
190 void signal(qlonglong);
191};
192const char TypesTest7_xml[] =
193 "<signal name=\"signal\"><arg type=\"x\"/></signal>";
194
195class TypesTest8: public QObject
196{
197 Q_OBJECT
198
199signals:
200 void signal(qulonglong);
201};
202const char TypesTest8_xml[] =
203 "<signal name=\"signal\"><arg type=\"t\"/></signal>";
204
205class TypesTest9: public QObject
206{
207 Q_OBJECT
208
209signals:
210 void signal(double);
211};
212const char TypesTest9_xml[] =
213 "<signal name=\"signal\"><arg type=\"d\"/></signal>";
214
215class TypesTest10: public QObject
216{
217 Q_OBJECT
218
219signals:
220 void signal(QString);
221};
222const char TypesTest10_xml[] =
223 "<signal name=\"signal\"><arg type=\"s\"/></signal>";
224
225class TypesTest11: public QObject
226{
227 Q_OBJECT
228
229signals:
230 void signal(QDBusObjectPath);
231};
232const char TypesTest11_xml[] =
233 "<signal name=\"signal\"><arg type=\"o\"/></signal>";
234
235class TypesTest12: public QObject
236{
237 Q_OBJECT
238
239signals:
240 void signal(QDBusSignature);
241};
242const char TypesTest12_xml[] =
243 "<signal name=\"signal\"><arg type=\"g\"/></signal>";
244
245class TypesTest13: public QObject
246{
247 Q_OBJECT
248
249signals:
250 void signal(QDBusVariant);
251};
252const char TypesTest13_xml[] =
253 "<signal name=\"signal\"><arg type=\"v\"/></signal>";
254
255class TypesTest14: public QObject
256{
257 Q_OBJECT
258
259signals:
260 void signal(QStringList);
261};
262const char TypesTest14_xml[] =
263 "<signal name=\"signal\"><arg type=\"as\"/></signal>";
264
265class TypesTest15: public QObject
266{
267 Q_OBJECT
268
269signals:
270 void signal(QByteArray);
271};
272const char TypesTest15_xml[] =
273 "<signal name=\"signal\"><arg type=\"ay\"/></signal>";
274
275class TypesTest16: public QObject
276{
277 Q_OBJECT
278
279signals:
280 void signal(StringPair);
281};
282const char TypesTest16_xml[] =
283 "<signal name=\"signal\"><arg type=\"(ss)\"/>"
284 "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"StringPair\"></signal>";
285
286class TypesTest17: public QObject
287{
288 Q_OBJECT
289
290signals:
291 void signal(Struct1);
292};
293const char TypesTest17_xml[] =
294 "<signal name=\"signal\"><arg type=\"(s)\"/>"
295 "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"Struct1\"></signal>";
296
297class TypesTest18: public QObject
298{
299 Q_OBJECT
300
301signals:
302 void signal(Struct4);
303};
304const char TypesTest18_xml[] =
305 "<signal name=\"signal\"><arg type=\"(ssa(ss)sayasx)\"/>"
306 "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"Struct4\"></signal>";
307
308class TypesTest19: public QObject
309{
310 Q_OBJECT
311
312signals:
313 void signal(QVariantList);
314};
315const char TypesTest19_xml[] =
316 "<signal name=\"signal\"><arg type=\"av\"/>"
317 "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QVariantList\"></signal>";
318
319class TypesTest20: public QObject
320{
321 Q_OBJECT
322
323signals:
324 void signal(QVariantMap);
325};
326const char TypesTest20_xml[] =
327 "<signal name=\"signal\"><arg type=\"a{sv}\"/>"
328 "<annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"QVariantMap\"></signal>";
329const char TypesTest20_oldxml[] =
330 "<signal name=\"signal\"><arg type=\"a{sv}\"/>"
331 "<annotation name=\"com.trolltech.QtDBus.QtTypeName.Out0\" value=\"QVariantMap\"></signal>";
332
333
334void tst_QDBusMetaObject::types_data()
335{
336 QTest::addColumn<const QMetaObject *>(name: "metaobject");
337 QTest::addColumn<QString>(name: "xml");
338
339 QTest::newRow(dataTag: "byte") << &TypesTest1::staticMetaObject << QString(TypesTest1_xml);
340 QTest::newRow(dataTag: "bool") << &TypesTest2::staticMetaObject << QString(TypesTest2_xml);
341 QTest::newRow(dataTag: "short") << &TypesTest3::staticMetaObject << QString(TypesTest3_xml);
342 QTest::newRow(dataTag: "ushort") << &TypesTest4::staticMetaObject << QString(TypesTest4_xml);
343 QTest::newRow(dataTag: "int") << &TypesTest5::staticMetaObject << QString(TypesTest5_xml);
344 QTest::newRow(dataTag: "uint") << &TypesTest6::staticMetaObject << QString(TypesTest6_xml);
345 QTest::newRow(dataTag: "qlonglong") << &TypesTest7::staticMetaObject << QString(TypesTest7_xml);
346 QTest::newRow(dataTag: "qulonglong") << &TypesTest8::staticMetaObject << QString(TypesTest8_xml);
347 QTest::newRow(dataTag: "double") << &TypesTest9::staticMetaObject << QString(TypesTest9_xml);
348 QTest::newRow(dataTag: "QString") << &TypesTest10::staticMetaObject << QString(TypesTest10_xml);
349 QTest::newRow(dataTag: "QDBusObjectPath") << &TypesTest11::staticMetaObject << QString(TypesTest11_xml);
350 QTest::newRow(dataTag: "QDBusSignature") << &TypesTest12::staticMetaObject << QString(TypesTest12_xml);
351 QTest::newRow(dataTag: "QDBusVariant") << &TypesTest13::staticMetaObject << QString(TypesTest13_xml);
352 QTest::newRow(dataTag: "QStringList") << &TypesTest14::staticMetaObject << QString(TypesTest14_xml);
353 QTest::newRow(dataTag: "QByteArray") << &TypesTest15::staticMetaObject << QString(TypesTest15_xml);
354 QTest::newRow(dataTag: "StringPair") << &TypesTest16::staticMetaObject << QString(TypesTest16_xml);
355 QTest::newRow(dataTag: "Struct1") << &TypesTest17::staticMetaObject << QString(TypesTest17_xml);
356 QTest::newRow(dataTag: "Struct4") << &TypesTest18::staticMetaObject << QString(TypesTest18_xml);
357 QTest::newRow(dataTag: "QVariantList") << &TypesTest19::staticMetaObject << QString(TypesTest19_xml);
358 QTest::newRow(dataTag: "QVariantMap") << &TypesTest20::staticMetaObject << QString(TypesTest20_xml);
359 QTest::newRow(dataTag: "QVariantMap-oldannotation") << &TypesTest20::staticMetaObject << QString(TypesTest20_oldxml);
360}
361
362void tst_QDBusMetaObject::types()
363{
364 QFETCH(const QMetaObject*, metaobject);
365 QFETCH(QString, xml);
366
367 // add the rest of the XML tags
368 xml = QString("<node><interface name=\"local.Interface\">%1</interface></node>")
369 .arg(a: xml);
370
371 QDBusError error;
372
373 const QScopedPointer<QDBusMetaObject> result(QDBusMetaObject::createMetaObject(interface: "local.Interface", xml, map, error));
374 QVERIFY2(result, qPrintable(error.message()));
375
376 QCOMPARE(result->enumeratorCount(), 0);
377 QCOMPARE(result->classInfoCount(), 0);
378
379 // compare the meta objects
380 QCOMPARE(result->methodCount() - result->methodOffset(),
381 metaobject->methodCount() - metaobject->methodOffset());
382 QCOMPARE(result->propertyCount() - result->propertyOffset(),
383 metaobject->propertyCount() - metaobject->propertyOffset());
384
385 for (int i = metaobject->methodOffset(); i < metaobject->methodCount(); ++i) {
386 QMetaMethod expected = metaobject->method(index: i);
387
388 int methodIdx = result->indexOfMethod(method: expected.methodSignature().constData());
389 QVERIFY(methodIdx != -1);
390 QMetaMethod constructed = result->method(index: methodIdx);
391
392 QCOMPARE(int(constructed.access()), int(expected.access()));
393 QCOMPARE(int(constructed.methodType()), int(expected.methodType()));
394 QCOMPARE(constructed.name(), expected.name());
395 QCOMPARE(constructed.parameterCount(), expected.parameterCount());
396 QCOMPARE(constructed.parameterNames(), expected.parameterNames());
397 QCOMPARE(constructed.parameterTypes(), expected.parameterTypes());
398 for (int j = 0; j < constructed.parameterCount(); ++j)
399 QCOMPARE(constructed.parameterType(j), expected.parameterType(j));
400 QCOMPARE(constructed.tag(), expected.tag());
401 QCOMPARE(constructed.typeName(), expected.typeName());
402 QCOMPARE(constructed.returnType(), expected.returnType());
403 }
404
405 for (int i = metaobject->propertyOffset(); i < metaobject->propertyCount(); ++i) {
406 QMetaProperty expected = metaobject->property(index: i);
407
408 int propIdx = result->indexOfProperty(name: expected.name());
409 QVERIFY(propIdx != -1);
410 QMetaProperty constructed = result->property(index: propIdx);
411
412 QCOMPARE(constructed.isDesignable(), expected.isDesignable());
413 QCOMPARE(constructed.isEditable(), expected.isEditable());
414 QCOMPARE(constructed.isEnumType(), expected.isEnumType());
415 QCOMPARE(constructed.isFlagType(), expected.isFlagType());
416 QCOMPARE(constructed.isReadable(), expected.isReadable());
417 QCOMPARE(constructed.isResettable(), expected.isResettable());
418 QCOMPARE(constructed.isScriptable(), expected.isScriptable());
419 QCOMPARE(constructed.isStored(), expected.isStored());
420 QCOMPARE(constructed.isUser(), expected.isUser());
421 QCOMPARE(constructed.isWritable(), expected.isWritable());
422 QCOMPARE(constructed.typeName(), expected.typeName());
423 QCOMPARE(constructed.type(), expected.type());
424 QCOMPARE(constructed.userType(), expected.userType());
425 }
426}
427
428class MethodTest1: public QObject
429{
430 Q_OBJECT
431
432public slots:
433 void method() { }
434};
435const char MethodTest1_xml[] =
436 "<method name=\"method\" />";
437
438class MethodTest2: public QObject
439{
440 Q_OBJECT
441
442public slots:
443 void method(int) { }
444};
445const char MethodTest2_xml[] =
446 "<method name=\"method\"><arg direction=\"in\" type=\"i\"/></method>";
447
448class MethodTest3: public QObject
449{
450 Q_OBJECT
451
452public slots:
453 void method(int input0) { Q_UNUSED(input0); }
454};
455const char MethodTest3_xml[] =
456 "<method name=\"method\"><arg direction=\"in\" type=\"i\" name=\"input0\"/></method>";
457
458class MethodTest4: public QObject
459{
460 Q_OBJECT
461
462public slots:
463 int method() { return 0; }
464};
465const char MethodTest4_xml[] =
466 "<method name=\"method\"><arg direction=\"out\" type=\"i\"/></method>";
467const char MethodTest4_xml2[] =
468 "<method name=\"method\"><arg direction=\"out\" type=\"i\" name=\"thisShouldNeverBeSeen\"/></method>";
469
470class MethodTest5: public QObject
471{
472 Q_OBJECT
473
474public slots:
475 int method(int input0) { return input0; }
476};
477const char MethodTest5_xml[] =
478 "<method name=\"method\">"
479 "<arg direction=\"in\" type=\"i\" name=\"input0\"/>"
480 "<arg direction=\"out\" type=\"i\"/>"
481 "</method>";
482
483class MethodTest6: public QObject
484{
485 Q_OBJECT
486
487public slots:
488 int method(int input0, int input1) { Q_UNUSED(input0); return input1; }
489};
490const char MethodTest6_xml[] =
491 "<method name=\"method\">"
492 "<arg direction=\"in\" type=\"i\" name=\"input0\"/>"
493 "<arg direction=\"out\" type=\"i\"/>"
494 "<arg direction=\"in\" type=\"i\" name=\"input1\"/>"
495 "</method>";
496
497class MethodTest7: public QObject
498{
499 Q_OBJECT
500
501public slots:
502 int method(int input0, int input1, int &output1) { output1 = input1; return input0; }
503};
504const char MethodTest7_xml[] =
505 "<method name=\"method\">"
506 "<arg direction=\"in\" type=\"i\" name=\"input0\"/>"
507 "<arg direction=\"in\" type=\"i\" name=\"input1\"/>"
508 "<arg direction=\"out\" type=\"i\"/>"
509 "<arg direction=\"out\" type=\"i\" name=\"output1\"/>"
510 "</method>";
511
512class MethodTest8: public QObject
513{
514 Q_OBJECT
515
516public slots:
517 int method(int input0, int input1, int &output1, int &output2) { output1 = output2 = input1; return input0; }
518};
519const char MethodTest8_xml[] =
520 "<method name=\"method\">"
521 "<arg direction=\"in\" type=\"i\" name=\"input0\"/>"
522 "<arg direction=\"in\" type=\"i\" name=\"input1\"/>"
523 "<arg direction=\"out\" type=\"i\"/>"
524 "<arg direction=\"out\" type=\"i\" name=\"output1\"/>"
525 "<arg direction=\"out\" type=\"i\" name=\"output2\"/>"
526 "</method>";
527
528class MethodTest9: public QObject
529{
530 Q_OBJECT
531
532public slots:
533 Q_NOREPLY void method(int) { }
534};
535const char MethodTest9_xml[] =
536 "<method name=\"method\">"
537 "<arg direction=\"in\" type=\"i\"/>"
538 "<annotation name=\"org.freedesktop.DBus.Method.NoReply\" value=\"true\"/>"
539 "</method>";
540
541void tst_QDBusMetaObject::methods_data()
542{
543 QTest::addColumn<const QMetaObject *>(name: "metaobject");
544 QTest::addColumn<QString>(name: "xml");
545
546 QTest::newRow(dataTag: "void-void") << &MethodTest1::staticMetaObject << QString(MethodTest1_xml);
547 QTest::newRow(dataTag: "void-int") << &MethodTest2::staticMetaObject << QString(MethodTest2_xml);
548 QTest::newRow(dataTag: "void-int-with-name") << &MethodTest3::staticMetaObject << QString(MethodTest3_xml);
549 QTest::newRow(dataTag: "int-void") << &MethodTest4::staticMetaObject << QString(MethodTest4_xml);
550 QTest::newRow(dataTag: "int-void2") << &MethodTest4::staticMetaObject << QString(MethodTest4_xml2);
551 QTest::newRow(dataTag: "int-int") << &MethodTest5::staticMetaObject << QString(MethodTest5_xml);
552 QTest::newRow(dataTag: "int-int,int") << &MethodTest6::staticMetaObject << QString(MethodTest6_xml);
553 QTest::newRow(dataTag: "int,int-int,int") << &MethodTest7::staticMetaObject << QString(MethodTest7_xml);
554 QTest::newRow(dataTag: "int,int,int-int,int") << &MethodTest8::staticMetaObject << QString(MethodTest8_xml);
555 QTest::newRow(dataTag: "Q_ASYNC") << &MethodTest9::staticMetaObject << QString(MethodTest9_xml);
556}
557
558void tst_QDBusMetaObject::methods()
559{
560 types();
561}
562
563class SignalTest1: public QObject
564{
565 Q_OBJECT
566
567signals:
568 void signal();
569};
570const char SignalTest1_xml[] =
571 "<signal name=\"signal\" />";
572
573class SignalTest2: public QObject
574{
575 Q_OBJECT
576
577signals:
578 void signal(int);
579};
580const char SignalTest2_xml[] =
581 "<signal name=\"signal\"><arg type=\"i\"/></signal>";
582
583class SignalTest3: public QObject
584{
585 Q_OBJECT
586
587signals:
588 void signal(int output0);
589};
590const char SignalTest3_xml[] =
591 "<signal name=\"signal\"><arg type=\"i\" name=\"output0\"/></signal>";
592
593class SignalTest4: public QObject
594{
595 Q_OBJECT
596
597signals:
598 void signal(int output0, int);
599};
600const char SignalTest4_xml[] =
601 "<signal name=\"signal\"><arg type=\"i\" name=\"output0\"/><arg type=\"i\"/></signal>";
602
603void tst_QDBusMetaObject::_signals_data()
604{
605 QTest::addColumn<const QMetaObject *>(name: "metaobject");
606 QTest::addColumn<QString>(name: "xml");
607
608 QTest::newRow(dataTag: "empty") << &SignalTest1::staticMetaObject << QString(SignalTest1_xml);
609 QTest::newRow(dataTag: "int") << &SignalTest2::staticMetaObject << QString(SignalTest2_xml);
610 QTest::newRow(dataTag: "int output0") << &SignalTest3::staticMetaObject << QString(SignalTest3_xml);
611 QTest::newRow(dataTag: "int output0,int") << &SignalTest4::staticMetaObject << QString(SignalTest4_xml);
612}
613
614void tst_QDBusMetaObject::_signals()
615{
616 types();
617}
618
619class PropertyTest1: public QObject
620{
621 Q_OBJECT
622 Q_PROPERTY(int property READ property)
623public:
624 int property() { return 0; }
625 void setProperty(int) { }
626};
627const char PropertyTest1_xml[] =
628 "<property name=\"property\" type=\"i\" access=\"read\"/>";
629
630class PropertyTest2: public QObject
631{
632 Q_OBJECT
633 Q_PROPERTY(int property READ property WRITE setProperty)
634public:
635 int property() { return 0; }
636 void setProperty(int) { }
637};
638const char PropertyTest2_xml[] =
639 "<property name=\"property\" type=\"i\" access=\"readwrite\"/>";
640
641class PropertyTest3: public QObject
642{
643 Q_OBJECT
644 Q_PROPERTY(int property WRITE setProperty)
645public:
646 int property() { return 0; }
647 void setProperty(int) { }
648};
649const char PropertyTest3_xml[] =
650 "<property name=\"property\" type=\"i\" access=\"write\"/>";
651
652class PropertyTest4: public QObject
653{
654 Q_OBJECT
655 Q_PROPERTY(Struct1 property WRITE setProperty)
656public:
657 Struct1 property() { return Struct1(); }
658 void setProperty(Struct1) { }
659};
660const char PropertyTest4_xml[] =
661 "<property name=\"property\" type=\"(s)\" access=\"write\">"
662 "<annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"Struct1\"/>"
663 "</property>";
664
665class PropertyTest_b: public QObject
666{
667 Q_OBJECT
668 Q_PROPERTY(bool property READ property WRITE setProperty)
669public:
670 bool property() { return false; }
671 void setProperty(bool) { }
672};
673const char PropertyTest_b_xml[] =
674 "<property name=\"property\" type=\"b\" access=\"readwrite\"/>";
675
676class PropertyTest_y: public QObject
677{
678 Q_OBJECT
679 Q_PROPERTY(uchar property READ property WRITE setProperty)
680public:
681 uchar property() { return 0; }
682 void setProperty(uchar) { }
683};
684const char PropertyTest_y_xml[] =
685 "<property name=\"property\" type=\"y\" access=\"readwrite\"/>";
686
687class PropertyTest_n: public QObject
688{
689 Q_OBJECT
690 Q_PROPERTY(short property READ property WRITE setProperty)
691public:
692 short property() { return 0; }
693 void setProperty(short) { }
694};
695const char PropertyTest_n_xml[] =
696 "<property name=\"property\" type=\"n\" access=\"readwrite\"/>";
697
698class PropertyTest_q: public QObject
699{
700 Q_OBJECT
701 Q_PROPERTY(ushort property READ property WRITE setProperty)
702public:
703 ushort property() { return 0; }
704 void setProperty(ushort) { }
705};
706const char PropertyTest_q_xml[] =
707 "<property name=\"property\" type=\"q\" access=\"readwrite\"/>";
708
709class PropertyTest_u: public QObject
710{
711 Q_OBJECT
712 Q_PROPERTY(uint property READ property WRITE setProperty)
713public:
714 uint property() { return 0; }
715 void setProperty(uint) { }
716};
717const char PropertyTest_u_xml[] =
718 "<property name=\"property\" type=\"u\" access=\"readwrite\"/>";
719
720class PropertyTest_x: public QObject
721{
722 Q_OBJECT
723 Q_PROPERTY(qlonglong property READ property WRITE setProperty)
724public:
725 qlonglong property() { return 0; }
726 void setProperty(qlonglong) { }
727};
728const char PropertyTest_x_xml[] =
729 "<property name=\"property\" type=\"x\" access=\"readwrite\"/>";
730
731class PropertyTest_t: public QObject
732{
733 Q_OBJECT
734 Q_PROPERTY(qulonglong property READ property WRITE setProperty)
735public:
736 qulonglong property() { return 0; }
737 void setProperty(qulonglong) { }
738};
739const char PropertyTest_t_xml[] =
740 "<property name=\"property\" type=\"t\" access=\"readwrite\"/>";
741
742class PropertyTest_d: public QObject
743{
744 Q_OBJECT
745 Q_PROPERTY(double property READ property WRITE setProperty)
746public:
747 double property() { return 0; }
748 void setProperty(double) { }
749};
750const char PropertyTest_d_xml[] =
751 "<property name=\"property\" type=\"d\" access=\"readwrite\"/>";
752
753class PropertyTest_s: public QObject
754{
755 Q_OBJECT
756 Q_PROPERTY(QString property READ property WRITE setProperty)
757public:
758 QString property() { return QString(); }
759 void setProperty(QString) { }
760};
761const char PropertyTest_s_xml[] =
762 "<property name=\"property\" type=\"s\" access=\"readwrite\"/>";
763
764class PropertyTest_v: public QObject
765{
766 Q_OBJECT
767 Q_PROPERTY(QDBusVariant property READ property WRITE setProperty)
768public:
769 QDBusVariant property() { return QDBusVariant(); }
770 void setProperty(QDBusVariant) { }
771};
772const char PropertyTest_v_xml[] =
773 "<property name=\"property\" type=\"v\" access=\"readwrite\"/>";
774
775class PropertyTest_o: public QObject
776{
777 Q_OBJECT
778 Q_PROPERTY(QDBusObjectPath property READ property WRITE setProperty)
779public:
780 QDBusObjectPath property() { return QDBusObjectPath(); }
781 void setProperty(QDBusObjectPath) { }
782};
783const char PropertyTest_o_xml[] =
784 "<property name=\"property\" type=\"o\" access=\"readwrite\"/>";
785
786class PropertyTest_g: public QObject
787{
788 Q_OBJECT
789 Q_PROPERTY(QDBusSignature property READ property WRITE setProperty)
790public:
791 QDBusSignature property() { return QDBusSignature(); }
792 void setProperty(QDBusSignature) { }
793};
794const char PropertyTest_g_xml[] =
795 "<property name=\"property\" type=\"g\" access=\"readwrite\"/>";
796
797class PropertyTest_h: public QObject
798{
799 Q_OBJECT
800 Q_PROPERTY(QDBusUnixFileDescriptor property READ property WRITE setProperty)
801public:
802 QDBusUnixFileDescriptor property() { return QDBusUnixFileDescriptor(); }
803 void setProperty(QDBusUnixFileDescriptor) { }
804};
805const char PropertyTest_h_xml[] =
806 "<property name=\"property\" type=\"h\" access=\"readwrite\"/>";
807
808class PropertyTest_ay: public QObject
809{
810 Q_OBJECT
811 Q_PROPERTY(QByteArray property READ property WRITE setProperty)
812public:
813 QByteArray property() { return QByteArray(); }
814 void setProperty(QByteArray) { }
815};
816const char PropertyTest_ay_xml[] =
817 "<property name=\"property\" type=\"ay\" access=\"readwrite\"/>";
818
819class PropertyTest_as: public QObject
820{
821 Q_OBJECT
822 Q_PROPERTY(QStringList property READ property WRITE setProperty)
823public:
824 QStringList property() { return QStringList(); }
825 void setProperty(QStringList) { }
826};
827const char PropertyTest_as_xml[] =
828 "<property name=\"property\" type=\"as\" access=\"readwrite\"/>";
829
830class PropertyTest_av: public QObject
831{
832 Q_OBJECT
833 Q_PROPERTY(QVariantList property READ property WRITE setProperty)
834public:
835 QVariantList property() { return QVariantList(); }
836 void setProperty(QVariantList) { }
837};
838const char PropertyTest_av_xml[] =
839 "<property name=\"property\" type=\"av\" access=\"readwrite\"/>";
840
841class PropertyTest_ao: public QObject
842{
843 Q_OBJECT
844 Q_PROPERTY(QList<QDBusObjectPath> property READ property WRITE setProperty)
845public:
846 QList<QDBusObjectPath> property() { return QList<QDBusObjectPath>(); }
847 void setProperty(QList<QDBusObjectPath>) { }
848};
849const char PropertyTest_ao_xml[] =
850 "<property name=\"property\" type=\"ao\" access=\"readwrite\"/>";
851
852class PropertyTest_ag: public QObject
853{
854 Q_OBJECT
855 Q_PROPERTY(QList<QDBusSignature> property READ property WRITE setProperty)
856public:
857 QList<QDBusSignature> property() { return QList<QDBusSignature>(); }
858 void setProperty(QList<QDBusSignature>) { }
859};
860const char PropertyTest_ag_xml[] =
861 "<property name=\"property\" type=\"ag\" access=\"readwrite\"/>";
862
863void tst_QDBusMetaObject::properties_data()
864{
865 QTest::addColumn<const QMetaObject *>(name: "metaobject");
866 QTest::addColumn<QString>(name: "xml");
867
868 QTest::newRow(dataTag: "read") << &PropertyTest1::staticMetaObject << QString(PropertyTest1_xml);
869 QTest::newRow(dataTag: "readwrite") << &PropertyTest2::staticMetaObject << QString(PropertyTest2_xml);
870 QTest::newRow(dataTag: "write") << &PropertyTest3::staticMetaObject << QString(PropertyTest3_xml);
871 QTest::newRow(dataTag: "customtype") << &PropertyTest4::staticMetaObject << QString(PropertyTest4_xml);
872
873 QTest::newRow(dataTag: "bool") << &PropertyTest_b::staticMetaObject << QString(PropertyTest_b_xml);
874 QTest::newRow(dataTag: "byte") << &PropertyTest_y::staticMetaObject << QString(PropertyTest_y_xml);
875 QTest::newRow(dataTag: "short") << &PropertyTest_n::staticMetaObject << QString(PropertyTest_n_xml);
876 QTest::newRow(dataTag: "ushort") << &PropertyTest_q::staticMetaObject << QString(PropertyTest_q_xml);
877 QTest::newRow(dataTag: "uint") << &PropertyTest_u::staticMetaObject << QString(PropertyTest_u_xml);
878 QTest::newRow(dataTag: "qlonglong") << &PropertyTest_x::staticMetaObject << QString(PropertyTest_x_xml);
879 QTest::newRow(dataTag: "qulonglong") << &PropertyTest_t::staticMetaObject << QString(PropertyTest_t_xml);
880 QTest::newRow(dataTag: "double") << &PropertyTest_d::staticMetaObject << QString(PropertyTest_d_xml);
881 QTest::newRow(dataTag: "QString") << &PropertyTest_s::staticMetaObject << QString(PropertyTest_s_xml);
882 QTest::newRow(dataTag: "QDBusVariant") << &PropertyTest_v::staticMetaObject << QString(PropertyTest_v_xml);
883 QTest::newRow(dataTag: "QDBusObjectPath") << &PropertyTest_o::staticMetaObject << QString(PropertyTest_o_xml);
884 QTest::newRow(dataTag: "QDBusSignature") << &PropertyTest_g::staticMetaObject << QString(PropertyTest_g_xml);
885 QTest::newRow(dataTag: "QDBusUnixFileDescriptor") << &PropertyTest_h::staticMetaObject << QString(PropertyTest_h_xml);
886 QTest::newRow(dataTag: "QByteArray") << &PropertyTest_ay::staticMetaObject << QString(PropertyTest_ay_xml);
887 QTest::newRow(dataTag: "QStringList") << &PropertyTest_as::staticMetaObject << QString(PropertyTest_as_xml);
888 QTest::newRow(dataTag: "QVariantList") << &PropertyTest_av::staticMetaObject << QString(PropertyTest_av_xml);
889 QTest::newRow(dataTag: "QList<QDBusObjectPath>") << &PropertyTest_ao::staticMetaObject << QString(PropertyTest_ao_xml);
890 QTest::newRow(dataTag: "QList<QDBusSignature>") << &PropertyTest_ag::staticMetaObject << QString(PropertyTest_ag_xml);
891}
892
893void tst_QDBusMetaObject::properties()
894{
895 types();
896}
897
898
899QTEST_MAIN(tst_QDBusMetaObject)
900#include "tst_qdbusmetaobject.moc"
901

source code of qtbase/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp