Merge lp:~dobey/ubuntuone-control-panel/update-from-trunk into lp:ubuntuone-control-panel/stable-3-0

Proposed by dobey
Status: Merged
Approved by: dobey
Approved revision: 259
Merged at revision: 259
Proposed branch: lp:~dobey/ubuntuone-control-panel/update-from-trunk
Merge into: lp:ubuntuone-control-panel/stable-3-0
Diff against target: 296 lines (+134/-8)
8 files modified
ubuntuone/controlpanel/gui/__init__.py (+4/-0)
ubuntuone/controlpanel/gui/qt/controlpanel.py (+1/-0)
ubuntuone/controlpanel/gui/qt/gui.py (+26/-2)
ubuntuone/controlpanel/gui/qt/loadingoverlay.py (+1/-1)
ubuntuone/controlpanel/gui/qt/tests/__init__.py (+7/-0)
ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+2/-0)
ubuntuone/controlpanel/gui/qt/tests/test_gui.py (+76/-5)
ubuntuone/controlpanel/gui/qt/tests/test_start.py (+17/-0)
To merge this branch: bzr merge lp:~dobey/ubuntuone-control-panel/update-from-trunk
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+101470@code.launchpad.net

Commit message

[Diego Sarmentero]

  - Restarting the wizard on current device removed.

[Natalia Bidart]

  - Check for updates when the main window is shown. On linux, this is a no-op.
    On windows, this will check for new versions of the software and will
    prompt the user for confirmation to install updates.
  - Make the LOADING_OVERLAY_MARKUP use a smaller font.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
--- ubuntuone/controlpanel/gui/__init__.py 2012-03-29 16:56:35 +0000
+++ ubuntuone/controlpanel/gui/__init__.py 2012-04-11 01:13:24 +0000
@@ -247,6 +247,10 @@
247VALUE_ERROR = _('Value could not be retrieved.')247VALUE_ERROR = _('Value could not be retrieved.')
248UNKNOWN_ERROR = _('Unknown error')248UNKNOWN_ERROR = _('Unknown error')
249USAGE_LABEL = _('%(used)s of %(total)s')249USAGE_LABEL = _('%(used)s of %(total)s')
250# TODO: mark the following strings translatable after precise is released
251UPDATE_TITLE = APP_NAME
252UPDATE_SOFTWARE = ('There is a new update available.'
253 ' Would you like to install it?')
250QUIT_LABEL = _('Quit Ubuntu One')254QUIT_LABEL = _('Quit Ubuntu One')
251255
252# pylint: enable=E0602256# pylint: enable=E0602
253257
=== modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py'
--- ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-03-30 17:34:33 +0000
+++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-04-11 01:13:24 +0000
@@ -93,6 +93,7 @@
93 @log_call(logger.debug)93 @log_call(logger.debug)
94 def on_credentials_not_found(self):94 def on_credentials_not_found(self):
95 """Credentials are not found or were removed."""95 """Credentials are not found or were removed."""
96 self.ui.wizard.restart()
96 self.ui.switcher.setCurrentWidget(self.ui.wizard)97 self.ui.switcher.setCurrentWidget(self.ui.wizard)
97 self.is_processing = False98 self.is_processing = False
9899
99100
=== modified file 'ubuntuone/controlpanel/gui/qt/gui.py'
--- ubuntuone/controlpanel/gui/qt/gui.py 2012-03-29 19:05:02 +0000
+++ ubuntuone/controlpanel/gui/qt/gui.py 2012-04-11 01:13:24 +0000
@@ -18,9 +18,13 @@
1818
19from PyQt4 import QtGui, QtCore19from PyQt4 import QtGui, QtCore
2020
21from twisted.internet import defer
22
23from ubuntuone.controlpanel import utils
24from ubuntuone.controlpanel.logger import setup_logging
25from ubuntuone.controlpanel.gui import UPDATE_TITLE, UPDATE_SOFTWARE
21from ubuntuone.controlpanel.gui.qt.systray import TrayIcon26from ubuntuone.controlpanel.gui.qt.systray import TrayIcon
22from ubuntuone.controlpanel.gui.qt.ui import mainwindow_ui27from ubuntuone.controlpanel.gui.qt.ui import mainwindow_ui
23from ubuntuone.controlpanel.utils import add_to_autostart
2428
25# pylint: disable=E061129# pylint: disable=E0611
26try:30try:
@@ -30,6 +34,8 @@
30 USE_LIBUNITY = False34 USE_LIBUNITY = False
31# pylint: enable=E061135# pylint: enable=E0611
3236
37logger = setup_logging('qt.gui')
38
33U1_DOTDESKTOP = "ubuntuone-installer.desktop"39U1_DOTDESKTOP = "ubuntuone-installer.desktop"
3440
3541
@@ -49,7 +55,7 @@
49 self.installer = installer55 self.installer = installer
50 if installer:56 if installer:
51 self.ui.control_panel.start_from_license()57 self.ui.control_panel.start_from_license()
52 add_to_autostart()58 utils.add_to_autostart()
53 if USE_LIBUNITY:59 if USE_LIBUNITY:
54 self.entry = Unity.LauncherEntry.get_for_desktop_id(U1_DOTDESKTOP)60 self.entry = Unity.LauncherEntry.get_for_desktop_id(U1_DOTDESKTOP)
55 else:61 else:
@@ -87,6 +93,23 @@
8793
88 # pylint: enable=C010394 # pylint: enable=C0103
8995
96 @defer.inlineCallbacks
97 def check_updates(self):
98 """Offer the user to update if there are updates available."""
99 logger.debug('Checking for updates.')
100 are_present = yield utils.are_updates_present()
101 logger.info('Updates available? %r', are_present)
102 if are_present:
103 buttons = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
104 result = QtGui.QMessageBox.question(self, UPDATE_TITLE,
105 UPDATE_SOFTWARE,
106 buttons, QtGui.QMessageBox.Yes)
107 if result == QtGui.QMessageBox.Yes:
108 logger.info('Performing auto-update.')
109 utils.perform_update()
110 else:
111 logger.info('User do not want to update.')
112
90113
91def start(close_callback, minimized=False, with_icon=False, installer=False):114def start(close_callback, minimized=False, with_icon=False, installer=False):
92 """Show the UI elements."""115 """Show the UI elements."""
@@ -102,6 +125,7 @@
102 QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,125 QtCore.Qt.LeftToRight, QtCore.Qt.AlignCenter,
103 window.size(), app.desktop().availableGeometry())126 window.size(), app.desktop().availableGeometry())
104 window.setGeometry(style)127 window.setGeometry(style)
128 window.check_updates()
105 window.show()129 window.show()
106 else:130 else:
107 window = None131 window = None
108132
=== modified file 'ubuntuone/controlpanel/gui/qt/loadingoverlay.py'
--- ubuntuone/controlpanel/gui/qt/loadingoverlay.py 2012-03-14 20:01:00 +0000
+++ ubuntuone/controlpanel/gui/qt/loadingoverlay.py 2012-04-11 01:13:24 +0000
@@ -23,7 +23,7 @@
23from ubuntuone.controlpanel.gui import LOADING_OVERLAY23from ubuntuone.controlpanel.gui import LOADING_OVERLAY
24from ubuntuone.controlpanel.gui.qt.ui import loadingoverlay_ui24from ubuntuone.controlpanel.gui.qt.ui import loadingoverlay_ui
2525
26LOADING_OVERLAY_MARKUP = u'<span style="font-size:xx-large;">{0}</span>'26LOADING_OVERLAY_MARKUP = u'<span style="font-size:x-large;">{0}</span>'
2727
2828
29class LoadingOverlay(QtGui.QFrame):29class LoadingOverlay(QtGui.QFrame):
3030
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-03-28 12:06:28 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-04-11 01:13:24 +0000
@@ -210,6 +210,13 @@
210 cls.kwargs = kw210 cls.kwargs = kw
211 return cls.response211 return cls.response
212212
213 @classmethod
214 def question(cls, *a, **kw):
215 """Simulate a question message."""
216 cls.args = a
217 cls.kwargs = kw
218 return cls.response
219
213 # Invalid name "setDetailedText", "setDefaultButton"220 # Invalid name "setDetailedText", "setDefaultButton"
214 # pylint: disable=C0103221 # pylint: disable=C0103
215222
216223
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2012-03-26 21:00:47 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2012-04-11 01:13:24 +0000
@@ -68,9 +68,11 @@
6868
69 def test_on_credentials_not_found(self):69 def test_on_credentials_not_found(self):
70 """The wizard panel is shown."""70 """The wizard panel is shown."""
71 self.patch(self.ui.ui.wizard, 'restart', self._set_called)
71 self.ui.on_credentials_found()72 self.ui.on_credentials_found()
72 self.ui.on_credentials_not_found()73 self.ui.on_credentials_not_found()
73 self.assertIs(self.ui.ui.switcher.currentWidget(), self.ui.ui.wizard)74 self.assertIs(self.ui.ui.switcher.currentWidget(), self.ui.ui.wizard)
75 self.assertEqual(self._called, ((), {}))
7476
75 @defer.inlineCallbacks77 @defer.inlineCallbacks
76 def test_on_credentials_found_called(self):78 def test_on_credentials_found_called(self):
7779
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_gui.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_gui.py 2012-03-26 13:30:07 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_gui.py 2012-04-11 01:13:24 +0000
@@ -1,8 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2
3# Authors: Alejandro J. Cura <alecu@canonical.com>
4#2#
5# Copyright 2011 Canonical Ltd.3# Copyright 2011-2012 Canonical Ltd.
6#4#
7# This program is free software: you can redistribute it and/or modify it5# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published6# under the terms of the GNU General Public License version 3, as published
@@ -21,7 +19,7 @@
21from twisted.internet import defer19from twisted.internet import defer
2220
23from ubuntuone.controlpanel.gui.qt import gui21from ubuntuone.controlpanel.gui.qt import gui
24from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase22from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase, FakedDialog
2523
2624
27class FakeEntry(object):25class FakeEntry(object):
@@ -119,13 +117,86 @@
119 self.assertEqual(entry.called, (('urgent', "foo"), {}))117 self.assertEqual(entry.called, (('urgent', "foo"), {}))
120118
121119
120class CheckUpdatesNoUpdatesTestCase(MainWindowTestCase):
121 """Test the check_updates method when there are no updates."""
122
123 updates_available = False
124
125 @defer.inlineCallbacks
126 def setUp(self):
127 """Set the different tests."""
128 yield super(CheckUpdatesNoUpdatesTestCase, self).setUp()
129 self.patch(gui.utils, 'are_updates_present',
130 lambda: defer.succeed(self.updates_available))
131 self.patch(gui.utils, 'perform_update',
132 lambda: defer.fail(ValueError()))
133
134 @defer.inlineCallbacks
135 def test_update_confirmation_dialog(self):
136 """The confirmation dialog is not shown."""
137 yield self.ui.check_updates()
138 self.assertEqual(None, FakedDialog.args)
139 self.assertEqual(None, FakedDialog.kwargs)
140
141 @defer.inlineCallbacks
142 def test_perform_update(self):
143 """The perform_update method is not called."""
144 yield self.ui.check_updates()
145 self.assertFalse(self._called)
146
147
148class CheckUpdatesUserSaysNoTestCase(CheckUpdatesNoUpdatesTestCase):
149 """Test check_updates when there are updates and user rejects them."""
150
151 updates_available = True
152 user_response = gui.QtGui.QMessageBox.No
153
154 @defer.inlineCallbacks
155 def setUp(self):
156 """Set the different tests."""
157 yield super(CheckUpdatesUserSaysNoTestCase, self).setUp()
158 self.patch(FakedDialog, 'response', self.user_response)
159
160 @defer.inlineCallbacks
161 def test_update_confirmation_dialog(self):
162 """The confirmation dialog is shown with correct params."""
163 yield self.ui.check_updates()
164 args = (self.ui, gui.UPDATE_TITLE, gui.UPDATE_SOFTWARE,
165 gui.QtGui.QMessageBox.Yes | gui.QtGui.QMessageBox.No,
166 gui.QtGui.QMessageBox.Yes)
167 self.assertEqual(args, FakedDialog.args)
168 self.assertEqual({}, FakedDialog.kwargs)
169
170
171class CheckUpdatesUserSaysYesTestCase(CheckUpdatesUserSaysNoTestCase):
172 """Test check_updates when there are updates and user accepts them."""
173
174 user_response = gui.QtGui.QMessageBox.Yes
175
176 @defer.inlineCallbacks
177 def setUp(self):
178 """Set the different tests."""
179 self.updated = defer.Deferred()
180 yield super(CheckUpdatesUserSaysYesTestCase, self).setUp()
181 self.patch(gui.utils, 'perform_update',
182 lambda *a, **kw: self.updated.callback((a, kw)))
183
184 @defer.inlineCallbacks
185 def test_perform_update(self):
186 """The perform_update method is called."""
187 yield self.ui.check_updates()
188 result = yield self.updated # perform_update will fire this deferred
189
190 self.assertEqual(result, ((), {}))
191
192
122class AutoStartTestCase(MainWindowTestCase):193class AutoStartTestCase(MainWindowTestCase):
123 """Test the add_to_autostart call."""194 """Test the add_to_autostart call."""
124195
125 @defer.inlineCallbacks196 @defer.inlineCallbacks
126 def setUp(self):197 def setUp(self):
127 # Be sure to patch add_to_autostart *before* class_ui creation occurs.198 # Be sure to patch add_to_autostart *before* class_ui creation occurs.
128 self.patch(gui, "add_to_autostart", self._set_called)199 self.patch(gui.utils, "add_to_autostart", self._set_called)
129 yield super(AutoStartTestCase, self).setUp()200 yield super(AutoStartTestCase, self).setUp()
130201
131 def test_add_to_autostart(self):202 def test_add_to_autostart(self):
132203
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_start.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_start.py 2012-03-20 19:13:28 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_start.py 2012-04-11 01:13:24 +0000
@@ -34,6 +34,7 @@
3434
35 def __init__(self):35 def __init__(self):
36 self.args = []36 self.args = []
37 self.updates_checked = defer.Deferred()
3738
38 def __call__(self, *args, **kwargs):39 def __call__(self, *args, **kwargs):
39 self.args.append((args, kwargs))40 self.args.append((args, kwargs))
@@ -50,10 +51,17 @@
50 """Save the new geometry."""51 """Save the new geometry."""
51 self.style = style52 self.style = style
5253
54 def check_updates(self):
55 """Fake the check updates call."""
56 self.updates_checked.callback(None)
57 return self.updates_checked
58
5359
54class StartTestCase(TestCase):60class StartTestCase(TestCase):
55 """Test the qt control panel."""61 """Test the qt control panel."""
5662
63 timeout = 2
64
57 @defer.inlineCallbacks65 @defer.inlineCallbacks
58 def setUp(self):66 def setUp(self):
59 yield super(StartTestCase, self).setUp()67 yield super(StartTestCase, self).setUp()
@@ -106,3 +114,12 @@
106 gui.QtCore.Qt.AlignCenter, self.main_window.size(),114 gui.QtCore.Qt.AlignCenter, self.main_window.size(),
107 app.desktop().availableGeometry())115 app.desktop().availableGeometry())
108 self.assertEqual(self.main_window.style, expected)116 self.assertEqual(self.main_window.style, expected)
117
118 @defer.inlineCallbacks
119 def test_updates_are_checked(self):
120 """When creating the window, updates are checked."""
121 gui.start(close_callback=self.close_cb)
122
123 # a timeout in this test means that the check_updates method
124 # was not called
125 yield self.main_window.updates_checked

Subscribers

People subscribed via source and target branches

to all changes: