summaryrefslogtreecommitdiffstats
path: root/tests/auto/integration/tst_integration.cpp
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-05-02 21:00:15 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2021-06-04 09:54:04 +0200
commit7dcb801dca2ce76211ecef33050e60452dc0de24 (patch)
tree9b90717665b5396ca4b609edbe4fce20950c01b1 /tests/auto/integration/tst_integration.cpp
parent9a50496e8abc8be42e8c206e75ec6f5ee71eb27c (diff)
Port QRemoteObjectRegistry to new property system
Task-number: QTBUG-90687 Change-Id: I6c75b7e4cac09f110c377ebc7ed1d72774ffb765 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/auto/integration/tst_integration.cpp')
-rw-r--r--tests/auto/integration/tst_integration.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp
index 3e58807..e2cd192 100644
--- a/tests/auto/integration/tst_integration.cpp
+++ b/tests/auto/integration/tst_integration.cpp
@@ -480,6 +480,90 @@ private slots:
QCOMPARE(instances, QStringList({"Engine2"}));
}
+ void registrySourceLocationBindings()
+ {
+ QFETCH_GLOBAL(QUrl, registryUrl);
+ QFETCH_GLOBAL(QUrl, hostUrl);
+ if (registryUrl.isEmpty())
+ QSKIP("Skipping registry tests for external QIODevice types.");
+
+ setupRegistry();
+ setupHost(true);
+ setupClient(true);
+
+ QVERIFY(host->registry()->sourceLocations().empty());
+ QVERIFY(client->registry()->sourceLocations().empty());
+
+ QVERIFY(host->registry()->bindableSourceLocations().isReadOnly());
+ QVERIFY(client->registry()->bindableSourceLocations().isReadOnly());
+
+ Engine e1;
+ const auto engine1 = QStringLiteral("Engine1");
+ Engine e2;
+ const auto engine2 = QStringLiteral("Engine2");
+
+ QRemoteObjectSourceLocations expectedSourceLocations;
+ expectedSourceLocations[engine1] = { QStringLiteral("Engine"), hostUrl };
+
+ int hostSrcLocationsChanged = 0;
+ auto hostHandler = host->registry()->bindableSourceLocations().onValueChanged([&] {
+ QCOMPARE(host->registry()->sourceLocations(), expectedSourceLocations);
+ ++hostSrcLocationsChanged;
+ });
+
+ int clientSrcLocationsChanged = 0;
+ auto clientHandler = client->registry()->bindableSourceLocations().onValueChanged([&] {
+ QCOMPARE(client->registry()->sourceLocations(), expectedSourceLocations);
+ ++clientSrcLocationsChanged;
+ });
+
+ QProperty<QRemoteObjectSourceLocations> hostObserver;
+ hostObserver.setBinding([&] { return host->registry()->sourceLocations(); });
+
+ QProperty<QRemoteObjectSourceLocations> clientObserver;
+ clientObserver.setBinding([&] { return client->registry()->sourceLocations(); });
+
+ QSignalSpy hostSpy(host->registry(), &QRemoteObjectRegistry::remoteObjectAdded);
+ QSignalSpy clientSpy(client->registry(), &QRemoteObjectRegistry::remoteObjectAdded);
+
+ host->enableRemoting(&e1, engine1);
+ QTRY_COMPARE(hostSpy.count(), 1);
+ QTRY_COMPARE(clientSpy.count(), 1);
+ QCOMPARE(hostObserver.value(), host->registry()->sourceLocations());
+ QCOMPARE(clientObserver.value(), client->registry()->sourceLocations());
+ QCOMPARE(hostObserver.value(), clientObserver.value());
+ QCOMPARE(hostObserver.value(), expectedSourceLocations);
+ QCOMPARE(hostSrcLocationsChanged, 1);
+ QCOMPARE(clientSrcLocationsChanged, 1);
+
+ expectedSourceLocations[engine2] = { QStringLiteral("Engine"), hostUrl };
+ host->enableRemoting(&e2, engine2);
+ QTRY_COMPARE(hostSpy.count(), 2);
+ QTRY_COMPARE(clientSpy.count(), 2);
+ QCOMPARE(hostObserver.value(), host->registry()->sourceLocations());
+ QCOMPARE(clientObserver.value(), client->registry()->sourceLocations());
+ QCOMPARE(hostObserver.value(), clientObserver.value());
+ QCOMPARE(hostObserver.value(), expectedSourceLocations);
+ QCOMPARE(hostSrcLocationsChanged, 2);
+ QCOMPARE(clientSrcLocationsChanged, 2);
+
+ // Test source removal
+ host->disableRemoting(&e1);
+ expectedSourceLocations.remove(engine1);
+ QSignalSpy srcRemovedHostSpy(host->registry(), &QRemoteObjectRegistry::remoteObjectRemoved);
+ QSignalSpy srcRemovedClientSpy(client->registry(),
+ &QRemoteObjectRegistry::remoteObjectRemoved);
+
+ QTRY_COMPARE(srcRemovedHostSpy.count(), 1);
+ QTRY_COMPARE(srcRemovedClientSpy.count(), 1);
+ QCOMPARE(hostObserver.value(), host->registry()->sourceLocations());
+ QCOMPARE(clientObserver.value(), client->registry()->sourceLocations());
+ QCOMPARE(hostObserver.value(), clientObserver.value());
+ QCOMPARE(hostObserver.value(), expectedSourceLocations);
+ QCOMPARE(hostSrcLocationsChanged, 3);
+ QCOMPARE(clientSrcLocationsChanged, 3);
+ }
+
void registryAddedTest()
{
QFETCH_GLOBAL(QUrl, registryUrl);