forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package glfw | ||
|
||
import ( | ||
"testing" | ||
|
||
"fyne.io/fyne" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_Menu_Empty(t *testing.T) { | ||
w := createWindow("Menu Test").(*window) | ||
bar := buildMenuOverlay(fyne.NewMainMenu(), w.canvas) | ||
assert.Nil(t, bar) // no bar but does not crash | ||
} | ||
|
||
func Test_Menu_AddsQuit(t *testing.T) { | ||
w := createWindow("Menu Test").(*window) | ||
mainMenu := fyne.NewMainMenu(fyne.NewMenu("File")) | ||
bar := buildMenuOverlay(mainMenu, w.canvas) | ||
assert.NotNil(t, bar) | ||
assert.Equal(t, 1, len(mainMenu.Items)) | ||
assert.Equal(t, 2, len(mainMenu.Items[0].Items)) // separator+quit inserted | ||
} | ||
|
||
func Test_Menu_LeaveQuit(t *testing.T) { | ||
w := createWindow("Menu Test").(*window) | ||
mainMenu := fyne.NewMainMenu(fyne.NewMenu("File", fyne.NewMenuItem("Quit", nil))) | ||
bar := buildMenuOverlay(mainMenu, w.canvas) | ||
assert.NotNil(t, bar) | ||
assert.Equal(t, 1, len(mainMenu.Items[0].Items)) // no separator added | ||
assert.Nil(t, mainMenu.Items[0].Items[0].Action) // no quit handler added | ||
} |