diff options
Diffstat (limited to 'tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp')
-rw-r--r-- | tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp | 67 |
1 files changed, 60 insertions, 7 deletions
diff --git a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp index fc20b47768..c4f6a74fe8 100644 --- a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp +++ b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** @@ -10,9 +10,9 @@ ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser @@ -23,8 +23,8 @@ ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ @@ -69,6 +69,19 @@ struct Struct4 // (ssa(ss)sayasx) QStringList m6; qlonglong m7; }; +struct Struct5 // a{sa{sv}} - non-standard outer struct is used as a local +{ // container, see marshalling operator below. + QVariantMap m1; + QVariantMap m2; + QVariantMap m3; +}; +struct Struct6 // av - non-standard outer struct is used as a local container, +{ // see marshalling operator below. + QVariant v1; + QVariant v2; + QVariant v3; +}; + struct Invalid0 { }; // empty struct Invalid1 { }; // s @@ -84,6 +97,8 @@ Q_DECLARE_METATYPE(Struct2) Q_DECLARE_METATYPE(Struct3) Q_DECLARE_METATYPE(Struct4) Q_DECLARE_METATYPE(StringPair) +Q_DECLARE_METATYPE(Struct5) +Q_DECLARE_METATYPE(Struct6) Q_DECLARE_METATYPE(Invalid0) Q_DECLARE_METATYPE(Invalid1) @@ -141,6 +156,34 @@ QDBusArgument &operator<<(QDBusArgument &arg, const Struct4 &s) return arg; } +QDBusArgument &operator<<(QDBusArgument &arg, const Struct5 &s) +{ + arg.beginMap(qMetaTypeId<QString>(), qMetaTypeId<QVariantMap>()); + + arg.beginMapEntry(); + arg << QStringLiteral("map1") << s.m1; + arg.endMapEntry(); + + arg.beginMapEntry(); + arg << QStringLiteral("map2") << s.m2; + arg.endMapEntry(); + + arg.beginMapEntry(); + arg << QStringLiteral("map3") << s.m3; + arg.endMapEntry(); + + arg.endMap(); + return arg; +} + +QDBusArgument &operator<<(QDBusArgument &arg, const Struct6 &s) +{ + arg.beginArray(qMetaTypeId<QDBusVariant>()); + arg << QDBusVariant(s.v1) << QDBusVariant(s.v2) << QDBusVariant(s.v3); + arg.endArray(); + return arg; +} + QDBusArgument &operator<<(QDBusArgument &arg, const Invalid0 &) { return arg; @@ -194,6 +237,10 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, Struct3 &) { return arg; } const QDBusArgument &operator>>(const QDBusArgument &arg, Struct4 &) { return arg; } +const QDBusArgument &operator>>(const QDBusArgument &arg, Struct5 &) +{ return arg; } +const QDBusArgument &operator>>(const QDBusArgument &arg, Struct6 &) +{ return arg; } const QDBusArgument &operator>>(const QDBusArgument &arg, StringPair &) { return arg; } const QDBusArgument &operator>>(const QDBusArgument &arg, Invalid0 &) @@ -220,6 +267,8 @@ void tst_QDBusMetaType::initTestCase() qDBusRegisterMetaType<Struct2>(); qDBusRegisterMetaType<Struct3>(); qDBusRegisterMetaType<Struct4>(); + qDBusRegisterMetaType<Struct5>(); + qDBusRegisterMetaType<Struct6>(); qDBusRegisterMetaType<StringPair>(); qDBusRegisterMetaType<QList<Struct1> >(); @@ -297,6 +346,10 @@ void tst_QDBusMetaType::dynamicTypes_data() QTest::newRow("Struct4") << QVariant::Type(qMetaTypeId<Struct4>()) << "(ssa(ss)sayasx)"; QTest::newRow("QList<Struct4>") << QVariant::Type(qMetaTypeId<QList<Struct4> >()) << "a(ssa(ss)sayasx)"; + QTest::newRow("Struct5") << QVariant::Type(qMetaTypeId<Struct5>()) << "a{sa{sv}}"; + + QTest::newRow("Struct6") << QVariant::Type(qMetaTypeId<Struct6>()) << "av"; + QTest::newRow("QMap<int,QString>") << QVariant::Type(intStringMap) << "a{is}"; QTest::newRow("QMap<QString,QString>") << QVariant::Type(stringStringMap) << "a{ss}"; QTest::newRow("QMap<QString,Struct1>") << QVariant::Type(stringStruct1Map) << "a{s(s)}"; |