Skip to content

Commit

Permalink
Add NewTempWindow to the new test window file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jun 17, 2024
1 parent d51e9c9 commit 9177057
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/window.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package test

import (
"testing"

"fyne.io/fyne/v2"
)

Expand All @@ -18,6 +20,16 @@ type window struct {
menu *fyne.MainMenu
}

// NewTempWindow creates and registers a new window for test purposes.
// This window will get removed automatically once the running test ends.
//
// Since: 2.5
func NewTempWindow(t testing.TB, content fyne.CanvasObject) fyne.Window {
window := NewWindow(content)
t.Cleanup(window.Close)
return window
}

// NewWindow creates and registers a new window for test purposes
func NewWindow(content fyne.CanvasObject) fyne.Window {
window := fyne.CurrentApp().NewWindow("")
Expand Down

0 comments on commit 9177057

Please sign in to comment.