Merge lp:~diegosarmentero/ubuntu-sso-client/overlay-improves into lp:ubuntu-sso-client

Proposed by Diego Sarmentero
Status: Merged
Approved by: Natalia Bidart
Approved revision: 895
Merged at revision: 890
Proposed branch: lp:~diegosarmentero/ubuntu-sso-client/overlay-improves
Merge into: lp:ubuntu-sso-client
Diff against target: 925 lines (+161/-172)
16 files modified
data/qt/stylesheet.qss (+7/-29)
ubuntu_sso/qt/current_user_sign_in_page.py (+3/-13)
ubuntu_sso/qt/email_verification_page.py (+0/-8)
ubuntu_sso/qt/forgotten_password_page.py (+3/-12)
ubuntu_sso/qt/network_detection_page.py (+0/-2)
ubuntu_sso/qt/reset_password_page.py (+3/-16)
ubuntu_sso/qt/setup_account_page.py (+4/-11)
ubuntu_sso/qt/sso_wizard_page.py (+13/-13)
ubuntu_sso/qt/tests/__init__.py (+39/-11)
ubuntu_sso/qt/tests/test_current_user_sign_in_page.py (+10/-15)
ubuntu_sso/qt/tests/test_email_verification.py (+0/-9)
ubuntu_sso/qt/tests/test_forgotten_password.py (+8/-14)
ubuntu_sso/qt/tests/test_network_detection.py (+0/-8)
ubuntu_sso/qt/tests/test_setup_account.py (+15/-9)
ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py (+42/-2)
ubuntu_sso/qt/ubuntu_sso_wizard.py (+14/-0)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntu-sso-client/overlay-improves
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Brian Curtin (community) Approve
Review via email: mp+94828@code.launchpad.net

Commit message

- Fixed: The header in the pages is above the overlay (LP: #934523).

To post a comment you must log in.
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Looks reasonable to me.

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

Thanks for working on this!

I'm may be missing something, but from my POV the overlay should be in each page, since we want the widget to "block" itself while processing a request, so if it's embed in some other parent widget, we don't need to add an overlay as well.

Can we talk about this branch, so perhaps you can explain to me the goal of it?

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

Forgot to vote.

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

> Thanks for working on this!
>
> I'm may be missing something, but from my POV the overlay should be in each
> page, since we want the widget to "block" itself while processing a request,
> so if it's embed in some other parent widget, we don't need to add an overlay
> as well.
>
> Can we talk about this branch, so perhaps you can explain to me the goal of
> it?

Hi, i think this is a better approach because what we are actually doing right now is blocking the wizard, also we are having in this moment a lot of overlays that do the same thing, but with this branch we'll have only one, that is going to be triggered depending on each page need.
This change also allows to have the pages embedded in some other parent widget as you mention, but when this pages needs to be block because they are processing some operation, they will notify the parent of that situation, and the parent can block it in the best way, using the same overlay or some other visual feedback that suit better this other application.

892. By Diego Sarmentero

Improving button style handling

893. By Diego Sarmentero

Some minor fixes.

894. By Diego Sarmentero

Fix: The wizard doesn't close the window on finish

895. By Diego Sarmentero

removing setFocus

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

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/stylesheet.qss'
2--- data/qt/stylesheet.qss 2012-02-23 20:16:46 +0000
3+++ data/qt/stylesheet.qss 2012-03-01 13:37:18 +0000
4@@ -28,79 +28,57 @@
5 padding-left: 20px;
6 padding-right: 20px;
7 border-width: 1px;
8- height: 14px;
9 }
10
11-QPushButton[default="true"] {
12+QPushButton:default:enabled {
13 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
14 stop: 0 #fe9e84,stop: 1.0 #dd4814);
15 color: white;
16 border-color: #999999;
17 }
18
19-QPushButton:hover[default="true"] {
20+QPushButton:hover:default:enabled {
21 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
22 stop: 0 #ffb19c,stop: 1.0 #dd4814);
23 color: white;
24 border-color: #999999;
25 }
26
27-QPushButton:pressed[default="true"] {
28+QPushButton:pressed:default:enabled {
29 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
30 stop: 0 #b93f14,stop: 1.0 #dd4814);
31 color: white;
32 border-color: #999999;
33 }
34
35-QPushButton[default="false"] {
36+QPushButton:enabled {
37 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
38 stop: 0 #ffffff,stop: 1.0 #e6e6e6);
39 color: #333333;
40 border-color: #999999;
41 }
42
43-QPushButton:hover[default="false"] {
44+QPushButton:hover:enabled {
45 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
46 stop: 0 #ffffff,stop: 1.0 #ededed);
47 color: #333333;
48 border-color: #999999;
49 }
50
51-QPushButton:pressed[default="false"] {
52+QPushButton:pressed:enabled {
53 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
54 stop: 0 #d9d9d9,stop: 1.0 #fefefe);
55 color: #333333;
56 border-color: #999999;
57 }
58
59-QPushButton[DisabledState="true"] {
60+QPushButton:disabled {
61 background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
62 stop: 0 #eaeaea, stop: 1.0 #cacaca);
63 color: #595959;
64 border-color: #939389;
65 }
66
67-QPushButton[DisabledState="false"] {
68- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
69- stop: 0 #fe9e84,stop: 1.0 #dd4814);
70- color: white;
71- border-color: #999999;
72-}
73-
74-QPushButton:hover[DisabledState="false"] {
75- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
76- stop: 0 #ffb19c,stop: 1.0 #dd4814);
77- color: white;
78- border-color: #999999;
79-}
80-
81-QPushButton:pressed[DisabledState="false"] {
82- background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
83- stop: 0 #b93f14,stop: 1.0 #dd4814);
84- color: white;
85- border-color: #999999;
86-}
87-
88 QFrame#frm_box {
89 background: #ffffff;
90 border-radius: 5px;
91
92=== modified file 'ubuntu_sso/qt/current_user_sign_in_page.py'
93--- ubuntu_sso/qt/current_user_sign_in_page.py 2012-02-23 21:17:37 +0000
94+++ ubuntu_sso/qt/current_user_sign_in_page.py 2012-03-01 13:37:18 +0000
95@@ -88,12 +88,6 @@
96 # Set sign_in_button as default when the page is shown.
97 self.ui.sign_in_button.setDefault(True)
98 self.ui.sign_in_button.setEnabled(False)
99- self.ui.sign_in_button.setProperty("DisabledState",
100- not self.ui.sign_in_button.isEnabled())
101- self.ui.sign_in_button.style().unpolish(
102- self.ui.sign_in_button)
103- self.ui.sign_in_button.style().polish(
104- self.ui.sign_in_button)
105
106 def cleanupPage(self):
107 """Reset the wizard buttons."""
108@@ -126,10 +120,6 @@
109 if not correct_mail or not password:
110 valid = False
111 self.ui.sign_in_button.setEnabled(valid)
112- self.ui.sign_in_button.setProperty("DisabledState",
113- not self.ui.sign_in_button.isEnabled())
114- self.ui.sign_in_button.style().unpolish(self.ui.sign_in_button)
115- self.ui.sign_in_button.style().polish(self.ui.sign_in_button)
116
117 def login(self):
118 """Perform the login using the self.backend."""
119@@ -144,7 +134,7 @@
120 else:
121 f = self.backend.login
122
123- self.overlay.show()
124+ self.show_overlay()
125 error_handler = partial(self._handle_error, f, self.on_login_error)
126 f(*args, reply_handler=NO_OP, error_handler=error_handler)
127
128@@ -153,14 +143,14 @@
129 # let the user know
130 logger.error('Got error when login %s, error: %s',
131 self.app_name, error)
132- self.overlay.hide()
133+ self.hide_overlay()
134 self.message_box.critical(self, self.app_name,
135 build_general_error_message(error))
136
137 def on_logged_in(self, app_name, result):
138 """We managed to log in."""
139 logger.info('Logged in for %s', app_name)
140- self.overlay.hide()
141+ self.hide_overlay()
142 email = unicode(self.ui.email_edit.text())
143 self.userLoggedIn.emit(app_name, email)
144 logger.debug('Wizard.loginSuccess emitted.')
145
146=== modified file 'ubuntu_sso/qt/email_verification_page.py'
147--- ubuntu_sso/qt/email_verification_page.py 2012-02-23 19:49:02 +0000
148+++ ubuntu_sso/qt/email_verification_page.py 2012-03-01 13:37:18 +0000
149@@ -81,10 +81,6 @@
150 code = self.verification_code.strip()
151 enabled = len(code) > 0
152 self.next_button.setEnabled(enabled)
153- self.next_button.setProperty('DisabledState',
154- not self.next_button.isEnabled())
155- self.next_button.style().unpolish(self.next_button)
156- self.next_button.style().polish(self.next_button)
157
158 def _set_translated_strings(self):
159 """Set the different titles."""
160@@ -139,8 +135,4 @@
161 """Called to prepare the page just before it is shown."""
162 self.next_button.setDefault(True)
163 self.next_button.setEnabled(False)
164- self.next_button.setProperty('DisabledState',
165- not self.next_button.isEnabled())
166- self.next_button.style().unpolish(self.next_button)
167- self.next_button.style().polish(self.next_button)
168 #pylint: enable=C0103
169
170=== modified file 'ubuntu_sso/qt/forgotten_password_page.py'
171--- ubuntu_sso/qt/forgotten_password_page.py 2012-02-23 19:49:02 +0000
172+++ ubuntu_sso/qt/forgotten_password_page.py 2012-03-01 13:37:18 +0000
173@@ -102,11 +102,6 @@
174 self.send_button.setDefault(True)
175 enabled = not self.ui.email_line_edit.text().isEmpty()
176 self.send_button.setEnabled(enabled)
177- # The style from this property come from the Wizard
178- self.send_button.setProperty("DisabledState",
179- not self.send_button.isEnabled())
180- self.send_button.style().unpolish(self.send_button)
181- self.send_button.style().polish(self.send_button)
182 #pylint: enable=C0103
183
184 def _register_fields(self):
185@@ -149,17 +144,13 @@
186 error_handler = partial(self._handle_error, f,
187 self.on_password_reset_error)
188
189- self.overlay.show()
190+ self.show_overlay()
191 f(*args, reply_handler=NO_OP, error_handler=error_handler)
192
193 def _validate(self):
194 """Validate that we have an email."""
195 email = unicode(self.email_address_line_edit.text())
196 self.send_button.setEnabled(is_correct_email(email))
197- self.send_button.setProperty("DisabledState",
198- not self.send_button.isEnabled())
199- self.send_button.style().unpolish(self.send_button)
200- self.send_button.style().polish(self.send_button)
201
202 def on_try_again(self):
203 """Set back the widget to the initial state."""
204@@ -169,13 +160,13 @@
205 def on_password_reset_token_sent(self, app_name, result):
206 """Action taken when we managed to get the password reset done."""
207 # ignore the result and move to the reset page
208- self.overlay.hide()
209+ self.hide_overlay()
210 self.passwordResetTokenSent.emit()
211
212 def on_password_reset_error(self, app_name, error):
213 """Action taken when there was an error requesting the reset."""
214 # set the error message
215- self.overlay.hide()
216+ self.hide_overlay()
217 msg = REQUEST_PASSWORD_TOKEN_TECH_ERROR
218 if error['errtype'] == 'ResetPasswordTokenError':
219 # the account provided is wrong, lets tell the user to try
220
221=== modified file 'ubuntu_sso/qt/network_detection_page.py'
222--- ubuntu_sso/qt/network_detection_page.py 2012-02-23 21:17:37 +0000
223+++ ubuntu_sso/qt/network_detection_page.py 2012-03-01 13:37:18 +0000
224@@ -68,8 +68,6 @@
225 {'app_name': self.app_name})
226 self.btn_try_again = self.wizard().button(QtGui.QWizard.CustomButton1)
227 self.btn_try_again.setDefault(True)
228- self.btn_try_again.style().unpolish(self.btn_try_again)
229- self.btn_try_again.style().polish(self.btn_try_again)
230 self.wizard().customButtonClicked.connect(self.try_again)
231
232 # pylint: enable=C0103
233
234=== modified file 'ubuntu_sso/qt/reset_password_page.py'
235--- ubuntu_sso/qt/reset_password_page.py 2012-02-23 19:49:02 +0000
236+++ ubuntu_sso/qt/reset_password_page.py 2012-03-01 13:37:18 +0000
237@@ -84,13 +84,6 @@
238
239 self.ui.reset_password_button.setDefault(True)
240 self.ui.reset_password_button.setEnabled(False)
241- # The style from this property come from the Wizard
242- self.ui.reset_password_button.setProperty("DisabledState",
243- not self.ui.reset_password_button.isEnabled())
244- self.ui.reset_password_button.style().unpolish(
245- self.ui.reset_password_button)
246- self.ui.reset_password_button.style().polish(
247- self.ui.reset_password_button)
248
249 def showEvent(self, event):
250 """Connect focusChanged signal from the application."""
251@@ -150,12 +143,6 @@
252 elif not code:
253 enabled = False
254 self.ui.reset_password_button.setEnabled(enabled)
255- self.ui.reset_password_button.setProperty("DisabledState",
256- not self.ui.reset_password_button.isEnabled())
257- self.ui.reset_password_button.style().unpolish(
258- self.ui.reset_password_button)
259- self.ui.reset_password_button.style().polish(
260- self.ui.reset_password_button)
261
262 def _add_line_edits_validations(self):
263 """Add the validations to be use by the line edits."""
264@@ -171,7 +158,7 @@
265
266 def on_password_changed(self, app_name, result):
267 """Let user know that the password was changed."""
268- self.overlay.hide()
269+ self.hide_overlay()
270 email = unicode(self.wizard().forgotten.ui.email_line_edit.text())
271 self.passwordChanged.emit(email)
272
273@@ -179,7 +166,7 @@
274 """Let the user know that there was an error."""
275 logger.error('Got error changing password for %s, error: %s',
276 self.app_name, error)
277- self.overlay.hide()
278+ self.hide_overlay()
279 self.message_box.critical(self, self.app_name,
280 build_general_error_message(error))
281
282@@ -194,7 +181,7 @@
283 f = self.backend.set_new_password
284 error_handler = partial(self._handle_error, f,
285 self.on_password_change_error)
286- self.overlay.show()
287+ self.show_overlay()
288 f(*args, reply_handler=NO_OP, error_handler=error_handler)
289
290 def is_correct_password_confirmation(self, password):
291
292=== modified file 'ubuntu_sso/qt/setup_account_page.py'
293--- ubuntu_sso/qt/setup_account_page.py 2012-02-24 15:52:33 +0000
294+++ ubuntu_sso/qt/setup_account_page.py 2012-03-01 13:37:18 +0000
295@@ -135,7 +135,7 @@
296 pass
297 self.setButtonText(QtGui.QWizard.CustomButton3, SET_UP_ACCOUNT_BUTTON)
298 self.set_up_button = self.wizard().button(QtGui.QWizard.CustomButton3)
299- self.set_up_button.clicked.connect(self.overlay.show)
300+ self.set_up_button.clicked.connect(self.show_overlay)
301 self.set_up_button.clicked.connect(self.set_next_validation)
302 self.set_up_button.setEnabled(False)
303
304@@ -277,9 +277,6 @@
305 email == confirm_email and len(name) > 0
306
307 self.set_up_button.setEnabled(enabled)
308- self.set_up_button.setProperty("DisabledState", not enabled)
309- self.set_up_button.style().unpolish(self.set_up_button)
310- self.set_up_button.style().polish(self.set_up_button)
311
312 def _refresh_captcha(self):
313 """Refresh the captcha image shown in the ui."""
314@@ -489,16 +486,12 @@
315 if self.set_up_button is not None:
316 self.set_up_button.setVisible(True)
317 self.set_up_button.setDefault(True)
318- if not self.set_up_button.isEnabled():
319- self.set_up_button.setProperty("DisabledState", True)
320- self.set_up_button.style().unpolish(self.set_up_button)
321- self.set_up_button.style().polish(self.set_up_button)
322 self.connect(QtGui.QApplication.instance(),
323 QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"),
324 self.focus_changed)
325 super(SetupAccountPage, self).showEvent(event)
326 if not self.captcha_received:
327- self.overlay.show()
328+ self.show_overlay()
329
330 def hideEvent(self, event):
331 """Disconnect the focusChanged signal when the page change."""
332@@ -517,12 +510,12 @@
333 def on_captcha_refreshing(self):
334 """Show overlay when captcha is refreshing."""
335 if self.isVisible():
336- self.overlay.show()
337+ self.show_overlay()
338 self.captcha_received = False
339
340 def on_captcha_refresh_complete(self):
341 """Hide overlay when captcha finished refreshing."""
342- self.overlay.hide()
343+ self.hide_overlay()
344 self.captcha_received = True
345
346 def get_captcha_image(self):
347
348=== modified file 'ubuntu_sso/qt/sso_wizard_page.py'
349--- ubuntu_sso/qt/sso_wizard_page.py 2012-02-24 15:52:33 +0000
350+++ ubuntu_sso/qt/sso_wizard_page.py 2012-03-01 13:37:18 +0000
351@@ -18,8 +18,7 @@
352 from functools import wraps
353
354 # pylint: disable=F0401,E0611
355-
356-from PyQt4.QtCore import Qt
357+from PyQt4.QtCore import Qt, pyqtSignal
358 from PyQt4.QtGui import (
359 QApplication,
360 QCursor,
361@@ -37,7 +36,6 @@
362 from ubuntu_sso import main
363 from ubuntu_sso.logger import setup_logging
364 from ubuntu_sso.qt import PREFERED_UI_SIZE
365-from ubuntu_sso.qt.loadingoverlay import LoadingOverlay
366 from ubuntu_sso.utils.ui import GENERIC_BACKEND_ERROR
367
368
369@@ -94,6 +92,8 @@
370
371 ui_class = None
372 _signals = {} # override in children
373+ processingStarted = pyqtSignal()
374+ processingFinished = pyqtSignal()
375
376 def __init__(self, app_name, **kwargs):
377 """Create a new instance."""
378@@ -106,9 +106,6 @@
379 self.ui = self.ui_class()
380 self.ui.setupUi(self)
381
382- self.overlay = LoadingOverlay(self)
383- self.overlay.hide()
384-
385 # store common useful data provided by the app
386 self.app_name = app_name
387 self.ping_url = kwargs.get('ping_url', '')
388@@ -127,6 +124,16 @@
389
390 self.setup_page()
391
392+ def show_overlay(self):
393+ """Emit the signal to notify the upper container that is loading."""
394+ self.setEnabled(False)
395+ self.processingStarted.emit()
396+
397+ def hide_overlay(self):
398+ """Emit the signal to notify the upper container that ends loading."""
399+ self.setEnabled(True)
400+ self.processingFinished.emit()
401+
402 @defer.inlineCallbacks
403 def setup_page(self):
404 """Setup the widget components."""
405@@ -138,12 +145,6 @@
406 self._connect_ui()
407
408 # pylint: disable=C0103
409-
410- def resizeEvent(self, event):
411- """Resize the overlay to fit all the widget."""
412- QWizardPage.resizeEvent(self, event)
413- self.overlay.resize(event.size())
414-
415 def setTitle(self, title=''):
416 """Set the Wizard Page Title."""
417 self.header.set_title(title)
418@@ -151,7 +152,6 @@
419 def setSubTitle(self, subtitle=''):
420 """Set the Wizard Page Subtitle."""
421 self.header.set_subtitle(subtitle)
422-
423 # pylint: enable=C0103
424
425 def _filter_by_app_name(self, f):
426
427=== modified file 'ubuntu_sso/qt/tests/__init__.py'
428--- ubuntu_sso/qt/tests/__init__.py 2012-02-23 19:49:02 +0000
429+++ ubuntu_sso/qt/tests/__init__.py 2012-03-01 13:37:18 +0000
430@@ -21,7 +21,6 @@
431 from twisted.trial.unittest import TestCase
432
433 from ubuntu_sso import main, NO_OP
434-from ubuntu_sso.qt import sso_wizard_page
435 from ubuntu_sso.tests import (
436 APP_NAME,
437 HELP_TEXT,
438@@ -195,6 +194,18 @@
439 self.target(*args)
440
441
442+class FakeOverlaySignal(FakeSignal):
443+
444+ """Fake Signal for show and hide overlay."""
445+
446+ def __init__(self, target):
447+ super(FakeOverlaySignal, self).__init__()
448+ self.target = target
449+
450+ def connect(self, target):
451+ """We ignore the target and just call the function from the init."""
452+
453+
454 class FakeWizardPage(object):
455
456 """A fake wizard page."""
457@@ -385,14 +396,6 @@
458 """Fake button style."""
459 return self
460
461- def polish(self, button):
462- """Fake polish."""
463- self.data['polish'] = button
464-
465- def unpolish(self, button):
466- """Fake unpolish."""
467- self.data['unpolish'] = button
468-
469 def next(self):
470 """Fake next for wizard."""
471 self.data['next'] = True
472@@ -416,8 +419,6 @@
473 self.patch(main, 'get_sso_client',
474 lambda *a: defer.succeed(backend))
475
476- self.patch(sso_wizard_page, 'LoadingOverlay', FakeOverlay)
477-
478 self.app_name = APP_NAME
479 self.ping_url = PING_URL
480 self.signals_results = []
481@@ -498,3 +499,30 @@
482
483 expected = ['_setup_signals', '_set_translated_strings', '_connect_ui']
484 self.assertEqual(expected, called)
485+
486+
487+class BaseTestCasePage(BaseTestCase):
488+
489+ """BaseTestCase with some specialization for the Wizard Pages."""
490+
491+ @defer.inlineCallbacks
492+ def setUp(self):
493+ yield super(BaseTestCasePage, self).setUp()
494+ self._overlay_show_counter = 0
495+ self._overlay_hide_counter = 0
496+
497+ if self.ui is not None:
498+ fake_show_overlay_signal = FakeOverlaySignal(
499+ self._show_overlay_slot)
500+ fake_hide_overlay_signal = FakeOverlaySignal(
501+ self._hide_overlay_slot)
502+ self.patch(self.ui, "processingStarted", fake_show_overlay_signal)
503+ self.patch(self.ui, "processingFinished", fake_hide_overlay_signal)
504+
505+ def _show_overlay_slot(self):
506+ """Fake show overlay slot."""
507+ self._overlay_show_counter += 1
508+
509+ def _hide_overlay_slot(self):
510+ """Fake hide overlay slot."""
511+ self._overlay_hide_counter += 1
512
513=== modified file 'ubuntu_sso/qt/tests/test_current_user_sign_in_page.py'
514--- ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-02-23 19:49:02 +0000
515+++ ubuntu_sso/qt/tests/test_current_user_sign_in_page.py 2012-03-01 13:37:18 +0000
516@@ -20,14 +20,14 @@
517
518 from ubuntu_sso.qt import current_user_sign_in_page
519 from ubuntu_sso.qt.tests import (
520- BaseTestCase,
521+ BaseTestCasePage,
522 FakePageUiStyle,
523 FakeWizardButtonStyle,
524 )
525
526
527 # pylint: disable=W0212
528-class CurrentUserSignInTestCase(BaseTestCase):
529+class CurrentUserSignInTestCase(BaseTestCasePage):
530 """Test the SetupAccountPage code."""
531
532 ui_class = current_user_sign_in_page.CurrentUserSignInPage
533@@ -63,9 +63,6 @@
534 wizard.called)
535 self.assertTrue(button.properties['default'])
536 self.assertFalse(button.isEnabled())
537- self.assertTrue(button.property("DisabledState"))
538- self.assertTrue(button.properties['unpolish'])
539- self.assertTrue(button.properties['polish'])
540
541 def test_set_translated_strings(self):
542 """Test the translated string method."""
543@@ -102,9 +99,6 @@
544 self.ui.ui.password_edit.setText('123456')
545 self.ui._validate()
546 self.assertFalse(button.isEnabled())
547- self.assertTrue(button.property("DisabledState"))
548- self.assertTrue(button.properties['unpolish'])
549- self.assertTrue(button.properties['polish'])
550
551 def test_validate_valid(self):
552 """Test validate method."""
553@@ -114,9 +108,6 @@
554 self.ui.ui.password_edit.setText('123456')
555 self.ui._validate()
556 self.assertTrue(button.isEnabled())
557- self.assertFalse(button.property("DisabledState"))
558- self.assertTrue(button.properties['unpolish'])
559- self.assertTrue(button.properties['polish'])
560
561 def test_login_with_ping(self):
562 """Test the login method."""
563@@ -125,7 +116,8 @@
564 self.ui.ui.email_edit.setText(email)
565 self.ui.ui.password_edit.setText(password)
566 self.ui.login()
567- self.assertEqual(self.ui.overlay.show_counter, 1)
568+ self.assertEqual(self._overlay_show_counter, 1)
569+ self.assertFalse(self.ui.isEnabled())
570 self.assert_backend_called('login_and_ping',
571 self.app_name, email, password, self.ping_url)
572
573@@ -137,7 +129,8 @@
574 self.ui.ui.email_edit.setText(email)
575 self.ui.ui.password_edit.setText(password)
576 self.ui.login()
577- self.assertEqual(self.ui.overlay.show_counter, 1)
578+ self.assertEqual(self._overlay_show_counter, 1)
579+ self.assertFalse(self.ui.isEnabled())
580 self.assert_backend_called('login',
581 self.app_name, email, password)
582
583@@ -148,7 +141,8 @@
584 self.ui.app_name = app_name
585 error = {'errtype': 'UserNotValidated'}
586 self.ui.on_login_error(app_name, error)
587- self.assertEqual(self.ui.overlay.hide_counter, 2)
588+ self.assertEqual(self._overlay_hide_counter, 1)
589+ self.assertTrue(self.ui.isEnabled())
590 expected = ((self.ui, 'my_app', ''), {})
591 self.assertTrue(expected, self._called)
592
593@@ -164,7 +158,8 @@
594 self.signals_results.append((app, email))
595 self.ui.userLoggedIn.connect(slot)
596 self.ui.on_logged_in(app_name, None)
597- self.assertEqual(self.ui.overlay.hide_counter, 2)
598+ self.assertEqual(self._overlay_hide_counter, 1)
599+ self.assertTrue(self.ui.isEnabled())
600 self.assertIn((app_name, email), self.signals_results)
601
602 def test_on_forgotten_password(self):
603
604=== modified file 'ubuntu_sso/qt/tests/test_email_verification.py'
605--- ubuntu_sso/qt/tests/test_email_verification.py 2012-02-24 15:52:33 +0000
606+++ ubuntu_sso/qt/tests/test_email_verification.py 2012-03-01 13:37:18 +0000
607@@ -64,9 +64,6 @@
608 self.ui.ui.verification_code_edit.setText(' ')
609 self.ui.validate_form()
610 self.assertFalse(button.isEnabled())
611- self.assertTrue(button.property("DisabledState"))
612- self.assertTrue(button.properties['unpolish'])
613- self.assertTrue(button.properties['polish'])
614
615 def test_validate_form_valid(self):
616 """Test validate method."""
617@@ -75,9 +72,6 @@
618 self.ui.ui.verification_code_edit.setText('asd123')
619 self.ui.validate_form()
620 self.assertTrue(button.isEnabled())
621- self.assertFalse(button.property("DisabledState"))
622- self.assertTrue(button.properties['unpolish'])
623- self.assertTrue(button.properties['polish'])
624
625 def test_set_titles(self):
626 """Test the set_titles method."""
627@@ -102,9 +96,6 @@
628 self.ui.initializePage()
629 self.assertTrue(button.properties['default'])
630 self.assertFalse(button.isEnabled())
631- self.assertTrue(button.property("DisabledState"))
632- self.assertTrue(button.properties['unpolish'])
633- self.assertTrue(button.properties['polish'])
634
635 def test_on_email_validation_error(self):
636 """Test the validate_email method."""
637
638=== modified file 'ubuntu_sso/qt/tests/test_forgotten_password.py'
639--- ubuntu_sso/qt/tests/test_forgotten_password.py 2012-02-23 19:51:04 +0000
640+++ ubuntu_sso/qt/tests/test_forgotten_password.py 2012-03-01 13:37:18 +0000
641@@ -20,7 +20,7 @@
642
643 from ubuntu_sso.qt import forgotten_password_page
644 from ubuntu_sso.qt.tests import (
645- BaseTestCase,
646+ BaseTestCasePage,
647 FakePageUiStyle,
648 )
649
650@@ -28,7 +28,7 @@
651 # pylint: disable=W0212, E1101
652
653
654-class ForgottenPasswordTestCase(BaseTestCase):
655+class ForgottenPasswordTestCase(BaseTestCasePage):
656 """Test the SetupAccountPage code."""
657
658 ui_class = forgotten_password_page.ForgottenPasswordPage
659@@ -42,7 +42,8 @@
660 self.ui.app_name = app_name
661 self.ui.ui.email_line_edit.setText(email)
662 self.ui.request_new_password()
663- self.assertEqual(self.ui.overlay.show_counter, 1)
664+ self.assertEqual(self._overlay_show_counter, 1)
665+ self.assertFalse(self.ui.isEnabled())
666 self.assert_backend_called('request_password_reset_token',
667 app_name, email)
668
669@@ -108,9 +109,6 @@
670 self.ui.initializePage()
671 self.assertTrue(button.properties['default'])
672 self.assertTrue(button.isEnabled())
673- self.assertFalse(button.property("DisabledState"))
674- self.assertTrue(button.properties['unpolish'])
675- self.assertTrue(button.properties['polish'])
676
677 def test_set_translated_strings(self):
678 """Test the translated string method."""
679@@ -148,9 +146,6 @@
680 self.patch(self.ui.ui, "send_button", button)
681 self.ui._validate()
682 self.assertFalse(button.isEnabled())
683- self.assertTrue(button.property("DisabledState"))
684- self.assertTrue(button.properties['unpolish'])
685- self.assertTrue(button.properties['polish'])
686
687 def test_validate_valid(self):
688 """Test validate method."""
689@@ -159,9 +154,6 @@
690 self.patch(self.ui.ui, "send_button", button)
691 self.ui._validate()
692 self.assertTrue(button.isEnabled())
693- self.assertFalse(button.property("DisabledState"))
694- self.assertTrue(button.properties['unpolish'])
695- self.assertTrue(button.properties['polish'])
696
697 def test_on_try_again(self):
698 """Test on_try_again method."""
699@@ -179,7 +171,8 @@
700 self.signals_results.append(1)
701 self.ui.passwordResetTokenSent.connect(slot)
702 self.ui.on_password_reset_token_sent('app_name', {})
703- self.assertEqual(self.ui.overlay.hide_counter, 2)
704+ self.assertEqual(self._overlay_hide_counter, 1)
705+ self.assertTrue(self.ui.isEnabled())
706 self.assertTrue(1 in self.signals_results)
707
708 def test_on_password_reset_error(self):
709@@ -196,7 +189,8 @@
710 self.assertFalse(self.ui.email_widget.isVisible())
711 self.assertFalse(self.ui.forgotted_password_intro_label.isVisible())
712 self.assertTrue(self.ui.try_again_widget.isVisible())
713- self.assertEqual(self.ui.overlay.hide_counter, 2)
714+ self.assertEqual(self._overlay_hide_counter, 1)
715+ self.assertTrue(self.ui.isEnabled())
716
717 def test_on_password_reset_error_with_token_error(self):
718 """Test on_password_reset_error method."""
719
720=== modified file 'ubuntu_sso/qt/tests/test_network_detection.py'
721--- ubuntu_sso/qt/tests/test_network_detection.py 2012-02-23 21:17:37 +0000
722+++ ubuntu_sso/qt/tests/test_network_detection.py 2012-03-01 13:37:18 +0000
723@@ -49,14 +49,6 @@
724 """Test the Try Again button properties."""
725 self.ui.initializePage()
726 self.assertTrue(self.ui.btn_try_again.isDefault())
727- self.assertIn('polish', self.ui.btn_try_again.data)
728- self.assertIn('unpolish', self.ui.btn_try_again.data)
729- self.assertEqual(
730- self.ui.btn_try_again.data['polish'],
731- self.ui.btn_try_again)
732- self.assertEqual(
733- self.ui.btn_try_again.data['unpolish'],
734- self.ui.btn_try_again)
735
736 def test_try_again_with_connection(self):
737 """Check try again method with connection."""
738
739=== modified file 'ubuntu_sso/qt/tests/test_setup_account.py'
740--- ubuntu_sso/qt/tests/test_setup_account.py 2012-02-24 17:25:42 +0000
741+++ ubuntu_sso/qt/tests/test_setup_account.py 2012-03-01 13:37:18 +0000
742@@ -20,12 +20,12 @@
743
744 from ubuntu_sso.qt import common, setup_account_page
745 from ubuntu_sso.qt.tests import (
746- BaseTestCase,
747+ BaseTestCasePage,
748 HELP_TEXT,
749 )
750
751
752-class SetupAccountTestCase(BaseTestCase):
753+class SetupAccountTestCase(BaseTestCasePage):
754 """Test the SetupAccountPage code."""
755
756 ui_class = setup_account_page.SetupAccountPage
757@@ -257,7 +257,8 @@
758
759 self.ui.set_up_button.clicked.emit(False)
760
761- self.assertEqual(self.ui.overlay.show_counter, 1)
762+ self.assertEqual(self._overlay_show_counter, 1)
763+ self.assertFalse(self.ui.isEnabled())
764 self.assertEqual(self._called, ((False,), {}))
765
766 def test_set_error_message(self):
767@@ -376,18 +377,23 @@
768
769 def test_on_captcha_refreshing(self):
770 """Check the state of the overlay on captcha refreshing."""
771- self.assertEqual(self.ui.overlay.show_counter, 0)
772+ self.assertEqual(self._overlay_show_counter, 0)
773 self.ui.on_captcha_refreshing()
774- self.assertEqual(self.ui.overlay.show_counter, 0)
775+ self.assertEqual(self._overlay_show_counter, 0)
776+ self.assertTrue(self.ui.isEnabled())
777 self.ui.captcha_received = True
778 self.ui.show()
779 self.addCleanup(self.ui.hide)
780- self.assertEqual(self.ui.overlay.show_counter, 0)
781+ self.assertEqual(self._overlay_show_counter, 0)
782+ self.assertTrue(self.ui.isEnabled())
783 self.ui.on_captcha_refreshing()
784- self.assertEqual(self.ui.overlay.show_counter, 1)
785+ self.assertFalse(self.ui.isEnabled())
786+ self.assertEqual(self._overlay_show_counter, 1)
787
788 def test_on_captcha_refresh_complete(self):
789 """Check the state of the overlay on captcha refreshing complete."""
790- self.assertEqual(self.ui.overlay.hide_counter, 1)
791+ self.assertEqual(self._overlay_hide_counter, 0)
792+ self.assertTrue(self.ui.isEnabled())
793 self.ui.on_captcha_refresh_complete()
794- self.assertEqual(self.ui.overlay.hide_counter, 2)
795+ self.assertEqual(self._overlay_hide_counter, 1)
796+ self.assertTrue(self.ui.isEnabled())
797
798=== modified file 'ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py'
799--- ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-02-24 17:25:42 +0000
800+++ ubuntu_sso/qt/tests/test_ubuntu_sso_wizard.py 2012-03-01 13:37:18 +0000
801@@ -20,7 +20,10 @@
802 from twisted.internet import defer
803
804 from ubuntu_sso.qt import PREFERED_UI_SIZE, ubuntu_sso_wizard
805-from ubuntu_sso.qt.tests import BaseTestCase
806+from ubuntu_sso.qt.tests import (
807+ BaseTestCase,
808+ FakeOverlay,
809+)
810
811
812 # is ok to access private method/attrs in tests
813@@ -67,6 +70,22 @@
814 self.assertEqual(self._called,
815 ((ubuntu_sso_wizard.USER_SUCCESS,), {}))
816
817+ def test_on_wizard_finish_done_called(self):
818+ """Test that the wizard actually close the window on finish."""
819+ self.ui.wizard._move_to_success_page()
820+ finish_button = self.ui.wizard.button(QtGui.QWizard.FinishButton)
821+ self.patch(self.ui.wizard, 'done', self._set_called)
822+ finish_button.clicked.emit(True)
823+ self.assertEqual(self._called, ((1,), {}))
824+
825+ def test_on_wizard_finish_close_called_on_done(self):
826+ """Test that the wizard actually close the window on finish."""
827+ self.ui.wizard._move_to_success_page()
828+ finish_button = self.ui.wizard.button(QtGui.QWizard.FinishButton)
829+ self.patch(self.ui.wizard, 'closeEvent', self._set_called)
830+ finish_button.clicked.emit(True)
831+ self.assertEqual(self._called, ((None,), {}))
832+
833
834 class UbuntuSSOWizardTestCase(BaseTestCase):
835
836@@ -76,12 +95,17 @@
837 ui_signals = ('recoverableError', 'loginSuccess', 'registrationSuccess')
838 ui_wizard_class = None
839
840+ @defer.inlineCallbacks
841+ def setUp(self):
842+ self.patch(ubuntu_sso_wizard, 'LoadingOverlay', FakeOverlay)
843+ yield super(UbuntuSSOWizardTestCase, self).setUp()
844+
845 def test_window_size(self):
846 """check the window size."""
847 self.ui.show()
848 self.addCleanup(self.ui.hide)
849 size = self.ui.size()
850- self.assertEqual(size.height(), PREFERED_UI_SIZE['height'])
851+ self.assertTrue(size.height() >= PREFERED_UI_SIZE['height'])
852 self.assertEqual(size.width(), PREFERED_UI_SIZE['width'])
853
854 def test_move_to_success_page_state(self):
855@@ -94,3 +118,19 @@
856 (([QtGui.QWizard.Stretch, QtGui.QWizard.FinishButton],), {}))
857 self.assertTrue(self.ui.button(QtGui.QWizard.FinishButton).isEnabled())
858 self.assertEqual(self.ui.exit_code, ubuntu_sso_wizard.USER_SUCCESS)
859+
860+ def test_overlay_shows(self):
861+ """Test if the signals call the overlay.show properly."""
862+ for page in self.ui._pages:
863+ page.show_overlay()
864+
865+ self.assertEqual(self.ui.overlay.show_counter, len(self.ui._pages))
866+
867+ def test_overlay_hides(self):
868+ """Test if the signals call the overlay.show properly."""
869+ for page in self.ui._pages:
870+ page.hide_overlay()
871+
872+ # We do +1 because a hide action is executed on the wizard init.
873+ self.assertEqual(self.ui.overlay.hide_counter,
874+ len(self.ui._pages) + 1)
875
876=== modified file 'ubuntu_sso/qt/ubuntu_sso_wizard.py'
877--- ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-02-24 17:22:32 +0000
878+++ ubuntu_sso/qt/ubuntu_sso_wizard.py 2012-03-01 13:37:18 +0000
879@@ -35,6 +35,7 @@
880 from ubuntu_sso.qt.email_verification_page import EmailVerificationPage
881 from ubuntu_sso.qt.error_page import ErrorPage
882 from ubuntu_sso.qt.forgotten_password_page import ForgottenPasswordPage
883+from ubuntu_sso.qt.loadingoverlay import LoadingOverlay
884 from ubuntu_sso.qt.reset_password_page import ResetPasswordPage
885 from ubuntu_sso.qt.setup_account_page import SetupAccountPage
886 from ubuntu_sso.qt.success_page import SuccessPage
887@@ -56,6 +57,8 @@
888 app_name, kwargs)
889 parent = kwargs.pop('parent', None)
890 super(UbuntuSSOWizard, self).__init__(parent=parent)
891+ self.overlay = LoadingOverlay(self)
892+ self.overlay.hide()
893 self._next_id = -1
894 self.setOption(QWizard.HaveFinishButtonOnEarlyPages, True)
895 self.setOption(QWizard.NoBackButtonOnStartPage, True)
896@@ -130,6 +133,8 @@
897 def addPage(self, page):
898 """Add 'page' to this wizard."""
899 page_id = super(UbuntuSSOWizard, self).addPage(page)
900+ page.processingStarted.connect(self.overlay.show)
901+ page.processingFinished.connect(self.overlay.hide)
902 self._pages[page] = page_id
903
904 # pylint: enable=C0103
905@@ -220,6 +225,10 @@
906 """Return the id of the error page."""
907 return self._pages[self.error]
908
909+ def done(self, result):
910+ """Replace the done method from the wizard."""
911+ self.closeEvent(None)
912+
913 # pylint: disable=C0103
914
915 def closeEvent(self, event):
916@@ -229,6 +238,11 @@
917 else:
918 sys.exit(self.exit_code)
919
920+ def resizeEvent(self, event):
921+ """Resize the overlay to fit all the widget."""
922+ super(UbuntuSSOWizard, self).resizeEvent(event)
923+ self.overlay.resize(event.size())
924+
925 # pylint: enable=C0103
926
927

Subscribers

People subscribed via source and target branches