Skip to content

Commit

Permalink
A different attempt to race test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Mar 7, 2025
1 parent 382f1ca commit 33a4732
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions internal/driver/glfw/menu_bar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestMenuBar(t *testing.T) {
menu := fyne.NewMainMenu(m1, m2, m3)

t.Run("mouse control and basic behaviour", func(t *testing.T) {
w := createWindow("menutest")
w := test.NewWindow(nil)
defer w.Close()
w.SetPadded(false)
w.Resize(fyne.NewSize(300, 300))
Expand All @@ -63,10 +63,10 @@ func TestMenuBar(t *testing.T) {
themeCounter++
})
container := container.NewWithoutLayout(button, menuBar)
w.SetContent(container)
w.Resize(fyne.NewSize(300, 300))

runOnMain(func() {
w.SetContent(container)
w.Resize(fyne.NewSize(300, 300))

button.Resize(button.MinSize())
button.Move(fyne.NewPos(100, 50))
menuBar.Resize(fyne.NewSize(300, 0).Max(menuBar.MinSize()))
Expand Down Expand Up @@ -298,7 +298,10 @@ func TestMenuBar(t *testing.T) {
t.Run(name, func(t *testing.T) {
test.MoveMouse(c, fyne.NewPos(0, 0))
test.TapCanvas(c, fyne.NewPos(0, 0))
capture := c.Capture()
var capture image.Image
runOnMain(func() {
capture = c.Capture()
})
if test.AssertImageMatches(t, "menu_bar_initial.png", capture) {
for i, s := range tt.steps {
t.Run("step "+strconv.Itoa(i+1), func(t *testing.T) {
Expand All @@ -312,7 +315,11 @@ func TestMenuBar(t *testing.T) {
test.TapCanvas(c, a.pos)
}
}
test.AssertImageMatches(t, s.wantImage, c.Capture())
var capture2 image.Image
runOnMain(func() {
capture2 = c.Capture()
})
test.AssertImageMatches(t, s.wantImage, capture2)
assert.Equal(t, s.wantAction, lastAction, "last action should match expected")
})
}
Expand Down

0 comments on commit 33a4732

Please sign in to comment.