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 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
1=== modified file 'data/qt/filesyncstatus.ui'
2--- data/qt/filesyncstatus.ui 2011-08-23 16:03:31 +0000
3+++ data/qt/filesyncstatus.ui 2012-02-17 12:07:20 +0000
4@@ -7,7 +7,7 @@
5 <x>0</x>
6 <y>0</y>
7 <width>94</width>
8- <height>49</height>
9+ <height>52</height>
10 </rect>
11 </property>
12 <property name="windowTitle">
13@@ -20,7 +20,14 @@
14 <item>
15 <layout class="QHBoxLayout" name="horizontalLayout">
16 <item>
17- <widget class="QLabel" name="sync_status_icon"/>
18+ <widget class="QLabel" name="sync_status_icon">
19+ <property name="sizePolicy">
20+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
21+ <horstretch>0</horstretch>
22+ <verstretch>0</verstretch>
23+ </sizepolicy>
24+ </property>
25+ </widget>
26 </item>
27 <item>
28 <widget class="QLabel" name="sync_status_label">
29
30=== modified file 'data/qt/images.qrc'
31--- data/qt/images.qrc 2011-09-06 13:43:25 +0000
32+++ data/qt/images.qrc 2012-02-17 12:07:20 +0000
33@@ -6,6 +6,7 @@
34 <file>../sync_status_alert.png</file>
35 <file>../sync_status_sync_done.png</file>
36 <file>../sync_status_syncing.png</file>
37+ <file>../sync_status_loading.png</file>
38 <file>../folder.png</file>
39 <file>../computer.png</file>
40 <file>../phone.png</file>
41
42=== added file 'data/sync_status_loading.png'
43Binary 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
44=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
45--- ubuntuone/controlpanel/gui/__init__.py 2012-02-06 15:23:27 +0000
46+++ ubuntuone/controlpanel/gui/__init__.py 2012-02-17 12:07:20 +0000
47@@ -153,6 +153,7 @@
48 NO_FOLDERS = _('No folders to show.')
49 NO_PAIRING_RECORD = _('There is no Ubuntu One pairing record.')
50 PERCENTAGE_LABEL = _('%(percentage)s used')
51+PLEASE_WAIT = _('Please wait')
52 QUOTA_LABEL = _('Using %(used)s of %(total)s (%(percentage).0f%%)')
53 USAGE_LABEL = _('%(used)s of %(total)s')
54 SERVICES_BUTTON_TOOLTIP = _('Manage the sync services')
55
56=== modified file 'ubuntuone/controlpanel/gui/qt/filesyncstatus.py'
57--- ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2011-09-02 17:59:39 +0000
58+++ ubuntuone/controlpanel/gui/qt/filesyncstatus.py 2012-02-17 12:07:20 +0000
59@@ -1,8 +1,6 @@
60 # -*- coding: utf-8 -*-
61-
62-# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
63 #
64-# Copyright 2011 Canonical Ltd.
65+# Copyright 2011-2012 Canonical Ltd.
66 #
67 # This program is free software: you can redistribute it and/or modify it
68 # under the terms of the GNU General Public License version 3, as published
69@@ -44,6 +42,8 @@
70 FILE_SYNC_STOP_TOOLTIP,
71 FILE_SYNC_STOPPED,
72 FILE_SYNC_SYNCING,
73+ LOADING,
74+ PLEASE_WAIT,
75 )
76 from ubuntuone.controlpanel.gui.qt import pixmap_from_name
77 from ubuntuone.controlpanel.gui.qt.ui import filesyncstatus_ui
78@@ -186,6 +186,15 @@
79 """Button was clicked, act accordingly to the label."""
80 self.ui.sync_status_button.setEnabled(False)
81 if self._backend_method is not None:
82+ self.ui.sync_status_label.setText(LOADING)
83+ self.ui.sync_status_button.setText(PLEASE_WAIT)
84+ pixmap = pixmap_from_name('sync_status_loading')
85+ self.ui.sync_status_icon.setPixmap(pixmap)
86+ self.ui.sync_status_button.setProperty("secondary", True)
87+ self.ui.sync_status_button.style().unpolish(
88+ self.ui.sync_status_button)
89+ self.ui.sync_status_button.style().polish(
90+ self.ui.sync_status_button)
91 self._backend_method()
92 else:
93 logger.error('on_sync_status_button_clicked: backend method is '
94
95=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
96--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-02-06 15:23:27 +0000
97+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2012-02-17 12:07:20 +0000
98@@ -233,6 +233,73 @@
99 # pylint: enable=C0103
100
101
102+class FakePageUiStyle(object):
103+ """Fake the page."""
104+
105+ def __init__(self):
106+ self.ui = self
107+ self.properties = {}
108+ super(FakePageUiStyle, self).__init__()
109+
110+ def wizard(self):
111+ """Use itself as a fake wizard, too."""
112+ return self
113+
114+ def text(self):
115+ """Return text."""
116+ return self.properties.get('text', '')
117+
118+ # setText, setEnabled are inherited
119+ # pylint: disable=C0103
120+ def setText(self, text):
121+ """Save text."""
122+ self.properties['text'] = text
123+
124+ def setEnabled(self, value):
125+ """Fake setEnabled."""
126+ self.properties['enabled'] = value
127+
128+ def enabled(self):
129+ """Fake enabled."""
130+ return self.properties.get('enabled', False)
131+
132+ def isEnabled(self):
133+ """Fake isEnabled."""
134+ return self.properties.get('enabled', False)
135+
136+ def setProperty(self, key, val):
137+ """Fake setProperty to restyle some widget."""
138+ self.properties[key] = val
139+
140+ def property(self, key):
141+ """Fake property from widget style."""
142+ return self.properties.get(key, False)
143+
144+ def setDefault(self, val):
145+ """Fake button setDefault."""
146+ self.properties['default'] = val
147+
148+ def style(self):
149+ """Fake style."""
150+ return self
151+
152+ def unpolish(self, *args):
153+ """Fake unpolish."""
154+ self.properties['unpolish'] = len(args) > 0
155+
156+ def polish(self, *args):
157+ """Fake polish."""
158+ self.properties['polish'] = len(args) > 0
159+
160+ def setVisible(self, val):
161+ """Fake setVisible from Qt."""
162+ self.properties['visible'] = val
163+
164+ def isVisible(self):
165+ """Fake isVisible from Qt."""
166+ return self.properties['visible']
167+
168+
169 class BaseTestCase(TestCase):
170 """Base Test Case."""
171
172
173=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py'
174--- ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2011-10-28 08:19:20 +0000
175+++ ubuntuone/controlpanel/gui/qt/tests/test_filesyncstatus.py 2012-02-17 12:07:20 +0000
176@@ -21,7 +21,14 @@
177 from twisted.internet import defer
178
179 from ubuntuone.controlpanel.gui.qt import filesyncstatus as gui
180-from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
181+from ubuntuone.controlpanel.gui.qt.tests import (
182+ BaseTestCase,
183+ FakePageUiStyle,
184+)
185+from ubuntuone.controlpanel.gui import (
186+ LOADING,
187+ PLEASE_WAIT,
188+)
189
190 backend = gui.backend # pylint: disable=C0103
191
192@@ -171,3 +178,24 @@
193 action=gui.FILE_SYNC_RESTART,
194 callback='restart_files',
195 tooltip=gui.FILE_SYNC_RESTART_TOOLTIP)
196+
197+ def test_on_sync_status_button_clicked(self):
198+ """Check the labels and icon when the button is pressed."""
199+ # Ensure the _backend_method is not None to execute the first
200+ # part of the If.
201+ self.ui._backend_method = lambda: 'Not None'
202+ self.patch(self.ui.ui, "sync_status_button", FakePageUiStyle())
203+ # Simulate the click event
204+ self.ui.on_sync_status_button_clicked()
205+ self.assertFalse(self.ui.ui.sync_status_button.isEnabled())
206+ self.assertTrue(self.ui.ui.sync_status_button.property("secondary"))
207+ actual_text = self.ui.ui.sync_status_label.text()
208+ self.assertEqual(actual_text, LOADING)
209+ self.assertEqual(self.ui.ui.sync_status_button.text(), PLEASE_WAIT)
210+ actual_icon = self.ui.ui.sync_status_icon.pixmap()
211+ expected_icon = gui.pixmap_from_name('sync_status_loading')
212+ self.assertEqualPixmaps(expected_icon, actual_icon)
213+ self.assertTrue(
214+ self.ui.ui.sync_status_button.properties.get('unpolish', True))
215+ self.assertTrue(
216+ self.ui.ui.sync_status_button.properties.get('polish', True))

Subscribers

People subscribed via source and target branches