This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eo-api-finalize
in repository ego.
View the commit online.
commit 40913827d93cf5389449026fea1901975ba442fc
Author: Cedric Bail <[email protected]>
AuthorDate: Thu Nov 26 12:01:19 2026 -0600
tests: a rendered frame no longer depends on how busy the machine is
Three tests of efl/ui failed when the machine was loaded: with 24
copies of the package's tests running at once, 93% of the runs
failed, and none of 72 does now.
RenderWindow drew whatever the canvas held. A widget shows its text
when its theme receives a signal, which Edje queues and handles in
a job before EFL draws a frame; a test that rendered before the
loop reached that job got a button, a check or a radio without
its text. RenderWindow now handles the queued signals first, as a
frame does.
The scroller fades the shadows at its edges out over a quarter of
a second as it appears, and its golden had recorded the frame 2 ms
into that. RenderSettled renders until the window stops changing,
and the golden is now that frame: the same picture without the
shadow at the bottom edge.
A paste is delivered by a future, a turn of the loop after it was
asked for; the form test now waits for it.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
efl/ui/form_example_test.go | 7 +++++-
efl/ui/scroller_example_test.go | 9 ++++---
efl/ui/testdata/scroller_default.png | Bin 1656 -> 1395 bytes
tests/harness/harness.go | 45 +++++++++++++++++++++++++++++++++++
4 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/efl/ui/form_example_test.go b/efl/ui/form_example_test.go
index 0e626810..0e9771d6 100644
--- a/efl/ui/form_example_test.go
+++ b/efl/ui/form_example_test.go
@@ -4,6 +4,7 @@ import (
"image"
"strings"
"testing"
+ "time"
"git.enlightenment.org/cedric/ego/efl"
"git.enlightenment.org/cedric/ego/efl/text_cursor"
@@ -163,7 +164,11 @@ func TestFormAgeDropsAZeroPastedOverTheSelection(t *testing.T) {
age.AllSelect()
age.SelectionPaste()
})
- assert.Equal(t, "", efl.SyncWithReturn(age.Text), "a pasted zero should not lead")
+ // The selection is handed over by a future, a turn of the loop or more
+ // after the paste was asked for.
+ harness.WaitFor(t, mainWindow, 5*time.Second, "the pasted zero to be dropped", func() bool {
+ return age.Text() == ""
+ })
}
// TestFormAgeRejectsLetters covers the accept set, and
diff --git a/efl/ui/scroller_example_test.go b/efl/ui/scroller_example_test.go
index 6e2ef792..aa4b8a9d 100644
--- a/efl/ui/scroller_example_test.go
+++ b/efl/ui/scroller_example_test.go
@@ -3,6 +3,7 @@ package ui_test
import (
"image"
"testing"
+ "time"
"git.enlightenment.org/cedric/ego/efl"
"git.enlightenment.org/cedric/ego/efl/ui"
@@ -63,11 +64,9 @@ func TestScrollerScreenshot(t *testing.T) {
require.NotNil(t, viewport, "Scroller should be created")
defer efl.Sync(func() { viewport.Unref() })
- var img image.Image
- efl.Sync(func() {
- img = harness.RenderWindow(mainWindow)
- })
- require.NotNil(t, img, "render should return an image")
+ // The shadows at a scroller's edges fade out as it appears.
+ img := harness.RenderSettled(mainWindow, 5*time.Second)
+ require.NotNil(t, img, "the scroller should stop changing")
assert.Tolerance = 2
defer func() { assert.Tolerance = 0 }()
diff --git a/efl/ui/testdata/scroller_default.png b/efl/ui/testdata/scroller_default.png
index 8b706689..9049e39a 100644
Binary files a/efl/ui/testdata/scroller_default.png and b/efl/ui/testdata/scroller_default.png differ
diff --git a/tests/harness/harness.go b/tests/harness/harness.go
index 4d9b733e..4773369f 100644
--- a/tests/harness/harness.go
+++ b/tests/harness/harness.go
@@ -27,6 +27,7 @@ static void _harness_focus(Eo *obj) {
import "C"
import (
+ "bytes"
"fmt"
"image"
"os"
@@ -230,6 +231,11 @@ func RenderWindow(obj efl.Objecter) image.Image {
C.ecore_evas_geometry_get(ee, nil, nil, &cw, &ch)
w, h := int(cw), int(ch)
+ // A frame EFL draws by itself comes after the signals a widget sent its
+ // theme have been handled -- the one showing a button's text among them:
+ // the job of edje_message_queue.c runs before the render. A test may
+ // render before the loop got to it.
+ C.edje_message_signal_process()
C.ecore_evas_manual_render(ee)
return renderEE(ee, w, h)
}
@@ -310,6 +316,45 @@ func RenderUntil(obj efl.Objecter, done func() bool, timeout time.Duration) bool
}
}
+// RenderSettled renders the window obj belongs to until it has not changed
+// for 40 ms -- three frames 20 ms apart come out the same -- and returns
+// that frame; nil if the window cannot be rendered, or is still changing
+// when timeout has passed. An animation that only starts after a delay is
+// not waited for.
+//
+// It is for a screenshot of a widget whose theme animates as it appears --
+// a scroller fades the shadow at its edges out over a quarter of a second --
+// where a single render records whichever moment of the animation the
+// machine happened to reach. It must be called off the EFL thread, as
+// RenderUntil must.
+func RenderSettled(obj efl.Objecter, timeout time.Duration) image.Image {
+ if efl.InLoop() {
+ panic("harness: RenderSettled called on the EFL thread, which it would block; call it from the test")
+ }
+ deadline := time.Now().Add(timeout)
+ var last *image.NRGBA
+ same := 0
+ for {
+ frame, _ := efl.SyncWithReturn(func() image.Image { return RenderWindow(obj) }).(*image.NRGBA)
+ if frame == nil || frame.Rect.Empty() {
+ return nil
+ }
+ if last != nil && frame.Rect == last.Rect && bytes.Equal(frame.Pix, last.Pix) {
+ same++
+ } else {
+ same = 0
+ }
+ if same == 2 {
+ return frame
+ }
+ last = frame
+ if time.Now().After(deadline) {
+ return nil
+ }
+ time.Sleep(20 * time.Millisecond)
+ }
+}
+
// WaitFor renders obj's window until ok, which runs on the EFL thread,
// holds, and fails the test if it has not within timeout. what says, in the
// failure, what was being waited for. It is RenderUntil for a test:
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.