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

Proposed by Leo Arias
Status: Merged
Approved by: dobey
Approved revision: 307
Merged at revision: 318
Proposed branch: lp:~elopio/unity-scope-click/split_scope
Merge into: lp:unity-scope-click/devel
Diff against target: 634 lines (+366/-124)
3 files modified
autopilot/unityclickscope/__init__.py (+128/-0)
autopilot/unityclickscope/fake_servers.py (+156/-50)
autopilot/unityclickscope/test_click_scope.py (+82/-74)
To merge this branch: bzr merge lp:~elopio/unity-scope-click/split_scope
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
dobey (community) Approve
Review via email: mp+224926@code.launchpad.net

Commit message

Updated the autopilot tests to use the split scopes.
Updated the tests to use dobey's application.
Moved all the helpers to the unityclickscope namespace, so they can be reused by UX tests.

To post a comment you must log in.
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) wrote :
review: Approve (continuous-integration)
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) wrote :
review: Approve (continuous-integration)
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) wrote :
review: Approve (continuous-integration)
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) wrote :
review: Approve (continuous-integration)
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) wrote :
review: Approve (continuous-integration)
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) wrote :
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: Needs Fixing (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
=== modified file 'autopilot/unityclickscope/__init__.py'
--- autopilot/unityclickscope/__init__.py 2013-12-28 02:13:26 +0000
+++ autopilot/unityclickscope/__init__.py 2014-07-07 21:14:23 +0000
@@ -0,0 +1,128 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2013, 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import logging
18
19import autopilot.logging
20import ubuntuuitoolkit
21from autopilot.introspection import dbus as autopilot_dbus
22from testtools.matchers import Equals, MatchesAny
23from unity8.shell.emulators import dash
24
25
26logger = logging.getLogger(__name__)
27
28
29class GenericScopeView(dash.DashApps):
30
31 """Autopilot helper for the generic scope view of the store."""
32
33 # XXX We need to set an objectName to this scope, so we can put a different
34 # name to this custom proxy object class. --elopio - 2014-06-28
35
36 def enter_search_query(self, query):
37 # TODO once http://pad.lv/1335551 is fixed, we can use the search
38 # helpers from unity. --elopio - 2014-06-28
39 search_text_field = self._get_search_text_field()
40 search_text_field.write(query)
41 search_text_field.state.wait_for('idle')
42
43 def _get_search_text_field(self):
44 page_header = self._get_scope_item_header()
45 search_container = page_header.select_single(
46 'QQuickItem', objectName='searchContainer')
47 search_container.state.wait_for(
48 MatchesAny(Equals('narrowActive'), Equals('active')))
49 return search_container.select_single(ubuntuuitoolkit.TextField)
50
51 def _get_scope_item_header(self):
52 return self._get_scope_item().select_single(
53 'PageHeader', objectName='')
54
55 def _get_scope_item(self):
56 return self.get_root_instance().select_single('ScopeItem')
57
58 @autopilot.logging.log_action(logger.info)
59 def open_preview(self, category, app_name):
60 """Open the preview of an application.
61
62 :parameter category: The name of the category where the application is.
63 :parameter app_name: The name of the application.
64 :return: The opened preview.
65
66 """
67 category_element = self._get_category_element(category)
68 icon = category_element.select_single('AbstractButton', title=app_name)
69 self.pointing_device.click_object(icon)
70 # TODO assign an object name to this preview list view.
71 # --elopio - 2014-06-29
72 preview_list = self._get_scope_item().wait_select_single(
73 'PreviewListView', objectName='')
74 preview_list.x.wait_for(0)
75 return preview_list.select_single(
76 Preview, objectName='preview{}'.format(preview_list.currentIndex))
77
78
79class DashApps(dash.DashApps):
80
81 """Autopilot helper for the applicatios scope."""
82
83 @autopilot.logging.log_action(logger.info)
84 def go_to_store(self):
85 """Open the applications store.
86
87 :return: The store Scope View.
88
89 """
90 # TODO call click_scope_item once the fix for bug http://pad.lv/1335548
91 # lands. --elopio - 2014-06-28
92 category_element = self._get_category_element('store')
93 icon = category_element.select_single(
94 'AbstractButton', title='Ubuntu Store')
95 self.pointing_device.click_object(icon)
96 scope_item = self.get_root_instance().select_single('ScopeItem')
97 scope_item.x.wait_for(0)
98 return scope_item.select_single(GenericScopeView)
99
100
101class Preview(dash.Preview):
102
103 """Autopilot helper for the application preview."""
104
105 def get_details(self):
106 """Return the details of the application whose preview is open."""
107 header_widget = self.select_single('PreviewWidget', objectName='hdr')
108 title_label = header_widget.select_single(
109 'Label', objectName='titleLabel')
110 subtitle_label = header_widget.select_single(
111 'Label', objectName='subtitleLabel')
112 return dict(
113 title=title_label.text, subtitle=subtitle_label.text)
114
115 def install(self):
116 parent = self.get_parent()
117 install_button = self.select_single(
118 'PreviewActionButton', objectName='buttoninstall_click')
119 self.pointing_device.click_object(install_button)
120 self.implicitHeight.wait_for(0)
121 parent.ready.wait_for(True)
122
123 def is_progress_bar_visible(self):
124 try:
125 self.select_single('ProgressBar', objectName='progressBar')
126 return True
127 except autopilot_dbus.StateNotFoundError:
128 return False
0129
=== modified file 'autopilot/unityclickscope/fake_servers.py'
--- autopilot/unityclickscope/fake_servers.py 2014-05-16 13:09:36 +0000
+++ autopilot/unityclickscope/fake_servers.py 2014-07-07 21:14:23 +0000
@@ -17,10 +17,16 @@
17import copy17import copy
18import http.server18import http.server
19import json19import json
20import logging
20import os21import os
21import tempfile22import tempfile
22import urllib.parse23import urllib.parse
2324
25import autopilot.logging
26
27
28logger = logging.getLogger(__name__)
29
2430
25class BaseFakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):31class BaseFakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
2632
@@ -55,71 +61,167 @@
55class FakeSearchRequestHandler(BaseFakeHTTPRequestHandler):61class FakeSearchRequestHandler(BaseFakeHTTPRequestHandler):
5662
57 _SEARCH_PATH = '/api/v1/search'63 _SEARCH_PATH = '/api/v1/search'
58 _FAKE_SEARCH_RESPONSE_DICT = [64 _FAKE_DELTA_RESULTS = {
59 {65 "publisher": "Rodney Dawes",
60 'resource_url': 'https://TODO/api/v1/package/com.ubuntu.shorts',66 "_links": {
61 'icon_url': '{U1_SEARCH_BASE_URL}extra/shorts.png',67 "self": {
62 'price': 0.0,68 "href": (
63 'name': 'com.ubuntu.shorts',69 "{U1_SEARCH_BASE_URL}api/v1/"
64 'title': 'Shorts'70 "package/com.ubuntu.developer.dobey.delta-web")
71 }
72 },
73 "architecture": ["all"],
74 "title": "Delta",
75 "icon_url": "http://TODO/delta-web.png",
76 "price": 0.0,
77 "name": "com.ubuntu.developer.dobey.delta-web"
78 }
79 _FAKE_SEARCH_RESPONSE_DICT = {
80 "_embedded": {
81 "clickindex:package": [_FAKE_DELTA_RESULTS]
82 },
83 }
84 _FAKE_DELTA_DETAILS_DICT = {
85 "website": "",
86 "description": (
87 "A simple web app for Delta.\n"
88 "Check in, view flight schedules, and book flights, on the Delta "
89 "mobile web site."),
90 "price": 0.0,
91 "date_published": "2014-05-03T15:30:16.431511Z",
92 "framework": ["ubuntu-sdk-14.04-qml-dev1"],
93 "terms_of_service": "",
94 "prices": {"USD": 0.0},
95 "screenshot_url": "http://TODO/delta-web-checkin.png",
96 "category": "Utility",
97 "publisher": "Rodney Dawes",
98 "name": "com.ubuntu.developer.dobey.delta-web",
99 "license": "GNU GPL v3",
100 "title": "Delta",
101 "support_url": "https://launchpad.net/~dobey",
102 "icon_url": "http://TODO/delta-web.png",
103 "changelog": "",
104 "binary_filesize": 23728,
105 "download_url": (
106 '{DOWNLOAD_BASE_URL}download/delta-dummy.click'),
107 "click_version": "0.1",
108 "developer_name": "Rodney Dawes",
109 "version": "1.0.1",
110 "company_name": "",
111 "keywords": [
112 "delta",
113 "airlines",
114 "flight",
115 "status",
116 "schedules"
117 ],
118 "department": ["Accessories"],
119 "screenshot_urls": [
120 "http://TODO/delta-web-checkin.png",
121 "https://TODO/delta-web-main.png"
122 ],
123 "architecture": ["all"]
124 }
125 _FAKE_DETAILS = {
126 'com.ubuntu.developer.dobey.delta-web': _FAKE_DELTA_DETAILS_DICT
127 }
128 _FAKE_INDEX = {
129 "_embedded": {
130 "clickindex:department": [
131 {
132 "has_children": False,
133 "_links": {
134 "self": {
135 "href": (
136 "{U1_SEARCH_BASE_URL}api/v1/departments/"
137 "accessories")
138 }
139 },
140 "name": "Accessories",
141 "slug": "accesories"
142 },
143 ],
144 "clickindex:highlight": [
145 {
146 "_embedded": {
147 "clickindex:package": [_FAKE_DELTA_RESULTS],
148 },
149 "_links": {
150 "self": {
151 "href": (
152 "{U1_SEARCH_BASE_URL}api/v1/highlights/"
153 "travel-apps")
154 }
155 },
156 "name": "Travel apps",
157 "slug": "travel-apps"
158 },
159 ],
160 },
161 '_links': {
162 'clickindex:department': {
163 'href': "{U1_SEARCH_BASE_URL}api/v1/departments/{slug}",
164 'templated': True,
165 'title': 'Department'
166 },
167 'clickindex:departments': {
168 'href': "{U1_SEARCH_BASE_URL}api/v1/departments",
169 'title': 'Departments'
170 },
171 'clickindex:highlight': {
172 'href': '{U1_SEARCH_BASE_URL}api/v1/highlights/{slug}',
173 'templated': True,
174 'title': 'Highlight'
175 },
176 'clickindex:highlights': {
177 'href': '{U1_SEARCH_BASE_URL}api/v1/highlights',
178 'title': 'Highlights'
179 },
180 'clickindex:package': {
181 'href': '{U1_SEARCH_BASE_URL}api/v1/package/{name}',
182 'templated': True,
183 'title': 'Package'
184 },
185 'curies': [
186 {
187 'href': '{U1_SEARCH_BASE_URL}docs/v1/relations.html{#rel}',
188 'name': 'clickindex',
189 'templated': True
190 }
191 ],
192 'search': {
193 'href': '{U1_SEARCH_BASE_URL}api/v1/search{?q}',
194 'templated': True,
195 'title': 'Search'
196 },
197 'self': {
198 'href': '{U1_SEARCH_BASE_URL}api/v1'
199 }
65 }200 }
66 ]
67 _FAKE_SHORTS_DETAILS_DICT = {
68 'website': 'https://launchpad.net/ubuntu-rssreader-app',
69 'description': (
70 'Shorts is an rssreader application\n'
71 'Shorts is an rss reader application that allows you to easily '
72 'search for new feeds.'),
73 'price': 0.0,
74 'framework': ["ubuntu-sdk-13.10"],
75 'terms_of_service': '',
76 'prices': {'USD': 0.0},
77 'screenshot_url': 'https://TODO/shorts0.png',
78 'date_published': '2013-10-16T15:58:52.469000',
79 'publisher': 'Ubuntu Click Loader',
80 'name': 'com.ubuntu.shorts',
81 'license': 'GNU GPL v3',
82 'changelog': 'Test fixes',
83 'support_url': 'mailto:ubuntu-touch-coreapps@lists.launchpad.net',
84 'icon_url': 'https://TODO/shorts.png',
85 'title': 'Shorts',
86 'binary_filesize': 164944,
87 'download_url': (
88 '{DOWNLOAD_BASE_URL}download/shorts-dummy.click'),
89 'click_version': '0.1',
90 'developer_name': 'Ubuntu Click Loader',
91 'version': '0.2.152',
92 'company_name': '',
93 'keywords': ['shorts', 'rss', 'news'],
94 'screenshot_urls': [
95 'https://TODO/shorts0.png',
96 'https://TODO/shorts1.png'
97 ],
98 'architecture': ['all']
99 }
100 _FAKE_DETAILS = {
101 'com.ubuntu.shorts': _FAKE_SHORTS_DETAILS_DICT
102 }201 }
103202
104 def do_GET(self):203 def do_GET(self):
105 parsed_path = urllib.parse.urlparse(self.path)204 parsed_path = urllib.parse.urlparse(self.path)
106 if parsed_path.path.startswith(self._SEARCH_PATH):205 if parsed_path.path.startswith(self._SEARCH_PATH):
107 self.send_json_reply(200, self._get_fake_search_response())206 self.send_search_results()
108 elif parsed_path.path.startswith('/extra/'):207 elif parsed_path.path.startswith('/extra/'):
109 self.send_file(parsed_path.path[1:])208 self.send_file(parsed_path.path[1:])
110 elif parsed_path.path.startswith('/api/v1/package/'):209 elif parsed_path.path.startswith('/api/v1/package/'):
111 package = parsed_path.path[16:]210 package = parsed_path.path[16:]
112 self.send_package_details(package)211 self.send_package_details(package)
212 elif parsed_path.path.startswith('/api/v1'):
213 self.send_index()
113 else:214 else:
215 logger.error(
216 'Not implemented path in fake server: {}'.format(self.path))
114 raise NotImplementedError(self.path)217 raise NotImplementedError(self.path)
115218
116 def _get_fake_search_response(self):219 @autopilot.logging.log_action(logger.debug)
117 fake_search_response = copy.deepcopy(self._FAKE_SEARCH_RESPONSE_DICT)220 def send_search_results(self):
118 for result in fake_search_response:221 results = json.dumps(self._FAKE_SEARCH_RESPONSE_DICT)
119 result['icon_url'] = result['icon_url'].format(222 self.send_json_reply(200, results)
120 U1_SEARCH_BASE_URL=os.environ.get('U1_SEARCH_BASE_URL'))
121 return json.dumps(fake_search_response)
122223
224 @autopilot.logging.log_action(logger.debug)
123 def send_package_details(self, package):225 def send_package_details(self, package):
124 details = copy.deepcopy(self._FAKE_DETAILS.get(package, None))226 details = copy.deepcopy(self._FAKE_DETAILS.get(package, None))
125 if details is not None:227 if details is not None:
@@ -130,6 +232,10 @@
130 else:232 else:
131 raise NotImplementedError(package)233 raise NotImplementedError(package)
132234
235 @autopilot.logging.log_action(logger.debug)
236 def send_index(self):
237 self.send_json_reply(200, json.dumps(self._FAKE_INDEX))
238
133239
134class FakeDownloadServer(http.server.HTTPServer, object):240class FakeDownloadServer(http.server.HTTPServer, object):
135241
136242
=== modified file 'autopilot/unityclickscope/test_click_scope.py'
--- autopilot/unityclickscope/test_click_scope.py 2014-05-26 08:06:08 +0000
+++ autopilot/unityclickscope/test_click_scope.py 2014-07-07 21:14:23 +0000
@@ -21,14 +21,12 @@
2121
22import dbusmock22import dbusmock
23import fixtures23import fixtures
24from autopilot.introspection import dbus as autopilot_dbus
25from autopilot.matchers import Eventually24from autopilot.matchers import Eventually
26from testtools.matchers import Equals25from testtools.matchers import Equals
27from unity8 import process_helpers26from unity8 import process_helpers
28from unity8.shell import tests as unity_tests27from unity8.shell import tests as unity_tests
29from unity8.shell.emulators import dash28
3029import unityclickscope
31
32from unityclickscope import credentials, fake_services, fixture_setup30from unityclickscope import credentials, fake_services, fixture_setup
3331
3432
@@ -53,11 +51,14 @@
5351
54 # We use fake servers by default because the current Jenkins52 # We use fake servers by default because the current Jenkins
55 # configuration does not let us override the variables.53 # configuration does not let us override the variables.
56 if os.environ.get('U1_SEARCH_BASE_URL', 'fake') == 'fake':
57 self._use_fake_server()
58 if os.environ.get('DOWNLOAD_BASE_URL', 'fake') == 'fake':54 if os.environ.get('DOWNLOAD_BASE_URL', 'fake') == 'fake':
59 self._use_fake_download_server()55 self._use_fake_download_server()
60 self._use_fake_download_service()56 self._use_fake_download_service()
57 if os.environ.get('U1_SEARCH_BASE_URL', 'fake') == 'fake':
58 self._use_fake_server()
59
60 self.useFixture(fixtures.EnvironmentVariable('U1_DEBUG', newvalue='1'))
61 self._restart_scopes()
6162
62 unity_proxy = self.launch_unity()63 unity_proxy = self.launch_unity()
63 process_helpers.unlock_unity(unity_proxy)64 process_helpers.unlock_unity(unity_proxy)
@@ -69,7 +70,6 @@
69 self.useFixture(fake_search_server)70 self.useFixture(fake_search_server)
70 self.useFixture(fixtures.EnvironmentVariable(71 self.useFixture(fixtures.EnvironmentVariable(
71 'U1_SEARCH_BASE_URL', newvalue=fake_search_server.url))72 'U1_SEARCH_BASE_URL', newvalue=fake_search_server.url))
72 self._restart_scope()
7373
74 def _use_fake_download_server(self):74 def _use_fake_download_server(self):
75 fake_download_server = fixture_setup.FakeDownloadServerRunning()75 fake_download_server = fixture_setup.FakeDownloadServerRunning()
@@ -106,43 +106,78 @@
106 dbus_mock.terminate()106 dbus_mock.terminate()
107 dbus_mock.wait()107 dbus_mock.wait()
108108
109 def _restart_scope(self):109 def _restart_scopes(self):
110 logging.info('Restarting click scope.')110 logging.info('Restarting click scope.')
111 scope_runner_path = self._get_scoperunner_path()
112 apps_scope_ini_path, store_scope_ini_path = self._get_scopes_ini_path()
113
111 os.system('pkill -f -9 clickscope.ini')114 os.system('pkill -f -9 clickscope.ini')
112 os.system(115 os.system('pkill -f -9 clickstore.ini')
113 "dpkg-architecture -c "116
114 "'{scoperunner} \"\" {clickscope}' &".format(117 os.system('{scoperunner} "" {appsscope} &'.format(
115 scoperunner=self._get_scoperunner_path(),118 scoperunner=scope_runner_path,
116 clickscope=self._get_scope_ini_path()))119 appsscope=apps_scope_ini_path))
120
121 os.system('{scoperunner} "" {storescope} &'.format(
122 scoperunner=scope_runner_path,
123 storescope=store_scope_ini_path))
117124
118 def _get_scoperunner_path(self):125 def _get_scoperunner_path(self):
119 return os.path.join(126 return os.path.join(
120 self._get_installed_unity_scopes_lib_dir(), 'scoperunner')127 self._get_installed_unity_scopes_lib_dir(), 'scoperunner')
121128
122 def _get_installed_unity_scopes_lib_dir(self):129 def _get_installed_unity_scopes_lib_dir(self):
123 return os.path.join('/usr/lib/$DEB_HOST_MULTIARCH/', 'unity-scopes')130 arch = subprocess.check_output(
131 ["dpkg-architecture", "-qDEB_HOST_MULTIARCH"],
132 universal_newlines=True).strip()
133 return os.path.join('/usr/lib/{}/'.format(arch), 'unity-scopes')
124134
125 def _get_scope_ini_path(self):135 def _get_scopes_ini_path(self):
126 build_dir = os.environ.get('BUILD_DIR', None)136 build_dir = os.environ.get('BUILD_DIR', None)
127 if build_dir is not None:137 if build_dir is not None:
128 return self._get_built_scope_ini_path(build_dir)138 return self._get_built_scopes_ini_path(build_dir)
129 else:139 else:
130 return os.path.join(140 app_scope_ini_path = os.path.join(
131 self._get_installed_unity_scopes_lib_dir(),141 self._get_installed_unity_scopes_lib_dir(),
132 'clickscope', 'clickscope.ini')142 'clickapps', 'clickscope.ini')
143 store_scope_ini_path = os.path.join(
144 self._get_installed_unity_scopes_lib_dir(),
145 'clickstore', 'com.canonical.scopes.clickstore.ini')
146 return app_scope_ini_path, store_scope_ini_path
133147
134 def _get_built_scope_ini_path(self, build_dir):148 def _get_built_scopes_ini_path(self, build_dir):
135 # The ini and the so files need to be on the same directory.149 # The ini and the so files need to be on the same directory.
136 # We copy them to a temp directory.150 # We copy them to a temp directory.
137 temp_dir_fixture = fixtures.TempDir()151 temp_dir_fixture = fixtures.TempDir()
138 self.useFixture(temp_dir_fixture)152 self.useFixture(temp_dir_fixture)
139 shutil.copy(153
140 os.path.join(build_dir, 'data', 'clickscope.ini'),154 built_apps_scope_ini = os.path.join(
141 temp_dir_fixture.path)155 build_dir, 'data', 'clickscope.ini')
142 shutil.copy(156 temp_apps_scope_dir = os.path.join(temp_dir_fixture.path, 'clickapps')
143 os.path.join(build_dir, 'scope', 'click', 'libclickscope.so'),157 os.mkdir(temp_apps_scope_dir)
144 temp_dir_fixture.path)158 shutil.copy(built_apps_scope_ini, temp_apps_scope_dir)
145 return os.path.join(temp_dir_fixture.path, 'clickscope.ini')159
160 built_apps_scope = os.path.join(
161 build_dir, 'scope', 'clickapps', 'scope.so')
162 shutil.copy(built_apps_scope, temp_apps_scope_dir)
163
164 built_store_scope_ini = os.path.join(
165 build_dir, 'data', 'com.canonical.scopes.clickstore.ini')
166 temp_store_scope_dir = os.path.join(
167 temp_dir_fixture.path, 'clickstore')
168 os.mkdir(temp_store_scope_dir)
169 shutil.copy(built_store_scope_ini, temp_store_scope_dir)
170
171 built_store_scope = os.path.join(
172 build_dir, 'scope', 'clickstore',
173 'com.canonical.scopes.clickstore.so')
174 shutil.copy(built_store_scope, temp_store_scope_dir)
175
176 app_scope_ini_path = os.path.join(
177 temp_apps_scope_dir, 'clickscope.ini')
178 store_scope_ini_path = os.path.join(
179 temp_store_scope_dir, 'com.canonical.scopes.clickstore.ini')
180 return app_scope_ini_path, store_scope_ini_path
146181
147 def _unlock_screen(self):182 def _unlock_screen(self):
148 self.main_window.get_greeter().swipe()183 self.main_window.get_greeter().swipe()
@@ -155,8 +190,8 @@
155 def search(self, query):190 def search(self, query):
156 search_indicator = self._proxy.select_single(191 search_indicator = self._proxy.select_single(
157 'SearchIndicator', objectName='search')192 'SearchIndicator', objectName='search')
158 self.touch.tap_object(search_indicator)193 search_indicator.pointing_device.click_object(search_indicator)
159 self.dash.enter_search_query(query)194 self.scope.enter_search_query(query)
160195
161 def open_app_preview(self, category, name):196 def open_app_preview(self, category, name):
162 self.search(name)197 self.search(name)
@@ -172,40 +207,46 @@
172 self.assertThat(scope.isCurrent, Equals(True))207 self.assertThat(scope.isCurrent, Equals(True))
173208
174209
175class TestCaseWithClickScopeOpen(BaseClickScopeTestCase):210class BaseTestCaseWithStoreScopeOpen(BaseClickScopeTestCase):
176211
177 def setUp(self):212 def setUp(self):
178 super(TestCaseWithClickScopeOpen, self).setUp()213 super(BaseTestCaseWithStoreScopeOpen, self).setUp()
179 self.scope = self.open_scope()214 app_scope = self.open_scope()
215 self.scope = app_scope.go_to_store()
216
217
218class TestCaseWithStoreScopeOpen(BaseTestCaseWithStoreScopeOpen):
180219
181 def test_search_available_app(self):220 def test_search_available_app(self):
182 self.search('Shorts')221 self.search('Delta')
183 applications = self.scope.get_applications('appstore')222 applications = self.scope.get_applications('appstore')
184 self.assertThat(applications[0], Equals('Shorts'))223 self.assertThat(applications[0], Equals('Delta'))
185224
186 def test_open_app_preview(self):225 def test_open_app_preview(self):
187 expected_details = dict(226 expected_details = dict(
188 title='Shorts', subtitle='Ubuntu Click Loader')227 title='Delta', subtitle='Rodney Dawes')
189 preview = self.open_app_preview('appstore', 'Shorts')228 preview = self.open_app_preview('appstore', 'Delta')
190 details = preview.get_details()229 details = preview.get_details()
191 self.assertEqual(details, expected_details)230 self.assertEqual(details, expected_details)
192231
193 def test_install_without_credentials(self):232 def test_install_without_credentials(self):
194 preview = self.open_app_preview('appstore', 'Shorts')233 preview = self.open_app_preview('appstore', 'Delta')
195 preview.install()234 preview.install()
196 error = self.dash.wait_select_single(Preview)235 error = self.dash.wait_select_single(unityclickscope.Preview)
197236
198 details = error.get_details()237 details = error.get_details()
199 self.assertEqual('Login Error', details.get('title'))238 self.assertEqual('Login Error', details.get('title'))
200239
201240
202class ClickScopeTestCaseWithCredentials(BaseClickScopeTestCase):241class ClickScopeTestCaseWithCredentials(BaseTestCaseWithStoreScopeOpen):
203242
204 def setUp(self):243 def setUp(self):
244 self.skipTest(
245 'We cannot add credentials yet because the keyring dialog will be '
246 'opened prompting for a password. http://pad.lv/1338714')
205 self.add_u1_credentials()247 self.add_u1_credentials()
206 super(ClickScopeTestCaseWithCredentials, self).setUp()248 super(ClickScopeTestCaseWithCredentials, self).setUp()
207 self.scope = self.open_scope()249 self.preview = self.open_app_preview('appstore', 'Delta')
208 self.preview = self.open_app_preview('appstore', 'Shorts')
209250
210 def add_u1_credentials(self):251 def add_u1_credentials(self):
211 account_manager = credentials.AccountManager()252 account_manager = credentials.AccountManager()
@@ -224,36 +265,3 @@
224 self.preview.install()265 self.preview.install()
225 self.assertThat(266 self.assertThat(
226 self.preview.is_progress_bar_visible, Eventually(Equals(True)))267 self.preview.is_progress_bar_visible, Eventually(Equals(True)))
227
228
229class DashApps(dash.DashApps):
230 """Autopilot emulator for the applicatios scope."""
231
232
233class Preview(dash.Preview):
234 """Autopilot emulator for the application preview."""
235
236 def get_details(self):
237 """Return the details of the application whose preview is open."""
238 header_widget = self.select_single('PreviewWidget', objectName='hdr')
239 title_label = header_widget.select_single(
240 'Label', objectName='titleLabel')
241 subtitle_label = header_widget.select_single(
242 'Label', objectName='subtitleLabel')
243 return dict(
244 title=title_label.text, subtitle=subtitle_label.text)
245
246 def install(self):
247 parent = self.get_parent()
248 install_button = self.select_single(
249 'PreviewActionButton', objectName='buttoninstall_click')
250 self.pointing_device.click_object(install_button)
251 self.implicitHeight.wait_for(0)
252 parent.ready.wait_for(True)
253
254 def is_progress_bar_visible(self):
255 try:
256 self.select_single('ProgressBar', objectName='progressBar')
257 return True
258 except autopilot_dbus.StateNotFoundError:
259 return False

Subscribers

People subscribed via source and target branches

to all changes: