Merge lp:~konrad11901/ubuntu-system-tests/add-gnome-software-tests into lp:ubuntu-system-tests

Proposed by Konrad Krawiec
Status: Merged
Merged at revision: 580
Proposed branch: lp:~konrad11901/ubuntu-system-tests/add-gnome-software-tests
Merge into: lp:ubuntu-system-tests
Diff against target: 455 lines (+349/-6)
5 files modified
ubuntu_system_tests/helpers/application.py (+10/-1)
ubuntu_system_tests/helpers/chromium/app.py (+30/-0)
ubuntu_system_tests/helpers/entangle/app.py (+30/-0)
ubuntu_system_tests/helpers/gnome_sofware/cpo.py (+39/-3)
ubuntu_system_tests/tests/test_gnome_software.py (+240/-2)
To merge this branch: bzr merge lp:~konrad11901/ubuntu-system-tests/add-gnome-software-tests
Reviewer Review Type Date Requested Status
platform-qa-bot continuous-integration Needs Fixing
Heber Parrucci (community) Approve
Review via email: mp+336169@code.launchpad.net

Description of the change

Add eight testcases:
1. Existing application packaged as deb (not installed)
2. Existing application packaged as snap (installed)
3. Existing application packaged as snap (not installed)
4. Mixed results (deb, snap, installed and not installed)
5. Number of characters in search string
6. Multi words search
7. Several searches in a row
8. Featured application - Verify that clicking on the image opens the detailed page of the application

It's important to note that testcase number 4 works only sometimes (chromium snap isn't always detected as installed, don't know why) and the testcase no. 8 doesn't work at all and requires fixing (I'd be really thankful for the help with this).

Also, you might notice that I added 0.1s sleep after clicking the search button in every search testcase. It's because in my testing environment sometimes the first letter of the string wasn't typed, so sometimes instead of i.e. 'gnome-software', 'nome-software' was typed. If it shouldn't be here, feel free to tell me and I'll remove that.

To post a comment you must log in.
Revision history for this message
Heber Parrucci (heber013) wrote :

Looks good in general. Some corrections to make.

review: Needs Fixing
Revision history for this message
Konrad Krawiec (konrad11901) wrote :

I added the suggested changes.

Revision history for this message
Heber Parrucci (heber013) wrote :

Looks good. For those tests that fail randomly or do not work at all, please add @skip and the reason so we can fix them later. Apart from the ones you mentioned, this one is also failing:
2. Existing application packaged as snap

review: Needs Fixing
Revision history for this message
Heber Parrucci (heber013) wrote :

Looks good to me.

review: Approve
Revision history for this message
platform-qa-bot (platform-qa-bot) wrote :

FAILED: Autolanding.
No commit message was specified in the merge proposal. Hit 'Add commit message' on the merge proposal web page or follow the link below. You can approve the merge proposal yourself to rerun.
https://code.launchpad.net/~konrad11901/ubuntu-system-tests/add-gnome-software-tests/+merge/336169/+edit-commit-message

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntu_system_tests/helpers/application.py'
--- ubuntu_system_tests/helpers/application.py 2017-09-14 14:06:34 +0000
+++ ubuntu_system_tests/helpers/application.py 2018-01-18 21:17:49 +0000
@@ -36,6 +36,7 @@
36)36)
3737
38from ubuntu_system_tests.helpers.utils import is_discovery38from ubuntu_system_tests.helpers.utils import is_discovery
39from ubuntu_system_tests.helpers.testbed import run_command_with_sudo
3940
40logger = logging.getLogger(__name__)41logger = logging.getLogger(__name__)
41logger.setLevel(logging.INFO)42logger.setLevel(logging.INFO)
@@ -207,7 +208,15 @@
207 return len(output) > 0 and 'ok installed' in output.decode()208 return len(output) > 0 and 'ok installed' in output.decode()
208 except subprocess.CalledProcessError:209 except subprocess.CalledProcessError:
209 try:210 try:
210 output = subprocess.check_output(cmd + [self.package_name])211 output = subprocess.check_output(cmd + [self.package_name or ''])
211 return len(output) > 0 and 'ok installed' in output.decode()212 return len(output) > 0 and 'ok installed' in output.decode()
212 except subprocess.CalledProcessError:213 except subprocess.CalledProcessError:
213 return False214 return False
215
216 def install(self):
217 cmd = ['apt', 'install', self.app_name, '-y']
218 run_command_with_sudo(cmd)
219
220 def remove(self):
221 cmd = ['apt', 'remove', self.app_name, '-y']
222 run_command_with_sudo(cmd)
214223
=== added directory 'ubuntu_system_tests/helpers/chromium'
=== added file 'ubuntu_system_tests/helpers/chromium/app.py'
--- ubuntu_system_tests/helpers/chromium/app.py 1970-01-01 00:00:00 +0000
+++ ubuntu_system_tests/helpers/chromium/app.py 2018-01-18 21:17:49 +0000
@@ -0,0 +1,30 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Ubuntu System Tests
5# Copyright (C) 2015-2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21from ubuntu_system_tests.helpers.application import Deb
22
23APP_NAME = 'chromium-browser'
24APP_ID = 'chromium-browser'
25
26
27class Chromium(Deb):
28
29 def __init__(self):
30 super().__init__(APP_NAME, APP_ID)
031
=== added directory 'ubuntu_system_tests/helpers/entangle'
=== added file 'ubuntu_system_tests/helpers/entangle/app.py'
--- ubuntu_system_tests/helpers/entangle/app.py 1970-01-01 00:00:00 +0000
+++ ubuntu_system_tests/helpers/entangle/app.py 2018-01-18 21:17:49 +0000
@@ -0,0 +1,30 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
3#
4# Ubuntu System Tests
5# Copyright (C) 2015-2017 Canonical
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19#
20
21from ubuntu_system_tests.helpers.application import Deb
22
23APP_NAME = 'entangle'
24APP_ID = 'entangle'
25
26
27class Entangle(Deb):
28
29 def __init__(self):
30 super().__init__(APP_NAME, APP_ID)
031
=== modified file 'ubuntu_system_tests/helpers/gnome_sofware/cpo.py'
--- ubuntu_system_tests/helpers/gnome_sofware/cpo.py 2018-01-04 00:36:29 +0000
+++ ubuntu_system_tests/helpers/gnome_sofware/cpo.py 2018-01-18 21:17:49 +0000
@@ -60,6 +60,7 @@
60 :param text: the string to write in search box60 :param text: the string to write in search box
61 :return: ResultsPage object61 :return: ResultsPage object
62 """62 """
63 time.sleep(0.1)
63 self.get_entry_search(is_focus=True)64 self.get_entry_search(is_focus=True)
64 input_manager.keyboard.type(text)65 input_manager.keyboard.type(text)
65 return ResultsPage(self.proxy)66 return ResultsPage(self.proxy)
@@ -163,6 +164,19 @@
163 except (DBusException, StateNotFoundError):164 except (DBusException, StateNotFoundError):
164 return False165 return False
165166
167 def open_featured_app(self):
168 """Open the featured app's description
169 :return The page with the featured app's description
170 """
171 item = self.proxy.wait_select_single(BuilderName='GsFeatureTile', visible=True)
172 box = item.wait_select_single(BuilderName='box')
173 # This line throws an exception:
174 input_manager.pointer.click_object(box)
175 self.proxy.wait_select_single(
176 BuilderName='box_details',
177 visible=True)
178 return ItemDetailsPage(self.proxy.select_single(BuilderName='details_page'))
179
166180
167class ResultsPage(GnomeSoftwareCPO):181class ResultsPage(GnomeSoftwareCPO):
168 def __init__(self, proxy):182 def __init__(self, proxy):
@@ -172,12 +186,12 @@
172 """Get the current results186 """Get the current results
173 :return the list with the current results or empty187 :return the list with the current results or empty
174 """188 """
189 attempts = 1
190 retries = kwargs.pop('retries', 10)
191 wait = kwargs.pop('wait', 5)
175 search = self.proxy.wait_select_single(BuilderName='list_box_search',192 search = self.proxy.wait_select_single(BuilderName='list_box_search',
176 *args,193 *args,
177 **kwargs)194 **kwargs)
178 attempts = 1
179 retries = kwargs.pop('retries', 10)
180 wait = kwargs.pop('wait', 5)
181 # Wait until search finishes and return results195 # Wait until search finishes and return results
182 while attempts < retries:196 while attempts < retries:
183 try:197 try:
@@ -205,6 +219,28 @@
205 except (DBusException, StateNotFoundError):219 except (DBusException, StateNotFoundError):
206 return False220 return False
207221
222 @staticmethod
223 def check_app_present(items, app_to_search):
224 """Check if the given application is present in the search results
225 :param items: the list of results to check
226 :param app_to_search: the name (visible in GNOME Software)
227 of the application to find
228 :return True if the given application is present in the search results
229 """
230 for item in items:
231 try:
232 label = item.select_single(BuilderName="name_label", visible=True).label
233 if label == app_to_search:
234 return True
235 except (DBusException, StateNotFoundError):
236 pass
237 return False
238
239 @staticmethod
240 def get_app_name(item):
241 """Gets the name of the application taken from the search results."""
242 return item.select_single(BuilderName="name_label", visible=True).label
243
208 def open_item(self, item):244 def open_item(self, item):
209 """Click on the given item245 """Click on the given item
210 :param item: the item click on246 :param item: the item click on
211247
=== modified file 'ubuntu_system_tests/tests/test_gnome_software.py'
--- ubuntu_system_tests/tests/test_gnome_software.py 2018-01-11 13:14:30 +0000
+++ ubuntu_system_tests/tests/test_gnome_software.py 2018-01-18 21:17:49 +0000
@@ -16,7 +16,7 @@
16# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19from testtools import skipIf19from testtools import skipIf, skip
2020
21from ubuntu_system_tests.helpers.session.release import get_release, XENIAL21from ubuntu_system_tests.helpers.session.release import get_release, XENIAL
2222
@@ -24,6 +24,9 @@
24from ubuntu_system_tests.helpers.testbed import run_command24from ubuntu_system_tests.helpers.testbed import run_command
25from ubuntu_system_tests.helpers.gnome_sofware.app import GnomeSoftware25from ubuntu_system_tests.helpers.gnome_sofware.app import GnomeSoftware
26from ubuntu_system_tests.tests.base import BaseUbuntuSystemTestCase26from ubuntu_system_tests.tests.base import BaseUbuntuSystemTestCase
27from ubuntu_system_tests.helpers.snapd.snapd import Snapd
28from ubuntu_system_tests.helpers.chromium.app import Chromium
29from ubuntu_system_tests.helpers.entangle.app import Entangle
2730
2831
29class TestGnomeSoftware(BaseUbuntuSystemTestCase):32class TestGnomeSoftware(BaseUbuntuSystemTestCase):
@@ -47,7 +50,7 @@
47 'Search entry is not hidden')50 'Search entry is not hidden')
4851
49 def test_check_installed_deb(self):52 def test_check_installed_deb(self):
50 """ Check already installed deb """53 """Check already installed deb"""
51 # Perform the search54 # Perform the search
52 self.app.click_search_button()55 self.app.click_search_button()
53 results_page = self.app.write_search('gnome-software')56 results_page = self.app.write_search('gnome-software')
@@ -66,6 +69,60 @@
66 item_details = results_page.open_item(item)69 item_details = results_page.open_item(item)
67 self.assertTrue(item_details.check_description())70 self.assertTrue(item_details.check_description())
6871
72 def test_number_of_characters_in_search_string(self):
73 """Check the 2, 3 and 5 chars long search strings"""
74 # Perform the search with 2 chars
75 self.app.click_search_button()
76 results_page = self.app.write_search('ge')
77 results = results_page.get_results(retries=2)
78 # Verify that no search was performed
79 self.assertEquals(0, len(results),
80 'Expected 0 items. But found: %s' % len(results))
81 # Add the third character
82 results_page = self.app.write_search('d')
83 results = results_page.get_results()
84 # Check if the search results contain 'gedit'
85 self.assertTrue(results_page.check_app_present(results,
86 'gedit'))
87 items_number = len(results)
88 # Add another two chars, so we have 'gedit' in the box
89 results_page = self.app.write_search('it')
90 results = results_page.get_results()
91 # Check if the search results contain 'gedit'
92 self.assertTrue(results_page.check_app_present(results,
93 'gedit'))
94 # Check if there are fewer results than before
95 self.assertTrue(items_number > len(results))
96
97 def test_several_searches(self):
98 """Check if several searches in a row perform normally"""
99 # Perform the first search
100 self.app.click_search_button()
101 results_page = self.app.write_search('gimp')
102 # Verify that the search results contain 'GIMP'
103 results = results_page.get_results()
104 self.assertTrue(results_page.check_app_present(results,
105 'GIMP'))
106 # Clean the search box by double clicking the button and
107 # perform the second search
108 self.app.click_search_button()
109 self.app.click_search_button()
110 results_page = self.app.write_search('editor')
111 # Check if the search results contain 'gedit'
112 results = results_page.get_results()
113 self.assertTrue(results_page.check_app_present(results,
114 'gedit'))
115
116 def test_multi_words_search(self):
117 """Check if multi words search performs normally"""
118 # Perform the multi words search
119 self.app.click_search_button()
120 results_page = self.app.write_search('gnome software')
121 # Verify that the search results contain 'GNOME Software'
122 results = results_page.get_results()
123 self.assertTrue(results_page.check_app_present(results,
124 'GNOME Software'))
125
69 def test_all_page_sections(self):126 def test_all_page_sections(self):
70 """Check categories after clicking on down arrow"""127 """Check categories after clicking on down arrow"""
71 labels = self.app.get_all_page_sections()128 labels = self.app.get_all_page_sections()
@@ -111,3 +168,184 @@
111 items = self.app.get_editors_picks()168 items = self.app.get_editors_picks()
112 for item in items:169 for item in items:
113 self.assertTrue(self.app.check_item(item, 'image'))170 self.assertTrue(self.app.check_item(item, 'image'))
171
172 @skip('This test never passes, open_featured_app function needs to be fixed')
173 def test_featured_application_description(self):
174 """Check there is a description after clicking the featured
175 application image"""
176 featured_details = self.app.open_featured_app()
177 self.assertTrue(featured_details.check_description())
178
179
180class TestGnomeSoftwareMixedResults(BaseUbuntuSystemTestCase):
181
182 def setUp(self):
183 super(TestGnomeSoftwareMixedResults, self).setUp()
184 self.snapd = Snapd()
185 run_command('killall gnome-software')
186 self.is_snap_installed = self.snapd.is_installed('chromium')
187 if not self.is_snap_installed:
188 self.snapd.install('chromium')
189 self.chromium = Chromium()
190 self.is_deb_installed = self.chromium._is_installed()
191 if self.is_deb_installed:
192 self.chromium.remove()
193 self.root = GnomeSoftware().launch(app_type='gtk')
194 self.app = GnomeSoftwareCPO(self.root)
195
196 @skip('This tests randomly fails, so it needs to be fixed')
197 def test_mixed_results(self):
198 """Check there are deb and snap versions"""
199 # Perform the search
200 self.app.click_search_button()
201 results_page = self.app.write_search('chromium')
202 # Verify that there is more than one result
203 results = results_page.get_results()
204 self.assertTrue(len(results) > 1)
205 # Check item attributes in results
206 self.assertTrue(results_page.check_item(results[0],
207 'image',
208 'description_label'))
209 self.assertTrue(results_page.check_item(results[1],
210 'image',
211 'description_label'))
212 # Determine which result is a snap and which is a deb
213 if (results_page.get_app_name(results[0]) == 'Chromium'):
214 i = 0
215 j = 1
216 else:
217 i = 1
218 j = 0
219 # Check if the snap is visible as installed
220 self.assertTrue(results_page.check_item(results[i],
221 'label_installed'))
222 # Check if there is rating of the deb
223 self.assertTrue(results_page.check_item(results[j],
224 'star'))
225 # Check if the deb is visible as not installed
226 self.assertFalse(results_page.check_item(results[j],
227 'label_installed'))
228
229 def tearDown(self):
230 super(TestGnomeSoftwareMixedResults, self).tearDown()
231 if not self.is_snap_installed:
232 self.snapd.remove('chromium')
233 if self.is_deb_installed:
234 self.chromium.install()
235
236
237class TestGnomeSoftwareInstalledSnap(BaseUbuntuSystemTestCase):
238
239 def setUp(self):
240 super(TestGnomeSoftwareInstalledSnap, self).setUp()
241 self.snapd = Snapd()
242 run_command('killall gnome-software')
243 self.is_installed = self.snapd.is_installed('hello-unity')
244 if not self.is_installed:
245 self.snapd.install('hello-unity')
246 self.root = GnomeSoftware().launch(app_type='gtk')
247 self.app = GnomeSoftwareCPO(self.root)
248
249 @skip('In some cases this test freezes at setup, so it needs to be fixed')
250 def test_check_installed_snap(self):
251 """Check already installed snap"""
252 # Perform the search
253 self.app.click_search_button()
254 results_page = self.app.write_search('hello-unity')
255 # Verify that the result contains only 1 line with hello-unity.
256 results = results_page.get_results()
257 self.assertEquals(1, len(results),
258 'Expected 1 item. But found: %s' % len(results))
259 item = results[0]
260 # Check item attributes in results
261 self.assertTrue(results_page.check_item(item,
262 'image',
263 'description_label',
264 'label_installed'))
265 # Open item and check details
266 item_details = results_page.open_item(item)
267 self.assertTrue(item_details.check_description())
268
269 def tearDown(self):
270 super(TestGnomeSoftwareInstalledSnap, self).tearDown()
271 if not self.is_installed:
272 self.snapd.remove('hello-unity')
273
274
275class TestGnomeSoftwareNotInstalledSnap(BaseUbuntuSystemTestCase):
276
277 def setUp(self):
278 super(TestGnomeSoftwareNotInstalledSnap, self).setUp()
279 self.snapd = Snapd()
280 run_command('killall gnome-software')
281 self.is_installed = self.snapd.is_installed('hugo')
282 if self.is_installed:
283 self.snapd.remove('hugo')
284 self.root = GnomeSoftware().launch(app_type='gtk')
285 self.app = GnomeSoftwareCPO(self.root)
286
287 def test_check_not_installed_snap(self):
288 """Check not installed snap"""
289 # Verify if the snap is not installed
290 self.assertFalse(self.snapd.is_installed('hugo'))
291 # Perform the search
292 self.app.click_search_button()
293 results_page = self.app.write_search('hugo')
294 # Verify that the result contains only 1 line with hugo.
295 results = results_page.get_results()
296 self.assertEquals(1, len(results),
297 'Expected 1 item. But found: %s' % len(results))
298 item = results[0]
299 # Check item attributes in results
300 self.assertTrue(results_page.check_item(item,
301 'image',
302 'description_label'))
303 self.assertFalse(results_page.check_item(item,
304 'label_installed'))
305 # Open item and check details
306 item_details = results_page.open_item(item)
307 self.assertTrue(item_details.check_description())
308
309 def tearDown(self):
310 super(TestGnomeSoftwareNotInstalledSnap, self).tearDown()
311 if self.is_installed:
312 self.snapd.install('hugo')
313
314
315class TestGnomeSoftwareNotInstalledDeb(BaseUbuntuSystemTestCase):
316
317 def setUp(self):
318 super(TestGnomeSoftwareNotInstalledDeb, self).setUp()
319 run_command('killall gnome-software')
320 self.entangle = Entangle()
321 self.is_installed = self.entangle._is_installed()
322 if self.is_installed:
323 self.entangle.remove()
324 self.root = GnomeSoftware().launch(app_type='gtk')
325 self.app = GnomeSoftwareCPO(self.root)
326
327 def test_check_not_installed_deb(self):
328 """Check not installed deb"""
329 # Perform the search
330 self.app.click_search_button()
331 results_page = self.app.write_search('entangle')
332 # Verify that the result contains only 1 line with entangle.
333 results = results_page.get_results()
334 self.assertEquals(1, len(results),
335 'Expected 1 item. But found: %s' % len(results))
336 item = results[0]
337 # Check item attributes in results
338 self.assertTrue(results_page.check_item(item,
339 'image',
340 'star',
341 'description_label'))
342 self.assertFalse(results_page.check_item(item,
343 'label_installed'))
344 # Open item and check details
345 item_details = results_page.open_item(item)
346 self.assertTrue(item_details.check_description())
347
348 def tearDown(self):
349 super(TestGnomeSoftwareNotInstalledDeb, self).tearDown()
350 if self.is_installed:
351 self.entangle.install()

Subscribers

People subscribed via source and target branches