tests: add (broken) debug_project test, fix edit_project wxPython4
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 04 Jul 2022 08:44:23 +0200
branchwxPython4
changeset 3528 c269f256a7c4
parent 3527 fbe924df437b
child 3529 b9737bb5f92a
tests: add (broken) debug_project test, fix edit_project
exemples/python/plc.xml
tests/ide_tests/debug_project.sikuli/1646062660770.png
tests/ide_tests/debug_project.sikuli/debug_project.py
tests/ide_tests/edit_project.sikuli/edit_project.py
tests/ide_tests/sikuliberemiz.py
--- a/exemples/python/plc.xml	Mon Jul 04 08:35:47 2022 +0200
+++ b/exemples/python/plc.xml	Mon Jul 04 08:44:23 2022 +0200
@@ -1,7 +1,7 @@
 <?xml version='1.0' encoding='utf-8'?>
 <project xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
   <fileHeader companyName="" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:21:19" contentDescription="This example shows many features in Beremiz:&#10;&#10;   1. How to implement python extensions.&#10;   2. How to implement basic C extension.&#10;   3. How to use C code in IEC POUs.&#10;   4. How to call C functions from python code.&#10;   5. How to avoid race conditions between IEC, C and python code.&#10;   6. How to convert betweet different IEC types.&#10;"/>
-  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2020-10-19T23:53:08">
+  <contentHeader name="Beremiz Python Support Tests" modificationDateTime="2022-07-03T16:04:31">
     <coordinateInfo>
       <pageSize x="1024" y="1024"/>
       <fbd>
@@ -269,12 +269,12 @@
         </interface>
         <body>
           <FBD>
-            <inVariable localId="4" height="30" width="160" executionOrderId="0" negated="false">
-              <position x="295" y="450"/>
-              <connectionPointOut>
-                <relPosition x="160" y="15"/>
-              </connectionPointOut>
-              <expression>'666'</expression>
+            <inVariable localId="4" height="30" width="315" executionOrderId="0" negated="false">
+              <position x="200" y="390"/>
+              <connectionPointOut>
+                <relPosition x="315" y="15"/>
+              </connectionPointOut>
+              <expression>'sys.stdout.write("Hello world\n")'</expression>
             </inVariable>
             <block localId="5" width="125" height="80" typeName="python_eval" instanceName="py1" executionOrderId="0">
               <position x="686" y="400"/>
@@ -293,9 +293,11 @@
                 <variable formalParameter="CODE">
                   <connectionPointIn>
                     <relPosition x="0" y="65"/>
-                    <connection refLocalId="4">
+                    <connection refLocalId="80" formalParameter="OUT">
                       <position x="686" y="465"/>
-                      <position x="455" y="465"/>
+                      <position x="653" y="465"/>
+                      <position x="653" y="485"/>
+                      <position x="630" y="485"/>
                     </connection>
                   </connectionPointIn>
                 </variable>
@@ -739,12 +741,6 @@
 Happy hacking! ]]></xhtml:p>
               </content>
             </comment>
-            <comment localId="31" height="90" width="345">
-              <position x="295" y="485"/>
-              <content>
-                <xhtml:p><![CDATA[Sleep here is bad. It blocks other py_eval instances. Whith a wxGlade GUI, GUI freeze for a second.]]></xhtml:p>
-              </content>
-            </comment>
             <comment localId="6" height="80" width="345">
               <position x="295" y="630"/>
               <content>
@@ -1443,10 +1439,10 @@
               </connectionPointIn>
               <expression>Test_Python_Var</expression>
             </outVariable>
-            <inVariable localId="79" executionOrderId="0" height="25" width="30" negated="false">
+            <inVariable localId="79" executionOrderId="0" height="27" width="30" negated="false">
               <position x="560" y="1340"/>
               <connectionPointOut>
-                <relPosition x="30" y="10"/>
+                <relPosition x="30" y="15"/>
               </connectionPointOut>
               <expression>23</expression>
             </inVariable>
@@ -1464,6 +1460,44 @@
               </connectionPointOut>
               <expression>SomeVarName</expression>
             </inOutVariable>
+            <block localId="80" typeName="MOVE" executionOrderId="0" height="40" width="60">
+              <position x="570" y="455"/>
+              <inputVariables>
+                <variable formalParameter="IN">
+                  <connectionPointIn>
+                    <relPosition x="0" y="30"/>
+                    <connection refLocalId="82">
+                      <position x="578" y="485"/>
+                      <position x="532" y="485"/>
+                    </connection>
+                  </connectionPointIn>
+                </variable>
+              </inputVariables>
+              <inOutVariables/>
+              <outputVariables>
+                <variable formalParameter="OUT">
+                  <connectionPointOut>
+                    <relPosition x="60" y="30"/>
+                  </connectionPointOut>
+                </variable>
+              </outputVariables>
+            </block>
+            <connector name="Connection0" localId="81" height="30" width="130">
+              <position x="545" y="390"/>
+              <connectionPointIn>
+                <relPosition x="0" y="15"/>
+                <connection refLocalId="4">
+                  <position x="545" y="405"/>
+                  <position x="515" y="405"/>
+                </connection>
+              </connectionPointIn>
+            </connector>
+            <continuation name="Connection0" localId="82" height="30" width="130">
+              <position x="410" y="470"/>
+              <connectionPointOut>
+                <relPosition x="130" y="15"/>
+              </connectionPointOut>
+            </continuation>
           </FBD>
         </body>
       </pou>
Binary file tests/ide_tests/debug_project.sikuli/1646062660770.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/ide_tests/debug_project.sikuli/debug_project.py	Mon Jul 04 08:44:23 2022 +0200
@@ -0,0 +1,68 @@
+""" 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
+
+def test(app):
+
+    app.k.Clean()
+    
+    app.waitForChangeAndIdleStdout()
+    
+    app.k.Build()
+    
+    app.waitForChangeAndIdleStdout()
+    
+    app.k.Connect()
+    
+    app.waitForChangeAndIdleStdout()
+    
+    app.k.Transfer()
+    
+    app.waitForChangeAndIdleStdout()
+    
+    app.click("1646062660770.png")
+
+    app.WaitIdleUI()
+    
+    app.click("1646066996789.png")
+
+    app.WaitIdleUI()
+
+    app.click("example")
+
+    app.WaitIdleUI()
+
+    app.type(Key.DOWN * 10, Key.CTRL)
+
+    app.WaitIdleUI()
+
+    app.k.Run()
+
+    # wait up to 10 seconds for 10 Grumpfs
+    app.waitPatternInStdout("Grumpf", 10, 10)
+
+    app.rightClick("1646066996790.png")
+
+    app.wait("Force",10)
+    
+    app.click("Force")
+
+    app.k.SelectAll()
+
+    app.type("'sys.stdout.write(\"DEBUG TEST OK\\n\")'")
+
+    app.type(Key.ENTER)
+    
+    # wait 10 seconds for 10 patterns
+    return app.waitPatternInStdout("DEBUG TEST OK", 10)
+
+run_test(test, exemple="python")
--- a/tests/ide_tests/edit_project.sikuli/edit_project.py	Mon Jul 04 08:35:47 2022 +0200
+++ b/tests/ide_tests/edit_project.sikuli/edit_project.py	Mon Jul 04 08:44:23 2022 +0200
@@ -25,7 +25,7 @@
 
     app.WaitIdleUI()
 
-    app.doubleClick("1646066996620.png")
+    app.doubleClick("Hello world")
 
     app.WaitIdleUI()
 
--- a/tests/ide_tests/sikuliberemiz.py	Mon Jul 04 08:35:47 2022 +0200
+++ b/tests/ide_tests/sikuliberemiz.py	Mon Jul 04 08:44:23 2022 +0200
@@ -29,6 +29,7 @@
              "Connect":  sikuli.Key.F7,
              "Clean":    sikuli.Key.F9,
              "Build":    sikuli.Key.F11,
+             "SelectAll":("a",sikuli.Key.CTRL),
              "Save":     ("s",sikuli.Key.CTRL),
              "New":      ("n",sikuli.Key.CTRL),
              "Address":  ("l",sikuli.Key.CTRL)}  # to reach address bar in GTK's file selector
@@ -110,6 +111,9 @@
 
         self.thread = Thread(target = self._waitStdoutProc).start()
 
+    def __del__(self):
+        pass  # self.thread.join() ?
+
     def _waitStdoutProc(self):
         while True:
             a = self.proc.stdout.readline()
@@ -265,11 +269,11 @@
         stdoutIdleObserver.__init__(self)
 
         # stubs for common sikuli calls to allow adding hooks later
-        for name in ["click","doubleClick","type"]:
+        for name in ["click","doubleClick","type","rightClick","wait"]:
             def makeMyMeth(n):
                 def myMeth(*args, **kwargs):
+                    self.ReportScreenShot(n + "(" + repr(args) + "," + repr(kwargs) + ")")
                     getattr(sikuli, n)(*args, **kwargs)
-                    self.ReportScreenShot(n + "(" + repr(args) + "," + repr(kwargs) + ")")
                 return myMeth
             setattr(self, name, makeMyMeth(name))