Merge lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872 into lp:ubuntuone-windows-installer

Proposed by Diego Sarmentero
Status: Merged
Approved by: Roberto Alsina
Approved revision: 38
Merged at revision: 33
Proposed branch: lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872
Merge into: lp:ubuntuone-windows-installer
Diff against target: 125 lines (+42/-11)
3 files modified
data/qt/ubuntuone.qss (+5/-0)
ubuntuone_installer/gui/qt/gui.py (+16/-6)
ubuntuone_installer/gui/qt/tests/test_gui.py (+21/-5)
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/bug-820872
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+71773@code.launchpad.net

Commit message

Show Form Errors at the bottom of each Page.

Description of the change

Show Form Errors at the bottom of each Page.

To post a comment you must log in.
36. By Diego Sarmentero

adding tests for adding and removing the form error message.

37. By Diego Sarmentero

reverting changes in qss and setup_account.ui

38. By Diego Sarmentero

adding missing style to qss

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

Looks great!

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/ubuntuone.qss'
2--- data/qt/ubuntuone.qss 2011-08-11 11:58:23 +0000
3+++ data/qt/ubuntuone.qss 2011-08-17 14:36:24 +0000
4@@ -169,3 +169,8 @@
5 background: #f7f6f5;
6 alternate-background-color: #efedec;
7 }
8+
9+QLabel#form_errors{
10+ font: bold 14px;
11+ color: #dd4814;
12+}
13
14=== modified file 'ubuntuone_installer/gui/qt/gui.py'
15--- ubuntuone_installer/gui/qt/gui.py 2011-08-15 21:41:54 +0000
16+++ ubuntuone_installer/gui/qt/gui.py 2011-08-17 14:36:24 +0000
17@@ -302,6 +302,11 @@
18 self.setWizardStyle(self.ModernStyle)
19 self.close_callback = close_callback
20
21+ # Label for Form Errors
22+ self.form_errors_label = QtGui.QLabel()
23+ self.form_errors_label.setObjectName("form_errors")
24+ self.form_errors_label.hide()
25+
26 self.setSideWidget(SideWidget())
27 self.overlay = LoadingOverlay(self)
28
29@@ -412,8 +417,7 @@
30 def creds_eb(self, exc):
31 """Handle credentials error."""
32 self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE
33- self.critical(self, CREDENTIALS_ERROR_TITLE,
34- CREDENTIALS_ERROR % exc.value)
35+ self.critical(CREDENTIALS_ERROR % exc.value)
36 logger.error(
37 'Error while getting the credentials: %r', exc.value)
38 self.close()
39@@ -426,14 +430,20 @@
40 else:
41 self.LICENSE_PAGE._next_id = self.local_folders_page_id
42
43- def critical(self, *args, **kwargs):
44- """Wrapper for QMessageBox.critical that hides the overlay."""
45+ def critical(self, message):
46+ """Show a message at the bottom of the page on form errors."""
47 self.overlay.hide()
48- QtGui.QMessageBox.critical(*args, **kwargs)
49+ self.form_errors_label.setText(message)
50+ self.form_errors_label.show()
51+ if self.currentPage():
52+ self.currentPage().layout().addWidget(self.form_errors_label)
53
54 def next(self):
55- """Show the next page to display."""
56+ """Show the next page to display and remove the form errors label."""
57 self.overlay.hide()
58+ self.form_errors_label.hide()
59+ self.currentPage().layout().removeWidget(self.form_errors_label)
60+ self.form_errors_label.setParent(None)
61 super(MainWindow, self).next()
62
63 def nextId(self):
64
65=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
66--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-15 21:41:54 +0000
67+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-17 14:36:24 +0000
68@@ -262,10 +262,9 @@
69 def test_critical(self):
70 """Show a critical popup, but first hide the overlay."""
71 self.assertEqual(self.ui.overlay.hide_counter, 1)
72- self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
73 self.ui.critical("WORRY!")
74 self.assertEqual(self.ui.overlay.hide_counter, 2)
75- self.assertEqual(self._called, (('WORRY!',), {}))
76+ self.assertEqual(self.ui.form_errors_label.text(), "WORRY!")
77
78 def test_forgotten_password_controller_error(self):
79 """When there is an error, it should hide the overlay."""
80@@ -311,11 +310,29 @@
81
82 def test_next_hides_overlay(self):
83 """Make sure next() hides the overlay."""
84+ self.ui.setStartId(self.ui.LICENSE_PAGE_ID)
85+ self.ui.restart()
86+ self.ui.show()
87 self.ui.next()
88 # This is 2 because we hide it once on __init__()
89 # and then again on next()
90 self.assertEqual(self.ui.overlay.hide_counter, 2)
91
92+ def test_insert_remove_critical_message(self):
93+ """Make sure critical message is added and next() removes it."""
94+ self.ui.setStartId(self.ui.LICENSE_PAGE_ID)
95+ self.ui.restart()
96+ self.ui.show()
97+ license_page = self.ui.page(self.ui.LICENSE_PAGE_ID)
98+ self.assertEqual(self.ui.form_errors_label.parentWidget(), None)
99+ self.ui.critical("test critical message")
100+ self.assertEqual(self.ui.form_errors_label.parentWidget(),
101+ license_page)
102+ self.assertEqual(self.ui.form_errors_label.text(),
103+ "test critical message")
104+ self.ui.next()
105+ self.assertEqual(self.ui.form_errors_label.parentWidget(), None)
106+
107 def test_done_calls_custom_close_callback(self):
108 """When closing the window, close_callback is called."""
109 gui.AreYouSure.result = 0
110@@ -938,7 +955,6 @@
111 self.patch(gui, "LocalFoldersPage", FakeLocalFoldersPage)
112 self.patch(qt.preferences, "PreferencesPanel", FakePreferencesPanel)
113 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
114- self.patch(gui.QtGui.QMessageBox, "critical", self._set_called)
115 self.patch(gui, "CredentialsManagementTool",
116 FakeFailingCredentialsManagementTool)
117 super(CredsFailureMainWindowTestCase, self).setUp()
118@@ -949,5 +965,5 @@
119
120 def test_critical(self):
121 """Credential errors should display a critical message."""
122- self.assertEqual(self._called, ((self.ui, 'Error getting credentials',
123- "Application will close.\n\nException()"), {}))
124+ self.assertEqual(self.ui.form_errors_label.text(),
125+ "Application will close.\n\nException()")

Subscribers

People subscribed via source and target branches