Merge lp:~om26er/ubuntu-system-settings/fix_tests into lp:ubuntu-system-settings

Proposed by Omer Akram
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 665
Merged at revision: 681
Proposed branch: lp:~om26er/ubuntu-system-settings/fix_tests
Merge into: lp:ubuntu-system-settings
Prerequisite: lp:~vrruiz/ubuntu-system-settings/helper-launch-system-settings
Diff against target: 475 lines (+221/-119)
5 files modified
plugins/about/License.qml (+0/-1)
plugins/about/Software.qml (+1/-0)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+20/-8)
tests/autopilot/ubuntu_system_settings/tests/test_about.py (+177/-91)
tests/autopilot/ubuntu_system_settings/tests/test_search.py (+23/-19)
To merge this branch: bzr merge lp:~om26er/ubuntu-system-settings/fix_tests
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+213691@code.launchpad.net

This proposal supersedes a proposal from 2014-03-09.

Commit message

autopilot tests improvements:
 * Improved existing tests to compare values with backends instead of just testing the 'item' is there.
 * Fixed a skipped failing test
 * Delete label tests and those which are trying to make sure certain elements exist.

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: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (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
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

\o/

On Tue, Mar 11, 2014 at 4:17 AM, PS Jenkins bot <
<email address hidden>> wrote:

> Review: Approve continuous-integration
>
> PASSED: Continuous integration, rev:649
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/693/
> Executed test runs:
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3801
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3386
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-amd64-ci/209
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-armhf-ci/197
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-i386-ci/196
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3338
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3819
> deb:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3819/artifact/work/output/*zip*/output.zip
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3388
> deb:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3388/artifact/work/output/*zip*/output.zip
> SUCCESS:
> http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5754
> SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4639
>
> Click here to trigger a rebuild:
> http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/693/rebuild
>
> --
>
> https://code.launchpad.net/~om26er/ubuntu-system-settings/fix_tests/+merge/210102
> You are the owner of lp:~om26er/ubuntu-system-settings/fix_tests.
>

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: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (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
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Thank you for your work, that looks mostly fine, 3 of the StorageTestCase tests fail if the xdg directories are missing though

e.g

"Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ubuntu_system_settings/tests/test_about.py", line 161, in test_space_used_by_music
    music_space = self._get_space_by_directory('Music')
  File "/usr/lib/python2.7/dist-packages/ubuntu_system_settings/tests/test_about.py", line 131, in _get_space_by_directory
    output = subprocess.check_output(['du', '--block-size=1', location])
  File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
CalledProcessError: Command '['du', '--block-size=1', '/home/user/Videos']' returned non-zero exit status 1

same for Pictures and Music

Those directories are translated if you use a different locale (e.g they are "Vidéos" "Images" "Musique" on a french system). You either need to restore the translations or handle the directories not being there

review: Needs Fixing
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

Thanks for the review, I have fixed that problem, now we are translating those names.

Revision history for this message
Iain Lane (laney) wrote : Posted in a previous version of this proposal

Drive-by commenting...

On Tue, Apr 01, 2014 at 04:22:31PM -0000, Omer Akram wrote:
> Thanks for the review, I have fixed that problem, now we are translating those names.

You can do this more flexibly (since users are allowed to change these
directories to anything they want) by retrieving the actual user dir in
use.

For example using GLib with gi like so:

>>> from gi.repository import GLib
>>> GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_MUSIC)
'/home/laney/Music'

It's not essential, but it'd be nice to do that this time round if you
can. This is the kind of enhancement that falls through the cracks.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

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
Sebastien Bacher (seb128) wrote : Posted in a previous version of this proposal

Thanks, the tests still can fail though (if you run under a C local on a non english desktop, or if the directories are missing), the proper solution is the one hinted by Laney. We should also handle without failing the case when one of the directory is missing on disk (which can happen)

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:654
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~om26er/ubuntu-system-settings/fix_tests/+merge/213691/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-ci/752/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4433
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/4031
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-amd64-ci/268
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-armhf-ci/256
    SUCCESS: http://jenkins.qa.ubuntu.com/job/ubuntu-system-settings-trusty-i386-ci/255
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3833
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4537
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4537/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4055
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4055/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/6289
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5502

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/ubuntu-system-settings-ci/752/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

> 222 + @skipUnless(
> 223 + model() == 'Nexus 4',
> 224 + 'Nexus 4 is currently the only telephony device that we support'
> 225 + )
> 226 + def test_imei_information_is_correct(self):

Is there a way we could make that more dynamic and check through ofono for the imei information being there, instead of coding a specific model in the test?

review: Needs Fixing
Revision history for this message
Sebastien Bacher (seb128) wrote :

same about the model() == 'Desktop' skips, can't we just check for the service/command to be there or not and handle the case where it's not?

Revision history for this message
Iain Lane (laney) wrote :

> Is there a way we could make that more dynamic and check through ofono for the
> imei information being there, instead of coding a specific model in the test?

It should display 'N/A' when no IMEI is available.

I see some tests that are skipped on desktop too - do you think we could test the corresponding desktop case as well?

Revision history for this message
Iain Lane (laney) wrote :

> I see some tests that are skipped on desktop too - do you think we could test
> the corresponding desktop case as well?

Like check if the data is available and if it's not that the correct 'not available' string is displayed in the UI, instead of having conditional skips.

655. By Omer Akram

use glib to get directory locations inside HOME

656. By Omer Akram

make tests more solid by using Eventually

657. By Omer Akram

skip test if the directory does not exist

658. By Omer Akram

don't skip tests based on platform, rather handle cases in code

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
659. By Omer Akram

skip test if getprop is not found instead of making it platform dependent

660. By Omer Akram

fix pep8/pyflakes complaints

Revision history for this message
Omer Akram (om26er) wrote :

Thanks for the review. I have fixed everything suggested above.

Now getting directory locations from GLib and if a directory does not exist we skip the test gracefully.
Also not skipping tests based on what platforms they are run on rather checking if the required functionality is available to use, also enhances the tests a bit to tests the cases for Desktop scenario.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
661. By Omer Akram

merge with trunk, fix conflicts

Revision history for this message
Omer Akram (om26er) wrote :

Merged with trunk again and fixed conflicts.

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) wrote :
review: Needs Fixing (continuous-integration)
662. By Omer Akram

fix

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

thanks

> 217 +
> 218 + if model() == 'Desktop':
> 219 + self.assertThat(item.visible, Equals(False))

that still special case "Desktop", which means those would fail on e.g a tablet, can't you just call self._get_device_serial_number() and test if the return is empty/null?

Looks fine out of those issues (same for serial and imei)

review: Needs Fixing
Revision history for this message
Sebastien Bacher (seb128) wrote :

oh, another issues, the checks for the space used by the movie/music/picture directories fail if the computation takes more than 10 seconds (they value are only displayed when all results are received, or the "space taken by Ubuntu" can easily take a minute on a desktop installation)

Not sure how to address those though, does anyone has a suggestion?

663. By Omer Akram

don't skip tests based on platform, rather check if the required backend is availabe or not and test accordingly

664. By Omer Akram

skip disk storage tests on desktop as they can fail because the calculation can take a long time, bug 1304328

Revision history for this message
Omer Akram (om26er) wrote :

> thanks
>
> > 217 +
> > 218 + if model() == 'Desktop':
> > 219 + self.assertThat(item.visible, Equals(False))
>
> that still special case "Desktop", which means those would fail on e.g a
> tablet, can't you just call self._get_device_serial_number() and test if the
> return is empty/null?
>
> Looks fine out of those issues (same for serial and imei)

Fixed that now.

Revision history for this message
Omer Akram (om26er) wrote :

> oh, another issues, the checks for the space used by the movie/music/picture
> directories fail if the computation takes more than 10 seconds (they value are
> only displayed when all results are received, or the "space taken by Ubuntu"
> can easily take a minute on a desktop installation)
>
> Not sure how to address those though, does anyone has a suggestion?

As discussed on IRC, I have skipped those tests on the Desktop and reported bug 1304328 to track what needs to be changed in the system settings.

Revision history for this message
Sebastien Bacher (seb128) wrote :

> As discussed on IRC, I have skipped those tests on the Desktop

We didn't say "on the Desktop", as in previous comment I don't think we should special case Desktop. The factor there is how much datas you have and how slow the storage access is. Looking at an android tablet it's likely that the estimate are going to take longer than 10 seconds on devices as well... can we just skip those tests, and not only on desktop, as long as they are not reliable

review: Needs Fixing
665. By Omer Akram

skip disk space tests, in some cases they can be slow

Revision history for this message
Omer Akram (om26er) wrote :

> > As discussed on IRC, I have skipped those tests on the Desktop
>
> We didn't say "on the Desktop", as in previous comment I don't think we should
> special case Desktop. The factor there is how much datas you have and how slow
> the storage access is. Looking at an android tablet it's likely that the
> estimate are going to take longer than 10 seconds on devices as well... can we
> just skip those tests, and not only on desktop, as long as they are not
> reliable

Now they are skipped.

Given the amount of disk space on touch devices (max 64GB currently) and only a limited part of them allocated for the system partition i.e. where Ubuntu is installed, I believe this would not have caused trouble for us, at least if we gave the calculations a few retries just to be sure. Though I do agree that on the desktop we never be sure.

Revision history for this message
Sebastien Bacher (seb128) wrote :

> Now they are skipped.

thanks!

> i.e. where Ubuntu is installed, I believe this would not have caused trouble for us, at least if we gave the calculations a few retries just to be sure

well
- even on small disk it's easy to go over 10 seconds (I've seen android devices taking over 30 seconds on devices with 16GB of disk)
- having to retry sometime is a no go, we don't want flacky tests
- we need to design the tests to be robust on any device, not just to work on a new install in the QA test config

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
Sebastien Bacher (seb128) wrote :

Thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/about/License.qml'
2--- plugins/about/License.qml 2014-03-04 12:45:06 +0000
3+++ plugins/about/License.qml 2014-04-08 12:01:45 +0000
4@@ -8,7 +8,6 @@
5 property string binary;
6
7 id: licensesPage
8- objectName: "licensesPage"
9 title: binary
10 flickable: scrollWidget
11
12
13=== modified file 'plugins/about/Software.qml'
14--- plugins/about/Software.qml 2013-07-29 14:08:10 +0000
15+++ plugins/about/Software.qml 2014-04-08 12:01:45 +0000
16@@ -7,6 +7,7 @@
17
18 ItemPage {
19 id: licensesPage
20+ objectName: "licensesPage"
21 title: i18n.tr("Software licenses")
22 flickable: softwareList
23
24
25=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
26--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-03-31 15:42:50 +0000
27+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-04-08 12:01:45 +0000
28@@ -9,7 +9,6 @@
29
30 from __future__ import absolute_import
31
32-from ubuntu_system_settings.utils.i18n import ugettext as _
33 from ubuntu_system_settings import helpers
34
35 from autopilot.input import Mouse, Touch, Pointer
36@@ -163,6 +162,7 @@
37 def setUp(self):
38 """ Go to About page """
39 super(AboutBaseTestCase, self).setUp('about')
40+ self.assertThat(self.about_page.active, Eventually(Equals(True)))
41
42 @property
43 def about_page(self):
44@@ -177,10 +177,13 @@
45 """ Go to Storage Page """
46 super(StorageBaseTestCase, self).setUp()
47 # Click on 'Storage' option
48- button = self.about_page.select_single(objectName='storageItem')
49- self.assertThat(button, NotEquals(None))
50+ button = self.about_page.select_single(
51+ 'Standard', objectName='storageItem'
52+ )
53 self.scroll_to_and_click(button)
54
55+ self.assertThat(self.storage_page.active, Eventually(Equals(True)))
56+
57 def assert_space_item(self, object_name, text):
58 """ Checks whether an space item exists and returns a value """
59 item = self.storage_page.select_single(objectName=object_name)
60@@ -193,10 +196,17 @@
61 values = size_label.text.split(' ') # Format: "00.0 (bytes|MB|GB)"
62 self.assertThat(len(values), GreaterThan(1))
63
64+ def get_storage_space_used_by_category(self, objectName):
65+ return self.main_view.wait_select_single(
66+ 'StorageItem', objectName=objectName
67+ ).value
68+
69 @property
70 def storage_page(self):
71 """ Return 'Storage' page """
72- return self.main_view.select_single(objectName='storagePage')
73+ return self.main_view.select_single(
74+ 'Storage', objectName='storagePage'
75+ )
76
77
78 class LicenseBaseTestCase(AboutBaseTestCase):
79@@ -206,15 +216,17 @@
80 """ Go to License Page """
81 super(LicenseBaseTestCase, self).setUp()
82 # Click on 'Software licenses' option
83- button = self.main_view.select_single(objectName='licenseItem')
84- self.assertThat(button, NotEquals(None))
85- self.assertThat(button.text, Equals(_('Software licenses')))
86+ button = self.main_view.select_single(
87+ 'Standard', objectName='licenseItem'
88+ )
89 self.scroll_to_and_click(button)
90
91 @property
92 def licenses_page(self):
93 """ Return 'License' page """
94- return self.main_view.select_single(objectName='licensesPage')
95+ return self.main_view.wait_select_single(
96+ 'ItemPage', objectName='licensesPage'
97+ )
98
99
100 class SystemUpdatesBaseTestCase(UbuntuSystemSettingsTestCase):
101
102=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_about.py'
103--- tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-04-02 09:06:34 +0000
104+++ tests/autopilot/ubuntu_system_settings/tests/test_about.py 2014-04-08 12:01:45 +0000
105@@ -5,11 +5,15 @@
106 # under the terms of the GNU General Public License version 3, as published
107 # by the Free Software Foundation.
108
109-from time import sleep
110-
111-from autopilot.platform import model
112-from testtools.matchers import Equals, NotEquals, GreaterThan
113-from unittest import expectedFailure
114+import os
115+import subprocess
116+import unittest
117+
118+from gi.repository import GLib
119+
120+from autopilot.matchers import Eventually
121+from testtools import skipIf
122+from testtools.matchers import Equals, NotEquals
123
124 from ubuntu_system_settings.tests import (
125 AboutBaseTestCase,
126@@ -18,97 +22,148 @@
127 )
128 from ubuntu_system_settings.utils.i18n import ugettext as _
129
130+import dbus
131+
132
133 class AboutTestCase(AboutBaseTestCase):
134 """ Tests for About this phone Page """
135
136- def test_about_page(self):
137- """ Checks whether About page is available """
138- self.assertThat(self.about_page, NotEquals(None))
139- self.assertThat(self.about_page.title, Equals(_('About this phone')))
140-
141- def test_device(self):
142- """ Checks whether Device info is shown """
143- device_label = self.about_page.select_single(objectName='deviceLabel')
144- self.assertThat(device_label, NotEquals(None))
145- self.assertThat(device_label.text, NotEquals(''))
146+ def _get_imei_from_dbus(self):
147+ bus = dbus.SystemBus()
148+ try:
149+ manager = dbus.Interface(
150+ bus.get_object('org.ofono', '/'), 'org.ofono.Manager'
151+ )
152+ except dbus.exceptions.DBusException:
153+ # oFono interface not found, probably its a desktop.
154+ return None
155+
156+ modems = manager.GetModems()
157+ for path, properties in modems:
158+ return properties['Serial']
159+
160+ def _get_os_name(self):
161+ os_id = subprocess.check_output(['lsb_release', '-is'])
162+ os_release = subprocess.check_output(['lsb_release', '-rs'])
163+
164+ return '{} {}'.format(os_id.strip(), os_release.strip())
165+
166+ def _get_device_serial_number(self):
167+ try:
168+ return subprocess.check_output(['getprop', 'ro.serialno']).strip()
169+ except OSError:
170+ # getprop is only available on android hardware.
171+ return None
172+
173+ def _get_device_manufacturer_and_model(self):
174+ manufacturer = subprocess.check_output(
175+ ['getprop', 'ro.product.manufacturer']
176+ ).strip()
177+ hw_model = subprocess.check_output(
178+ ['getprop', 'ro.product.model']
179+ ).strip()
180+
181+ return '{} {}'.format(manufacturer, hw_model)
182+
183+ def _get_system_image_iface(self):
184+ bus = dbus.SystemBus()
185+ service = bus.get_object('com.canonical.SystemImage', '/Service')
186+ iface = dbus.Interface(service, 'com.canonical.SystemImage')
187+ return iface.Info()
188+
189+ def _get_last_updated_date(self):
190+ info = self._get_system_image_iface()[3]
191+
192+ if info == 'Unknown':
193+ return _('Never')
194+ else:
195+ return str(info.split()[0])
196
197 def test_serial(self):
198- """ Checks whether Serial info is available """
199+ """Checks whether the UI is showing the correct serial number."""
200 item = self.about_page.select_single(objectName='serialItem')
201- if (model() == 'Desktop'):
202- self.assertThat(item.visible, Equals(False))
203- else:
204- self.assertThat(item.visible, Equals(True))
205- self.assertThat(item.text, Equals(_('Serial')))
206- self.assertThat(item.value, NotEquals(_('N/A')))
207-
208- def test_imei(self):
209- """ Checks whether IMEI info is available """
210- item = self.about_page.select_single(objectName='imeiItem')
211- if (model() == 'Desktop'):
212- self.assertThat(item.visible, Equals(False))
213- else:
214- self.assertThat(item.visible, Equals(True))
215- self.assertThat(item.text, Equals(_('IMEI')))
216- self.assertThat(item.value, NotEquals(_('N/A')))
217-
218- def test_software(self):
219- """ Checks whether Software info is available """
220- item = self.about_page.select_single(objectName='softwareItem')
221- self.assertThat(item, NotEquals(None))
222- self.assertThat(item.text, Equals(_('Software:')))
223-
224- def test_os(self):
225- """ Checks whether OS info is available """
226+ serial = self._get_device_serial_number()
227+
228+ if not serial:
229+ self.assertThat(item.visible, Equals(False))
230+ else:
231+ self.assertThat(
232+ item.value, Equals(self._get_device_serial_number())
233+ )
234+
235+ def test_imei_information_is_correct(self):
236+ """Checks whether the UI is exposing the right IMEI."""
237+ imei_item = self.about_page.wait_select_single(
238+ objectName='imeiItem')
239+ imei_ofono = self._get_imei_from_dbus()
240+
241+ if not imei_ofono:
242+ self.assertThat(imei_item.visible, Equals(False))
243+ else:
244+ self.assertEquals(imei_item.value, imei_ofono)
245+
246+ def test_settings_show_correct_version_of_the_os(self):
247+ """Ensure the UI is showing the correct version of the OS."""
248 item = self.about_page.select_single(objectName='osItem')
249- self.assertThat(item, NotEquals(None))
250- self.assertThat(item.text, Equals(_('OS')))
251- info = item.value.split()
252- self.assertThat(len(info), GreaterThan(1))
253- self.assertThat(info[0], Equals(_('Ubuntu')))
254- self.assertThat(info[1], NotEquals(''))
255- if (len(info) > 2):
256- self.assertThat(info[2], NotEquals(''))
257+ # TODO: find a way to check the image build number as well
258+ # -- om26er 10-03-2014
259+ self.assertTrue(self._get_os_name() in item.value)
260+
261+ @skipIf(subprocess.call(
262+ ['which', 'getprop'], stdout=subprocess.PIPE) != 0,
263+ 'program "getprop" not found'
264+ )
265+ def test_hardware_name(self):
266+ """Ensure the UI is showing the correct device name."""
267+ device_label = self.about_page.select_single(
268+ objectName='deviceLabel'
269+ ).text
270+ device_name_from_getprop = self._get_device_manufacturer_and_model()
271+
272+ self.assertEquals(device_label, device_name_from_getprop)
273
274 def test_last_updated(self):
275- """ Checks whether Last Updated info is available """
276- item = self.about_page.select_single(objectName='lastUpdatedItem')
277- self.assertThat(item, NotEquals(None))
278- self.assertThat(item.text, Equals(_('Last updated')))
279- date = item.value.split('-')
280- if (len(date) == 1):
281- self.assertThat(item.value, Equals(_('Never')))
282- else:
283- # 2013-10-19
284- self.assertThat(len(item.value), Equals(10))
285-
286- def test_legal(self):
287- """ Checks whether Legal info is available """
288- item = self.about_page.select_single(objectName='legalItem')
289- self.assertThat(item, NotEquals(None))
290- self.assertThat(item.text, Equals(_('Legal:')))
291-
292- def test_update(self):
293- """ Checks whether Update button is available """
294- button = self.about_page.select_single(objectName='updateButton')
295- self.assertThat(button, NotEquals(None))
296- self.assertThat(button.text, Equals(_('Check for updates')))
297+ """Checks whether Last Updated info is correct."""
298+ last_updated = self.about_page.select_single(
299+ objectName='lastUpdatedItem'
300+ ).value
301+
302+ self.assertEquals(last_updated, self._get_last_updated_date())
303
304
305 class StorageTestCase(StorageBaseTestCase):
306 """ Tests for Storage """
307
308- def test_storage_page(self):
309- """ Check whether Storage page is available """
310- self.assertThat(self.storage_page, NotEquals(None))
311+ def _get_space_by_directory(self, dir_name):
312+ if dir_name == 'Music':
313+ location = GLib.get_user_special_dir(
314+ GLib.UserDirectory.DIRECTORY_MUSIC
315+ )
316+ elif dir_name == 'Videos':
317+ location = GLib.get_user_special_dir(
318+ GLib.UserDirectory.DIRECTORY_VIDEOS
319+ )
320+ elif dir_name == 'Pictures':
321+ location = GLib.get_user_special_dir(
322+ GLib.UserDirectory.DIRECTORY_PICTURES
323+ )
324+ else:
325+ raise ValueError(
326+ '{} directory not handled by this fuction, you need to enhance'
327+ ' this function to handle that directory.'.format(dir_name)
328+ )
329+
330+ if not os.path.exists(location):
331+ self.skipTest('glib directory {} does not exist'.format(dir_name))
332+
333+ output = subprocess.check_output(['du', '--block-size=1', location])
334+ disk_space = output.split()[len(output.split()) - 2]
335+ return disk_space
336
337 def test_disk(self):
338 """ Checks whether disk item is available """
339- sleep(5)
340- disk_item = self.storage_page.select_single(objectName='diskItem')
341- self.assertThat(disk_item, NotEquals(None))
342- self.assertThat(disk_item.text, Equals(_('Total storage')))
343+ disk_item = self.storage_page.wait_select_single(objectName='diskItem')
344+ self.assertThat(disk_item.text, Equals('Total storage'))
345
346 def test_space(self):
347 """ Checks whether storage item is available """
348@@ -118,17 +173,49 @@
349 """ Checks storage item """
350 self.assert_space_item('usedByUbuntuItem', _('Used by Ubuntu'))
351
352- def test_space_movies(self):
353- """ Checks whether space item is available """
354- self.assert_space_item('moviesItem', _('Videos'))
355-
356- def test_space_audio(self):
357- """ Checks whether space item is available """
358- self.assert_space_item('audioItem', _('Audio'))
359-
360- def test_space_pictures(self):
361- """ Checks whether space item is available """
362- self.assert_space_item('picturesItem', _('Pictures'))
363+ @unittest.skip(
364+ 'Disk calculation can take a while depending on different factors '
365+ 'we dont want to wait for it to calculate.'
366+ )
367+ def test_space_used_by_movies(self):
368+ """ Checks whether space shown to be used by movies is
369+ correct. """
370+ movie_space = self._get_space_by_directory('Videos')
371+ movie_space_in_ui = self.get_storage_space_used_by_category(
372+ 'moviesItem'
373+ )
374+
375+ self.assertThat(movie_space_in_ui, Eventually(Equals(movie_space)))
376+
377+ @unittest.skip(
378+ 'Disk calculation can take a while depending on different factors '
379+ 'we dont want to wait for it to calculate.'
380+ )
381+ def test_space_used_by_music(self):
382+ """ Checks whether space shown to be used by music is
383+ correct. """
384+ music_space = self._get_space_by_directory('Music')
385+ music_space_in_ui = self.get_storage_space_used_by_category(
386+ 'audioItem'
387+ )
388+
389+ self.assertThat(music_space_in_ui, Eventually(Equals(music_space)))
390+
391+ @unittest.skip(
392+ 'Disk calculation can take a while depending on different factors '
393+ 'we dont want to wait for it to calculate.'
394+ )
395+ def test_space_used_by_pictures(self):
396+ """ Checks whether space shown to be used by pictures is
397+ correct. """
398+ pictures_space = self._get_space_by_directory('Pictures')
399+ pictures_space_in_ui = self.get_storage_space_used_by_category(
400+ 'picturesItem'
401+ )
402+
403+ self.assertThat(
404+ pictures_space_in_ui, Eventually(Equals(pictures_space))
405+ )
406
407 def test_space_other_files(self):
408 """ Checks whether space item is available """
409@@ -149,7 +236,6 @@
410 class LicenseTestCase(LicenseBaseTestCase):
411 """ Tests for Licenses """
412
413- @expectedFailure
414 def test_licenses_page(self):
415 """ Check whether Storage page is available """
416- self.assertThat(self.licenses_page, NotEquals(None))
417+ self.assertThat(self.licenses_page.active, Eventually(Equals(True)))
418
419=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_search.py'
420--- tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-03-10 11:24:08 +0000
421+++ tests/autopilot/ubuntu_system_settings/tests/test_search.py 2014-04-08 12:01:45 +0000
422@@ -6,7 +6,8 @@
423 # by the Free Software Foundation.
424
425 from autopilot.introspection.dbus import StateNotFoundError
426-from testtools.matchers import Equals, NotEquals
427+from testtools.matchers import Equals
428+from autopilot.matchers import Eventually
429
430 from ubuntu_system_settings.tests import UbuntuSystemSettingsTestCase
431 from ubuntu_system_settings.utils.i18n import ugettext as _
432@@ -21,22 +22,25 @@
433 def setUp(self):
434 super(SearchTestCases, self).setUp()
435
436- def test_search(self):
437+ def _get_entry_component(self, name):
438+ return self.main_view.wait_select_single(
439+ objectName='entryComponent-' + name
440+ )
441+
442+ def _type_into_search_box(self, text):
443+ search_box = self.main_view.select_single(
444+ objectName='searchTextField'
445+ )
446+ self.scroll_to_and_click(search_box)
447+ self.keyboard.type(_(text))
448+ self.assertThat(search_box.text, Eventually(Equals(text)))
449+
450+ def test_search_filter_results(self):
451 """ Checks whether Search box actually filters the results """
452- # Select search text field
453- search = self.main_view.select_single(objectName='searchTextField')
454- self.assertThat(search, NotEquals(None))
455- # Move to text field
456- self.scroll_to_and_click(search)
457- # Filter by string
458- self.keyboard.type(_('Sound'))
459- # Search component
460- sound = self.main_view.select_single(objectName='entryComponent-sound')
461- self.assertThat(sound, NotEquals(None))
462- try:
463- background = self.main_view.select_single(
464- objectName='entryComponent-background'
465- )
466- except StateNotFoundError:
467- background = None
468- self.assertThat(background, Equals(None))
469+ self._type_into_search_box('Sound')
470+ sound_icon = self._get_entry_component('sound')
471+
472+ self.assertThat(sound_icon.visible, Eventually(Equals(True)))
473+ self.assertRaises(
474+ StateNotFoundError, self._get_entry_component, 'background'
475+ )

Subscribers

People subscribed via source and target branches