Merge lp:~allanlesage/ubuntu-system-settings/settings-new-designs-background-autopilot-refactors into lp:~jonas-drange/ubuntu-system-settings/1297418-apply-new-designs-to-background-panel

Proposed by Allan LeSage
Status: Merged
Merged at revision: 739
Proposed branch: lp:~allanlesage/ubuntu-system-settings/settings-new-designs-background-autopilot-refactors
Merge into: lp:~jonas-drange/ubuntu-system-settings/1297418-apply-new-designs-to-background-panel
Diff against target: 111 lines (+20/-26)
1 file modified
tests/autopilot/ubuntu_system_settings/tests/test_background.py (+20/-26)
To merge this branch: bzr merge lp:~allanlesage/ubuntu-system-settings/settings-new-designs-background-autopilot-refactors
Reviewer Review Type Date Requested Status
Jonas G. Drange Pending
Review via email: mp+224207@code.launchpad.net

Description of the change

Some suggestions for economy and clarity for our very cool existing autopilot test :) .

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_background.py'
2--- tests/autopilot/ubuntu_system_settings/tests/test_background.py 2014-06-17 15:07:32 +0000
3+++ tests/autopilot/ubuntu_system_settings/tests/test_background.py 2014-06-23 19:46:35 +0000
4@@ -8,27 +8,29 @@
5 from __future__ import absolute_import
6
7 import os
8-
9 from time import sleep
10-from autopilot.introspection.dbus import StateNotFoundError
11-from testtools.matchers import Equals, NotEquals, raises
12+
13+from testtools.matchers import Equals
14
15 from ubuntu_system_settings.tests import BackgroundBaseTestCase
16 from ubuntu_system_settings.utils.i18n import ugettext as _
17
18-from ubuntuuitoolkit import emulators as toolkit_emulators
19
20 def get_wallpapers_from_grid(grid):
21- return grid.select_many('*', objectName='itemImg')
22+ return grid.select_many(objectName='itemImg')
23+
24
25 class BackgroundTestCase(BackgroundBaseTestCase):
26 """ Tests for Background Page """
27
28+ def setUp(self):
29+ super(BackgroundTestCase, self).setUp()
30+ self.background_page = self.system_settings.main_view.background_page
31+
32 def get_wallpapergrid(self, name):
33 """Return a WallpaperGrid with given name, or
34 all of them"""
35- return self.system_settings.main_view.background_page.\
36- select_single('WallpaperGrid', objectName=name)
37+ return self.select_single('WallpaperGrid', objectName=name)
38
39 def get_wallpapers(self, name=None):
40 """Return individual wallpapers (QQuickImage) in given grid,
41@@ -41,8 +43,7 @@
42 @property
43 def all_wallpapergrids(self):
44 """Return all WallpaperGrids"""
45- return self.system_settings.main_view.background_page.\
46- select_many('WallpaperGrid')
47+ return self.background_page.select_many('WallpaperGrid')
48
49 @property
50 def all_wallpapers(self):
51@@ -56,9 +57,8 @@
52 def selected_wallpaper(self):
53 """Return the currently selected QQuickImage.
54 We grab the orange border and traverse a bit to get to this image"""
55- selected_shape = self.system_settings.main_view.background_page.\
56- select_single(
57- 'UbuntuShape', objectName='SelectedShape', visible=True)
58+ selected_shape = self.background_page.select_single(
59+ 'UbuntuShape', objectName='SelectedShape', visible=True)
60
61 return selected_shape.get_parent().select_single(
62 'QQuickImage', objectName='itemImg')
63@@ -66,23 +66,16 @@
64 def save_wallpaper(self):
65 """Click on Set/Save button when previewing a wallpaper"""
66 save = self.system_settings.main_view.wait_select_single(
67- '*', objectName='saveButton')
68+ objectName='saveButton')
69 self.system_settings.main_view.scroll_to_and_click(save)
70
71- def test_background_page(self):
72+ def test_background_page_title_is_correct(self):
73 """ Checks whether Background page is available """
74- self.assertThat(
75- self.system_settings.main_view.background_page,
76- NotEquals(None)
77- )
78- self.assertThat(
79- self.system_settings.main_view.background_page.title,
80- Equals(_('Background'))
81- )
82+ self.assertThat(self.background_page.title, Equals(_('Background')))
83
84 def test_that_the_currently_selected_background_comes_from_dbus(self):
85 """Test that background file from dbus is selected in UI"""
86- current_file = self.selected_wallpaper.get_properties()['source']
87+ current_file = self.selected_wallpaper.source
88
89 dbus_file = os.path.realpath(self.user_props['BackgroundFile'])
90 dbus_file = 'file://%s' % dbus_file
91@@ -93,16 +86,17 @@
92 """Test happy path for changing background"""
93
94 # wallpaper source that is selected now
95- old = self.selected_wallpaper.get_properties()['source']
96+ old = self.selected_wallpaper.source
97
98 # click a wallpaper that is not selected
99- self.system_settings.main_view.pointer.click_object(self.all_wallpapers[3])
100+ self.system_settings.main_view.pointer.click_object(
101+ self.all_wallpapers[3])
102
103 # click set/save
104 self.save_wallpaper()
105
106 # the newly selected wallpaper source
107- new = self.selected_wallpaper.get_properties()['source']
108+ new = self.selected_wallpaper.source
109
110 # assert that UI is updated
111 self.assertNotEqual(new, old)

Subscribers

People subscribed via source and target branches

to all changes: