summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2018-02-09 12:58:52 +0100
committerFrank Meerkoetter <frank.meerkoetter@basyskom.com>2018-02-15 10:44:05 +0000
commitc102a5f62859dbebcd01c80286a142ac795d45e8 (patch)
tree98aa234b4d4e25f53cb79949fbf05e5c588b4500 /tests
parent055e7ed9c9a5d20437c2a3ccb595ad2e96da6d1e (diff)
Give the user access to the namespace array
The index of an URI in the namespace array corresponds to the namespace index x needed for node ids in the "ns=x;i=1234"format. This patch adds methods to request and return the namespaces array from the server (value attribute of ns=0;i=2255). Change-Id: Ie3f0d264551941fd8dafe8b737eeb72ab058bfb7 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qopcuaclient/tst_client.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index 4fc3bcc..006d586 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -228,6 +228,9 @@ private slots:
defineDataMethod(stringCharset_data)
void stringCharset();
+ defineDataMethod(namespaceArray_data)
+ void namespaceArray();
+
// This test case restarts the server. It must be run last to avoid
// destroying state required by other test cases.
defineDataMethod(connectionLost_data)
@@ -1829,6 +1832,32 @@ void Tst_QOpcUaClient::stringCharset()
QVERIFY(result.toList()[1].value<QOpcUa::QLocalizedText>() == lt2);
}
+void Tst_QOpcUaClient::namespaceArray()
+{
+ QFETCH(QOpcUaClient *, opcuaClient);
+ OpcuaConnector connector(opcuaClient, m_endpoint);
+
+ QCOMPARE(opcuaClient->namespaceArray().size(), 0);
+
+ QSignalSpy spy(opcuaClient, &QOpcUaClient::namespaceArrayUpdated);
+ QCOMPARE(opcuaClient->updateNamespaceArray(), true);
+
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+
+ QStringList namespaces = opcuaClient->namespaceArray();
+ QVERIFY(namespaces.size() == 4);
+
+ int nsIndex = namespaces.indexOf("http://qt-project.org");
+ QVERIFY(nsIndex > 0);
+
+ QString nodeId = QStringLiteral("ns=%1;s=Demo.Static.Scalar.String").arg(nsIndex);
+ QScopedPointer<QOpcUaNode> node(opcuaClient->node(nodeId));
+ READ_MANDATORY_BASE_NODE(node);
+
+ QCOMPARE(node->attribute(QOpcUa::NodeAttribute::DisplayName).value<QOpcUa::QLocalizedText>().text, "ns=2;s=Demo.Static.Scalar.String");
+}
+
void Tst_QOpcUaClient::connectionLost()
{
// Restart the test server if necessary