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

Proposed by Omer Akram
Status: Work in progress
Proposed branch: lp:~om26er/ubuntu-system-settings/upgrade_testing_prerequisite
Merge into: lp:ubuntu-system-settings
Diff against target: 136 lines (+102/-0)
2 files modified
plugins/system-update/PageComponent.qml (+4/-0)
tests/autopilot/ubuntu_system_settings/emulators.py (+98/-0)
To merge this branch: bzr merge lp:~om26er/ubuntu-system-settings/upgrade_testing_prerequisite
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+214722@code.launchpad.net

Commit message

prerequisite for upgrade testing, to land in system-image source.

Description of the change

prerequisite for upgrade testing, to land in system-image source.

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: Needs Fixing (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

Somehow need to figure out how to fake the download manager to be able to write tests for these helpers so that we are sure they don't regress

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

Thanks for the work, seems like similar work was started before on https://code.launchpad.net/~chris.gagnon/ubuntu-system-settings/barebones-autopilot-emulator-for-updates-page/+merge/210036 ... are you guys coordinating there? How are the changes differents?

> Somehow need to figure out how to fake the download manager to be able to write tests for these helpers so that we are sure they don't regress

Do you plan to do that? Do you consider your changes useful even if that doesn't happen, or should those works being synchronized?

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

> Thanks for the work, seems like similar work was started before on
> https://code.launchpad.net/~chris.gagnon/ubuntu-system-settings/barebones-
> autopilot-emulator-for-updates-page/+merge/210036 ... are you guys
> coordinating there? How are the changes differents?
>

Hi! thanks for your reply and sorry for the delay. Chris's branch is at halt now and my branch is doing a bit different things, so this doesn't need any co-ordination.
>
> > Somehow need to figure out how to fake the download manager to be able to
> write tests for these helpers so that we are sure they don't regress
>
> Do you plan to do that? Do you consider your changes useful even if that
> doesn't happen, or should those works being synchronized?

Yes, at this moment we cannot test these helpers due to missing features like a dummy mode for the upgrader, so you can merge this in now and we'll try to figure out a solution for that sometime in future.

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

Should that be marked "work in progress"? The CI seems still unhappy there...

Note that https://code.launchpad.net/~elopio/ubuntu-system-settings/refactor_about_tests/+merge/226468 is about the land and that your changes are going to need to be rebased, since there is a conflict when applying those on top of trunk

review: Needs Fixing

Unmerged revisions

679. By Omer Akram

add pointer parameter to the class

678. By Omer Akram

fix things a bit

677. By Omer Akram

explain

676. By Omer Akram

add helpers for upgrade testing.

675. By Omer Akram

add objectName for a few objects, also add new property updatesDownloaded for upgrade testing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/system-update/PageComponent.qml'
2--- plugins/system-update/PageComponent.qml 2014-03-17 02:08:47 +0000
3+++ plugins/system-update/PageComponent.qml 2014-04-09 18:08:02 +0000
4@@ -35,6 +35,7 @@
5 title: i18n.tr("Updates")
6
7 property bool installAll: false
8+ property bool updatesDownloaded: false
9 property int updatesAvailable: 0
10
11 DeviceInfo {
12@@ -45,11 +46,13 @@
13 id: dialogInstallComponent
14 Dialog {
15 id: dialogueInstall
16+ objectName: "dialogInstall"
17 title: i18n.tr("Update System")
18 text: i18n.tr("The phone needs to restart to install the system update.")
19
20 Button {
21 text: i18n.tr("Install & Restart")
22+ objectName: "btnInstallUpdate"
23 color: UbuntuColors.orange
24 onClicked: {
25 installingImageUpdate.visible = true;
26@@ -157,6 +160,7 @@
27
28 onSystemUpdateDownloaded: {
29 root.updatesAvailable -= 1;
30+ root.updatesDownloaded = true;
31 PopupUtils.open(dialogInstallComponent);
32 }
33
34
35=== added file 'tests/autopilot/ubuntu_system_settings/emulators.py'
36--- tests/autopilot/ubuntu_system_settings/emulators.py 1970-01-01 00:00:00 +0000
37+++ tests/autopilot/ubuntu_system_settings/emulators.py 2014-04-09 18:08:02 +0000
38@@ -0,0 +1,98 @@
39+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
40+#
41+# Copyright (C) 2014 Canonical Ltd.
42+#
43+# This program is free software; you can redistribute it and/or modify
44+# it under the terms of the GNU Lesser General Public License as published by
45+# the Free Software Foundation; version 3.
46+#
47+# This program is distributed in the hope that it will be useful,
48+# but WITHOUT ANY WARRANTY; without even the implied warranty of
49+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50+# GNU Lesser General Public License for more details.
51+#
52+# You should have received a copy of the GNU Lesser General Public License
53+# along with this program. If not, see <http://www.gnu.org/licenses/>.
54+
55+"""Emulators for updates page used by upgrade tests."""
56+
57+import time
58+import logging
59+
60+logger = logging.getLogger(__name__)
61+
62+
63+class UpdatesPage(object):
64+
65+ def __init__(self, app, pointer):
66+ self.app = app
67+ self.pointer = pointer
68+
69+ def _get_updates_view(self):
70+ return self.app.select_single(
71+ 'PageComponent', objectName='systemUpdatesPage'
72+ )
73+
74+ def _get_install_dialog(self):
75+ return self.app.wait_select_single(
76+ 'Dialog', objectName='dialogInstall'
77+ )
78+
79+ def _wait_for_dialog(self):
80+ dialog = self._get_install_dialog()
81+
82+ dialog.opacity.wait_for(1.0)
83+
84+ def get_installing_update_screen(self):
85+ return self.app.wait_select_single(
86+ 'QQuickRectangle', objectName='installingImageUpdate'
87+ )
88+
89+ def wait_for_updates_to_download(self, timeout=40):
90+ """Wait for system updates to download
91+
92+ :returns: None
93+ :raises: ValueError
94+ """
95+ while timeout > 0:
96+ download_state = self._get_updates_view().updatesDownloaded
97+ if download_state:
98+ return
99+
100+ timeout = timeout - 1
101+ time.sleep(5)
102+ else:
103+ raise ValueError(
104+ "Download didn't complete in given time, check your "
105+ "internet and try again."
106+ )
107+
108+ def wait_for_state(self, state, timeout=60):
109+ """Wait for expected state
110+
111+ :returns: state
112+ :raises: SystemSettingsEmulatorException
113+ """
114+ for wait in range(timeout):
115+ status = self._get_updates_view().state
116+ logger.info(
117+ 'State: {} waiting for {}'.format(status, state)
118+ )
119+ if state == status:
120+ return state
121+ time.sleep(1)
122+
123+ raise ValueError(
124+ 'Error state {} not found before timeout'.format(state)
125+ )
126+
127+ def click_install_and_restart_button(self):
128+ """Wait for the install dialog to appear before clicking
129+ on its button.
130+ """
131+ self._wait_for_dialog()
132+ button = self.app.select_single(
133+ 'Button', objectName='btnInstallUpdate'
134+ )
135+
136+ self.pointer.click_object(button)

Subscribers

People subscribed via source and target branches