Merge lp:~ted/ubuntu-system-settings/silent-mode into lp:ubuntu-system-settings/rtm-14.09

Proposed by Ted Gould
Status: Merged
Approved by: Ken VanDine
Approved revision: 1131
Merged at revision: 951
Proposed branch: lp:~ted/ubuntu-system-settings/silent-mode
Merge into: lp:ubuntu-system-settings/rtm-14.09
Diff against target: 353 lines (+91/-59)
6 files modified
plugins/sound/PageComponent.qml (+13/-5)
plugins/sound/SoundsList.qml (+15/-3)
plugins/sound/sound.cpp (+1/-21)
plugins/sound/sound.h (+0/-7)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+51/-5)
tests/autopilot/ubuntu_system_settings/tests/test_sound.py (+11/-18)
To merge this branch: bzr merge lp:~ted/ubuntu-system-settings/silent-mode
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+241559@code.launchpad.net

Commit message

Make silent mode use the action state in the sound user service

Description of the change

Make silent mode use the action state in the sound user service

To post a comment you must log in.
1115. By Ted Gould

Remove headers, not for RTM

1116. By Ted Gould

A couple more divider designations

1117. By Ted Gould

Switch to a binding which is supposed to be better for two way stuff.

1118. By Ted Gould

Activate on clicked

1119. By Ted Gould

Removing warning testing, as we removed it

1120. By Ted Gould

Drop silent mode from the list of properties

1121. By Ted Gould

Adding in an indicator sound action mock

1122. By Ted Gould

Make sure to shutdown our isound

1123. By Ted Gould

Try to check the calls to the sound mock

1124. By Ted Gould

PEP8 Fixes

1125. By Ted Gould

Session bus seems to be 'False'

1126. By Ted Gould

Check the activate signal is using silent mode

1127. By Ted Gould

Moving defines to reduce conflicts

1128. By Ted Gould

No clue why this is better, but PEP8 makes the code look like this. Enjoy.

1129. By Ted Gould

Merge rtm-14.09 branch

Revision history for this message
Ken VanDine (ken-vandine) wrote :

This reverts part of the fix that recently landed for keeping the switches in sync with the indicators. Please double check the switch and make sure this is what we want.

review: Needs Fixing
1130. By Ted Gould

Switching from a binding to a shadow property

1131. By Ted Gould

Start a session bus

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks, looks good now

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/sound/PageComponent.qml'
2--- plugins/sound/PageComponent.qml 2014-11-12 16:28:12 +0000
3+++ plugins/sound/PageComponent.qml 2014-11-24 15:17:41 +0000
4@@ -65,15 +65,14 @@
5 anchors.left: parent.left
6 anchors.right: parent.right
7
8- SilentModeWarning { visible: backendInfo.silentMode }
9-
10 ListItem.Standard {
11 control: Switch {
12+ id: silentModeSwitch
13 objectName: "silentMode"
14- property bool serverChecked: backendInfo.silentMode
15+ property bool serverChecked: soundActionGroup.silentMode.state
16 onServerCheckedChanged: checked = serverChecked
17 Component.onCompleted: checked = serverChecked
18- onTriggered: backendInfo.silentMode = checked
19+ onTriggered: soundActionGroup.silentMode.activate()
20 }
21 text: i18n.tr("Silent Mode")
22 }
23@@ -89,6 +88,8 @@
24 objectPath: "/com/canonical/indicator/sound"
25
26 property variant volume: action("volume")
27+ property variant silentMode: action("silent-mode")
28+ property variant highVolume: action("high-volume")
29
30 Component.onCompleted: start()
31 }
32@@ -98,7 +99,7 @@
33 property: "value"
34 value: soundActionGroup.volume.state
35 }
36-
37+
38 Menus.SliderMenu {
39 id: sliderMenu
40 objectName: "sliderMenu"
41@@ -110,6 +111,12 @@
42 onUpdated: soundActionGroup.volume.updateState(value);
43 }
44
45+ ListItem.Standard {
46+ id: highVolumeWarning
47+ visible: soundActionGroup.highVolume.state == true
48+ text: i18n.tr("High volume can damage your hearing.")
49+ }
50+
51 SettingsItemTitle {
52 text: i18n.tr("Phone calls:")
53 }
54@@ -217,6 +224,7 @@
55 }
56
57 ListItem.Standard {
58+ id: lockSound
59 control: Switch {
60 checked: false
61 }
62
63=== modified file 'plugins/sound/SoundsList.qml'
64--- plugins/sound/SoundsList.qml 2014-10-16 17:05:01 +0000
65+++ plugins/sound/SoundsList.qml 2014-11-24 15:17:41 +0000
66@@ -5,6 +5,7 @@
67 import Ubuntu.Components 0.1
68 import Ubuntu.Components.ListItems 0.1 as ListItem
69 import Ubuntu.SystemSettings.Sound 1.0
70+import QMenuModel 0.1
71
72 import "utilities.js" as Utilities
73
74@@ -40,6 +41,17 @@
75 schema.id: "com.ubuntu.touch.sound"
76 }
77
78+ QDBusActionGroup {
79+ id: soundActionGroup
80+ busType: DBus.SessionBus
81+ busName: "com.canonical.indicator.sound"
82+ objectPath: "/com/canonical/indicator/sound"
83+
84+ property variant silentMode: action("silent-mode")
85+
86+ Component.onCompleted: start()
87+ }
88+
89 Audio {
90 id: soundEffect
91 audioRole: MediaPlayer.alert
92@@ -50,7 +62,7 @@
93 anchors.left: parent.left
94 anchors.right: parent.right
95
96- SilentModeWarning { visible: backendInfo.silentMode }
97+ SilentModeWarning { visible: soundActionGroup.silentMode.state }
98
99 ListItem.SingleControl {
100 id: listId
101@@ -61,7 +73,7 @@
102 soundEffect.stop()
103 }
104 enabled: soundEffect.playbackState == Audio.PlayingState
105- visible: showStopButton && !backendInfo.silentMode
106+ visible: showStopButton && !soundActionGroup.silentMode.state
107 }
108 }
109
110@@ -92,7 +104,7 @@
111 backendInfo.incomingMessageSound = soundFileNames[index]
112 }
113 /* Only preview the file if not in silent mode */
114- if (!backendInfo.silentMode) {
115+ if (!soundActionGroup.silentMode.state) {
116 soundEffect.source = soundFileNames[index]
117 soundEffect.play()
118 }
119
120=== modified file 'plugins/sound/sound.cpp'
121--- plugins/sound/sound.cpp 2014-11-10 17:59:34 +0000
122+++ plugins/sound/sound.cpp 2014-11-24 15:17:41 +0000
123@@ -45,9 +45,7 @@
124 if (interface != AS_INTERFACE)
125 return;
126
127- if (property == "SilentMode") {
128- Q_EMIT silentModeChanged();
129- } else if (property == "IncomingCallSound") {
130+ if (property == "IncomingCallSound") {
131 Q_EMIT incomingCallSoundChanged();
132 } else if (property == "IncomingMessageSound") {
133 Q_EMIT incomingMessageSoundChanged();
134@@ -69,7 +67,6 @@
135 // Tell QML so that it refreshes its view of the property
136 Q_EMIT incomingCallSoundChanged();
137 Q_EMIT incomingMessageSoundChanged();
138- Q_EMIT silentModeChanged();
139 Q_EMIT incomingCallVibrateChanged();
140 Q_EMIT incomingMessageVibrateChanged();
141 Q_EMIT incomingCallVibrateSilentModeChanged();
142@@ -111,23 +108,6 @@
143 Q_EMIT(incomingMessageSoundChanged());
144 }
145
146-bool Sound::getSilentMode()
147-{
148- return m_accountsService.getUserProperty(AS_INTERFACE,
149- "SilentMode").toBool();
150-}
151-
152-void Sound::setSilentMode(bool enabled)
153-{
154- if (enabled == getSilentMode())
155- return;
156-
157- m_accountsService.setUserProperty(AS_INTERFACE,
158- "SilentMode",
159- QVariant::fromValue(enabled));
160- Q_EMIT(silentModeChanged());
161-}
162-
163 bool Sound::getIncomingCallVibrate()
164 {
165 return m_accountsService.getUserProperty(AS_INTERFACE,
166
167=== modified file 'plugins/sound/sound.h'
168--- plugins/sound/sound.h 2014-10-16 17:05:01 +0000
169+++ plugins/sound/sound.h 2014-11-24 15:17:41 +0000
170@@ -41,10 +41,6 @@
171 READ getIncomingMessageSound
172 WRITE setIncomingMessageSound
173 NOTIFY incomingMessageSoundChanged)
174- Q_PROPERTY (bool silentMode
175- READ getSilentMode
176- WRITE setSilentMode
177- NOTIFY silentModeChanged)
178 Q_PROPERTY (bool incomingCallVibrate
179 READ getIncomingCallVibrate
180 WRITE setIncomingCallVibrate
181@@ -75,7 +71,6 @@
182 Q_SIGNALS:
183 void incomingCallSoundChanged();
184 void incomingMessageSoundChanged();
185- void silentModeChanged();
186 void incomingCallVibrateChanged();
187 void incomingMessageVibrateChanged();
188 void incomingCallVibrateSilentModeChanged();
189@@ -89,8 +84,6 @@
190 void setIncomingCallSound(QString sound);
191 QString getIncomingMessageSound();
192 void setIncomingMessageSound(QString sound);
193- bool getSilentMode();
194- void setSilentMode(bool enabled);
195 bool getIncomingCallVibrate();
196 void setIncomingCallVibrate(bool enabled);
197 bool getIncomingMessageVibrate();
198
199=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
200--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-10-22 21:34:08 +0000
201+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-11-24 15:17:41 +0000
202@@ -28,6 +28,9 @@
203 ACCOUNTS_OBJ = '/org/freedesktop/Accounts'
204 ACCOUNTS_SERVICE = 'com.canonical.unity.AccountsService'
205 ACCOUNTS_SOUND_IFACE = 'com.ubuntu.touch.AccountsService.Sound'
206+ISOUND_SERVICE = 'com.canonical.indicator.sound'
207+ISOUND_ACTION_PATH = '/com/canonical/indicator/sound'
208+GTK_ACTIONS_IFACE = 'org.gtk.Actions'
209 MODEM_IFACE = 'org.ofono.Modem'
210 CONNMAN_IFACE = 'org.ofono.ConnectionManager'
211 RDO_IFACE = 'org.ofono.RadioSettings'
212@@ -520,14 +523,15 @@
213 @classmethod
214 def setUpClass(klass):
215 klass.start_system_bus()
216+ klass.start_session_bus()
217 klass.dbus_con = klass.get_dbus(True)
218+ klass.dbus_con_session = klass.get_dbus(False)
219
220 def setUp(self, panel='sound'):
221
222 user_obj = '/user/foo'
223
224 self.accts_snd_props = {
225- 'SilentMode': dbus.Boolean(False, variant_level=1),
226 'IncomingCallVibrate': dbus.Boolean(False, variant_level=1),
227 'IncomingCallVibrateSilentMode': dbus.Boolean(False,
228 variant_level=1),
229@@ -543,6 +547,12 @@
230 ACCOUNTS_IFACE, system_bus=True,
231 stdout=subprocess.PIPE)
232
233+ # start isound
234+ self.mock_isound = self.spawn_server(ISOUND_SERVICE,
235+ ISOUND_ACTION_PATH,
236+ GTK_ACTIONS_IFACE,
237+ stdout=subprocess.PIPE)
238+
239 sleep(2)
240
241 self.dbus_mock = dbus.Interface(self.dbus_con.get_object(
242@@ -550,6 +560,14 @@
243 ACCOUNTS_OBJ,
244 ACCOUNTS_IFACE),
245 dbusmock.MOCK_IFACE)
246+
247+ self.dbus_mock_isound = dbus.Interface(
248+ self.dbus_con_session.get_object(
249+ ISOUND_SERVICE,
250+ ISOUND_ACTION_PATH,
251+ GTK_ACTIONS_IFACE),
252+ dbusmock.MOCK_IFACE)
253+
254 # let accountservice find a user object path
255 self.dbus_mock.AddMethod(ACCOUNTS_IFACE, 'FindUserById', 'x', 'o',
256 'ret = "%s"' % user_obj)
257@@ -576,10 +594,6 @@
258 user_obj, ACCOUNTS_SOUND_IFACE, self.accts_snd_props,
259 [
260 (
261- 'GetSilentMode', '', 'v',
262- 'ret = self.Get("%s", "SilentMode")' %
263- ACCOUNTS_SOUND_IFACE),
264- (
265 'GetIncomingCallVibrate', '', 'v',
266 'ret = self.Get("%s", "IncomingCallVibrate")' %
267 ACCOUNTS_SOUND_IFACE),
268@@ -606,6 +620,36 @@
269 self.obj_test = self.dbus_con.get_object(ACCOUNTS_IFACE, user_obj,
270 ACCOUNTS_IFACE)
271
272+ self.dbus_mock_isound.AddMethods(
273+ GTK_ACTIONS_IFACE,
274+ [
275+ (
276+ 'Activate', 'sava{sv}', '',
277+ ''
278+ ),
279+ (
280+ 'Describe', 's', '(bsav)',
281+ 'if args[0] == "silent-mode":'
282+ ' ret = [True, "", [False]]'
283+ 'if args[0] == "volume":'
284+ ' ret = [True, "i", [0.4]]'
285+ ),
286+ (
287+ 'DescribeAll', 's', 'a{s(bsav)}',
288+ 'ret = {'
289+ '"silent-mode": [True, "", [False]],'
290+ '"volume": [True, "i", [0.4]]}'
291+ ),
292+ (
293+ 'List', '', 'as',
294+ 'ret = ["silent-mode", "volume"]'
295+ ),
296+ (
297+ 'SetState', 'sva{sv}', '',
298+ ''
299+ )
300+ ])
301+
302 super(SoundBaseTestCase, self).setUp(panel)
303
304 """ Go to Sound page """
305@@ -616,6 +660,8 @@
306 def tearDown(self):
307 self.mock_server.terminate()
308 self.mock_server.wait()
309+ self.mock_isound.terminate()
310+ self.mock_isound.wait()
311 super(SoundBaseTestCase, self).tearDown()
312
313
314
315=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_sound.py'
316--- tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-08-28 17:33:40 +0000
317+++ tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-11-24 15:17:41 +0000
318@@ -31,24 +31,17 @@
319 """ Check that silent_mode is present and clickable"""
320 snd = self.system_settings.main_view.sound_page.select_single(
321 objectName="silentMode")
322- prev_value = self.obj_test.GetSilentMode()
323- self.system_settings.main_view.scroll_to_and_click(snd)
324- sleep(0.2)
325- self.assertNotEqual(
326- self.obj_test.GetSilentMode(),
327- prev_value)
328-
329- def test_silent_mode_warning(self):
330- """ Check that silent_mode warning is shown"""
331- sndwarn = self.system_settings.main_view.sound_page.select_single(
332- objectName="silentModeWarning")
333- snd = self.system_settings.main_view.sound_page.select_single(
334- objectName="silentMode")
335- self.system_settings.main_view.scroll_to_and_click(snd)
336- sleep(0.2)
337- self.assertThat(
338- sndwarn.get_properties()["visible"],
339- Eventually(Equals(True)))
340+ self.system_settings.main_view.scroll_to_and_click(snd)
341+ sleep(0.2)
342+ calls = self.dbus_mock_isound.GetCalls()
343+ self.assertThat(
344+ calls[0][1],
345+ Equals('Activate')
346+ )
347+ self.assertThat(
348+ calls[0][2][0],
349+ Equals('silent-mode')
350+ )
351
352 def test_call_vibrate_sound_switch(self):
353 """ Check that call vibrate is present and clickable"""

Subscribers

People subscribed via source and target branches