summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2019-05-07 08:55:15 +0200
committerRainer Keller <Rainer.Keller@qt.io>2019-05-17 10:34:54 +0000
commit27ded19887a5bdb6dbcc8aa34acff92d6d600682 (patch)
tree5b9ff0da9990c2a1826dcf731ad6b3e1e8392926
parent387309bd295256dd1668fc7fa7de979331763a77 (diff)
tests: QML autotest support custom server
In case a custom server is specified via environment variables, the QML autotests have to use a different discovery URL. Change-Id: I8b21420fc7690e67b07fad793874a14ab8c5c6d4 Reviewed-by: Rainer Keller <Rainer.Keller@qt.io>
-rw-r--r--tests/auto/declarative/AbsoluteNodeTest.qml2
-rw-r--r--tests/auto/declarative/AuthorizationTest.qml4
-rw-r--r--tests/auto/declarative/BatchReadWriteTest.qml2
-rw-r--r--tests/auto/declarative/DataChangeFilterTest.qml2
-rw-r--r--tests/auto/declarative/DiscoveryTest.qml4
-rw-r--r--tests/auto/declarative/MethodnodeTest.qml2
-rw-r--r--tests/auto/declarative/RelativenodeTest.qml2
-rw-r--r--tests/auto/declarative/SubscriptionsTest.qml2
-rw-r--r--tests/auto/declarative/tst_opcua.cpp7
9 files changed, 15 insertions, 12 deletions
diff --git a/tests/auto/declarative/AbsoluteNodeTest.qml b/tests/auto/declarative/AbsoluteNodeTest.qml
index 2aa8e1c..c1f567d 100644
--- a/tests/auto/declarative/AbsoluteNodeTest.qml
+++ b/tests/auto/declarative/AbsoluteNodeTest.qml
@@ -79,7 +79,7 @@ Item {
if (children[i].objectName == "TestCase")
availableTestCases += 1;
}
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
}
CompletionLoggingTestCase {
diff --git a/tests/auto/declarative/AuthorizationTest.qml b/tests/auto/declarative/AuthorizationTest.qml
index 00d14de..c4d680d 100644
--- a/tests/auto/declarative/AuthorizationTest.qml
+++ b/tests/auto/declarative/AuthorizationTest.qml
@@ -82,7 +82,7 @@ Item {
if (children[i].objectName == "TestCase")
availableTestCases += 1;
}
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
}
QtOpcUa.ValueNode {
@@ -111,7 +111,7 @@ Item {
authInfo.setUsernameAuthentication("user1", "password");
connection.authenticationInformation = authInfo;
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
connection1ConnectedSpy.wait();
verify(connection.connected);
diff --git a/tests/auto/declarative/BatchReadWriteTest.qml b/tests/auto/declarative/BatchReadWriteTest.qml
index 52d33aa..0591ce4 100644
--- a/tests/auto/declarative/BatchReadWriteTest.qml
+++ b/tests/auto/declarative/BatchReadWriteTest.qml
@@ -79,7 +79,7 @@ Item {
if (children[i].objectName == "TestCase")
availableTestCases += 1;
}
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
}
CompletionLoggingTestCase {
diff --git a/tests/auto/declarative/DataChangeFilterTest.qml b/tests/auto/declarative/DataChangeFilterTest.qml
index 2ca77f7..8d0e8e8 100644
--- a/tests/auto/declarative/DataChangeFilterTest.qml
+++ b/tests/auto/declarative/DataChangeFilterTest.qml
@@ -66,7 +66,7 @@ Item {
Binding on discoveryUrl {
when: shouldRun && Component.completed
- value: "opc.tcp://127.0.0.1:43344"
+ value: OPCUA_DISCOVERY_URL
}
}
diff --git a/tests/auto/declarative/DiscoveryTest.qml b/tests/auto/declarative/DiscoveryTest.qml
index ba1def3..361a135 100644
--- a/tests/auto/declarative/DiscoveryTest.qml
+++ b/tests/auto/declarative/DiscoveryTest.qml
@@ -131,7 +131,7 @@ Item {
function test_nodeTest() {
compare(myServers1.count, 0);
- myServers1.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ myServers1.discoveryUrl = OPCUA_DISCOVERY_URL;
serversStatusSpy1.wait();
compare(myServers1.status.status, QtOpcUa.Status.GoodCompletesAsynchronously);
@@ -242,7 +242,7 @@ Item {
function test_nodeTest() {
compare(myServers2.count, 0);
- myServers2.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ myServers2.discoveryUrl = OPCUA_DISCOVERY_URL;
serversStatusSpy2.wait();
compare(myServers2.status.status, QtOpcUa.Status.GoodCompletesAsynchronously);
diff --git a/tests/auto/declarative/MethodnodeTest.qml b/tests/auto/declarative/MethodnodeTest.qml
index fcf29e7..918f85a 100644
--- a/tests/auto/declarative/MethodnodeTest.qml
+++ b/tests/auto/declarative/MethodnodeTest.qml
@@ -79,7 +79,7 @@ Item {
if (children[i].objectName == "TestCase")
availableTestCases += 1;
}
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
}
CompletionLoggingTestCase {
diff --git a/tests/auto/declarative/RelativenodeTest.qml b/tests/auto/declarative/RelativenodeTest.qml
index f725fcb..69ba3ed 100644
--- a/tests/auto/declarative/RelativenodeTest.qml
+++ b/tests/auto/declarative/RelativenodeTest.qml
@@ -79,7 +79,7 @@ Item {
if (children[i].objectName == "TestCase")
availableTestCases += 1;
}
- serverDiscovery.discoveryUrl = "opc.tcp://127.0.0.1:43344";
+ serverDiscovery.discoveryUrl = OPCUA_DISCOVERY_URL;
}
CompletionLoggingTestCase {
diff --git a/tests/auto/declarative/SubscriptionsTest.qml b/tests/auto/declarative/SubscriptionsTest.qml
index b63670d..cad8ff5 100644
--- a/tests/auto/declarative/SubscriptionsTest.qml
+++ b/tests/auto/declarative/SubscriptionsTest.qml
@@ -66,7 +66,7 @@ Item {
Binding on discoveryUrl {
when: shouldRun && Component.completed
- value: "opc.tcp://127.0.0.1:43344"
+ value: OPCUA_DISCOVERY_URL
}
}
diff --git a/tests/auto/declarative/tst_opcua.cpp b/tests/auto/declarative/tst_opcua.cpp
index 893a8c6..2fc387d 100644
--- a/tests/auto/declarative/tst_opcua.cpp
+++ b/tests/auto/declarative/tst_opcua.cpp
@@ -107,8 +107,9 @@ public slots:
// Let the server come up
QTest::qSleep(2000);
}
- QString host = envOrDefault("OPCUA_HOST", defaultHost.toString());
- QString port = envOrDefault("OPCUA_PORT", QString::number(defaultPort));
+ const QString host = envOrDefault("OPCUA_HOST", defaultHost.toString());
+ const QString port = envOrDefault("OPCUA_PORT", QString::number(defaultPort));
+ m_opcuaDiscoveryUrl = QString::fromLatin1("opc.tcp://%1:%2").arg(host).arg(port);
}
void qmlEngineAvailable(QQmlEngine *engine) {
bool value = false;
@@ -116,6 +117,7 @@ public slots:
value = true;
#endif
engine->rootContext()->setContextProperty("SERVER_SUPPORTS_SECURITY", value);
+ engine->rootContext()->setContextProperty("OPCUA_DISCOVERY_URL", m_opcuaDiscoveryUrl);
}
void cleanupTestCase() {
if (m_serverProcess.state() == QProcess::Running) {
@@ -126,6 +128,7 @@ public slots:
private:
QProcess m_serverProcess;
QString m_testServerPath;
+ QString m_opcuaDiscoveryUrl;
};
QUICK_TEST_MAIN_WITH_SETUP(opcua, SetupClass)