Merge lp:~elopio/unity-scope-click/update_new_scopes into lp:unity-scope-click/devel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: dobey
Approved revision: 209
Merged at revision: 214
Proposed branch: lp:~elopio/unity-scope-click/update_new_scopes
Merge into: lp:unity-scope-click/devel
Prerequisite: lp:~alecu/unity-scope-click/refactor-search
Diff against target: 214 lines (+60/-61)
1 file modified
autopilot/unityclickscope/test_click_scope.py (+60/-61)
To merge this branch: bzr merge lp:~elopio/unity-scope-click/update_new_scopes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
dobey (community) Approve
Review via email: mp+217054@code.launchpad.net

This proposal supersedes a proposal from 2014-04-01.

Commit message

Updated the autopilot tests to work with the new scopes.

Description of the change

Updated the autopilot tests to work with the new scopes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'autopilot/unityclickscope/test_click_scope.py'
2--- autopilot/unityclickscope/test_click_scope.py 2014-02-03 15:42:51 +0000
3+++ autopilot/unityclickscope/test_click_scope.py 2014-04-24 14:14:49 +0000
4@@ -22,13 +22,11 @@
5 import fixtures
6 from autopilot.introspection import dbus as autopilot_dbus
7 from autopilot.matchers import Eventually
8-from testtools.matchers import Equals
9-from ubuntuuitoolkit import emulators as toolkit_emulators
10+from testtools.matchers import Equals, MatchesAny
11 from unity8 import process_helpers
12-from unity8.shell import (
13- emulators as unity_emulators,
14- tests as unity_tests
15-)
16+from unity8.shell import tests as unity_tests
17+from unity8.shell.emulators import dash
18+
19
20 from unityclickscope import credentials, fake_services, fixture_setup
21
22@@ -36,6 +34,10 @@
23 logger = logging.getLogger(__name__)
24
25
26+class ClickScopeException(Exception):
27+ """Exception raised when there's a problem with the scope."""
28+
29+
30 class BaseClickScopeTestCase(dbusmock.DBusTestCase, unity_tests.UnityTestCase):
31
32 scenarios = [
33@@ -57,7 +59,7 @@
34 unity_proxy = self.launch_unity()
35 process_helpers.unlock_unity(unity_proxy)
36 self.dash = self.main_window.get_dash()
37- self.scope = self.dash.get_scope('applications')
38+ self.scope = self.dash.get_scope('clickscope')
39
40 def _use_fake_server(self):
41 fake_search_server = fixture_setup.FakeSearchServerRunning()
42@@ -103,64 +105,76 @@
43
44 def _restart_scope(self):
45 logging.info('Restarting click scope.')
46- os.system('pkill click-scope')
47+ os.system('pkill -f -9 clickscope.ini')
48+ lib_path = '/usr/lib/$DEB_HOST_MULTIARCH/'
49+ scoperunner_path = os.path.join(lib_path, 'scoperunner/scoperunner')
50+ clickscope_config_ini_path = os.path.join(
51+ lib_path, 'unity-scopes/clickscope/clickscope.ini')
52 os.system(
53 "dpkg-architecture -c "
54- "'/usr/lib/$DEB_HOST_MULTIARCH//unity-scope-click/click-scope' &")
55+ "'{scoperunner} \"\" {clickscope}' &".format(
56+ scoperunner=scoperunner_path,
57+ clickscope=clickscope_config_ini_path))
58
59 def _unlock_screen(self):
60 self.main_window.get_greeter().swipe()
61
62 def open_scope(self):
63- self.dash.open_scope('applications')
64- self.scope.isCurrent.wait_for(True)
65-
66- def open_app_preview(self, name):
67- self.search(name)
68- icon = self.scope.wait_select_single('Tile', text=name)
69- pointing_device = toolkit_emulators.get_pointing_device()
70- pointing_device.click_object(icon)
71- preview = self.dash.wait_select_single(AppPreview)
72- preview.showProcessingAction.wait_for(False)
73- return preview
74+ scope = self.dash.open_scope('clickscope')
75+ scope.isCurrent.wait_for(True)
76+ return scope
77
78 def search(self, query):
79 # TODO move this to the unity8 main view emulator.
80 # --elopio - 2013-12-27
81- search_box = self._proxy.select_single("SearchIndicator")
82- self.touch.tap_object(search_box)
83+ search_indicator = self._proxy.select_single(
84+ 'SearchIndicator', objectName='search')
85+ self.touch.tap_object(search_indicator)
86+ page_header = self._proxy.select_single(
87+ 'PageHeader', objectName='pageHeader')
88+ search_container = page_header.select_single(
89+ 'QQuickItem', objectName='searchContainer')
90+ search_container.state.wait_for(
91+ MatchesAny(Equals('narrowActive'), Equals('active')))
92 self.keyboard.type(query)
93
94+ def open_app_preview(self, category, name):
95+ self.search(name)
96+ preview = self.scope.open_preview(category, name)
97+ preview.get_parent().ready.wait_for(True)
98+ return preview
99+
100
101 class TestCaseWithHomeScopeOpen(BaseClickScopeTestCase):
102
103 def test_open_scope_scrolling(self):
104- self.assertFalse(self.scope.isCurrent)
105- self.dash.open_scope('applications')
106- self.assertThat(self.scope.isCurrent, Eventually(Equals(True)))
107+ scope = self.dash.open_scope('clickscope')
108+ self.assertThat(scope.isCurrent, Equals(True))
109
110
111 class TestCaseWithClickScopeOpen(BaseClickScopeTestCase):
112
113 def setUp(self):
114 super(TestCaseWithClickScopeOpen, self).setUp()
115- self.open_scope()
116+ self.scope = self.open_scope()
117
118 def test_search_available_app(self):
119 self.search('Shorts')
120- self.scope.wait_select_single('Tile', text='Shorts')
121+ applications = self.scope.get_applications('appstore')
122+ self.assertThat(applications[0].title, Equals('Shorts'))
123
124 def test_open_app_preview(self):
125 expected_details = dict(
126- title='Shorts', publisher='Ubuntu Click Loader')
127- preview = self.open_app_preview('Shorts')
128+ title='Shorts', subtitle='Shorts is an rssreader application')
129+ preview = self.open_app_preview('appstore', 'Shorts')
130 details = preview.get_details()
131 self.assertEqual(details, expected_details)
132
133 def test_install_without_credentials(self):
134- preview = self.open_app_preview('Shorts')
135+ preview = self.open_app_preview('appstore', 'Shorts')
136 preview.install()
137- error = self.dash.wait_select_single(DashPreview)
138+ error = self.dash.wait_select_single(Preview)
139+
140 details = error.get_details()
141 self.assertEqual('Login Error', details.get('title'))
142
143@@ -168,12 +182,14 @@
144 class ClickScopeTestCaseWithCredentials(BaseClickScopeTestCase):
145
146 def setUp(self):
147+ self.skipTest('segfaults. TODO in following branches.')
148 self.add_u1_credentials()
149 super(ClickScopeTestCaseWithCredentials, self).setUp()
150- self.open_scope()
151- self.preview = self.open_app_preview('Shorts')
152+ self.scope = self.open_scope()
153+ self.preview = self.open_app_preview('appstore', 'Shorts')
154
155 def add_u1_credentials(self):
156+ import pdb; pdb.set_trace()
157 account_manager = credentials.AccountManager()
158 account = account_manager.add_u1_credentials(
159 'dummy@example.com', 'dummy')
160@@ -187,43 +203,26 @@
161 self.preview.is_progress_bar_visible, Eventually(Equals(True)))
162
163
164-class Preview(object):
165-
166- def get_details(self):
167- """Return the details of the open preview."""
168- title = self.select_single('Label', objectName='titleLabel').text
169- subtitle = self.select_single(
170- 'Label', objectName='subtitleLabel').text
171- # The description label doesn't have an object name. Reported as bug
172- # http://pad.lv/1269114 -- elopio - 2014-1-14
173- # description = self.select_single(
174- # 'Label', objectName='descriptionLabel').text
175- # TODO check screenshots, icon, rating and reviews.
176- return dict(title=title, subtitle=subtitle)
177-
178-
179-# TODO move this to unity. --elopio - 2014-1-22
180-class DashPreview(unity_emulators.UnityEmulatorBase, Preview):
181- """Autopilot emulator for the generic preview."""
182-
183-
184-# TODO move this to unity. --elopio - 2014-1-14
185-class AppPreview(unity_emulators.UnityEmulatorBase, Preview):
186+class DashApps(dash.DashApps):
187+ """Autopilot emulator for the applicatios scope."""
188+
189+
190+class Preview(dash.Preview):
191 """Autopilot emulator for the application preview."""
192
193 def get_details(self):
194 """Return the details of the application whose preview is open."""
195- details = super(AppPreview, self).get_details()
196+ card_header = self.select_single('CardHeader', objectName='cardHeader')
197 return dict(
198- title=details.get('title'), publisher=details.get('subtitle'))
199+ title=card_header.title, subtitle=card_header.subtitle)
200
201 def install(self):
202- install_button = self.select_single('Button', objectName='button0')
203- if install_button.text != 'Install':
204- raise unity_emulators.UnityEmulatorException(
205- 'Install button not found.')
206+ parent = self.get_parent()
207+ install_button = self.select_single(
208+ 'PreviewActionButton', objectName='buttoninstall_click')
209 self.pointing_device.click_object(install_button)
210 self.implicitHeight.wait_for(0)
211+ parent.ready.wait_for(True)
212
213 def is_progress_bar_visible(self):
214 try:

Subscribers

People subscribed via source and target branches

to all changes: