Merge lp:~ted/indicator-sound/lp1422745-menu-open into lp:indicator-sound/15.04

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 483
Merged at revision: 483
Proposed branch: lp:~ted/indicator-sound/lp1422745-menu-open
Merge into: lp:indicator-sound/15.04
Prerequisite: lp:~ted/indicator-sound/lp1422745-max-volume
Diff against target: 111 lines (+56/-4)
2 files modified
src/service.vala (+7/-3)
tests/notifications-test.cc (+49/-1)
To merge this branch: bzr merge lp:~ted/indicator-sound/lp1422745-menu-open
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+250827@code.launchpad.net

Commit message

Switch to an internal variable to track blocking notifications

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/service.vala'
--- src/service.vala 2015-02-24 19:06:39 +0000
+++ src/service.vala 2015-02-24 19:06:39 +0000
@@ -97,12 +97,16 @@
97 /* Hide the notification when the menu is shown */97 /* Hide the notification when the menu is shown */
98 var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;98 var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;
99 shown_action.change_state.connect ((state) => {99 shown_action.change_state.connect ((state) => {
100 if (state.get_boolean()) {100 block_notifications = state.get_boolean();
101 if (block_notifications) {
102 debug("Indicator is shown");
101 try {103 try {
102 sync_notification.close();104 sync_notification.close();
103 } catch (Error e) {105 } catch (Error e) {
104 warning("Unable to close synchronous volume notification: %s", e.message);106 warning("Unable to close synchronous volume notification: %s", e.message);
105 }107 }
108 } else {
109 debug("Indicator is hidden");
106 }110 }
107 });111 });
108112
@@ -280,6 +284,7 @@
280284
281 private bool check_sync_notification = false;285 private bool check_sync_notification = false;
282 private bool support_sync_notification = false;286 private bool support_sync_notification = false;
287 private bool block_notifications = false;
283288
284 void update_sync_notification () {289 void update_sync_notification () {
285 if (!check_sync_notification) {290 if (!check_sync_notification) {
@@ -294,8 +299,7 @@
294 if (!support_sync_notification)299 if (!support_sync_notification)
295 return;300 return;
296301
297 var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;302 if (block_notifications)
298 if (shown_action != null && shown_action.get_state().get_boolean())
299 return;303 return;
300304
301 /* Determine Label */305 /* Determine Label */
302306
=== modified file 'tests/notifications-test.cc'
--- tests/notifications-test.cc 2015-02-24 19:06:39 +0000
+++ tests/notifications-test.cc 2015-02-24 19:06:39 +0000
@@ -146,6 +146,25 @@
146 volume_control_set_volume(volumeControl.get(), vol);146 volume_control_set_volume(volumeControl.get(), vol);
147 g_object_unref(vol);147 g_object_unref(vol);
148 }148 }
149
150 void setIndicatorShown (bool shown) {
151 auto bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
152
153 g_dbus_connection_call(bus,
154 g_dbus_connection_get_unique_name(bus),
155 "/com/canonical/indicator/sound",
156 "org.gtk.Actions",
157 "SetState",
158 g_variant_new("(sva{sv})", "indicator-shown", g_variant_new_boolean(shown), nullptr),
159 nullptr,
160 G_DBUS_CALL_FLAGS_NONE,
161 -1,
162 nullptr,
163 nullptr,
164 nullptr);
165
166 g_clear_object(&bus);
167 }
149};168};
150169
151TEST_F(NotificationsTest, BasicObject) {170TEST_F(NotificationsTest, BasicObject) {
@@ -357,6 +376,36 @@
357 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);376 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);
358}377}
359378
379TEST_F(NotificationsTest, MenuHide) {
380 auto volumeControl = volumeControlMock();
381 auto soundService = standardService(volumeControl, playerListMock());
382
383 /* Set a volume */
384 notifications->clearNotifications();
385 setMockVolume(volumeControl, 0.50);
386 loop(50);
387 auto notev = notifications->getNotifications();
388 EXPECT_EQ(1, notev.size());
389
390 /* Set the indicator to shown, and set a new volume */
391 notifications->clearNotifications();
392 setIndicatorShown(true);
393 loop(50);
394 setMockVolume(volumeControl, 0.60);
395 loop(50);
396 notev = notifications->getNotifications();
397 EXPECT_EQ(0, notev.size());
398
399 /* Set the indicator to hidden, and set a new volume */
400 notifications->clearNotifications();
401 setIndicatorShown(false);
402 loop(50);
403 setMockVolume(volumeControl, 0.70);
404 loop(50);
405 notev = notifications->getNotifications();
406 EXPECT_EQ(1, notev.size());
407}
408
360TEST_F(NotificationsTest, ExtendendVolumeNotification) {409TEST_F(NotificationsTest, ExtendendVolumeNotification) {
361 auto volumeControl = volumeControlMock();410 auto volumeControl = volumeControlMock();
362 auto soundService = standardService(volumeControl, playerListMock());411 auto soundService = standardService(volumeControl, playerListMock());
@@ -397,4 +446,3 @@
397 ASSERT_EQ(1, notev.size());446 ASSERT_EQ(1, notev.size());
398 EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);447 EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);
399}448}
400

Subscribers

People subscribed via source and target branches