Skip to content

Commit

Permalink
Merge pull request #5470 from andydotxyz/fix/preftest
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz authored Jan 27, 2025
2 parents 093b53e + efd6f41 commit 7bfcab6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
6 changes: 4 additions & 2 deletions data/binding/preference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/test"
"github.com/stretchr/testify/assert"
)
Expand All @@ -20,11 +21,12 @@ func TestBindPreference_DataRace(t *testing.T) {
binds := make([]Int, n)
for i := 0; i < n; i++ {
wg.Add(1)
go func(index int) {
index := i
fyne.Do(func() {
bind := BindPreferenceInt(key, p)
binds[index] = bind
wg.Done()
}(i)
})
}

wg.Wait()
Expand Down
14 changes: 10 additions & 4 deletions internal/driver/glfw/canvas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,7 @@ func TestGlCanvas_ResizeWithPopUpOverlay(t *testing.T) {
content := widget.NewLabel("Content")
over := widget.NewPopUp(widget.NewLabel("Over"), w.Canvas())
w.SetContent(content)
runOnMain(func() {
over.Show()
})
over.Show()
ensureCanvasSize(t, w, fyne.NewSize(69, 36))

size := fyne.NewSize(200, 100)
Expand All @@ -515,8 +513,8 @@ func TestGlCanvas_ResizeWithModalPopUpOverlay(t *testing.T) {

popup := widget.NewModalPopUp(widget.NewLabel("PopUp"), w.Canvas())
popupBgSize := fyne.NewSize(975, 575)
popup.Show()
runOnMain(func() {
popup.Show()
popup.Resize(popupBgSize)
})
ensureCanvasSize(t, w, fyne.NewSize(69, 36))
Expand Down Expand Up @@ -653,6 +651,14 @@ func (s *safeCanvas) setMenuOverlay(o fyne.CanvasObject) {
})
}

func (s *safeCanvas) Overlays() (ret fyne.OverlayStack) {
runOnMain(func() {
ret = s.glCanvas.Overlays()
})

return ret
}

func (s *safeCanvas) Padded() (ret bool) {
runOnMain(func() {
ret = s.glCanvas.Padded()
Expand Down
7 changes: 6 additions & 1 deletion internal/driver/glfw/window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,8 +1746,9 @@ func TestWindow_SetContent_Twice(t *testing.T) {
}

func TestWindow_SetFullScreen(t *testing.T) {
var w *window
runOnMain(func() { // tests launch in a different context
w := d.CreateWindow("Full").(*window)
w = d.CreateWindow("Full").(*window)
w.SetFullScreen(true)
w.create()

Expand All @@ -1756,6 +1757,10 @@ func TestWindow_SetFullScreen(t *testing.T) {
assert.Zero(t, w.height)

w.SetFullScreen(false)
})

time.Sleep(time.Second) // macOS fullscreen transition takes time
runOnMain(func() {
// ensure we realised size now!
assert.NotZero(t, w.width)
assert.NotZero(t, w.height)
Expand Down

0 comments on commit 7bfcab6

Please sign in to comment.