Tests: Add OPC-UA server browsing and veriable picking UI test. wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Thu, 10 Nov 2022 19:41:31 +0100
branchwxPython4
changeset 3672 230c8b90f3dc
parent 3671 973a7681f206
child 3673 6a04e7a90ceb
Tests: Add OPC-UA server browsing and veriable picking UI test.
tests/ide_tests/opcua_browse.sikuli/opcua_browse.py
tests/ide_tests/opcua_browse.sikuli/opcua_browse_server.png
tests/ide_tests/opcua_browse.sikuli/opcua_node.png
tests/ide_tests/opcua_browse.sikuli/opcua_service.bash
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ide_tests/opcua_browse.sikuli/opcua_browse.py	Thu Nov 10 19:41:31 2022 +0100
@@ -0,0 +1,67 @@
+""" This test opens, modifies, builds and runs exemple project named "python".
+Test succeeds if runtime's stdout behaves as expected
+"""
+
+import os
+import time
+
+# allow module import from current test directory's parent
+addImportPath(os.path.dirname(getBundlePath()))
+
+# common test definitions module
+from sikuliberemiz import run_test, AuxiliaryProcess
+
+def test(app):
+
+    server = AuxiliaryProcess(app, ["/bin/bash",os.path.join(getBundlePath(),"opcua_service.bash")])
+    #server = AuxiliaryProcess(app, ["/bin/bash","-c","echo $PWD"])
+
+    app.doubleClick("opcua_node.png")
+
+    app.WaitIdleUI()
+
+    # app.click("Browse Server") # OCR didn't work because of gradient in button...
+    app.click("opcua_browse_server.png")
+
+    app.WaitIdleUI()
+
+    app.doubleClick("Objects")
+
+    app.WaitIdleUI()
+
+    app.doubleClick("TestObject")
+
+    app.dragNdrop("TestIn", "output variables")
+
+    app.wait(1)
+
+    app.dragNdrop("TestOut", "input variables")
+
+    app.wait(3)
+
+    app.k.Clean()
+
+    app.waitForChangeAndIdleStdout()
+
+    app.k.Build()
+
+    app.waitForChangeAndIdleStdout()
+
+    app.k.Connect()
+
+    app.waitForChangeAndIdleStdout()
+
+    app.k.Transfer()
+
+    app.waitForChangeAndIdleStdout()
+
+    app.k.Run()
+
+    # wait 10 seconds for 10 patterns
+    res = app.waitPatternInStdout("6.8", 10)
+
+    server.close()
+
+    return res
+
+run_test(test, testproject="opcua_browse")
Binary file tests/ide_tests/opcua_browse.sikuli/opcua_browse_server.png has changed
Binary file tests/ide_tests/opcua_browse.sikuli/opcua_node.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ide_tests/opcua_browse.sikuli/opcua_service.bash	Thu Nov 10 19:41:31 2022 +0100
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+echo "Instant OPC-UA server for test"
+
+# Run server
+exec $BEREMIZPYTHONPATH - << EOF
+
+import sys
+import time
+
+from opcua import ua, Server
+
+server = Server()
+server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+
+uri = "http://beremiz.github.io"
+idx = server.register_namespace(uri)
+
+objects = server.get_objects_node()
+
+testobj = objects.add_object(idx, "TestObject")
+testvarout = testobj.add_variable(idx, "TestOut", 1.2)
+testvar = testobj.add_variable(idx, "TestIn", 5.6)
+testvar.set_writable()
+
+server.start()
+
+try:
+    while True:
+        time.sleep(1)
+        inval=testvar.get_value()
+        print inval
+        testvarout.set_value(inval*2)
+        sys.stdout.flush()
+finally:
+    server.stop()
+EOF