Merge lp:~elopio/ubuntu-system-settings/click_item into lp:ubuntu-system-settings

Proposed by Leo Arias
Status: Work in progress
Proposed branch: lp:~elopio/ubuntu-system-settings/click_item
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~elopio/ubuntu-system-settings/python3
Diff against target: 795 lines (+316/-208)
10 files modified
plugins/about/License.qml (+0/-1)
plugins/time-date/ChooseTimeZone.qml (+1/-0)
src/qml/EntryComponent.qml (+1/-0)
tests/autopilot/ubuntu_system_settings/__init__.py (+201/-47)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+12/-37)
tests/autopilot/ubuntu_system_settings/tests/test_about.py (+51/-42)
tests/autopilot/ubuntu_system_settings/tests/test_cellular.py (+3/-2)
tests/autopilot/ubuntu_system_settings/tests/test_datetime.py (+23/-39)
tests/autopilot/ubuntu_system_settings/tests/test_search.py (+21/-38)
tests/autopilot/ubuntu_system_settings/tests/test_sound.py (+3/-2)
To merge this branch: bzr merge lp:~elopio/ubuntu-system-settings/click_item
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Touch System Settings Pending
Review via email: mp+225277@code.launchpad.net

This proposal supersedes a proposal from 2014-07-02.

Commit message

NOT READY FOR REVIEW

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for your work, I didn't review the changes yet but could you describe the changeset a bit?

758. By Leo Arias

Refactored the search test cases.

759. By Leo Arias

Refactored the time zone tests.

Revision history for this message
Leo Arias (elopio) wrote :

Sorry Sebastian, I'm currently working on this.
I wanted to add a helper to be used on UX tests that involve the system settings app and other apps.
But then I got caught refactoring tests and adding more helpers. Now I'm just trying to make them run again without this branch growing twice as big.

Revision history for this message
Sebastien Bacher (seb128) wrote :

@Leo: when things are not ready for review it's better to set the merge request on "work in progress" rather than "needs review" (Iain just did that for you there)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:757
http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/915/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-utopic-touch/1453
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-utopic/1251
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-amd64-ci/107
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/107
        deb: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-armhf-ci/107/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-utopic-i386-ci/107
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/1738
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/2419
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-armhf/2419/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/9141
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-utopic/1031
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/1399
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-utopic-amd64/1399/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/915/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

This got unmanageable so I'm splitting it in smaller chunks.
Here's the first one: https://code.launchpad.net/~elopio/ubuntu-system-settings/refactor_about_tests/+merge/225425

Unmerged revisions

759. By Leo Arias

Refactored the time zone tests.

758. By Leo Arias

Refactored the search test cases.

757. By Leo Arias

First part of the refactors to add the click_item autopilot helper.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/about/License.qml'
2--- plugins/about/License.qml 2014-03-18 17:34:06 +0000
3+++ plugins/about/License.qml 2014-07-02 09:53:40 +0000
4@@ -32,4 +32,3 @@
5 }
6 }
7 }
8-
9
10=== modified file 'plugins/time-date/ChooseTimeZone.qml'
11--- plugins/time-date/ChooseTimeZone.qml 2014-06-11 13:05:23 +0000
12+++ plugins/time-date/ChooseTimeZone.qml 2014-07-02 09:53:40 +0000
13@@ -25,6 +25,7 @@
14 import Ubuntu.SystemSettings.TimeDate 1.0
15
16 ItemPage {
17+ objectName: "timeZonePage"
18 title: i18n.tr("Time zone")
19
20 Timer {
21
22=== modified file 'src/qml/EntryComponent.qml'
23--- src/qml/EntryComponent.qml 2013-11-13 15:12:36 +0000
24+++ src/qml/EntryComponent.qml 2014-07-02 09:53:40 +0000
25@@ -43,6 +43,7 @@
26 source: model.icon
27 }
28 Label {
29+ objectName: 'entryComponentNameLabel'
30 anchors.horizontalCenter: parent.horizontalCenter
31 text: i18n.dtr(model.item.translations, model.displayName)
32 width: col.width
33
34=== modified file 'tests/autopilot/ubuntu_system_settings/__init__.py'
35--- tests/autopilot/ubuntu_system_settings/__init__.py 2014-06-11 09:36:44 +0000
36+++ tests/autopilot/ubuntu_system_settings/__init__.py 2014-07-02 09:53:40 +0000
37@@ -14,10 +14,14 @@
38 # You should have received a copy of the GNU Lesser General Public License
39 # along with this program. If not, see <http://www.gnu.org/licenses/>.
40
41-from time import sleep
42-
43-from autopilot import platform
44-from ubuntuuitoolkit import emulators as toolkit_emulators
45+import logging
46+
47+import autopilot.logging
48+import ubuntuuitoolkit
49+from autopilot import introspection, platform
50+
51+
52+logger = logging.getLogger(__name__)
53
54
55 class SystemSettings():
56@@ -65,7 +69,7 @@
57 app = testobj.launch_test_application(
58 *params,
59 app_type='qt',
60- emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
61+ emulator_base=ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase)
62
63 return app
64
65@@ -75,38 +79,72 @@
66 return self.app.select_single(MainWindow)
67
68
69-class MainWindow(toolkit_emulators.MainView):
70- """An emulator class that makes it easy to interact with the UI."""
71-
72- @property
73- def pointer(self):
74- """ Return pointer """
75- return toolkit_emulators.get_pointing_device()
76-
77- def scroll_to(self, obj):
78- page = self.select_single(objectName='systemSettingsPage')
79- page_right = page.globalRect[0] + page.globalRect[2]
80- page_bottom = page.globalRect[1] + page.globalRect[3]
81- page_center_x = int(page_right / 2)
82- page_center_y = int(page_bottom / 2)
83- while obj.globalRect[1] + obj.height > page_bottom:
84- self.pointer.drag(
85- page_center_x,
86- page_center_y,
87- page_center_x,
88- page_center_y - obj.height * 2
89- )
90- # avoid a flick
91- sleep(0.5)
92-
93- def scroll_to_and_click(self, obj):
94- self.scroll_to(obj)
95- self.pointer.click_object(obj)
96-
97- @property
98- def about_page(self):
99- """ Return 'About' page """
100- return self.select_single(objectName='aboutPage')
101+class MainWindow(ubuntuuitoolkit.MainView):
102+
103+ """An Autopilot helper for the Main Window."""
104+
105+ @autopilot.logging.log_action(logger.debug)
106+ def search(self, query):
107+ search_text_field = self.select_single(
108+ ubuntuuitoolkit.TextField, objectName='searchTextField')
109+ search_text_field.swipe_into_view()
110+ search_text_field.write(query)
111+
112+ def get_items(self):
113+ """Get the available items on the System Settings page.
114+
115+ :return: A list with the names of the visible items, sorted in the same
116+ order they are displayed.
117+
118+ """
119+ entry_components = self.select_many('EntryComponent')
120+ # sort by y, x
121+ entry_components = sorted(
122+ entry_components,
123+ key=lambda entry: (entry.globalRect.y, entry.globalRect.x))
124+
125+ result = []
126+ for entry in entry_components:
127+ if entry.visible:
128+ label = entry.select_single(
129+ 'Label', objectName='entryComponentNameLabel')
130+ result.append(label.text)
131+ return result
132+
133+ @autopilot.logging.log_action(logger.debug)
134+ def click_item(self, object_name):
135+ """Click a system settings item.
136+
137+ :param object_name: The objectName property of the item to click.
138+
139+ """
140+ item = self.select_single(objectName=object_name)
141+ item.swipe_into_view()
142+ self.pointing_device.click_object(item)
143+
144+ @autopilot.logging.log_action(logger.info)
145+ def go_to_about_page(self):
146+ """Open the About page.
147+
148+ :return: The About page.
149+
150+ """
151+ return self._go_to_page('entryComponent-about', 'aboutPage')
152+
153+ def _go_to_page(self, item_object_name, page_object_name):
154+ self.click_item(item_object_name)
155+ page = self.wait_select_single(objectName=page_object_name)
156+ page.active.wait_for(True)
157+ return page
158+
159+ @autopilot.logging.log_action(logger.info)
160+ def go_to_time_and_date_page(self):
161+ """Open the Time & Date page.
162+
163+ :return: The Time & Date page.
164+
165+ """
166+ return self._go_to_page('entryComponent-time-date', 'timeDatePage')
167
168 @property
169 def cellular_page(self):
170@@ -119,21 +157,137 @@
171 return self.select_single(objectName="chooseCarrierPage")
172
173 @property
174- def licenses_page(self):
175- """ Return 'License' page """
176- return self.select_single(objectName='licensesPage')
177-
178- @property
179 def storage_page(self):
180 """ Return 'Storage' page """
181 return self.select_single(objectName='storagePage')
182
183 @property
184- def updates_page(self):
185- """ Return 'System Update' page """
186- return self.select_single(objectName='systemUpdatesPage')
187-
188- @property
189 def sound_page(self):
190 """ Return 'Sound' page """
191 return self.select_single(objectName='soundPage')
192+
193+
194+class ItemPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
195+
196+ class_name = b'ItemPage'
197+ object_name = None
198+
199+ @classmethod
200+ def validate_dbus_object(cls, path, state):
201+ name = introspection.get_classname_from_path(path)
202+ if name == cls.class_name:
203+ if cls.object_name == state['objectName'][1]:
204+ return True
205+ return False
206+
207+
208+class AboutPage(ItemPage):
209+
210+ """Autopilot helper for the About page."""
211+
212+ object_name = 'aboutPage'
213+
214+ def get_device_name(self):
215+ device_label = self.select_single(objectName='deviceLabel')
216+ return device_label.text
217+
218+ def is_serial_visible(self):
219+ serial_item = self._get_serial_item()
220+ return serial_item.visible
221+
222+ def _get_serial_item(self):
223+ return self.select_single(objectName='serialItem')
224+
225+ def get_serial(self):
226+ serial_item = self._get_serial_item()
227+ return serial_item.value
228+
229+ def is_imei_visible(self):
230+ imei_item = self._get_imei_item()
231+ return imei_item.visible
232+
233+ def _get_imei_item(self):
234+ return self.wait_select_single(objectName='imeiItem')
235+
236+ def get_imei(self):
237+ imei_item = self._get_imei_item()
238+ return imei_item.value
239+
240+ def get_os_information(self):
241+ os_item = self.select_single(objectName='osItem')
242+ return os_item.value
243+
244+ def get_last_updated_date(self):
245+ last_updated_item = self.select_single(objectName='lastUpdatedItem')
246+ return last_updated_item.value
247+
248+ @autopilot.logging.log_action(logger.info)
249+ def go_to_check_for_updates(self):
250+ check_for_updates_button = self.select_single(
251+ objectName='updateButton')
252+ self.pointing_device.click_object(check_for_updates_button)
253+ system_updates_page = self.get_root_instance().wait_select_single(
254+ objectName='systemUpdatesPage')
255+ system_updates_page.active.wait_for(True)
256+ return system_updates_page
257+
258+ @autopilot.logging.log_action(logger.info)
259+ def go_to_software_licenses(self):
260+ license_item = self.select_single(
261+ ubuntuuitoolkit.listitems.Standard, objectName='licenseItem')
262+ license_item.swipe_into_view()
263+ self.pointing_device.click_object(license_item)
264+ licenses_page = self.get_root_instance().wait_select_single(
265+ objectName='licensesPage')
266+ licenses_page.active.wait_for(True)
267+ return licenses_page
268+
269+
270+class LicensesPage(ItemPage):
271+
272+ """Autopilot helper for the Licenses page."""
273+
274+ object_name = 'licensesPage'
275+
276+
277+class SystemUpdatesPage(ItemPage):
278+
279+ """Autopilot helper for the System Updates page."""
280+
281+ object_name = 'systemUpdatesPage'
282+
283+
284+class PageComponent(ItemPage):
285+
286+ """Autopilot helper for Page Components."""
287+
288+ class_name = b'PageComponent'
289+
290+
291+class TimeAndDatePage(PageComponent):
292+
293+ """Autopilot helper for the Time & Date page."""
294+
295+ object_name = 'timeDatePage'
296+
297+ @autopilot.logging.log_action(logger.info)
298+ def go_to_time_zone_page(self):
299+ time_zone_item = self.select_single(objectName='timeZone')
300+ self.pointing_device.click_object(time_zone_item)
301+ time_zone_page = self.get_root_instance().wait_select_single(
302+ objectName='timeZonePage')
303+ time_zone_page.active.wait_for(True)
304+ return time_zone_page
305+
306+
307+class TimeZonePage(ItemPage):
308+
309+ """Autopilot helper for the Time Zone page."""
310+
311+ object_name = 'timeZonePage'
312+
313+ @autopilot.logging.log_action(logger.info)
314+ def search(self, query):
315+ text_field = self.select_single(
316+ ubuntuuitoolkit.TextField, objectName='selectTimeZoneField')
317+ text_field.write(query)
318
319=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
320--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-06-11 09:36:44 +0000
321+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-07-02 09:53:40 +0000
322@@ -11,25 +11,20 @@
323
324 from ubuntu_system_settings import SystemSettings
325
326-from autopilot.input import Mouse, Touch
327-from autopilot.platform import model
328 from autopilot.matchers import Eventually
329 from testtools.matchers import Equals, NotEquals, GreaterThan
330
331-from ubuntuuitoolkit.base import UbuntuUIToolkitAppTestCase
332+import ubuntuuitoolkit
333
334 import dbus
335 import dbusmock
336 import subprocess
337
338
339-class UbuntuSystemSettingsTestCase(UbuntuUIToolkitAppTestCase):
340- """ Base class for Ubuntu System Settings """
341+class UbuntuSystemSettingsTestCase(
342+ ubuntuuitoolkit.base.UbuntuUIToolkitAppTestCase):
343
344- if model() == 'Desktop':
345- scenarios = [('with mouse', dict(input_device_class=Mouse))]
346- else:
347- scenarios = [('with touch', dict(input_device_class=Touch))]
348+ """Base class for Ubuntu System Settings."""
349
350 def setUp(self, panel=None):
351 super(UbuntuSystemSettingsTestCase, self).setUp()
352@@ -132,24 +127,18 @@
353
354 def setUp(self):
355 """ Go to About page """
356- super(AboutBaseTestCase, self).setUp('about')
357- self.assertThat(self.system_settings.main_view.about_page.active,
358- Eventually(Equals(True)))
359+ super(AboutBaseTestCase, self).setUp()
360+ self.about_page = self.system_settings.main_view.go_to_about_page()
361
362
363 class StorageBaseTestCase(AboutBaseTestCase):
364- """ Base class for Storage page tests """
365+
366+ """Base class for Storage page tests."""
367
368 def setUp(self):
369 """ Go to Storage Page """
370 super(StorageBaseTestCase, self).setUp()
371- # Click on 'Storage' option
372- button = self.system_settings.main_view.about_page.select_single(
373- 'Standard',
374- objectName='storageItem'
375- )
376- self.assertThat(button, NotEquals(None))
377- self.system_settings.main_view.scroll_to_and_click(button)
378+ self.system_settings.main_view.click_item('storageItem')
379 self.assertThat(self.storage_page.active, Eventually(Equals(True)))
380
381 def assert_space_item(self, object_name, text):
382@@ -185,18 +174,7 @@
383 def setUp(self):
384 """ Go to License Page """
385 super(LicenseBaseTestCase, self).setUp()
386- # Click on 'Software licenses' option
387- button = self.system_settings.main_view.select_single(
388- 'Standard',
389- objectName='licenseItem')
390- self.system_settings.main_view.scroll_to_and_click(button)
391-
392- @property
393- def licenses_page(self):
394- """ Return 'License' page """
395- return self.main_view.wait_select_single(
396- 'ItemPage', objectName='licensesPage'
397- )
398+ self.licenses_page = self.about_page.go_to_software_licenses()
399
400
401 class SystemUpdatesBaseTestCase(UbuntuSystemSettingsTestCase):
402@@ -205,11 +183,8 @@
403 def setUp(self):
404 """ Go to SystemUpdates Page """
405 super(SystemUpdatesBaseTestCase, self).setUp()
406- # Click on 'System Updates' option
407- button = self.system_settings.main_view.select_single(
408- objectName='entryComponent-system-update')
409- self.assertThat(button, NotEquals(None))
410- self.system_settings.main_view.scroll_to_and_click(button)
411+ self.system_settings.main_view.click_item(
412+ 'entryComponent-system-update')
413
414
415 class SoundBaseTestCase(UbuntuSystemSettingsTestCase):
416
417=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_about.py'
418--- tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-07-02 09:53:40 +0000
419+++ tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-07-02 09:53:40 +0000
420@@ -27,7 +27,8 @@
421
422
423 class AboutTestCase(AboutBaseTestCase):
424- """ Tests for About this phone Page """
425+
426+ """Tests for About this phone Page."""
427
428 def _get_imei_from_dbus(self):
429 bus = dbus.SystemBus()
430@@ -90,37 +91,48 @@
431 else:
432 return str(info.split()[0])
433
434- def test_serial(self):
435+ def test_device_with_serial_number_must_display_it(self):
436 """Checks whether the UI is showing the correct serial number."""
437- item = self.system_settings.main_view.about_page.select_single(
438- objectName='serialItem'
439- )
440- serial = self._get_device_serial_number()
441-
442- if not serial:
443- self.assertThat(item.visible, Equals(False))
444+ device_serial = self._get_device_serial_number()
445+ if not device_serial:
446+ self.skipTest('The device has no serial number.')
447 else:
448+ self.assertTrue(self.about_page.is_serial_visible())
449+ displayed_serial = self.about_page.get_serial()
450 self.assertThat(
451- item.value, Equals(self._get_device_serial_number())
452- )
453-
454- def test_imei_information_is_correct(self):
455+ displayed_serial, Equals(device_serial))
456+
457+ def test_device_without_serial_must_not_display_it(self):
458+ device_serial = self._get_device_serial_number()
459+ if device_serial:
460+ self.skipTest('The device has serial number.')
461+ else:
462+ self.assertFalse(self.about_page.is_serial_visible())
463+
464+ def test_device_with_imei_must_display_it(self):
465 """Checks whether the UI is exposing the right IMEI."""
466- imei_item = self.system_settings.main_view.about_page.wait_select_single(
467- objectName='imeiItem')
468- imei_ofono = self._get_imei_from_dbus()
469+ device_imei = self._get_imei_from_dbus()
470+ if not device_imei:
471+ self.skipTest('The device has no imei.')
472+ else:
473+ self.assertTrue(self.about_page.is_imei_visible())
474+ displayed_imei = self.about_page.get_imei()
475+ self.assertThat(displayed_imei, Equals(device_imei))
476
477- if not imei_ofono:
478- self.assertThat(imei_item.visible, Equals(False))
479+ def test_device_without_imei_must_not_display_it(self):
480+ device_imei = self._get_imei_from_dbus()
481+ if device_imei:
482+ self.skipTest('The device has imei.')
483 else:
484- self.assertEquals(imei_item.value, imei_ofono)
485+ self.assertFalse(self.about_page.is_imei_visible())
486
487 def test_settings_show_correct_version_of_the_os(self):
488 """Ensure the UI is showing the correct version of the OS."""
489- item = self.system_settings.main_view.about_page.select_single(objectName='osItem')
490+ device_os_version = self._get_os_name()
491+ displayed_os_info = self.about_page.get_os_information()
492 # TODO: find a way to check the image build number as well
493 # -- om26er 10-03-2014
494- self.assertTrue(self._get_os_name() in item.value)
495+ self.assertTrue(device_os_version in displayed_os_info)
496
497 @skipIf(subprocess.call(
498 ['which', 'getprop'], stdout=subprocess.PIPE) != 0,
499@@ -128,31 +140,26 @@
500 )
501 def test_hardware_name(self):
502 """Ensure the UI is showing the correct device name."""
503- device_label = self.system_settings.main_view.about_page.select_single(
504- objectName='deviceLabel'
505- ).text
506+ displayed_device_name = self.about_page.get_device_name()
507 device_name_from_getprop = self._get_device_manufacturer_and_model()
508
509- self.assertEquals(device_label, device_name_from_getprop)
510+ self.assertEquals(displayed_device_name, device_name_from_getprop)
511
512 def test_last_updated(self):
513 """Checks whether Last Updated info is correct."""
514- last_updated = self.system_settings.main_view.about_page.select_single(
515- objectName='lastUpdatedItem'
516- ).value
517-
518- self.assertEquals(last_updated, self._get_last_updated_date())
519+ last_updated_date_displayed = self.about_page.get_last_updated_date()
520+ self.assertEquals(
521+ last_updated_date_displayed, self._get_last_updated_date())
522
523 def test_check_for_updates(self):
524 """
525 Checks whether clicking on Check for Updates brings us
526 to the Updates page.
527 """
528- update_button = self.system_settings.main_view.about_page.select_single(
529- objectName='updateButton')
530- self.system_settings.main_view.pointer.click_object(update_button)
531- self.assertThat(self.system_settings.main_view.updates_page.visible,
532- Eventually(Equals(True)))
533+ system_updates_page = self.about_page.go_to_check_for_updates()
534+ self.assertThat(
535+ system_updates_page.visible, Eventually(Equals(True)))
536+
537
538 class StorageTestCase(StorageBaseTestCase):
539 """ Tests for Storage """
540@@ -258,10 +265,12 @@
541
542
543 class LicenseTestCase(LicenseBaseTestCase):
544- """ Tests for Licenses """
545-
546- def test_licenses_page(self):
547- """ Check whether Storage page is available """
548- self.assertThat(
549- self.system_settings.main_view.licenses_page.active,
550- Eventually(Equals(True)))
551+
552+ """Tests for Licenses."""
553+
554+ def test_open_licenses_page(self):
555+ """Check whether Storage page is available."""
556+ # FIXME this is not a good Autopilot tests. It would be better if it
557+ # opens one of the licenses and checks that it is visible.
558+ # --elopio - 2014-07-02
559+ self.assertThat(self.licenses_page.active, Equals(True))
560
561=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_cellular.py'
562--- tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2014-04-04 15:31:49 +0000
563+++ tests/autopilot/ubuntu_system_settings/tests/test_cellular.py 2014-07-02 09:53:40 +0000
564@@ -23,10 +23,11 @@
565 objectName="autoChooseCarrierSelector"
566 )
567 manual = selector.select_single('Label', text=_("Manually"))
568- self.system_settings.main_view.pointer.click_object(manual)
569+ self.system_settings.main_view.pointing_device.click_object(manual)
570 choosecarrier = self.system_settings.main_view.cellular_page.\
571 select_single(objectName="chooseCarrier")
572- self.system_settings.main_view.pointer.click_object(choosecarrier)
573+ self.system_settings.main_view.pointing_device.click_object(
574+ choosecarrier)
575 self.assertThat(
576 self.system_settings.main_view.choose_page.title,
577 Equals(_("Carrier"))
578
579=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_datetime.py'
580--- tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2014-06-12 10:33:31 +0000
581+++ tests/autopilot/ubuntu_system_settings/tests/test_datetime.py 2014-07-02 09:53:40 +0000
582@@ -10,7 +10,7 @@
583 from time import sleep
584
585 from autopilot.matchers import Eventually
586-from testtools.matchers import Equals, NotEquals, GreaterThan
587+from testtools.matchers import Equals, GreaterThan
588
589 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
590 from ubuntu_system_settings.utils.i18n import ugettext as _
591@@ -20,7 +20,8 @@
592
593 class TimeDateTestCase(UbuntuSystemSettingsTestCase,
594 dbusmock.DBusTestCase):
595- """ Tests for the Time & Date Page """
596+
597+ """Tests for the Time & Date Page."""
598
599 @classmethod
600 def setUpClass(klass):
601@@ -31,21 +32,11 @@
602 )
603
604 def setUp(self):
605- """ Go to Time & Date page """
606+ """Go to Time & Date page."""
607 self.obj_timedate1.Reset()
608- super(TimeDateTestCase, self).setUp("time-date")
609-
610- @property
611- def time_date_page(self):
612- return self.system_settings.main_view.select_single(
613- objectName='timeDatePage'
614- )
615-
616- @property
617- def tz_page(self):
618- return self.system_settings.main_view.select_single(
619- objectName='timeZone'
620- )
621+ super(TimeDateTestCase, self).setUp()
622+ self.time_and_date_page = (
623+ self.system_settings.main_view.go_to_time_and_date_page())
624
625 @staticmethod
626 def wait_select_listview_first(listview):
627@@ -60,29 +51,22 @@
628 else:
629 raise e
630
631- def click_tz_search_field(self):
632- self.system_settings.main_view.scroll_to_and_click(self.tz_page)
633- text_field = self.system_settings.main_view.select_single(
634- objectName='selectTimeZoneField'
635- )
636- self.system_settings.main_view.pointer.move_to_object(text_field)
637-
638- def test_time_date_page(self):
639- """ Checks whether Time & Date page is available """
640- self.assertThat(self.time_date_page, NotEquals(None))
641- self.assertThat(self.time_date_page.title, Equals(_('Time & Date')))
642+ def test_open_time_and_date_page(self):
643+ """Checks whether Time & Date page is available."""
644+ self.assertThat(
645+ self.time_and_date_page.title, Equals(_('Time & Date')))
646
647 def test_tz_list_initially_empty(self):
648- """ Checks that no list is displayed initially """
649- self.system_settings.main_view.scroll_to_and_click(self.tz_page)
650- labelVisible = self.system_settings.main_view.wait_select_single(
651+ """Checks that no list is displayed initially."""
652+ time_zone_page = self.time_and_date_page.go_to_time_zone_page()
653+ labelVisible = time_zone_page.wait_select_single(
654 objectName='nothingLabel').visible
655 self.assertThat(labelVisible, Equals(True))
656
657 def test_searching_tz(self):
658- """ Check that searching for a valid location shows something """
659- self.click_tz_search_field()
660- self.keyboard.type('London, United Kingdom')
661+ """Check that searching for a valid location shows something."""
662+ time_zone_page = self.time_and_date_page.go_to_time_zone_page()
663+ time_zone_page.search('London, United Kingdom')
664 listview = self.system_settings.main_view.select_single(
665 objectName='locationsListView'
666 )
667@@ -90,8 +74,8 @@
668
669 def test_searching_tz_not_found(self):
670 """ Check that searching for an invalid location shows nothing """
671- self.click_tz_search_field()
672- self.keyboard.type('Oh no you don\'t!')
673+ time_zone_page = self.time_and_date_page.go_to_time_zone_page()
674+ time_zone_page.search('Oh no you don\'t!')
675 listview = self.system_settings.main_view.select_single(
676 objectName='locationsListView'
677 )
678@@ -102,13 +86,13 @@
679
680 def test_manual_tz_selection(self):
681 """ Check that manually selecting a timezone sets it properly """
682- self.click_tz_search_field()
683- self.keyboard.type('London, United Kingdom')
684+ time_zone_page = self.time_and_date_page.go_to_time_zone_page()
685+ time_zone_page.search('London, United Kingdom')
686 listview = self.system_settings.main_view.select_single(
687 objectName='locationsListView'
688 )
689 london = TimeDateTestCase.wait_select_listview_first(listview)
690- self.system_settings.main_view.pointer.click_object(london)
691+ self.system_settings.main_view.pointing_device.click_object(london)
692 header = self.system_settings.main_view.select_single(
693 objectName='MainView_Header'
694 )
695@@ -128,7 +112,7 @@
696 )
697
698 preston = TimeDateTestCase.wait_select_listview_first(listview)
699- self.system_settings.main_view.pointer.click_object(preston)
700+ self.system_settings.main_view.pointing_device.click_object(preston)
701
702 # The timer is 1 second, wait and see that we haven't moved pages
703 sleep(2)
704
705=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_search.py'
706--- tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-05-27 15:56:15 +0000
707+++ tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-07-02 09:53:40 +0000
708@@ -1,53 +1,36 @@
709 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
710-# Copyright 2013 Canonical
711-#
712-# This program is free software: you can redistribute it and/or modify it
713-# under the terms of the GNU General Public License version 3, as published
714-# by the Free Software Foundation.
715+# Copyright 2013, 2014 Canonical
716+#
717+# This program is free software; you can redistribute it and/or modify
718+# it under the terms of the GNU Lesser General Public License as published by
719+# the Free Software Foundation; version 3.
720+#
721+# This program is distributed in the hope that it will be useful,
722+# but WITHOUT ANY WARRANTY; without even the implied warranty of
723+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
724+# GNU Lesser General Public License for more details.
725+#
726+# You should have received a copy of the GNU Lesser General Public License
727+# along with this program. If not, see <http://www.gnu.org/licenses/>.
728
729-from autopilot.introspection.dbus import StateNotFoundError
730-from testtools.matchers import Equals
731-from autopilot.matchers import Eventually
732+""" Tests for Ubuntu System Settings """
733
734 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
735-from ubuntu_system_settings.utils.i18n import ugettext as _
736-
737-
738-""" Tests for Ubuntu System Settings """
739
740
741 class SearchTestCases(UbuntuSystemSettingsTestCase):
742 """ Tests for Search """
743
744- def setUp(self):
745- super(SearchTestCases, self).setUp()
746-
747- def _get_entry_component(self, name):
748- return self.system_settings.main_view.wait_select_single(
749- objectName='entryComponent-' + name
750- )
751-
752- def _get_all_entry_components(self):
753- return self.system_settings.main_view.select_many(
754- 'EntryComponent')
755-
756- def _type_into_search_box(self, text):
757- search_box = self.system_settings.main_view.select_single(
758- objectName='searchTextField'
759- )
760- self.system_settings.main_view.scroll_to_and_click(search_box)
761- self.keyboard.type(_(text))
762- self.assertThat(search_box.text, Eventually(Equals(text)))
763-
764 def test_search_filter_results(self):
765 """ Checks whether Search box actually filters the results """
766- self._type_into_search_box('Sound')
767- sound_icon = self._get_entry_component('sound')
768+ self.system_settings.main_view.search('Sound')
769+ visible_items = self.system_settings.main_view.get_items()
770
771- self.assertThat(sound_icon.visible, Eventually(Equals(True)))
772- self.assertEquals(len(self._get_all_entry_components()), 1)
773+ self.assertIn('Sound', visible_items)
774
775 def test_search_filter_no_matches(self):
776 """ Checks that no results are returned if nothing matches """
777- self._type_into_search_box('foobar')
778- self.assertEquals(len(self._get_all_entry_components()), 0)
779+ self.system_settings.main_view.search('foobar')
780+ visible_items = self.system_settings.main_view.get_items()
781+
782+ self.assertEquals(visible_items, [])
783
784=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_sound.py'
785--- tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-06-11 09:38:03 +0000
786+++ tests/autopilot/ubuntu_system_settings/tests/test_sound.py 2014-07-02 09:53:40 +0000
787@@ -30,5 +30,6 @@
788 kbd_snd = self.system_settings.main_view.sound_page.select_single(
789 objectName="keyboardSoundSwitch")
790 current_value = kbd_snd.get_properties()["checked"]
791- self.system_settings.main_view.pointer.click_object(kbd_snd)
792- self.assertThat(kbd_snd.get_properties()["checked"], NotEquals(current_value))
793+ self.system_settings.main_view.pointing_device.click_object(kbd_snd)
794+ self.assertThat(
795+ kbd_snd.get_properties()["checked"], NotEquals(current_value))

Subscribers

People subscribed via source and target branches