summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2018-02-09 13:35:46 +0100
committerFrank Meerkoetter <frank.meerkoetter@basyskom.com>2018-02-23 11:05:57 +0000
commitcca7cbb039896e2757ed7e29661f7f11ace35534 (patch)
tree72672d5446217b5694bd8201360696010994166b /tests
parente453beb64d0a6c03ea530312668fc7f60fe942fc (diff)
Add helper functions for node id generation
These helper functions generate a node id string from a namespace index and a string, integer, guid or byte string. This makes the usage of namespace indices acquired at runtime easier. Change-Id: I02c69b091dd2323aafa54bcc782a5b319c574ffc Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qopcuaclient/tst_client.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index 6e21fa4..3366f53 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -208,6 +208,8 @@ private slots:
void methodCallInvalid();
defineDataMethod(malformedNodeString_data)
void malformedNodeString();
+ defineDataMethod(nodeIdGeneration_data)
+ void nodeIdGeneration();
void multipleClients();
defineDataMethod(nodeClass_data)
@@ -803,6 +805,18 @@ void Tst_QOpcUaClient::malformedNodeString()
QVERIFY(invalidNode == 0);
}
+void Tst_QOpcUaClient::nodeIdGeneration()
+{
+ QString nodeId = QOpcUa::nodeIdFromString(1, QStringLiteral("TestString"));
+ QCOMPARE(nodeId, QStringLiteral("ns=1;s=TestString"));
+ nodeId = QOpcUa::nodeIdFromInteger(1, 10);
+ QCOMPARE(nodeId, QStringLiteral("ns=1;i=10"));
+ nodeId = QOpcUa::nodeIdFromGuid(1, QUuid("08081e75-8e5e-319b-954f-f3a7613dc29b"));
+ QCOMPARE(nodeId, QStringLiteral("ns=1;g=08081e75-8e5e-319b-954f-f3a7613dc29b"));
+ nodeId = QOpcUa::nodeIdFromByteString(1, QByteArray::fromBase64("UXQgZnR3IQ=="));
+ QCOMPARE(nodeId, QStringLiteral("ns=1;b=UXQgZnR3IQ=="));
+}
+
void Tst_QOpcUaClient::multipleClients()
{
QScopedPointer<QOpcUaClient> a(m_opcUa.createClient(m_backends[0]));
@@ -1851,8 +1865,7 @@ void Tst_QOpcUaClient::namespaceArray()
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));
+ QScopedPointer<QOpcUaNode> node(opcuaClient->node(QOpcUa::nodeIdFromString(nsIndex, QStringLiteral("Demo.Static.Scalar.String"))));
READ_MANDATORY_BASE_NODE(node);
QCOMPARE(node->attribute(QOpcUa::NodeAttribute::DisplayName).value<QOpcUa::QLocalizedText>().text, "ns=2;s=Demo.Static.Scalar.String");