diff options
author | Michael Brasser <mbrasser@ford.com> | 2017-04-11 12:07:44 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2017-04-12 12:34:03 +0000 |
commit | 6937b9326583f4f4b0812ea93f420a9fd2132b85 (patch) | |
tree | 0b267a68da13f4284c3c9fbd8164a5d841396ba9 /tests/auto/integration/tst_integration.cpp | |
parent | 0eaa90b1245ba2932c895118418ff9dc4d8ab3c0 (diff) |
Don't hide QObject::setProperty for dynamic replicasv5.9.0-beta2
Change-Id: Ibcd573a610cbc88a9b82c45aa3eb6b1e2272744a
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'tests/auto/integration/tst_integration.cpp')
-rw-r--r-- | tests/auto/integration/tst_integration.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp index 9c35ace..a13bf2a 100644 --- a/tests/auto/integration/tst_integration.cpp +++ b/tests/auto/integration/tst_integration.cpp @@ -71,6 +71,32 @@ Q_SIGNALS: void send(const QByteArray &data); }; +class TestDynamic : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) +public: + TestDynamic(QObject *parent=nullptr) : + QObject(parent), + m_value(0) {} + + int value() const { return m_value; } + void setValue(int value) + { + if (m_value == value) + return; + + m_value = value; + emit valueChanged(); + } + +signals: + void valueChanged(); + +private: + int m_value; +}; + class Persist : public QRemoteObjectPersistedStore { public: @@ -973,6 +999,40 @@ private slots: QCOMPARE(speedometer_r->mph(), s.mph()); } + void rawDynamicReplicaTest() + { + QRemoteObjectHost host(hostUrl); + SET_NODE_NAME(host); + TestDynamic source; + host.enableRemoting(&source, "TestDynamic"); + + QRemoteObjectNode client; + client.connectToNode(hostUrl); + Q_SET_OBJECT_NAME(client); + + const QScopedPointer<QRemoteObjectDynamicReplica> replica(client.acquireDynamic(QStringLiteral("TestDynamic"))); + replica->waitForSource(); + QVERIFY(replica->isInitialized()); + + QSignalSpy spy(replica.data(), SIGNAL(valueChanged())); + + const QMetaObject *metaObject = replica->metaObject(); + const int propIndex = metaObject->indexOfProperty("value"); + QVERIFY(propIndex != -1); + const int signalIndex = metaObject->indexOfSignal("valueChanged()"); + QVERIFY(signalIndex != -1); + + // replica gets source change + source.setValue(1); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(replica->property("value"), QVariant(1)); + + // source gets replica change + replica->setProperty("value", 2); + QTRY_COMPARE(replica->property("value"), QVariant(2)); + QCOMPARE(source.value(), 2); + } + void dynamicReplicaTest() { QRemoteObjectHost host(hostUrl); |