diff options
Diffstat (limited to 'internal/notify/service_test.go')
| -rw-r--r-- | internal/notify/service_test.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/internal/notify/service_test.go b/internal/notify/service_test.go index 3d7c2cc..f7d7195 100644 --- a/internal/notify/service_test.go +++ b/internal/notify/service_test.go @@ -133,6 +133,46 @@ func TestNotifyMaterialisesImageData(t *testing.T) { } } +// The deprecated icon_data must lose to the image-path URI it outranked when +// the keys were read in one tier. +func TestNotifyIconDataDoesNotBeatImagePath(t *testing.T) { + var live []Popup + s := &Service{dir: t.TempDir(), timers: map[uint32]*time.Timer{}} + s.store = NewStore(s.emitClosed, func(l, _ []Popup) { live = l }, s.removeImage) + rgba := []byte{255, 0, 0, 255, 0, 255, 0, 255} + hints := map[string]dbus.Variant{ + "icon_data": dbus.MakeVariant([]interface{}{int32(2), int32(1), int32(8), true, int32(8), int32(4), rgba}), + "image-path": dbus.MakeVariant("/tmp/shot.png"), + } + if _, dbusErr := s.Notify("t", 0, "", "s", "b", nil, hints, -1); dbusErr != nil { + t.Fatal(dbusErr) + } + if len(live) != 1 || live[0].Image != "/tmp/shot.png" { + t.Fatalf("published %+v, want image-path", live) + } +} + +// image-data is tier 1, above both image-path and icon_data. +func TestNotifyImageDataBeatsIconDataAndPath(t *testing.T) { + var live []Popup + s := &Service{dir: t.TempDir(), timers: map[uint32]*time.Timer{}} + s.store = NewStore(s.emitClosed, func(l, _ []Popup) { live = l }, s.removeImage) + rgba := []byte{255, 0, 0, 255, 0, 255, 0, 255} + hints := map[string]dbus.Variant{ + "image-data": dbus.MakeVariant([]interface{}{int32(2), int32(1), int32(8), true, int32(8), int32(4), rgba}), + "icon_data": dbus.MakeVariant([]interface{}{int32(9), int32(1), int32(8), true, int32(8), int32(4), rgba}), + "image-path": dbus.MakeVariant("/tmp/shot.png"), + } + id, dbusErr := s.Notify("t", 0, "", "s", "b", nil, hints, -1) + if dbusErr != nil { + t.Fatal(dbusErr) + } + want := filepath.Join(ImagesDir(s.dir), strconv.FormatUint(uint64(id), 10)+".png") + if len(live) != 1 || live[0].Image != want { + t.Fatalf("published %+v, want image-data %q", live, want) + } +} + func TestNotifyReturnsAnIDAndPublishes(t *testing.T) { conn := busOrSkip(t) dir := t.TempDir() |
