--- a/tests/ide_tests/edit_project.sikuli/edit_project.py Tue Mar 29 08:50:01 2022 +0200
+++ b/tests/ide_tests/edit_project.sikuli/edit_project.py Thu Apr 07 07:40:32 2022 +0200
@@ -9,62 +9,55 @@
addImportPath(os.path.dirname(getBundlePath()))
# common test definitions module
-from sikuliberemiz import *
+from sikuliberemiz import run_test
-app = BeremizApp(exemple="python")
+ app.doubleClick("1646062660770.png") -app.doubleClick("1646062660770.png")
-app.type(Key.DOWN * 10, Key.CTRL)
+ app.type(Key.DOWN * 10, Key.CTRL) -app.doubleClick("1646066996620.png")
+ app.doubleClick("1646066996620.png") -app.type(Key.TAB*3) # select text content
-app.type("'sys.stdout.write(\"EDIT TEST OK\\n\")'")
+ app.type(Key.TAB*3) # select text content
+ app.type("'sys.stdout.write(\"EDIT TEST OK\\n\")'")
-app.waitForChangeAndIdleStdout()
-app.waitForChangeAndIdleStdout()
+ app.waitForChangeAndIdleStdout()
-app.waitForChangeAndIdleStdout()
+ app.waitForChangeAndIdleStdout()
-app.waitForChangeAndIdleStdout()
+ app.waitForChangeAndIdleStdout()
-# wait 10 seconds for 10 patterns
-found = app.waitPatternInStdout("EDIT TEST OK", 10)
+ app.waitForChangeAndIdleStdout()
+ # wait 10 seconds for 10 patterns + return app.waitPatternInStdout("EDIT TEST OK", 10) +run_test(test, exemple="python") --- a/tests/ide_tests/new_project.sikuli/new_project.py Tue Mar 29 08:50:01 2022 +0200
+++ b/tests/ide_tests/new_project.sikuli/new_project.py Thu Apr 07 07:40:32 2022 +0200
@@ -11,128 +11,122 @@
# common test definitions module
from sikuliberemiz import *
-# Start the app without any project given
-new_project_path = os.path.join(os.path.abspath(os.path.curdir), "new_test_project")
-# New project path must exist (usually created in directory selection dialog)
-os.mkdir(new_project_path)
-# Create new project (opens new project directory selection dialog)
-# Move to "Home" section of file selecor, otherwise address is
-# "file ignored" at first run
-# Enter directory by name
-app.type(new_project_path + Key.ENTER)
-# When prompted for creating first program select type ST
-app.type(Key.TAB*4) # go to lang dropdown
-app.type(Key.DOWN*2) # change selected language
-app.type(Key.ENTER) # validate
-app.type("Test program")
-# Focus on Variable grid
-{printf("Test OK\\n");fflush(stdout);}
+ new_project_path = os.path.join(os.path.abspath(os.path.curdir), "new_test_project") + # New project path must exist (usually created in directory selection dialog) + os.mkdir(new_project_path) + # Create new project (opens new project directory selection dialog) + # Move to "Home" section of file selecor, otherwise address is + # "file ignored" at first run + app.type("f", Key.CTRL) + # Enter directory by name + app.type(new_project_path + Key.ENTER) + # When prompted for creating first program select type ST + app.type(Key.TAB*4) # go to lang dropdown + app.type(Key.DOWN*2) # change selected language + app.type(Key.ENTER) # validate + app.type("Test program") + # Focus on Variable grid + LocalVar0 := LocalVar1; + {printf("Test OK\\n");fflush(stdout);} + app.type("w", Key.CTRL) + # Focus project tree and select root item + # FIXME: Select other field to ensure URI is validated + # Close project config editor + app.type("w", Key.CTRL) + # Focus seems undefined at that time (FIXME) + # Force focussing on "something" so that next shortcut is taken + app.waitIdleStdout(5,30) + return app.waitPatternInStdout("Test OK", 10)
-# Focus project tree and select root item
-# FIXME: Select other field to ensure URI is validated
-# Close project config editor
-# Focus seems undefined at that time (FIXME)
-# Force focussing on "something" so that next shortcut is taken
-app.waitIdleStdout(5,30)
-found = app.waitPatternInStdout("Test OK", 10)
--- a/tests/ide_tests/run_python_exemple.sikuli/run_python_exemple.py Tue Mar 29 08:50:01 2022 +0200
+++ b/tests/ide_tests/run_python_exemple.sikuli/run_python_exemple.py Thu Apr 07 07:40:32 2022 +0200
@@ -11,34 +11,29 @@
# common test definitions module
from sikuliberemiz import *
-app = BeremizApp(exemple="python")
-app.waitForChangeAndIdleStdout()
-app.waitForChangeAndIdleStdout()
-app.waitForChangeAndIdleStdout()
+ app.waitForChangeAndIdleStdout() + app.waitForChangeAndIdleStdout() + app.waitForChangeAndIdleStdout() + app.waitForChangeAndIdleStdout() + # wait 10 seconds for 10 Grumpfs + return app.waitPatternInStdout("Grumpf", 10, 10) +run_test(test, exemple="python")
-app.waitForChangeAndIdleStdout()
-# wait 10 seconds for 10 Grumpfs
-found = app.waitPatternInStdout("Grumpf", 10, 10)
--- a/tests/ide_tests/sikuliberemiz.py Tue Mar 29 08:50:01 2022 +0200
+++ b/tests/ide_tests/sikuliberemiz.py Thu Apr 07 07:40:32 2022 +0200
@@ -3,6 +3,7 @@
from threading import Thread, Event, Lock
from time import time as timesec
@@ -33,17 +34,17 @@
"Address": ("l",sikuli.Key.CTRL)} # to reach address bar in GTK's file selector
- self.app = app.sikuliapp
def __getattr__(self, name):
+ self.app.sikuliapp.focus() + self.app.ReportText("Sending " + name + " shortcut") @@ -86,6 +87,8 @@
+ self.ReportScreenShot("UI is idle" if c != 0 else "UI is not idle") raise Exception("Window did not idle before timeout")
@@ -113,6 +116,7 @@
if len(a) == 0 or a is None:
if self.pattern is not None and a.find(self.pattern) >= 0:
sys.stdout.write("found pattern in '" + a +"'")
@@ -126,7 +130,11 @@
- if self.event.wait(timeout):
+ wait_result = self.event.wait(timeout) + self.ReportScreenShot("stdout changed" if wait_result else "stdout didn't change") raise Exception("Stdout didn't become active before timeout")
@@ -148,8 +156,11 @@
# timeout -> no event -> idle -> exit
+ self.ReportScreenShot("stdout is idle") + self.ReportScreenShot("stdout did not idle") raise Exception("Stdout did not idle before timeout")
def waitPatternInStdout(self, pattern, timeout, count=1):
@@ -170,6 +181,7 @@
+ self.ReportScreenShot("found pattern" if res else "pattern not found") class BeremizApp(IDEIdleObserver, stdoutIdleObserver):
@@ -185,6 +197,21 @@
Sikuli App class instance
+ self.starttime = timesec() + self.screen = sikuli.Screen() + self.report = open("report.html", "w") + self.report.write("""<!doctype html> + <meta name="color-scheme" content="light dark"> + <title>Test report</title> command = [python_bin, opj(beremiz_path,"Beremiz.py"), "--log=/dev/stdout"]
@@ -198,6 +225,8 @@
# - use wmctrl to find IDE window details and maximize it
# - pass exact window title to App class constructor
+ self.ReportText("Launching " + repr(command)) self.proc = subprocess.Popen(command, stdout=subprocess.PIPE, bufsize=0)
# Window are macthed against process' PID
@@ -236,12 +265,21 @@
stdoutIdleObserver.__init__(self)
# stubs for common sikuli calls to allow adding hooks later
- for n in ["click","doubleClick","type"]:
- setattr(self, n, getattr(sikuli, n))
+ for name in ["click","doubleClick","type"]: + def myMeth(*args, **kwargs): + getattr(sikuli, n)(*args, **kwargs) + self.ReportScreenShot(n + "(" + repr(args) + "," + repr(kwargs) + ")") + setattr(self, name, makeMyMeth(name)) if self.sikuliapp is not None:
@@ -249,3 +287,44 @@
IDEIdleObserver.__del__(self)
stdoutIdleObserver.__del__(self)
+ def ReportScreenShot(self, msg): + elapsed = "%.3fs: "%(timesec() - self.starttime) + fname = "capture"+str(self.screenshotnum)+".png" + cap = self.screen.capture(self.r) + # self.report.write("ReportScreenShot " + msg + " " + fname + "\n") + self.screenshotnum = self.screenshotnum + 1 + self.report.write( "<p>" + elapsed + msg + "<img src=\""+ fname + "\">" + "</p>") + def ReportText(self, text): + elapsed = "%.3fs: "%(timesec() - self.starttime) + self.report.write("<p>" + elapsed + text + "</p>") + def ReportOutput(self, text): + elapsed = "%.3fs: "%(timesec() - self.starttime) + self.report.write("<pre>" + elapsed + text + "</pre>") +def run_test(func, *args, **kwargs): + app = BeremizApp(*args, **kwargs) + # sadly, sys.excepthook is broken in sikuli/jython + # purpose of this run_test function is to work around it. + # and catch exception cleanly anyhow + e_type, e_value, e_traceback = sys.exc_info() + err_msg = "\n".join(traceback.format_exception(e_type, e_value, e_traceback)) + sys.stdout.write(err_msg) + app.ReportOutput(err_msg)