diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2022-04-19 18:57:37 +0300 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-04-29 05:32:42 +0000 |
commit | 62e3ac42e85362ad2c9c3acc6f746ee261366c4e (patch) | |
tree | 641cba2842c21cf202a82fe3ea394bfc2768e41c | |
parent | 112d0bfc0cfbb95b40eb5316076b4c87213cbd58 (diff) |
Android: use localabstract socket on Android tests
Replace usage of local socket with localabstract for Android.
Task-number: QTBUG-100449
Change-Id: Ia15090b15fb2784fa9747e4568ca3ab0ebf885bd
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
(cherry picked from commit da527fcbdb15463ad4bacccf7c8b2252c7417e7a)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
19 files changed, 66 insertions, 36 deletions
diff --git a/tests/auto/benchmarks/tst_benchmarkstest.cpp b/tests/auto/benchmarks/tst_benchmarkstest.cpp index d943a3e..d546915 100644 --- a/tests/auto/benchmarks/tst_benchmarkstest.cpp +++ b/tests/auto/benchmarks/tst_benchmarkstest.cpp @@ -36,6 +36,8 @@ #include "rep_localdatacenter_replica.h" #include "rep_localdatacenter_source.h" +#include "../../shared/testutils.h" + class BenchmarksModel : public QAbstractListModel { // QAbstractItemModel interface @@ -98,14 +100,14 @@ BenchmarksTest::BenchmarksTest() } void BenchmarksTest::initTestCase() { - m_basicServer.setHostUrl(QUrl(QStringLiteral("local:benchmark_replica"))); + m_basicServer.setHostUrl(QUrl(QStringLiteral(LOCAL_SOCKET ":benchmark_replica"))); dataCenterLocal.reset(new LocalDataCenterSimpleSource); dataCenterLocal->setData1(5); const bool remoted = m_basicServer.enableRemoting(dataCenterLocal.data()); Q_ASSERT(remoted); Q_UNUSED(remoted) - m_basicClient.connectToNode(QUrl(QStringLiteral("local:benchmark_replica"))); + m_basicClient.connectToNode(QUrl(QStringLiteral(LOCAL_SOCKET ":benchmark_replica"))); Q_ASSERT(m_basicClient.lastError() == QRemoteObjectNode::NoError); m_basicServer.enableRemoting(&m_sourceModel, QStringLiteral("BenchmarkRemoteModel"), @@ -248,7 +250,7 @@ void BenchmarksTest::benchModelLinearAccess() // which are the last 50 items QBENCHMARK { QRemoteObjectNode localClient; - localClient.connectToNode(QUrl(QStringLiteral("local:benchmark_replica"))); + localClient.connectToNode(QUrl(QStringLiteral(LOCAL_SOCKET ":benchmark_replica"))); QScopedPointer<QAbstractItemModelReplica> model(localClient.acquireModel(QStringLiteral("BenchmarkRemoteModel"))); QEventLoop loop; QHash<int, QPair<QString, QString>> dataToWait; @@ -320,7 +322,7 @@ void BenchmarksTest::benchModelRandomAccess() { QBENCHMARK { QRemoteObjectNode localClient; - localClient.connectToNode(QUrl(QStringLiteral("local:benchmark_replica"))); + localClient.connectToNode(QUrl(QStringLiteral(LOCAL_SOCKET ":benchmark_replica"))); QScopedPointer<QAbstractItemModelReplica> model(localClient.acquireModel(QStringLiteral("BenchmarkRemoteModel"))); model->setRootCacheSize(5000); // we need to make room for all 5000 rows that we'll use QEventLoop loop; diff --git a/tests/auto/integration/tst_integration.cpp b/tests/auto/integration/tst_integration.cpp index 1903fac..546c5c3 100644 --- a/tests/auto/integration/tst_integration.cpp +++ b/tests/auto/integration/tst_integration.cpp @@ -51,6 +51,8 @@ #include "rep_localdatacenter_replica.h" #include "rep_tcpdatacenter_replica.h" +#include "../../shared/testutils.h" + #define SET_NODE_NAME(obj) (obj).setName(QLatin1String(#obj)) //DUMMY impl for variant comparison @@ -216,7 +218,7 @@ private slots: #ifdef __QNXNTO__ QTest::newRow("qnx") << QUrl(QLatin1String("qnx:replica")) << QUrl(QLatin1String("qnx:registry")); #endif - QTest::newRow("local") << QUrl(QLatin1String("local:replicaLocalIntegration")) << QUrl(QLatin1String("local:registryLocalIntegration")); + QTest::newRow("local") << QUrl(QLatin1String(LOCAL_SOCKET ":replicaLocalIntegration")) << QUrl(QLatin1String(LOCAL_SOCKET ":registryLocalIntegration")); #ifdef Q_OS_LINUX QTest::newRow("localabstract") << QUrl(QLatin1String("localabstract:replicaAbstractIntegration")) << QUrl(QLatin1String("localabstract:registryAbstractIntegration")); #endif @@ -1431,7 +1433,7 @@ private slots: QVERIFY(info.exists()); QRemoteObjectNode localSocketTestClient; - const QUrl connection = QUrl(QStringLiteral("local:crashMe")); + const QUrl connection = QUrl(QStringLiteral(LOCAL_SOCKET ":crashMe")); const QString objectname = QStringLiteral("connectme"); localSocketTestClient.connectToNode(connection); QVERIFY(localSocketTestClient.lastError() == QRemoteObjectNode::NoError); @@ -1465,7 +1467,7 @@ private slots: QVERIFY(info.exists()); QRemoteObjectNode localSocketTestClient; - const QUrl connection = QUrl(QStringLiteral("local:crashMe")); + const QUrl connection = QUrl(QStringLiteral(LOCAL_SOCKET ":crashMe")); const QString objectname = QStringLiteral("connectme"); localSocketTestClient.connectToNode(connection); QVERIFY(localSocketTestClient.lastError() == QRemoteObjectNode::NoError); diff --git a/tests/auto/localsockettestserver/main.cpp b/tests/auto/localsockettestserver/main.cpp index 045f6a4..33acc16 100644 --- a/tests/auto/localsockettestserver/main.cpp +++ b/tests/auto/localsockettestserver/main.cpp @@ -29,12 +29,14 @@ #include <QCoreApplication> #include <QRemoteObjectNode> +#include "../../shared/testutils.h" + int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QObject remotedObject; remotedObject.setObjectName(QStringLiteral("connectme")); - QRemoteObjectHost node(QUrl(QStringLiteral("local:crashMe"))); + QRemoteObjectHost node(QUrl(QStringLiteral(LOCAL_SOCKET ":crashMe"))); node.enableRemoting(&remotedObject); return a.exec(); diff --git a/tests/auto/proxy/tst_proxy.cpp b/tests/auto/proxy/tst_proxy.cpp index 342e8be..6cc9f31 100644 --- a/tests/auto/proxy/tst_proxy.cpp +++ b/tests/auto/proxy/tst_proxy.cpp @@ -34,12 +34,14 @@ #include <QRemoteObjectReplica> #include <QRemoteObjectNode> -const QUrl localHostUrl = QUrl(QLatin1String("local:testHost")); +#include "../../shared/testutils.h" + +const QUrl localHostUrl = QUrl(QLatin1String(LOCAL_SOCKET ":testHost")); const QUrl tcpHostUrl = QUrl(QLatin1String("tcp://127.0.0.1:9989")); const QUrl proxyNodeUrl = QUrl(QLatin1String("tcp://127.0.0.1:12123")); const QUrl remoteNodeUrl = QUrl(QLatin1String("tcp://127.0.0.1:23234")); -const QUrl registryUrl = QUrl(QLatin1String("local:testRegistry")); -const QUrl proxyHostUrl = QUrl(QLatin1String("local:fromProxy")); +const QUrl registryUrl = QUrl(QLatin1String(LOCAL_SOCKET ":testRegistry")); +const QUrl proxyHostUrl = QUrl(QLatin1String(LOCAL_SOCKET ":fromProxy")); #define SET_NODE_NAME(obj) (obj).setName(QLatin1String(#obj)) diff --git a/tests/auto/proxy_multiprocess/proxy/main.cpp b/tests/auto/proxy_multiprocess/proxy/main.cpp index 6e0932a..4ac390b 100644 --- a/tests/auto/proxy_multiprocess/proxy/main.cpp +++ b/tests/auto/proxy_multiprocess/proxy/main.cpp @@ -30,6 +30,8 @@ #include <QtRemoteObjects/qremoteobjectnode.h> #include <QtTest/QtTest> +#include "../../../shared/testutils.h" + class tst_Proxy_Process : public QObject { Q_OBJECT @@ -39,7 +41,7 @@ private Q_SLOTS: { m_hostNode.reset(new QRemoteObjectHost); m_hostNode->setHostUrl(QUrl(QStringLiteral("tcp://127.0.0.1:65213"))); - m_hostNode->proxy(QUrl("local:testRegistry")); + m_hostNode->proxy(QUrl(LOCAL_SOCKET ":testRegistry")); // our proxied object should be added, and then later removed when the server shuts down QSignalSpy addSpy(m_hostNode.data(), &QRemoteObjectNode::remoteObjectAdded); diff --git a/tests/auto/proxy_multiprocess/server/main.cpp b/tests/auto/proxy_multiprocess/server/main.cpp index f6429f6..3dbcc5b 100644 --- a/tests/auto/proxy_multiprocess/server/main.cpp +++ b/tests/auto/proxy_multiprocess/server/main.cpp @@ -33,6 +33,8 @@ #include <QCoreApplication> #include <QtTest/QtTest> +#include "../../../shared/testutils.h" + static QMap<int, MyPOD> int_map{{1, initialValue}, {16, initialValue}}; static MyTestServer::ActivePositions flags1 = MyTestServer::Position::position1; @@ -54,7 +56,7 @@ private Q_SLOTS: bool templated = qEnvironmentVariableIsSet("TEMPLATED_REMOTING"); qDebug() << "Starting tests:" << objectMode << "templated =" << templated; - QRemoteObjectRegistryHost srcNode(QUrl(QStringLiteral("local:testRegistry"))); + QRemoteObjectRegistryHost srcNode(QUrl(QStringLiteral(LOCAL_SOCKET ":testRegistry"))); MyTestServer parent; SubClassSimpleSource subclass; diff --git a/tests/auto/qml/usertypes/data/complex.qml b/tests/auto/qml/usertypes/data/complex.qml index 94c66eb..e924dea 100644 --- a/tests/auto/qml/usertypes/data/complex.qml +++ b/tests/auto/qml/usertypes/data/complex.qml @@ -4,6 +4,7 @@ import usertypes 1.0 ComplexTypeReplica { node: Node { - registryUrl: "local:testModel" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testModel" } } diff --git a/tests/auto/qml/usertypes/data/extraPropComplex.qml b/tests/auto/qml/usertypes/data/extraPropComplex.qml index bd16bbc..10edae1 100644 --- a/tests/auto/qml/usertypes/data/extraPropComplex.qml +++ b/tests/auto/qml/usertypes/data/extraPropComplex.qml @@ -7,7 +7,8 @@ ComplexTypeReplica { property QtObject object: QtObject {} node: Node { - registryUrl: "local:testExtraComplex" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testExtraComplex" } } diff --git a/tests/auto/qml/usertypes/data/extraprop.qml b/tests/auto/qml/usertypes/data/extraprop.qml index 5c48de3..9a1f969 100644 --- a/tests/auto/qml/usertypes/data/extraprop.qml +++ b/tests/auto/qml/usertypes/data/extraprop.qml @@ -4,9 +4,9 @@ import usertypes 1.0 SimpleClockReplica { property string result: hour // test that the existence of this property doesn't cause issues - node: Node { - registryUrl: "local:test" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":test" } onStateChanged: if (state == SimpleClockReplica.Valid) pushHour(10) } diff --git a/tests/auto/qml/usertypes/data/extraprop2.qml b/tests/auto/qml/usertypes/data/extraprop2.qml index 35d9d51..c829d83 100644 --- a/tests/auto/qml/usertypes/data/extraprop2.qml +++ b/tests/auto/qml/usertypes/data/extraprop2.qml @@ -6,6 +6,7 @@ SimpleClockReplica { property string result: hour // test that the existence of this property doesn't cause issues node: Node { - registryUrl: "local:test2" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":test2" } } diff --git a/tests/auto/qml/usertypes/data/hosted.qml b/tests/auto/qml/usertypes/data/hosted.qml index db1f1fd..b806232 100644 --- a/tests/auto/qml/usertypes/data/hosted.qml +++ b/tests/auto/qml/usertypes/data/hosted.qml @@ -8,7 +8,8 @@ Item { } Host { - hostUrl: "local:testHost" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + hostUrl: local_socket + ":testHost" Component.onCompleted: enableRemoting(clock) } diff --git a/tests/auto/qml/usertypes/data/model.qml b/tests/auto/qml/usertypes/data/model.qml index 2807d18..954ec61 100644 --- a/tests/auto/qml/usertypes/data/model.qml +++ b/tests/auto/qml/usertypes/data/model.qml @@ -4,6 +4,7 @@ import usertypes 1.0 TypeWithModelReplica { node: Node { - registryUrl: "local:testModel" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testModel" } } diff --git a/tests/auto/qml/usertypes/data/subObject.qml b/tests/auto/qml/usertypes/data/subObject.qml index fc7eb10..0a60257 100644 --- a/tests/auto/qml/usertypes/data/subObject.qml +++ b/tests/auto/qml/usertypes/data/subObject.qml @@ -6,7 +6,8 @@ Item { property int result: replica.clock.hour property Node sharedNode: Node { - registryUrl: "local:testSubObject" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testSubObject" } property TypeWithSubObjectReplica replica: TypeWithSubObjectReplica { diff --git a/tests/auto/qml/usertypes/data/twoReplicas.qml b/tests/auto/qml/usertypes/data/twoReplicas.qml index 1516465..31ef69c 100644 --- a/tests/auto/qml/usertypes/data/twoReplicas.qml +++ b/tests/auto/qml/usertypes/data/twoReplicas.qml @@ -8,7 +8,8 @@ Item { Node { id: sharedNode - registryUrl: "local:testTwoReplicas" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testTwoReplicas" } SimpleClockReplica { diff --git a/tests/auto/qml/usertypes/data/watcher.qml b/tests/auto/qml/usertypes/data/watcher.qml index b49d824..5e9638a 100644 --- a/tests/auto/qml/usertypes/data/watcher.qml +++ b/tests/auto/qml/usertypes/data/watcher.qml @@ -7,7 +7,8 @@ TypeWithReplyReplica { property bool hasError node: Node { - registryUrl: "local:testWatcher" + property string local_socket: Qt.platform.os == "android" ? "localabstract" : "local" + registryUrl: local_socket + ":testWatcher" } onStateChanged: function(state) { if (state != TypeWithReplyReplica.Valid) diff --git a/tests/auto/qml/usertypes/tst_usertypes.cpp b/tests/auto/qml/usertypes/tst_usertypes.cpp index 867f1eb..d6491f8 100644 --- a/tests/auto/qml/usertypes/tst_usertypes.cpp +++ b/tests/auto/qml/usertypes/tst_usertypes.cpp @@ -32,6 +32,8 @@ #include <qqmlcomponent.h> #include "rep_usertypes_merged.h" +#include "../../../shared/testutils.h" + class TypeWithReply : public TypeWithReplySimpleSource { public: @@ -77,7 +79,7 @@ void tst_usertypes::extraPropertyInQml() { qmlRegisterType<SimpleClockReplica>("usertypes", 1, 0, "SimpleClockReplica"); - QRemoteObjectRegistryHost host(QUrl("local:test")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":test")); SimpleClockSimpleSource clock; host.enableRemoting(&clock); @@ -93,7 +95,7 @@ void tst_usertypes::extraPropertyInQml2() { qmlRegisterType<SimpleClockReplica>("usertypes", 1, 0, "SimpleClockReplica"); - QRemoteObjectRegistryHost host(QUrl("local:test2")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":test2")); SimpleClockSimpleSource clock; clock.setHour(10); host.enableRemoting(&clock); @@ -109,7 +111,7 @@ void tst_usertypes::extraPropertyInQml2() void tst_usertypes::extraPropertyInQmlComplex() { - QRemoteObjectRegistryHost host(QUrl("local:testExtraComplex")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testExtraComplex")); SimpleClockSimpleSource clock; QStringListModel *model = new QStringListModel(); @@ -135,7 +137,7 @@ void tst_usertypes::modelInQml() { qmlRegisterType<TypeWithModelReplica>("usertypes", 1, 0, "TypeWithModelReplica"); - QRemoteObjectRegistryHost host(QUrl("local:testModel")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testModel")); QStringListModel *model = new QStringListModel(); model->setStringList(QStringList() << "Track1" << "Track2" << "Track3"); @@ -160,7 +162,7 @@ void tst_usertypes::subObjectInQml() { qmlRegisterType<TypeWithSubObjectReplica>("usertypes", 1, 0, "TypeWithSubObjectReplica"); - QRemoteObjectRegistryHost host(QUrl("local:testSubObject")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testSubObject")); SimpleClockSimpleSource clock; TypeWithSubObjectSimpleSource source; @@ -194,7 +196,7 @@ void tst_usertypes::complexInQml() QFETCH(bool, templated); QFETCH(bool, nullobject); - QRemoteObjectRegistryHost host(QUrl("local:testModel")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testModel")); QStringListModel *model = new QStringListModel(); model->setStringList(QStringList() << "Track1" << "Track2" << "Track3"); @@ -234,7 +236,7 @@ void tst_usertypes::watcherInQml() { qmlRegisterType<TypeWithReplyReplica>("usertypes", 1, 0, "TypeWithReplyReplica"); - QRemoteObjectRegistryHost host(QUrl("local:testWatcher")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testWatcher")); TypeWithReply source; host.enableRemoting(&source); @@ -267,7 +269,7 @@ void tst_usertypes::hostInQml() QVERIFY(obj); QRemoteObjectNode node; - node.connectToNode(QUrl("local:testHost")); + node.connectToNode(QUrl(LOCAL_SOCKET ":testHost")); SimpleClockReplica *replica = node.acquire<SimpleClockReplica>(); QTRY_COMPARE_WITH_TIMEOUT(replica->state(), QRemoteObjectReplica::Valid, 1000); @@ -280,7 +282,7 @@ void tst_usertypes::twoReplicas() { qmlRegisterType<SimpleClockReplica>("usertypes", 1, 0, "SimpleClockReplica"); - QRemoteObjectRegistryHost host(QUrl("local:testTwoReplicas")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":testTwoReplicas")); SimpleClockSimpleSource clock; clock.setHour(7); host.enableRemoting(&clock); @@ -301,7 +303,7 @@ void tst_usertypes::remoteCompositeType() QScopedPointer<QObject> obj(c.create()); QVERIFY(obj); - QRemoteObjectRegistryHost host(QUrl("local:remoteCompositeType")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":remoteCompositeType")); host.enableRemoting(obj.data(), "composite"); } diff --git a/tests/auto/reconnect/tst/tst_reconnect.cpp b/tests/auto/reconnect/tst/tst_reconnect.cpp index 4b29e87..4ec5081 100644 --- a/tests/auto/reconnect/tst/tst_reconnect.cpp +++ b/tests/auto/reconnect/tst/tst_reconnect.cpp @@ -40,7 +40,7 @@ private slots: void testRun_data() { QTest::addColumn<QString>("url"); - QTest::addRow("local") << QStringLiteral("local:replica"); + QTest::addRow("local") << QStringLiteral(LOCAL_SOCKET ":replica"); QTest::addRow("tcp") << QStringLiteral("tcp://127.0.0.1:65217"); } diff --git a/tests/auto/subclassreplica/tst_subclassreplicatest.cpp b/tests/auto/subclassreplica/tst_subclassreplicatest.cpp index d35207d..d073402 100644 --- a/tests/auto/subclassreplica/tst_subclassreplicatest.cpp +++ b/tests/auto/subclassreplica/tst_subclassreplicatest.cpp @@ -30,6 +30,8 @@ #include <QtTest> #include "rep_class_merged.h" +#include "../../shared/testutils.h" + class SubClassReplicaTest : public QObject { Q_OBJECT @@ -61,7 +63,7 @@ void SubClassReplicaTest::basicFunctions() QFETCH(bool, templated); QFETCH(bool, nullobject); - QRemoteObjectRegistryHost host(QUrl("local:test")); + QRemoteObjectRegistryHost host(QUrl(LOCAL_SOCKET ":test")); SubClassSimpleSource subclass1, subclass2; ParentClassSimpleSource parent; parent.setSub1(&subclass1); @@ -87,7 +89,7 @@ void SubClassReplicaTest::basicFunctions() else host.enableRemoting(&parent); - QRemoteObjectNode client(QUrl("local:test")); + QRemoteObjectNode client(QUrl(LOCAL_SOCKET ":test")); const QScopedPointer<ParentClassReplica> replica(client.acquire<ParentClassReplica>()); QVERIFY(replica->waitForSource(1000)); diff --git a/tests/shared/testutils.h b/tests/shared/testutils.h index 9c870e9..f2a2675 100644 --- a/tests/shared/testutils.h +++ b/tests/shared/testutils.h @@ -35,6 +35,12 @@ #include <QStandardPaths> #include <QCoreApplication> +#ifdef Q_OS_ANDROID +#define LOCAL_SOCKET "localabstract" +#else +#define LOCAL_SOCKET "local" +#endif + namespace TestUtils { QString subFolder; |