github.com/david-imola/snapd@v0.0.0-20210611180407-2de8ddeece6d/desktop/notification/hints_test.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2020 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package notification_test 21 22 import ( 23 . "gopkg.in/check.v1" 24 25 "github.com/snapcore/snapd/desktop/notification" 26 ) 27 28 type hintsSuite struct{} 29 30 var _ = Suite(&hintsSuite{}) 31 32 func (s *hintsSuite) TestWithActionIcons(c *C) { 33 val := true 34 c.Check(notification.WithActionIcons(), DeepEquals, notification.Hint{Name: "action-icons", Value: &val}) 35 } 36 37 func (s *hintsSuite) TestWithUrgency(c *C) { 38 val := notification.LowUrgency 39 c.Check(notification.WithUrgency(val), DeepEquals, notification.Hint{Name: "urgency", Value: &val}) 40 } 41 42 func (s *hintsSuite) TestWithCategory(c *C) { 43 val := notification.DeviceCategory 44 c.Check(notification.WithCategory(val), DeepEquals, notification.Hint{Name: "category", Value: &val}) 45 } 46 47 func (s *hintsSuite) TestWithDesktopEntry(c *C) { 48 val := "desktop-name" 49 c.Check(notification.WithDesktopEntry(val), DeepEquals, notification.Hint{Name: "desktop-entry", Value: &val}) 50 } 51 52 func (s *hintsSuite) TestWithTransient(c *C) { 53 val := true 54 c.Check(notification.WithTransient(), DeepEquals, notification.Hint{Name: "transient", Value: &val}) 55 } 56 57 func (s *hintsSuite) TestWithResident(c *C) { 58 val := true 59 c.Check(notification.WithResident(), DeepEquals, notification.Hint{Name: "resident", Value: &val}) 60 } 61 62 func (s *hintsSuite) TestWithPointToX(c *C) { 63 val := 10 64 c.Check(notification.WithPointToX(val), DeepEquals, notification.Hint{Name: "x", Value: &val}) 65 } 66 67 func (s *hintsSuite) TestWithPointToY(c *C) { 68 val := 10 69 c.Check(notification.WithPointToY(val), DeepEquals, notification.Hint{Name: "y", Value: &val}) 70 } 71 72 func (s *hintsSuite) TestWithImageFile(c *C) { 73 val := "/path/to/img" 74 c.Check(notification.WithImageFile(val), DeepEquals, notification.Hint{Name: "image-path", Value: &val}) 75 } 76 77 func (s *hintsSuite) TestWithSoundFile(c *C) { 78 val := "/path/to/snd" 79 c.Check(notification.WithSoundFile(val), DeepEquals, notification.Hint{Name: "sound-file", Value: &val}) 80 } 81 82 func (s *hintsSuite) TestWithSoundName(c *C) { 83 val := "sound" 84 c.Check(notification.WithSoundName(val), DeepEquals, notification.Hint{Name: "sound-name", Value: &val}) 85 } 86 87 func (s *hintsSuite) TestWithSuppressSound(c *C) { 88 val := true 89 c.Check(notification.WithSuppressSound(), DeepEquals, notification.Hint{Name: "suppress-sound", Value: &val}) 90 } 91 92 type urgencySuite struct{} 93 94 var _ = Suite(&urgencySuite{}) 95 96 func (s *urgencySuite) TestString(c *C) { 97 c.Check(notification.LowUrgency.String(), Equals, "low") 98 c.Check(notification.NormalUrgency.String(), Equals, "normal") 99 c.Check(notification.CriticalUrgency.String(), Equals, "critical") 100 c.Check(notification.Urgency(13).String(), Equals, "Urgency(13)") 101 }