summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJannis Voelker <jannis.voelker@basyskom.com>2017-11-30 13:50:25 +0100
committerFrank Meerkoetter <frank.meerkoetter@basyskom.com>2018-01-05 19:30:22 +0000
commit836d17cbf51708fa495e72fdf4ddf5882ac5276b (patch)
tree48a0dd6c07412b495e4755f76cba7f79bcaa208d /tests
parent79683a43326edef794eab69f2f470375fe032a01 (diff)
Add async browse support
This is a replacement for the synchronous childrenIds(). browseChildren() allow filtering for node classes and reference type. It returns detailed information on the children. The filtering makes it possible to find properties of a node. The following information on every child node matching the criteria is returned: - Reference type - Node Id - BrowseName - DisplayName - NodeClass This information is sufficient to create a tree structure without having to read attributes from each child node. Change-Id: Id488ec430e393f1881de483c24d392b8cb607989 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.cpp39
1 files changed, 27 insertions, 12 deletions
diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp
index 1ea3897..da6b35b 100644
--- a/tests/auto/qopcuaclient/tst_client.cpp
+++ b/tests/auto/qopcuaclient/tst_client.cpp
@@ -515,9 +515,12 @@ void Tst_QOpcUaClient::getChildren()
QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=1;s=Large.Folder"));
QVERIFY(node != 0);
- READ_MANDATORY_BASE_NODE(node)
- QCOMPARE(node->attribute(QOpcUa::NodeAttribute::DisplayName).value<QOpcUa::QLocalizedText>().text, QLatin1String("Large_Folder"));
- QCOMPARE(node->childrenIds().size(), 1001);
+ QSignalSpy spy(node.data(), &QOpcUaNode::browseFinished);
+ node->browseChildren(QOpcUa::ReferenceTypeId::HierarchicalReferences, QOpcUa::NodeClass::Object);
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+ QVector<QOpcUaReferenceDescription> ref = spy.at(0).at(0).value<QVector<QOpcUaReferenceDescription>>();
+ QCOMPARE(ref.size(), 1001);
}
void Tst_QOpcUaClient::childrenIdsString()
@@ -527,9 +530,13 @@ void Tst_QOpcUaClient::childrenIdsString()
QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=3;s=testStringIdsFolder"));
QVERIFY(node != 0);
- QStringList childrenIds = node->childrenIds();
- QCOMPARE(childrenIds.size(), 1);
- QCOMPARE(childrenIds.at(0), "ns=3;s=theStringId");
+ QSignalSpy spy(node.data(), &QOpcUaNode::browseFinished);
+ node->browseChildren(QOpcUa::ReferenceTypeId::Organizes, QOpcUa::NodeClass::Variable);
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+ QVector<QOpcUaReferenceDescription> ref = spy.at(0).at(0).value<QVector<QOpcUaReferenceDescription>>();
+ QCOMPARE(ref.size(), 1);
+ QCOMPARE(ref.at(0).nodeId(), "ns=3;s=theStringId");
}
void Tst_QOpcUaClient::childrenIdsGuidNodeId()
@@ -539,9 +546,13 @@ void Tst_QOpcUaClient::childrenIdsGuidNodeId()
QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=3;s=testGuidIdsFolder"));
QVERIFY(node != 0);
- const QStringList childrenIds = node->childrenIds();
- QCOMPARE(childrenIds.size(), 1);
- QCOMPARE(childrenIds.at(0), "ns=3;g=08081e75-8e5e-319b-954f-f3a7613dc29b");
+ QSignalSpy spy(node.data(), &QOpcUaNode::browseFinished);
+ node->browseChildren(QOpcUa::ReferenceTypeId::Organizes, QOpcUa::NodeClass::Variable);
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+ QVector<QOpcUaReferenceDescription> ref = spy.at(0).at(0).value<QVector<QOpcUaReferenceDescription>>();
+ QCOMPARE(ref.size(), 1);
+ QCOMPARE(ref.at(0).nodeId(), "ns=3;g=08081e75-8e5e-319b-954f-f3a7613dc29b");
}
void Tst_QOpcUaClient::childrenIdsOpaqueNodeId()
@@ -551,9 +562,13 @@ void Tst_QOpcUaClient::childrenIdsOpaqueNodeId()
QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=3;s=testOpaqueIdsFolder"));
QVERIFY(node != 0);
- const QStringList childrenIds = node->childrenIds();
- QCOMPARE(childrenIds.size(), 1);
- QCOMPARE(childrenIds.at(0), "ns=3;b=UXQgZnR3IQ==");
+ QSignalSpy spy(node.data(), &QOpcUaNode::browseFinished);
+ node->browseChildren(QOpcUa::ReferenceTypeId::Organizes, QOpcUa::NodeClass::Variable);
+ spy.wait();
+ QCOMPARE(spy.size(), 1);
+ QVector<QOpcUaReferenceDescription> ref = spy.at(0).at(0).value<QVector<QOpcUaReferenceDescription>>();
+ QCOMPARE(ref.size(), 1);
+ QCOMPARE(ref.at(0).nodeId(), "ns=3;b=UXQgZnR3IQ==");
}
void Tst_QOpcUaClient::dataChangeSubscription()