Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed pref test fix #5470

Merged
merged 3 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading