Merge lp:~diegosarmentero/ubuntuone-control-panel/reconnect-button into lp:ubuntuone-control-panel

Proposed by Diego Sarmentero
Status: Merged
Approved by: Natalia Bidart
Approved revision: 260
Merged at revision: 260
Proposed branch: lp:~diegosarmentero/ubuntuone-control-panel/reconnect-button
Merge into: lp:ubuntuone-control-panel
Diff against target: 216 lines (+119/-6)
6 files modified
data/qt/filesyncstatus.ui (+9/-2)
data/qt/images.qrc (+1/-0)
ubuntuone/controlpanel/gui/__init__.py (+1/-0)
ubuntuone/controlpanel/gui/qt/filesyncstatus.py (+12/-3)
ubuntuone/controlpanel/gui/qt/tests/__init__.py (+67/-0)
ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py (+29/-1)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-control-panel/reconnect-button
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+90758@code.launchpad.net

Commit message

- The QT UI will make a button inactive while a (re-) connection is in progress (LP: #878867).

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

+1

review: Approve
256. By Manuel de la Peña

Forward extra params to u1trial.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Can we please not depend on SSO qt-related stuff for the test suite?
Though is a valid dependency, we would need to hack tarmac regarding PYTHONPATH since we don't have -qt packages yet.

In particular, I'm having this:

  File "/home/nessita/canonical/controlpanel/review_reconnect-button/ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py", line 23, in <module>
    from ubuntu_sso.qt.tests import FakePageUiStyle

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> Can we please not depend on SSO qt-related stuff for the test suite?
> Though is a valid dependency, we would need to hack tarmac regarding
> PYTHONPATH since we don't have -qt packages yet.
>
> In particular, I'm having this:
>
> File "/home/nessita/canonical/controlpanel/review_reconnect-
> button/ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py", line 23,
> in <module>
> from ubuntu_sso.qt.tests import FakePageUiStyle

updated

257. By Natalia Bidart

- Avoid TypeError when fetching credentials in the Gtk OverviewPanel
   (LP: #927743).
- Run the whole test suite with a single command (LP: #927770).
- Do proper cleanup when dealing with UIs (LP: #925617).

258. By Natalia Bidart

 - Replaced custom webclient with the one from ubuntu-sso-client
   (LP: #926311).
- Removed the dependency on qt4reactor for Linux implementation.

259. By Natalia Bidart

- Install the uniqueapp module (LP: #930269).

260. By Diego Sarmentero

merge

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks great! and works as expected

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/qt/filesyncstatus.ui'
--- data/qt/filesyncstatus.ui 2011-08-23 16:03:31 +0000
+++ data/qt/filesyncstatus.ui 2012-02-17 12:07:20 +0000
@@ -7,7 +7,7 @@
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>94</width>9 <width>94</width>
10 <height>49</height>10 <height>52</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="windowTitle">13 <property name="windowTitle">
@@ -20,7 +20,14 @@
20 <item>20 <item>
21 <layout class="QHBoxLayout" name="horizontalLayout">21 <layout class="QHBoxLayout" name="horizontalLayout">
22 <item>22 <item>
23 <widget class="QLabel" name="sync_status_icon"/>23 <widget class="QLabel" name="sync_status_icon">
24 <property name="sizePolicy">
25 <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
26 <horstretch>0</horstretch>
27 <verstretch>0</verstretch>
28 </sizepolicy>
29 </property>
30 </widget>
24 </item>31 </item>
25 <item>32 <item>
26 <widget class="QLabel" name="sync_status_label">33 <widget class="QLabel" name="sync_status_label">
2734
=== modified file 'data/qt/images.qrc'
--- data/qt/images.qrc 2011-09-06 13:43:25 +0000
+++ data/qt/images.qrc 2012-02-17 12:07:20 +0000
@@ -6,6 +6,7 @@
6 <file>../sync_status_alert.png</file>6 <file>../sync_status_alert.png</file>
7 <file>../sync_status_sync_done.png</file>7 <file>../sync_status_sync_done.png</file>
8 <file>../sync_status_syncing.png</file>8 <file>../sync_status_syncing.png</file>
9 <file>../sync_status_loading.png</file>
9 <file>../folder.png</file>10 <file>../folder.png</file>
10 <file>../computer.png</file>11 <file>../computer.png</file>
11 <file>../phone.png</file>12 <file>../phone.png</file>
1213
=== added file 'data/sync_status_loading.png'
13Binary files data/sync_status_loading.png 1970-01-01 00:00:00 +0000 and data/sync_status_loading.png 2012-02-17 12:07:20 +0000 differ14Binary files data/sync_status_loading.png 1970-01-01 00:00:00 +0000 and data/sync_status_loading.png 2012-02-17 12:07:20 +0000 differ
=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
--- ubuntuone/controlpanel/gui/__init__.py 2012-02-06 15:23:27 +0000
+++ ubuntuone/controlpanel/gui/__init__.py 2012-02-17 12:07:20 +0000
@@ -153,6 +153,7 @@
153NO_FOLDERS = _('No folders to show.')153NO_FOLDERS = _('No folders to show.')
154NO_PAIRING_RECORD = _('There is no Ubuntu One pairing record.')154NO_PAIRING_RECORD = _('There is no Ubuntu One pairing record.')
155PERCENTAGE_LABEL = _('%(percentage)s used')155PERCENTAGE_LABEL = _('%(percentage)s used')
156PLEASE_WAIT = _('Please wait')
156QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).0f%%)')157QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).0f%%)')
157USAGE_LABEL = _('%(used)s of %(total)s')158USAGE_LABEL = _('%(used)s of %(total)s')
158SERVICES_BUTTON_TOOLTIP = _('Manage the sync services')159SERVICES_BUTTON_TOOLTIP = _('Manage the sync services')
159160
=== modified file 'ubuntuone/controlpanel/gui/qt/filesyncstatus.py'
--- ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2011-09-02 17:59:39 +0000
+++ ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2012-02-17 12:07:20 +0000
@@ -1,8 +1,6 @@
1# -*- coding: utf-8 -*-1# -*- coding: utf-8 -*-
2
3# Authors: Natalia B Bidart <natalia.bidart@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
@@ -44,6 +42,8 @@
44 FILE_SYNC_STOP_TOOLTIP,42 FILE_SYNC_STOP_TOOLTIP,
45 FILE_SYNC_STOPPED,43 FILE_SYNC_STOPPED,
46 FILE_SYNC_SYNCING,44 FILE_SYNC_SYNCING,
45 LOADING,
46 PLEASE_WAIT,
47)47)
48from ubuntuone.controlpanel.gui.qt import pixmap_from_name48from ubuntuone.controlpanel.gui.qt import pixmap_from_name
49from ubuntuone.controlpanel.gui.qt.ui import filesyncstatus_ui49from ubuntuone.controlpanel.gui.qt.ui import filesyncstatus_ui
@@ -186,6 +186,15 @@
186 """Button was clicked, act accordingly to the label."""186 """Button was clicked, act accordingly to the label."""
187 self.ui.sync_status_button.setEnabled(False)187 self.ui.sync_status_button.setEnabled(False)
188 if self._backend_method is not None:188 if self._backend_method is not None:
189 self.ui.sync_status_label.setText(LOADING)
190 self.ui.sync_status_button.setText(PLEASE_WAIT)
191 pixmap = pixmap_from_name('sync_status_loading')
192 self.ui.sync_status_icon.setPixmap(pixmap)
193 self.ui.sync_status_button.setProperty("secondary", True)
194 self.ui.sync_status_button.style().unpolish(
195 self.ui.sync_status_button)
196 self.ui.sync_status_button.style().polish(
197 self.ui.sync_status_button)
189 self._backend_method()198 self._backend_method()
190 else:199 else:
191 logger.error('on_sync_status_button_clicked: backend method is '200 logger.error('on_sync_status_button_clicked: backend method is '
192201
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-02-06 15:23:27 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-02-17 12:07:20 +0000
@@ -233,6 +233,73 @@
233 # pylint: enable=C0103233 # pylint: enable=C0103
234234
235235
236class FakePageUiStyle(object):
237 """Fake the page."""
238
239 def __init__(self):
240 self.ui = self
241 self.properties = {}
242 super(FakePageUiStyle, self).__init__()
243
244 def wizard(self):
245 """Use itself as a fake wizard, too."""
246 return self
247
248 def text(self):
249 """Return text."""
250 return self.properties.get('text', '')
251
252 # setText, setEnabled are inherited
253 # pylint: disable=C0103
254 def setText(self, text):
255 """Save text."""
256 self.properties['text'] = text
257
258 def setEnabled(self, value):
259 """Fake setEnabled."""
260 self.properties['enabled'] = value
261
262 def enabled(self):
263 """Fake enabled."""
264 return self.properties.get('enabled', False)
265
266 def isEnabled(self):
267 """Fake isEnabled."""
268 return self.properties.get('enabled', False)
269
270 def setProperty(self, key, val):
271 """Fake setProperty to restyle some widget."""
272 self.properties[key] = val
273
274 def property(self, key):
275 """Fake property from widget style."""
276 return self.properties.get(key, False)
277
278 def setDefault(self, val):
279 """Fake button setDefault."""
280 self.properties['default'] = val
281
282 def style(self):
283 """Fake style."""
284 return self
285
286 def unpolish(self, *args):
287 """Fake unpolish."""
288 self.properties['unpolish'] = len(args) > 0
289
290 def polish(self, *args):
291 """Fake polish."""
292 self.properties['polish'] = len(args) > 0
293
294 def setVisible(self, val):
295 """Fake setVisible from Qt."""
296 self.properties['visible'] = val
297
298 def isVisible(self):
299 """Fake isVisible from Qt."""
300 return self.properties['visible']
301
302
236class BaseTestCase(TestCase):303class BaseTestCase(TestCase):
237 """Base Test Case."""304 """Base Test Case."""
238305
239306
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-10-28 08:19:20 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2012-02-17 12:07:20 +0000
@@ -21,7 +21,14 @@
21from twisted.internet import defer21from twisted.internet import defer
2222
23from ubuntuone.controlpanel.gui.qt import filesyncstatus as gui23from ubuntuone.controlpanel.gui.qt import filesyncstatus as gui
24from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase24from ubuntuone.controlpanel.gui.qt.tests import (
25 BaseTestCase,
26 FakePageUiStyle,
27)
28from ubuntuone.controlpanel.gui import (
29 LOADING,
30 PLEASE_WAIT,
31)
2532
26backend = gui.backend # pylint: disable=C010333backend = gui.backend # pylint: disable=C0103
2734
@@ -171,3 +178,24 @@
171 action=gui.FILE_SYNC_RESTART,178 action=gui.FILE_SYNC_RESTART,
172 callback='restart_files',179 callback='restart_files',
173 tooltip=gui.FILE_SYNC_RESTART_TOOLTIP)180 tooltip=gui.FILE_SYNC_RESTART_TOOLTIP)
181
182 def test_on_sync_status_button_clicked(self):
183 """Check the labels and icon when the button is pressed."""
184 # Ensure the _backend_method is not None to execute the first
185 # part of the If.
186 self.ui._backend_method = lambda: 'Not None'
187 self.patch(self.ui.ui, "sync_status_button", FakePageUiStyle())
188 # Simulate the click event
189 self.ui.on_sync_status_button_clicked()
190 self.assertFalse(self.ui.ui.sync_status_button.isEnabled())
191 self.assertTrue(self.ui.ui.sync_status_button.property("secondary"))
192 actual_text = self.ui.ui.sync_status_label.text()
193 self.assertEqual(actual_text, LOADING)
194 self.assertEqual(self.ui.ui.sync_status_button.text(), PLEASE_WAIT)
195 actual_icon = self.ui.ui.sync_status_icon.pixmap()
196 expected_icon = gui.pixmap_from_name('sync_status_loading')
197 self.assertEqualPixmaps(expected_icon, actual_icon)
198 self.assertTrue(
199 self.ui.ui.sync_status_button.properties.get('unpolish', True))
200 self.assertTrue(
201 self.ui.ui.sync_status_button.properties.get('polish', True))

Subscribers

People subscribed via source and target branches