forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.go
31 lines (25 loc) · 841 Bytes
/
notification.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
package test
import (
"testing"
"github.com/qmsu/fyne/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// AssertNotificationSent allows an app developer to assert that a notification was sent.
// After the content of f has executed this utility will check that the specified notification was sent.
func AssertNotificationSent(t *testing.T, n *fyne.Notification, f func()) {
require.NotNil(t, f, "function has to be specified")
require.IsType(t, &testApp{}, fyne.CurrentApp())
a := fyne.CurrentApp().(*testApp)
a.lastNotification = nil
f()
if n == nil {
assert.Nil(t, a.lastNotification)
return
} else if a.lastNotification == nil {
t.Error("No notification sent")
return
}
assert.Equal(t, n.Title, a.lastNotification.Title)
assert.Equal(t, n.Content, a.lastNotification.Content)
}