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
1=== modified file 'src/service.vala'
2--- src/service.vala 2015-02-24 19:06:39 +0000
3+++ src/service.vala 2015-02-24 19:06:39 +0000
4@@ -97,12 +97,16 @@
5 /* Hide the notification when the menu is shown */
6 var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;
7 shown_action.change_state.connect ((state) => {
8- if (state.get_boolean()) {
9+ block_notifications = state.get_boolean();
10+ if (block_notifications) {
11+ debug("Indicator is shown");
12 try {
13 sync_notification.close();
14 } catch (Error e) {
15 warning("Unable to close synchronous volume notification: %s", e.message);
16 }
17+ } else {
18+ debug("Indicator is hidden");
19 }
20 });
21
22@@ -280,6 +284,7 @@
23
24 private bool check_sync_notification = false;
25 private bool support_sync_notification = false;
26+ private bool block_notifications = false;
27
28 void update_sync_notification () {
29 if (!check_sync_notification) {
30@@ -294,8 +299,7 @@
31 if (!support_sync_notification)
32 return;
33
34- var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction;
35- if (shown_action != null && shown_action.get_state().get_boolean())
36+ if (block_notifications)
37 return;
38
39 /* Determine Label */
40
41=== modified file 'tests/notifications-test.cc'
42--- tests/notifications-test.cc 2015-02-24 19:06:39 +0000
43+++ tests/notifications-test.cc 2015-02-24 19:06:39 +0000
44@@ -146,6 +146,25 @@
45 volume_control_set_volume(volumeControl.get(), vol);
46 g_object_unref(vol);
47 }
48+
49+ void setIndicatorShown (bool shown) {
50+ auto bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr);
51+
52+ g_dbus_connection_call(bus,
53+ g_dbus_connection_get_unique_name(bus),
54+ "/com/canonical/indicator/sound",
55+ "org.gtk.Actions",
56+ "SetState",
57+ g_variant_new("(sva{sv})", "indicator-shown", g_variant_new_boolean(shown), nullptr),
58+ nullptr,
59+ G_DBUS_CALL_FLAGS_NONE,
60+ -1,
61+ nullptr,
62+ nullptr,
63+ nullptr);
64+
65+ g_clear_object(&bus);
66+ }
67 };
68
69 TEST_F(NotificationsTest, BasicObject) {
70@@ -357,6 +376,36 @@
71 EXPECT_GVARIANT_EQ("@s 'true'", notev[0].hints["x-canonical-value-bar-tint"]);
72 }
73
74+TEST_F(NotificationsTest, MenuHide) {
75+ auto volumeControl = volumeControlMock();
76+ auto soundService = standardService(volumeControl, playerListMock());
77+
78+ /* Set a volume */
79+ notifications->clearNotifications();
80+ setMockVolume(volumeControl, 0.50);
81+ loop(50);
82+ auto notev = notifications->getNotifications();
83+ EXPECT_EQ(1, notev.size());
84+
85+ /* Set the indicator to shown, and set a new volume */
86+ notifications->clearNotifications();
87+ setIndicatorShown(true);
88+ loop(50);
89+ setMockVolume(volumeControl, 0.60);
90+ loop(50);
91+ notev = notifications->getNotifications();
92+ EXPECT_EQ(0, notev.size());
93+
94+ /* Set the indicator to hidden, and set a new volume */
95+ notifications->clearNotifications();
96+ setIndicatorShown(false);
97+ loop(50);
98+ setMockVolume(volumeControl, 0.70);
99+ loop(50);
100+ notev = notifications->getNotifications();
101+ EXPECT_EQ(1, notev.size());
102+}
103+
104 TEST_F(NotificationsTest, ExtendendVolumeNotification) {
105 auto volumeControl = volumeControlMock();
106 auto soundService = standardService(volumeControl, playerListMock());
107@@ -397,4 +446,3 @@
108 ASSERT_EQ(1, notev.size());
109 EXPECT_GVARIANT_EQ("@i 100", notev[0].hints["value"]);
110 }
111-

Subscribers

People subscribed via source and target branches