Merge lp:~canonical-platform-qa/ubuntu-system-settings/cchange_ringtone_tests into lp:ubuntu-system-settings
- cchange_ringtone_tests
- Merge into trunk
Status: | Work in progress |
---|---|
Proposed branch: | lp:~canonical-platform-qa/ubuntu-system-settings/cchange_ringtone_tests |
Merge into: | lp:ubuntu-system-settings |
Diff against target: |
373 lines (+215/-23) 8 files modified
plugins/sound/PageComponent.qml (+1/-0) plugins/sound/SoundsList.qml (+4/-0) src/main.cpp (+2/-1) tests/autopilot/ubuntu_system_settings/__init__.py (+84/-10) tests/autopilot/ubuntu_system_settings/fixture_setup.py (+38/-0) tests/autopilot/ubuntu_system_settings/helpers.py (+39/-0) tests/autopilot/ubuntu_system_settings/tests/__init__.py (+8/-8) tests/autopilot/ubuntu_system_settings/tests/test_sound.py (+39/-4) |
To merge this branch: | bzr merge lp:~canonical-platform-qa/ubuntu-system-settings/cchange_ringtone_tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Sebastien Bacher | Pending | ||
Leo Arias | Pending | ||
Review via email: mp+228884@code.launchpad.net |
This proposal supersedes a proposal from 2014-07-25.
Commit message
Add tests to make sure ringtone change saves in the backend.
Description of the change
Leo Arias (elopio) wrote : Posted in a previous version of this proposal | # |
Christopher Lee (veebers) wrote : Posted in a previous version of this proposal | # |
Hi Omer, I'm just being very nosey. Is the sleep on diff line 130 required? Esp. if you're doing a wait_for just after that.
Looks nice and clean :-)
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
> Hi Omer, I'm just being very nosey. Is the sleep on diff line 130 required?
> Esp. if you're doing a wait_for just after that.
>
> Looks nice and clean :-)
Thanks for the comment.
That sleep is required. When you open the ringtone settings page, initially the page is not moving but if the current selected ringtone is at the bottom of the list and not visible on screen, it automatically scrolls down. So we try to workaround that.
Ideally it would always show the selected ringtone at the center whenever the list is opened but currently its not doing that.
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
> Just please rename this:
>
> + def ringtone_
>
> to:
>
> get_current_value
>
> Nice work, thanks!
Done!
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:713
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:714
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:715
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:715
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal | # |
Thank you for your work, the approach seems fine, CI is unhappy it seems though, could you have a look to that?
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
Not ready, just changed status for CI.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:716
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:718
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:719
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:720
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:722
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:723
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:725
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:726
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal | # |
Should that be marked "work in progress"? The CI seems still unhappy there...
Note that https:/
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:727
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : Posted in a previous version of this proposal | # |
I've been able to make it work fixing some things.
First, one second is not enough. And then, it's safest if you also wait for the dragging property.
Instead of:
186 + sleep(1)
187 + list_view.
sleep(3)
list_view.
list_view.
Then, you will need this branch to land on the toolkit:
https:/
Please review it.
Now, it's really important to notice that the need for a sleep is a typical case of a UX bug. For some seconds, the page does nothing. Enough time for the user to start an action. And when the user is just about to click an element on the list or swipe it, the list is swiped by itself making the user click the wrong thing, or just wondering what caused the magic swipe.
Leo Arias (elopio) wrote : Posted in a previous version of this proposal | # |
I reported that bug here: https:/
Please add a comment on the sleep with a reference to that bug.
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
Hi Leo,
I incorporated your suggestions into my code. Also your branch improves the situation and my code does not fail now.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:837
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:838
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
FAILURE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : Posted in a previous version of this proposal | # |
Omer, you still haven't reviewed the branch that you need. Without a QA revision it's going to be harder to get it merged soon.
This branch is blocked by mine, so setting back as work in progress.
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
I had reviewed, just didn't change the status. Did that now
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:839
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:843
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal | # |
the CI seems unhappy, can you have a look at that?
Omer Akram (om26er) wrote : Posted in a previous version of this proposal | # |
Sorry for that, tests were passing on my phone so I thought its ready. Will make sure this time its fixed fully before changing to 'Needs fixing'.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:844
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Omer Akram (om26er) wrote : | # |
This is crazy, my test fails while trying to get SystemBus, it works on my phone, not really sure what's difference is there in the phone in the lab. Help ?
testtools.
File "/usr/lib/
self.
File "/usr/lib/
fixture.setUp()
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
accounts_iface = get_accounts_
File "/usr/lib/
bus = dbus.SystemBus()
File "/usr/lib/
private=
File "/usr/lib/
bus = BusConnection.
File "/usr/lib/
bus = cls._new_
dbus.exceptions
Leo Arias (elopio) wrote : | # |
I asked you about precisely this related to my previous system settings branches and you told me that they were intermittent issues on Jenkins. That they disappeared so you didn't dig into them.
I kept running my branches until I got a successful run.
Omer Akram (om26er) wrote : | # |
You see, there is a difference, the problem we discussed was happening in otto setup and I had different errors in mind at that time. But now the issue is with mako which I never saw before and was not happening when we discussed a few weeks ago.
Leo Arias (elopio) wrote : | # |
Well, it was happening to me:
https:/
I dug a little and found there was a crash.
Here's your crash file: https:/
Sebastien Bacher (seb128) wrote : | # |
setting to "work in progress" to get out of the review queue until the CI issues are sorted out
Unmerged revisions
- 844. By Omer Akram
-
add test to make sure ringtone settings are saved in the backend
- 843. By Launchpad Translations on behalf of system-settings-touch
-
Launchpad automatic translations update.
Preview Diff
1 | === modified file 'plugins/sound/PageComponent.qml' |
2 | --- plugins/sound/PageComponent.qml 2014-07-25 14:19:30 +0000 |
3 | +++ plugins/sound/PageComponent.qml 2014-07-30 15:30:26 +0000 |
4 | @@ -112,6 +112,7 @@ |
5 | } |
6 | |
7 | ListItem.SingleValue { |
8 | + objectName: 'ringtoneListItem' |
9 | text: i18n.tr("Ringtone") |
10 | value: Utilities.buildDisplayName( |
11 | backendInfo.incomingCallSound) |
12 | |
13 | === modified file 'plugins/sound/SoundsList.qml' |
14 | --- plugins/sound/SoundsList.qml 2014-07-16 16:20:23 +0000 |
15 | +++ plugins/sound/SoundsList.qml 2014-07-30 15:30:26 +0000 |
16 | @@ -84,6 +84,10 @@ |
17 | Utilities.indexSelectedFile(soundFileNames, |
18 | backendInfo.incomingMessageSound) |
19 | } |
20 | + delegate: OptionSelectorDelegate { |
21 | + objectName: "ringtone-" + modelData |
22 | + text: modelData |
23 | + } |
24 | onDelegateClicked: { |
25 | if (soundType == 0) { |
26 | soundSettings.incomingCallSound = soundFileNames[index] |
27 | |
28 | === modified file 'src/main.cpp' |
29 | --- src/main.cpp 2014-02-18 11:53:03 +0000 |
30 | +++ src/main.cpp 2014-07-30 15:30:26 +0000 |
31 | @@ -41,7 +41,8 @@ |
32 | * add some unneeded overhead => Let's load the testability driver on our |
33 | * own. |
34 | */ |
35 | - if (app.arguments().contains(QStringLiteral("-testability"))) { |
36 | + if (app.arguments().contains(QStringLiteral("-testability")) || |
37 | + qgetenv("QT_LOAD_TESTABILITY") == "1") { |
38 | QLibrary testLib(QStringLiteral("qttestability")); |
39 | if (testLib.load()) { |
40 | typedef void (*TasInitialize)(void); |
41 | |
42 | === modified file 'tests/autopilot/ubuntu_system_settings/__init__.py' |
43 | --- tests/autopilot/ubuntu_system_settings/__init__.py 2014-07-22 18:29:46 +0000 |
44 | +++ tests/autopilot/ubuntu_system_settings/__init__.py 2014-07-30 15:30:26 +0000 |
45 | @@ -35,49 +35,70 @@ |
46 | """Helper class for System Settings application""" |
47 | |
48 | APP_PATH = '/usr/bin/system-settings' |
49 | + APP_UPSTART_ID = 'ubuntu-system-settings' |
50 | DESKTOP_FILE = '/usr/share/applications/ubuntu-system-settings.desktop' |
51 | |
52 | - def __init__(self, testobj, panel=None): |
53 | + def __init__(self, testobj, panel=None, upstart_launch=False): |
54 | """Constructor. Launches system settings application |
55 | |
56 | :param testobj: An AutopilotTestCase object, needed to call |
57 | testobj.launch_test_application() |
58 | |
59 | :param panel: Launch to a specific panel. Default None. |
60 | + :param upstart_launch: whether to launch settings with upstart. |
61 | """ |
62 | self.testobj = testobj |
63 | self.panel = panel |
64 | + self.upstart_launch = upstart_launch |
65 | # Launches application |
66 | self.app = self.launch( |
67 | self.testobj, |
68 | self.APP_PATH, |
69 | self.DESKTOP_FILE, |
70 | - panel=self.panel) |
71 | + panel=self.panel, |
72 | + upstart_launch=self.upstart_launch) |
73 | |
74 | - def launch(self, testobj, app_path, desktop_file, panel=None): |
75 | + def launch( |
76 | + self, |
77 | + testobj, |
78 | + app_path, |
79 | + desktop_file, |
80 | + panel=None, |
81 | + upstart_launch=False): |
82 | """Launch system settings application |
83 | |
84 | :param testobj: An AutopilotTestCase object, needed to call |
85 | testobj.launch_test_application() |
86 | |
87 | :param panel: Launch to a specific panel. Default None. |
88 | + :param upstart_launch: whether to launch settings with upstart. |
89 | |
90 | :returns: A proxy object that represents the application. Introspection |
91 | data is retrievable via this object. |
92 | """ |
93 | - params = [app_path] |
94 | - if platform.model() != 'Desktop': |
95 | + if upstart_launch: |
96 | + params = [self.APP_UPSTART_ID] |
97 | + elif platform.model() is 'Desktop': |
98 | + params = [app_path] |
99 | + else: |
100 | + params = [app_path] |
101 | params.append('--desktop_file_hint={}'.format(desktop_file)) |
102 | |
103 | # Launch to a specific panel |
104 | if panel is not None: |
105 | params.append(panel) |
106 | |
107 | - app = testobj.launch_test_application( |
108 | - *params, |
109 | - app_type='qt', |
110 | - emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase, |
111 | - capture_output=True) |
112 | + toolkit_base = ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase |
113 | + if upstart_launch: |
114 | + app = testobj.launch_upstart_application( |
115 | + *params, |
116 | + emulator_base=toolkit_base) |
117 | + else: |
118 | + app = testobj.launch_test_application( |
119 | + *params, |
120 | + app_type='qt', |
121 | + emulator_base=toolkit_base, |
122 | + capture_output=True) |
123 | |
124 | return app |
125 | |
126 | @@ -183,6 +204,59 @@ |
127 | return True |
128 | return False |
129 | |
130 | + def _get_ringtone_setting_button(self): |
131 | + return self.wait_select_single( |
132 | + 'SingleValue', objectName='ringtoneListItem') |
133 | + |
134 | + def get_ringtone_setting_button_current_value(self): |
135 | + """current value of the ringtone setting button. |
136 | + |
137 | + :return: name of the currently selected ringtone. |
138 | + |
139 | + """ |
140 | + return self._get_ringtone_setting_button().value |
141 | + |
142 | + @autopilot.logging.log_action(logger.info) |
143 | + def open_ringtone_selector(self): |
144 | + """Open the ringtone selector. |
145 | + |
146 | + :return: The page with ringtones list. |
147 | + |
148 | + """ |
149 | + ringtone_setting_button = self._get_ringtone_setting_button() |
150 | + self.pointing_device.click_object(ringtone_setting_button) |
151 | + |
152 | + root = self.get_root_instance() |
153 | + return root.wait_select_single(SoundsList) |
154 | + |
155 | + |
156 | +class SoundsList(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
157 | + |
158 | + def choose_ringtone(self, name): |
159 | + """Choose a new ringtone. |
160 | + |
161 | + :param name: name of the ringtone to select. |
162 | + :return: newly selected ringtone item. |
163 | + |
164 | + """ |
165 | + list_view = self.select_single('QQuickListView', objectName='listView') |
166 | + # When last item of a long list is preselected the list scrolls |
167 | + # down automatically, wait for the list to scroll down before |
168 | + # trying to do anything. -- om26er. |
169 | + sleep(3) |
170 | + list_view.dragging.wait_for(False) |
171 | + list_view.moving.wait_for(False) |
172 | + list_view.click_element('ringtone-' + name) |
173 | + |
174 | + return self.select_single( |
175 | + 'OptionSelectorDelegate', objectName='ringtone-' + name) |
176 | + |
177 | + @autopilot.logging.log_action(logger.info) |
178 | + def go_back_to_sound_page(self): |
179 | + """Go back to the sound settings main page.""" |
180 | + main_window = self.get_root_instance().select_single(MainWindow) |
181 | + main_window.go_back() |
182 | + |
183 | |
184 | class AboutPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase): |
185 | |
186 | |
187 | === added file 'tests/autopilot/ubuntu_system_settings/fixture_setup.py' |
188 | --- tests/autopilot/ubuntu_system_settings/fixture_setup.py 1970-01-01 00:00:00 +0000 |
189 | +++ tests/autopilot/ubuntu_system_settings/fixture_setup.py 2014-07-30 15:30:26 +0000 |
190 | @@ -0,0 +1,38 @@ |
191 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
192 | +# |
193 | +# Copyright (C) 2014 Canonical Ltd. |
194 | +# |
195 | +# This program is free software; you can redistribute it and/or modify |
196 | +# it under the terms of the GNU Lesser General Public License as published by |
197 | +# the Free Software Foundation; version 3. |
198 | +# |
199 | +# This program is distributed in the hope that it will be useful, |
200 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
201 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
202 | +# GNU Lesser General Public License for more details. |
203 | +# |
204 | +# You should have received a copy of the GNU Lesser General Public License |
205 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
206 | + |
207 | +import fixtures |
208 | + |
209 | +from ubuntu_system_settings import helpers |
210 | + |
211 | + |
212 | +class RingtoneBackup(fixtures.Fixture): |
213 | + """Fixture to backup and restore ringtone.""" |
214 | + |
215 | + def setUp(self): |
216 | + super(RingtoneBackup, self).setUp() |
217 | + self.addCleanup(self._restore_ringtone) |
218 | + self._backup_ringtone() |
219 | + |
220 | + def _backup_ringtone(self): |
221 | + self.ringtone_backup = helpers.get_current_ringtone_from_backend() |
222 | + |
223 | + def _restore_ringtone(self): |
224 | + iface = helpers.get_accounts_service_iface() |
225 | + iface.Set( |
226 | + 'com.ubuntu.touch.AccountsService.Sound', |
227 | + 'IncomingCallSound', |
228 | + self.ringtone_backup) |
229 | |
230 | === added file 'tests/autopilot/ubuntu_system_settings/helpers.py' |
231 | --- tests/autopilot/ubuntu_system_settings/helpers.py 1970-01-01 00:00:00 +0000 |
232 | +++ tests/autopilot/ubuntu_system_settings/helpers.py 2014-07-30 15:30:26 +0000 |
233 | @@ -0,0 +1,39 @@ |
234 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
235 | +# |
236 | +# Copyright (C) 2014 Canonical Ltd. |
237 | +# |
238 | +# This program is free software; you can redistribute it and/or modify |
239 | +# it under the terms of the GNU Lesser General Public License as published by |
240 | +# the Free Software Foundation; version 3. |
241 | +# |
242 | +# This program is distributed in the hope that it will be useful, |
243 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
244 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
245 | +# GNU Lesser General Public License for more details. |
246 | +# |
247 | +# You should have received a copy of the GNU Lesser General Public License |
248 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
249 | + |
250 | +import os |
251 | + |
252 | +import dbus |
253 | + |
254 | + |
255 | +def get_accounts_service_iface(): |
256 | + """Return the accountsservice dbus interface.""" |
257 | + uid = os.geteuid() |
258 | + bus = dbus.SystemBus() |
259 | + proxy = bus.get_object( |
260 | + 'org.freedesktop.Accounts', |
261 | + '/org/freedesktop/Accounts/User{}'.format(uid)) |
262 | + |
263 | + return dbus.Interface(proxy, 'org.freedesktop.DBus.Properties') |
264 | + |
265 | + |
266 | +def get_current_ringtone_from_backend(): |
267 | + """Return the URI of the current ringtone.""" |
268 | + accounts_iface = get_accounts_service_iface() |
269 | + |
270 | + return accounts_iface.Get( |
271 | + 'com.ubuntu.touch.AccountsService.Sound', |
272 | + 'IncomingCallSound') |
273 | |
274 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py' |
275 | --- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-07-25 18:12:58 +0000 |
276 | +++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-07-30 15:30:26 +0000 |
277 | @@ -39,9 +39,10 @@ |
278 | |
279 | """Base class for Ubuntu System Settings.""" |
280 | |
281 | - def setUp(self, panel=None): |
282 | + def setUp(self, panel=None, upstart_launch=False): |
283 | super(UbuntuSystemSettingsTestCase, self).setUp() |
284 | - self.system_settings = SystemSettings(self, panel=panel) |
285 | + self.system_settings = SystemSettings( |
286 | + self, panel=panel, upstart_launch=upstart_launch) |
287 | self.assertThat( |
288 | self.system_settings.main_view.visible, |
289 | Eventually(Equals(True))) |
290 | @@ -467,9 +468,8 @@ |
291 | class SoundBaseTestCase(UbuntuSystemSettingsTestCase): |
292 | """ Base class for sound settings tests""" |
293 | |
294 | - def setUp(self): |
295 | - |
296 | - """ Go to Sound page """ |
297 | - super(SoundBaseTestCase, self).setUp('sound') |
298 | - self.assertThat(self.system_settings.main_view.sound_page.active, |
299 | - Eventually(Equals(True))) |
300 | + def setUp(self, panel='sound', upstart_launch=False): |
301 | + """Go to Sound page.""" |
302 | + super(SoundBaseTestCase, self).setUp(panel, upstart_launch) |
303 | + self.sound_page = self.system_settings.main_view.select_single( |
304 | + objectName='soundPage') |
305 | |
306 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/test_sound.py' |
307 | --- tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-07-11 14:17:51 +0000 |
308 | +++ tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-07-30 15:30:26 +0000 |
309 | @@ -5,8 +5,13 @@ |
310 | # under the terms of the GNU General Public License version 3, as published |
311 | # by the Free Software Foundation. |
312 | |
313 | +from autopilot import platform |
314 | +from autopilot.matchers import Eventually |
315 | +from testtools import skipIf |
316 | from testtools.matchers import Equals, NotEquals |
317 | |
318 | +from ubuntu_system_settings import fixture_setup |
319 | +from ubuntu_system_settings import helpers |
320 | from ubuntu_system_settings.tests import SoundBaseTestCase |
321 | from ubuntu_system_settings.utils.i18n import ugettext as _ |
322 | |
323 | @@ -18,12 +23,10 @@ |
324 | """ Checks whether Sound page is available """ |
325 | self.assertThat( |
326 | self.system_settings.main_view.sound_page, |
327 | - NotEquals(None) |
328 | - ) |
329 | + NotEquals(None)) |
330 | self.assertThat( |
331 | self.system_settings.main_view.sound_page.title, |
332 | - Equals(_('Sound')) |
333 | - ) |
334 | + Equals(_('Sound'))) |
335 | |
336 | def test_keyboard_sound_switch(self): |
337 | """ Check that keyboard sound is present and clickable""" |
338 | @@ -33,3 +36,35 @@ |
339 | self.system_settings.main_view.pointing_device.click_object(kbd_snd) |
340 | self.assertThat( |
341 | kbd_snd.get_properties()["checked"], NotEquals(current_value)) |
342 | + |
343 | + |
344 | +@skipIf(platform.model() is 'Desktop', 'Phones only') |
345 | +class RingtoneSettingTestCase(SoundBaseTestCase): |
346 | + |
347 | + ringtone = 'Supreme' |
348 | + |
349 | + def setUp(self): |
350 | + self.useFixture(fixture_setup.RingtoneBackup()) |
351 | + super(RingtoneSettingTestCase, self).setUp(upstart_launch=True) |
352 | + |
353 | + def test_ringtone_setting_change_in_ui(self): |
354 | + """Ensure ringtone change is shown in UI.""" |
355 | + sounds_list = self.sound_page.open_ringtone_selector() |
356 | + sounds_list.choose_ringtone(self.ringtone) |
357 | + |
358 | + sounds_list.go_back_to_sound_page() |
359 | + |
360 | + self.assertThat( |
361 | + self.sound_page.get_ringtone_setting_button_current_value(), |
362 | + Eventually(Equals(self.ringtone))) |
363 | + |
364 | + def test_ringtone_setting_change_in_backend(self): |
365 | + """Ensure ringtone change saves in backend.""" |
366 | + sounds_list = self.sound_page.open_ringtone_selector() |
367 | + current_ringtone = sounds_list.choose_ringtone(self.ringtone) |
368 | + |
369 | + self.assertThat( |
370 | + current_ringtone.selected, Eventually(Equals(True))) |
371 | + self.assertThat( |
372 | + lambda: helpers.get_current_ringtone_from_backend().endswith( |
373 | + self.ringtone + '.ogg'), Eventually(Equals(True))) |
Just please rename this:
+ def ringtone_ setting_ button_ current_ value(self) :
to:
get_current_value
Nice work, thanks!