-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
app_test.go
50 lines (38 loc) · 965 Bytes
/
app_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package app
import (
"net/url"
"os/exec"
"strings"
"testing"
"fyne.io/fyne/v2"
_ "fyne.io/fyne/v2/test"
"github.com/stretchr/testify/assert"
)
func TestDummyApp(t *testing.T) {
app := NewWithID("io.fyne.test")
app.Quit()
}
func TestCurrentApp(t *testing.T) {
app := NewWithID("io.fyne.test")
assert.Equal(t, app, fyne.CurrentApp())
}
func TestFyneApp_UniqueID(t *testing.T) {
appID := "io.fyne.test"
app := NewWithID(appID)
assert.Equal(t, appID, app.UniqueID())
}
func TestFyneApp_OpenURL(t *testing.T) {
opened := ""
app := NewWithID("io.fyne.test")
app.(*fyneApp).exec = func(cmd string, arg ...string) *exec.Cmd {
opened = arg[len(arg)-1]
return exec.Command("")
}
urlStr := "https://fyne.io"
u, _ := url.Parse(urlStr)
err := app.OpenURL(u)
if err != nil && strings.Contains(err.Error(), "unknown operating system") {
return // when running in CI mode we don't actually open URLs...
}
assert.Equal(t, urlStr, opened)
}