From dc2a1411a7989c54f71698605c3405a0de84a263 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 24 Feb 2015 11:35:55 -0600 Subject: Writing a test to show that we're not checking the hide --- tests/notifications-test.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'tests/notifications-test.cc') diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc index 88ed6c6..62e8c26 100644 --- a/tests/notifications-test.cc +++ b/tests/notifications-test.cc @@ -146,6 +146,25 @@ class NotificationsTest : public ::testing::Test volume_control_set_volume(volumeControl.get(), vol); g_object_unref(vol); } + + void setIndicatorShown (bool shown) { + auto bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr); + + g_dbus_connection_call(bus, + g_dbus_connection_get_unique_name(bus), + "/com/canonical/indicator/sound", + "org.gtk.Actions", + "SetState", + g_variant_new("(sva{sv})", "indicator-shown", g_variant_new_boolean(shown), nullptr), + nullptr, + G_DBUS_CALL_FLAGS_NONE, + -1, + nullptr, + nullptr, + nullptr); + + g_clear_object(&bus); + } }; TEST_F(NotificationsTest, BasicObject) { @@ -356,3 +375,33 @@ TEST_F(NotificationsTest, HighVolume) { EXPECT_EQ("High volume", notev[0].body); EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]); } + +TEST_F(NotificationsTest, MenuHide) { + auto volumeControl = volumeControlMock(); + auto soundService = standardService(volumeControl, playerListMock()); + + /* Set a volume */ + notifications->clearNotifications(); + setMockVolume(volumeControl, 0.50); + loop(50); + auto notev = notifications->getNotifications(); + EXPECT_EQ(1, notev.size()); + + /* Set the indicator to shown, and set a new volume */ + notifications->clearNotifications(); + setIndicatorShown(true); + loop(50); + setMockVolume(volumeControl, 0.60); + loop(50); + notev = notifications->getNotifications(); + EXPECT_EQ(0, notev.size()); + + /* Set the indicator to hidden, and set a new volume */ + notifications->clearNotifications(); + setIndicatorShown(false); + loop(50); + setMockVolume(volumeControl, 0.70); + loop(50); + notev = notifications->getNotifications(); + EXPECT_EQ(1, notev.size()); +} -- cgit v1.2.3