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
1=== modified file 'ubuntu_system_tests/helpers/application.py'
2--- ubuntu_system_tests/helpers/application.py 2017-09-14 14:06:34 +0000
3+++ ubuntu_system_tests/helpers/application.py 2018-01-18 21:17:49 +0000
4@@ -36,6 +36,7 @@
5 )
6
7 from ubuntu_system_tests.helpers.utils import is_discovery
8+from ubuntu_system_tests.helpers.testbed import run_command_with_sudo
9
10 logger = logging.getLogger(__name__)
11 logger.setLevel(logging.INFO)
12@@ -207,7 +208,15 @@
13 return len(output) > 0 and 'ok installed' in output.decode()
14 except subprocess.CalledProcessError:
15 try:
16- output = subprocess.check_output(cmd + [self.package_name])
17+ output = subprocess.check_output(cmd + [self.package_name or ''])
18 return len(output) > 0 and 'ok installed' in output.decode()
19 except subprocess.CalledProcessError:
20 return False
21+
22+ def install(self):
23+ cmd = ['apt', 'install', self.app_name, '-y']
24+ run_command_with_sudo(cmd)
25+
26+ def remove(self):
27+ cmd = ['apt', 'remove', self.app_name, '-y']
28+ run_command_with_sudo(cmd)
29
30=== added directory 'ubuntu_system_tests/helpers/chromium'
31=== added file 'ubuntu_system_tests/helpers/chromium/app.py'
32--- ubuntu_system_tests/helpers/chromium/app.py 1970-01-01 00:00:00 +0000
33+++ ubuntu_system_tests/helpers/chromium/app.py 2018-01-18 21:17:49 +0000
34@@ -0,0 +1,30 @@
35+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
36+
37+#
38+# Ubuntu System Tests
39+# Copyright (C) 2015-2017 Canonical
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU General Public License as published by
43+# the Free Software Foundation, either version 3 of the License, or
44+# (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU General Public License for more details.
50+#
51+# You should have received a copy of the GNU General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+
55+from ubuntu_system_tests.helpers.application import Deb
56+
57+APP_NAME = 'chromium-browser'
58+APP_ID = 'chromium-browser'
59+
60+
61+class Chromium(Deb):
62+
63+ def __init__(self):
64+ super().__init__(APP_NAME, APP_ID)
65
66=== added directory 'ubuntu_system_tests/helpers/entangle'
67=== added file 'ubuntu_system_tests/helpers/entangle/app.py'
68--- ubuntu_system_tests/helpers/entangle/app.py 1970-01-01 00:00:00 +0000
69+++ ubuntu_system_tests/helpers/entangle/app.py 2018-01-18 21:17:49 +0000
70@@ -0,0 +1,30 @@
71+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
72+
73+#
74+# Ubuntu System Tests
75+# Copyright (C) 2015-2017 Canonical
76+#
77+# This program is free software: you can redistribute it and/or modify
78+# it under the terms of the GNU General Public License as published by
79+# the Free Software Foundation, either version 3 of the License, or
80+# (at your option) any later version.
81+#
82+# This program is distributed in the hope that it will be useful,
83+# but WITHOUT ANY WARRANTY; without even the implied warranty of
84+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85+# GNU General Public License for more details.
86+#
87+# You should have received a copy of the GNU General Public License
88+# along with this program. If not, see <http://www.gnu.org/licenses/>.
89+#
90+
91+from ubuntu_system_tests.helpers.application import Deb
92+
93+APP_NAME = 'entangle'
94+APP_ID = 'entangle'
95+
96+
97+class Entangle(Deb):
98+
99+ def __init__(self):
100+ super().__init__(APP_NAME, APP_ID)
101
102=== modified file 'ubuntu_system_tests/helpers/gnome_sofware/cpo.py'
103--- ubuntu_system_tests/helpers/gnome_sofware/cpo.py 2018-01-04 00:36:29 +0000
104+++ ubuntu_system_tests/helpers/gnome_sofware/cpo.py 2018-01-18 21:17:49 +0000
105@@ -60,6 +60,7 @@
106 :param text: the string to write in search box
107 :return: ResultsPage object
108 """
109+ time.sleep(0.1)
110 self.get_entry_search(is_focus=True)
111 input_manager.keyboard.type(text)
112 return ResultsPage(self.proxy)
113@@ -163,6 +164,19 @@
114 except (DBusException, StateNotFoundError):
115 return False
116
117+ def open_featured_app(self):
118+ """Open the featured app's description
119+ :return The page with the featured app's description
120+ """
121+ item = self.proxy.wait_select_single(BuilderName='GsFeatureTile', visible=True)
122+ box = item.wait_select_single(BuilderName='box')
123+ # This line throws an exception:
124+ input_manager.pointer.click_object(box)
125+ self.proxy.wait_select_single(
126+ BuilderName='box_details',
127+ visible=True)
128+ return ItemDetailsPage(self.proxy.select_single(BuilderName='details_page'))
129+
130
131 class ResultsPage(GnomeSoftwareCPO):
132 def __init__(self, proxy):
133@@ -172,12 +186,12 @@
134 """Get the current results
135 :return the list with the current results or empty
136 """
137+ attempts = 1
138+ retries = kwargs.pop('retries', 10)
139+ wait = kwargs.pop('wait', 5)
140 search = self.proxy.wait_select_single(BuilderName='list_box_search',
141 *args,
142 **kwargs)
143- attempts = 1
144- retries = kwargs.pop('retries', 10)
145- wait = kwargs.pop('wait', 5)
146 # Wait until search finishes and return results
147 while attempts < retries:
148 try:
149@@ -205,6 +219,28 @@
150 except (DBusException, StateNotFoundError):
151 return False
152
153+ @staticmethod
154+ def check_app_present(items, app_to_search):
155+ """Check if the given application is present in the search results
156+ :param items: the list of results to check
157+ :param app_to_search: the name (visible in GNOME Software)
158+ of the application to find
159+ :return True if the given application is present in the search results
160+ """
161+ for item in items:
162+ try:
163+ label = item.select_single(BuilderName="name_label", visible=True).label
164+ if label == app_to_search:
165+ return True
166+ except (DBusException, StateNotFoundError):
167+ pass
168+ return False
169+
170+ @staticmethod
171+ def get_app_name(item):
172+ """Gets the name of the application taken from the search results."""
173+ return item.select_single(BuilderName="name_label", visible=True).label
174+
175 def open_item(self, item):
176 """Click on the given item
177 :param item: the item click on
178
179=== modified file 'ubuntu_system_tests/tests/test_gnome_software.py'
180--- ubuntu_system_tests/tests/test_gnome_software.py 2018-01-11 13:14:30 +0000
181+++ ubuntu_system_tests/tests/test_gnome_software.py 2018-01-18 21:17:49 +0000
182@@ -16,7 +16,7 @@
183 # You should have received a copy of the GNU General Public License
184 # along with this program. If not, see <http://www.gnu.org/licenses/>.
185
186-from testtools import skipIf
187+from testtools import skipIf, skip
188
189 from ubuntu_system_tests.helpers.session.release import get_release, XENIAL
190
191@@ -24,6 +24,9 @@
192 from ubuntu_system_tests.helpers.testbed import run_command
193 from ubuntu_system_tests.helpers.gnome_sofware.app import GnomeSoftware
194 from ubuntu_system_tests.tests.base import BaseUbuntuSystemTestCase
195+from ubuntu_system_tests.helpers.snapd.snapd import Snapd
196+from ubuntu_system_tests.helpers.chromium.app import Chromium
197+from ubuntu_system_tests.helpers.entangle.app import Entangle
198
199
200 class TestGnomeSoftware(BaseUbuntuSystemTestCase):
201@@ -47,7 +50,7 @@
202 'Search entry is not hidden')
203
204 def test_check_installed_deb(self):
205- """ Check already installed deb """
206+ """Check already installed deb"""
207 # Perform the search
208 self.app.click_search_button()
209 results_page = self.app.write_search('gnome-software')
210@@ -66,6 +69,60 @@
211 item_details = results_page.open_item(item)
212 self.assertTrue(item_details.check_description())
213
214+ def test_number_of_characters_in_search_string(self):
215+ """Check the 2, 3 and 5 chars long search strings"""
216+ # Perform the search with 2 chars
217+ self.app.click_search_button()
218+ results_page = self.app.write_search('ge')
219+ results = results_page.get_results(retries=2)
220+ # Verify that no search was performed
221+ self.assertEquals(0, len(results),
222+ 'Expected 0 items. But found: %s' % len(results))
223+ # Add the third character
224+ results_page = self.app.write_search('d')
225+ results = results_page.get_results()
226+ # Check if the search results contain 'gedit'
227+ self.assertTrue(results_page.check_app_present(results,
228+ 'gedit'))
229+ items_number = len(results)
230+ # Add another two chars, so we have 'gedit' in the box
231+ results_page = self.app.write_search('it')
232+ results = results_page.get_results()
233+ # Check if the search results contain 'gedit'
234+ self.assertTrue(results_page.check_app_present(results,
235+ 'gedit'))
236+ # Check if there are fewer results than before
237+ self.assertTrue(items_number > len(results))
238+
239+ def test_several_searches(self):
240+ """Check if several searches in a row perform normally"""
241+ # Perform the first search
242+ self.app.click_search_button()
243+ results_page = self.app.write_search('gimp')
244+ # Verify that the search results contain 'GIMP'
245+ results = results_page.get_results()
246+ self.assertTrue(results_page.check_app_present(results,
247+ 'GIMP'))
248+ # Clean the search box by double clicking the button and
249+ # perform the second search
250+ self.app.click_search_button()
251+ self.app.click_search_button()
252+ results_page = self.app.write_search('editor')
253+ # Check if the search results contain 'gedit'
254+ results = results_page.get_results()
255+ self.assertTrue(results_page.check_app_present(results,
256+ 'gedit'))
257+
258+ def test_multi_words_search(self):
259+ """Check if multi words search performs normally"""
260+ # Perform the multi words search
261+ self.app.click_search_button()
262+ results_page = self.app.write_search('gnome software')
263+ # Verify that the search results contain 'GNOME Software'
264+ results = results_page.get_results()
265+ self.assertTrue(results_page.check_app_present(results,
266+ 'GNOME Software'))
267+
268 def test_all_page_sections(self):
269 """Check categories after clicking on down arrow"""
270 labels = self.app.get_all_page_sections()
271@@ -111,3 +168,184 @@
272 items = self.app.get_editors_picks()
273 for item in items:
274 self.assertTrue(self.app.check_item(item, 'image'))
275+
276+ @skip('This test never passes, open_featured_app function needs to be fixed')
277+ def test_featured_application_description(self):
278+ """Check there is a description after clicking the featured
279+ application image"""
280+ featured_details = self.app.open_featured_app()
281+ self.assertTrue(featured_details.check_description())
282+
283+
284+class TestGnomeSoftwareMixedResults(BaseUbuntuSystemTestCase):
285+
286+ def setUp(self):
287+ super(TestGnomeSoftwareMixedResults, self).setUp()
288+ self.snapd = Snapd()
289+ run_command('killall gnome-software')
290+ self.is_snap_installed = self.snapd.is_installed('chromium')
291+ if not self.is_snap_installed:
292+ self.snapd.install('chromium')
293+ self.chromium = Chromium()
294+ self.is_deb_installed = self.chromium._is_installed()
295+ if self.is_deb_installed:
296+ self.chromium.remove()
297+ self.root = GnomeSoftware().launch(app_type='gtk')
298+ self.app = GnomeSoftwareCPO(self.root)
299+
300+ @skip('This tests randomly fails, so it needs to be fixed')
301+ def test_mixed_results(self):
302+ """Check there are deb and snap versions"""
303+ # Perform the search
304+ self.app.click_search_button()
305+ results_page = self.app.write_search('chromium')
306+ # Verify that there is more than one result
307+ results = results_page.get_results()
308+ self.assertTrue(len(results) > 1)
309+ # Check item attributes in results
310+ self.assertTrue(results_page.check_item(results[0],
311+ 'image',
312+ 'description_label'))
313+ self.assertTrue(results_page.check_item(results[1],
314+ 'image',
315+ 'description_label'))
316+ # Determine which result is a snap and which is a deb
317+ if (results_page.get_app_name(results[0]) == 'Chromium'):
318+ i = 0
319+ j = 1
320+ else:
321+ i = 1
322+ j = 0
323+ # Check if the snap is visible as installed
324+ self.assertTrue(results_page.check_item(results[i],
325+ 'label_installed'))
326+ # Check if there is rating of the deb
327+ self.assertTrue(results_page.check_item(results[j],
328+ 'star'))
329+ # Check if the deb is visible as not installed
330+ self.assertFalse(results_page.check_item(results[j],
331+ 'label_installed'))
332+
333+ def tearDown(self):
334+ super(TestGnomeSoftwareMixedResults, self).tearDown()
335+ if not self.is_snap_installed:
336+ self.snapd.remove('chromium')
337+ if self.is_deb_installed:
338+ self.chromium.install()
339+
340+
341+class TestGnomeSoftwareInstalledSnap(BaseUbuntuSystemTestCase):
342+
343+ def setUp(self):
344+ super(TestGnomeSoftwareInstalledSnap, self).setUp()
345+ self.snapd = Snapd()
346+ run_command('killall gnome-software')
347+ self.is_installed = self.snapd.is_installed('hello-unity')
348+ if not self.is_installed:
349+ self.snapd.install('hello-unity')
350+ self.root = GnomeSoftware().launch(app_type='gtk')
351+ self.app = GnomeSoftwareCPO(self.root)
352+
353+ @skip('In some cases this test freezes at setup, so it needs to be fixed')
354+ def test_check_installed_snap(self):
355+ """Check already installed snap"""
356+ # Perform the search
357+ self.app.click_search_button()
358+ results_page = self.app.write_search('hello-unity')
359+ # Verify that the result contains only 1 line with hello-unity.
360+ results = results_page.get_results()
361+ self.assertEquals(1, len(results),
362+ 'Expected 1 item. But found: %s' % len(results))
363+ item = results[0]
364+ # Check item attributes in results
365+ self.assertTrue(results_page.check_item(item,
366+ 'image',
367+ 'description_label',
368+ 'label_installed'))
369+ # Open item and check details
370+ item_details = results_page.open_item(item)
371+ self.assertTrue(item_details.check_description())
372+
373+ def tearDown(self):
374+ super(TestGnomeSoftwareInstalledSnap, self).tearDown()
375+ if not self.is_installed:
376+ self.snapd.remove('hello-unity')
377+
378+
379+class TestGnomeSoftwareNotInstalledSnap(BaseUbuntuSystemTestCase):
380+
381+ def setUp(self):
382+ super(TestGnomeSoftwareNotInstalledSnap, self).setUp()
383+ self.snapd = Snapd()
384+ run_command('killall gnome-software')
385+ self.is_installed = self.snapd.is_installed('hugo')
386+ if self.is_installed:
387+ self.snapd.remove('hugo')
388+ self.root = GnomeSoftware().launch(app_type='gtk')
389+ self.app = GnomeSoftwareCPO(self.root)
390+
391+ def test_check_not_installed_snap(self):
392+ """Check not installed snap"""
393+ # Verify if the snap is not installed
394+ self.assertFalse(self.snapd.is_installed('hugo'))
395+ # Perform the search
396+ self.app.click_search_button()
397+ results_page = self.app.write_search('hugo')
398+ # Verify that the result contains only 1 line with hugo.
399+ results = results_page.get_results()
400+ self.assertEquals(1, len(results),
401+ 'Expected 1 item. But found: %s' % len(results))
402+ item = results[0]
403+ # Check item attributes in results
404+ self.assertTrue(results_page.check_item(item,
405+ 'image',
406+ 'description_label'))
407+ self.assertFalse(results_page.check_item(item,
408+ 'label_installed'))
409+ # Open item and check details
410+ item_details = results_page.open_item(item)
411+ self.assertTrue(item_details.check_description())
412+
413+ def tearDown(self):
414+ super(TestGnomeSoftwareNotInstalledSnap, self).tearDown()
415+ if self.is_installed:
416+ self.snapd.install('hugo')
417+
418+
419+class TestGnomeSoftwareNotInstalledDeb(BaseUbuntuSystemTestCase):
420+
421+ def setUp(self):
422+ super(TestGnomeSoftwareNotInstalledDeb, self).setUp()
423+ run_command('killall gnome-software')
424+ self.entangle = Entangle()
425+ self.is_installed = self.entangle._is_installed()
426+ if self.is_installed:
427+ self.entangle.remove()
428+ self.root = GnomeSoftware().launch(app_type='gtk')
429+ self.app = GnomeSoftwareCPO(self.root)
430+
431+ def test_check_not_installed_deb(self):
432+ """Check not installed deb"""
433+ # Perform the search
434+ self.app.click_search_button()
435+ results_page = self.app.write_search('entangle')
436+ # Verify that the result contains only 1 line with entangle.
437+ results = results_page.get_results()
438+ self.assertEquals(1, len(results),
439+ 'Expected 1 item. But found: %s' % len(results))
440+ item = results[0]
441+ # Check item attributes in results
442+ self.assertTrue(results_page.check_item(item,
443+ 'image',
444+ 'star',
445+ 'description_label'))
446+ self.assertFalse(results_page.check_item(item,
447+ 'label_installed'))
448+ # Open item and check details
449+ item_details = results_page.open_item(item)
450+ self.assertTrue(item_details.check_description())
451+
452+ def tearDown(self):
453+ super(TestGnomeSoftwareNotInstalledDeb, self).tearDown()
454+ if self.is_installed:
455+ self.entangle.install()

Subscribers

People subscribed via source and target branches