--- a/BeremizIDE.py Mon Feb 28 21:53:14 2022 +0100
+++ b/BeremizIDE.py Sat Mar 05 11:14:00 2022 +0100
@@ -136,6 +136,7 @@
def write(self, s, style=None):
if self.logf is not None:
self.stack.append((s, style))
--- a/tests/ide_tests/edit_project.sikuli/edit_project.py Mon Feb 28 21:53:14 2022 +0100
+++ b/tests/ide_tests/edit_project.sikuli/edit_project.py Sat Mar 05 11:14:00 2022 +0100
@@ -15,46 +15,55 @@
proc,app = StartBeremizApp(exemple="python")
# To detect when actions did finish because IDE content isn't changing
-# idle = IDEIdleObserver(app)
-# screencap based idle detection was making many false positive. Test is more stable with stdout based idle detection
+idle = IDEIdleObserver(app) doubleClick("1646062660770.png")
click("1646066794902.png")
type(Key.DOWN * 10, Key.CTRL)
doubleClick("1646066996620.png")
type(Key.TAB*3) # select text content
-type("'sys.stdout.write(\"EDIT TEST OK\")'")
+type("'sys.stdout.write(\"EDIT TEST OK\\n\")'") stdoutIdle = stdoutIdleObserver(proc)
-# To send keyboard shortuts
+stdoutIdle.WaitForChangeAndIdle(2,15)
+stdoutIdle.WaitForChangeAndIdle(2,15)
+stdoutIdle.WaitForChangeAndIdle(2,15)
+stdoutIdle.WaitForChangeAndIdle(2,15) --- a/tests/ide_tests/sikuliberemiz.py Mon Feb 28 21:53:14 2022 +0100
+++ b/tests/ide_tests/sikuliberemiz.py Sat Mar 05 11:14:00 2022 +0100
@@ -4,6 +4,7 @@
from threading import Thread, Event
+from time import time as timesec @@ -142,7 +143,7 @@
period (int): how many seconds with no change to consider idle
timeout (int): how long to wait for idle, in seconds
+ c = max(timeout/period,1) @@ -165,15 +166,37 @@
self.stdoutchanged = False
+ self.last_change_count = 0 self.thread = Thread(target = self._waitStdoutProc).start()
def _waitStdoutProc(self):
- a = self.proc.stdout.read(1)
+ a = self.proc.stdout.readline() if len(a) == 0 or a is None:
+ self.changes = self.changes + 1 + def WaitForChangeAndIdle(self, period, timeout): + Wait for IDE'stdout to start changing + timeout (int): how long to wait for change, in seconds + if self.changes == self.last_change_count: + if self.event.wait(timeout): + self.last_change_count = self.changes + raise Exception("Stdout didn't become active before timeout") + self.Wait(period, timeout - (timesec() - start_time)) def Wait(self, period, timeout):
@@ -182,11 +205,12 @@
period (int): how many seconds with no change to consider idle
timeout (int): how long to wait for idle, in seconds
+ c = max(timeout/period, 1) - self.idechanged = False
- if not self.idechanged:
+ if self.changes == changes: + self.last_change_count = self.changes @@ -204,8 +228,9 @@
a = proc.stdout.readline()
if len(a) == 0 or a is None:
raise Exception("App finished before producing expected stdout pattern")
+ sys.stdout.write("found pattern in '" + a +"'")