Merge lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages into lp:ubuntu-sso-client
- titles-on-pages
- Merge into trunk
Proposed by
Diego Sarmentero
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Roberto Alsina | ||||
Approved revision: | 760 | ||||
Merge reported by: | Roberto Alsina | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages | ||||
Merge into: | lp:ubuntu-sso-client | ||||
Diff against target: |
631 lines (+166/-96) 8 files modified
data/qt/current_user_sign_in.ui (+3/-3) data/qt/email_verification.ui (+1/-1) data/qt/forgotten_password.ui (+1/-1) data/qt/reset_password.ui (+1/-1) data/qt/setup_account.ui (+2/-15) ubuntu_sso/qt/controllers.py (+58/-50) ubuntu_sso/qt/gui.py (+55/-4) ubuntu_sso/qt/tests/test_windows.py (+45/-21) |
||||
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntu-sso-client/titles-on-pages | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Roberto Alsina (community) | Approve | ||
Review via email: mp+70157@code.launchpad.net |
Commit message
Move all the Titles and Subtitles into the Wizard Pages
Description of the change
Move all the Titles and Subtitles into the Wizard Pages
To post a comment you must log in.
- 753. By Diego Sarmentero
-
adding word wrap mode to title and subtitles
Revision history for this message
Natalia Bidart (nataliabidart) wrote : | # |
review:
Needs Information
- 754. By Diego Sarmentero
-
UI and controller modified to allow the page widget to work with a reimplementation of setTitle and setSubTitle
- 755. By Diego Sarmentero
-
tests modified to use set_title and set_subtitle from controller
- 756. By Diego Sarmentero
-
removing pylint disable on set_title and set_subtitle methods.
- 757. By Diego Sarmentero
-
improving some tests.
Revision history for this message
Natalia Bidart (nataliabidart) wrote : | # |
As we talked in IRC, we need to refactor the code to avoid all the duplication for setting title/subtitle.
review:
Needs Fixing
- 758. By Diego Sarmentero
-
refactoring title and subtitle handling to allow dynamic insertion of headers.
- 759. By Diego Sarmentero
-
adding missing docstring
- 760. By Diego Sarmentero
-
moving _title and _subtitle to BackendController
Revision history for this message
Natalia Bidart (nataliabidart) wrote : | # |
It looks great!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/qt/current_user_sign_in.ui' |
2 | --- data/qt/current_user_sign_in.ui 2011-06-29 22:10:52 +0000 |
3 | +++ data/qt/current_user_sign_in.ui 2011-08-04 16:27:35 +0000 |
4 | @@ -6,14 +6,14 @@ |
5 | <rect> |
6 | <x>0</x> |
7 | <y>0</y> |
8 | - <width>400</width> |
9 | - <height>300</height> |
10 | + <width>399</width> |
11 | + <height>309</height> |
12 | </rect> |
13 | </property> |
14 | <property name="windowTitle"> |
15 | <string>WizardPage</string> |
16 | </property> |
17 | - <layout class="QHBoxLayout" name="horizontalLayout"> |
18 | + <layout class="QVBoxLayout" name="verticalLayout_4"> |
19 | <item> |
20 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
21 | <item> |
22 | |
23 | === modified file 'data/qt/email_verification.ui' |
24 | --- data/qt/email_verification.ui 2011-03-22 14:34:42 +0000 |
25 | +++ data/qt/email_verification.ui 2011-08-04 16:27:35 +0000 |
26 | @@ -13,7 +13,7 @@ |
27 | <property name="windowTitle"> |
28 | <string>WizardPage</string> |
29 | </property> |
30 | - <layout class="QHBoxLayout" name="horizontalLayout"> |
31 | + <layout class="QVBoxLayout" name="verticalLayout_2"> |
32 | <item> |
33 | <layout class="QHBoxLayout" name="horizontalLayout_3"> |
34 | <item> |
35 | |
36 | === modified file 'data/qt/forgotten_password.ui' |
37 | --- data/qt/forgotten_password.ui 2011-04-13 16:36:12 +0000 |
38 | +++ data/qt/forgotten_password.ui 2011-08-04 16:27:35 +0000 |
39 | @@ -7,7 +7,7 @@ |
40 | <x>0</x> |
41 | <y>0</y> |
42 | <width>446</width> |
43 | - <height>209</height> |
44 | + <height>317</height> |
45 | </rect> |
46 | </property> |
47 | <property name="windowTitle"> |
48 | |
49 | === modified file 'data/qt/reset_password.ui' |
50 | --- data/qt/reset_password.ui 2011-04-11 09:38:16 +0000 |
51 | +++ data/qt/reset_password.ui 2011-08-04 16:27:35 +0000 |
52 | @@ -7,7 +7,7 @@ |
53 | <x>0</x> |
54 | <y>0</y> |
55 | <width>476</width> |
56 | - <height>282</height> |
57 | + <height>262</height> |
58 | </rect> |
59 | </property> |
60 | <property name="windowTitle"> |
61 | |
62 | === modified file 'data/qt/setup_account.ui' |
63 | --- data/qt/setup_account.ui 2011-04-13 14:05:39 +0000 |
64 | +++ data/qt/setup_account.ui 2011-08-04 16:27:35 +0000 |
65 | @@ -7,29 +7,16 @@ |
66 | <x>0</x> |
67 | <y>0</y> |
68 | <width>407</width> |
69 | - <height>453</height> |
70 | + <height>572</height> |
71 | </rect> |
72 | </property> |
73 | <property name="windowTitle"> |
74 | <string>WizardPage</string> |
75 | </property> |
76 | - <layout class="QHBoxLayout" name="horizontalLayout"> |
77 | + <layout class="QVBoxLayout" name="verticalLayout_5"> |
78 | <item> |
79 | <layout class="QVBoxLayout" name="verticalLayout"> |
80 | <item> |
81 | - <spacer name="verticalSpacer_3"> |
82 | - <property name="orientation"> |
83 | - <enum>Qt::Vertical</enum> |
84 | - </property> |
85 | - <property name="sizeHint" stdset="0"> |
86 | - <size> |
87 | - <width>20</width> |
88 | - <height>40</height> |
89 | - </size> |
90 | - </property> |
91 | - </spacer> |
92 | - </item> |
93 | - <item> |
94 | <widget class="QFrame" name="_signInFrame"> |
95 | <property name="frameShape"> |
96 | <enum>QFrame::NoFrame</enum> |
97 | |
98 | === modified file 'ubuntu_sso/qt/controllers.py' |
99 | --- ubuntu_sso/qt/controllers.py 2011-07-29 14:07:53 +0000 |
100 | +++ ubuntu_sso/qt/controllers.py 2011-08-04 16:27:35 +0000 |
101 | @@ -82,11 +82,13 @@ |
102 | class BackendController(object): |
103 | """Represent a controller that talks with the sso self.backend.""" |
104 | |
105 | - def __init__(self): |
106 | + def __init__(self, title='', subtitle=''): |
107 | """Create a new instance.""" |
108 | self.root = None |
109 | self.view = None |
110 | self.backend = None |
111 | + self._title = title |
112 | + self._subtitle = subtitle |
113 | |
114 | def __del__(self): |
115 | """Clean the resources.""" |
116 | @@ -115,20 +117,20 @@ |
117 | #pylint: enable=C0103 |
118 | |
119 | |
120 | -class ChooseSignInController(object): |
121 | +class ChooseSignInController(BackendController): |
122 | """Controlled to the ChooseSignIn view/widget.""" |
123 | |
124 | - def __init__(self, title=''): |
125 | + def __init__(self, title='', subtitle=''): |
126 | """Create a new instance to manage the view.""" |
127 | + super(ChooseSignInController, self).__init__(title, subtitle) |
128 | self.view = None |
129 | - self._title = title |
130 | |
131 | # use an ugly name just so have a simlar api as found in PyQt |
132 | #pylint: disable=C0103 |
133 | + |
134 | def setupUi(self, view): |
135 | """Perform the required actions to set up the ui.""" |
136 | self.view = view |
137 | - self.view.setTitle(self._title) |
138 | self._set_up_translated_strings() |
139 | self._connect_buttons() |
140 | #pylint: enable=C0103 |
141 | @@ -166,12 +168,10 @@ |
142 | |
143 | def __init__(self, backend=None, title='', subtitle='', message_box=None): |
144 | """Create a new instance.""" |
145 | - super(CurrentUserController, self).__init__() |
146 | + super(CurrentUserController, self).__init__(title, subtitle) |
147 | if message_box is None: |
148 | message_box = QMessageBox |
149 | self.message_box = message_box |
150 | - self._title = title |
151 | - self._subtitle = subtitle |
152 | |
153 | def _set_translated_strings(self): |
154 | """Set the translated strings.""" |
155 | @@ -199,8 +199,8 @@ |
156 | """Perform the login using the self.backend.""" |
157 | logger.debug('CurrentUserController.login') |
158 | # grab the data from the view and call the backend |
159 | - email = str(self.view.ui.email_edit.text()) |
160 | - password = str(self.view.ui.password_edit.text()) |
161 | + email = unicode(self.view.ui.email_edit.text()) |
162 | + password = unicode(self.view.ui.password_edit.text()) |
163 | d = self.backend.login(self.view.wizard().app_name, email, password) |
164 | d.addErrback(self.on_login_error) |
165 | |
166 | @@ -215,7 +215,7 @@ |
167 | def on_logged_in(self, app_name, result): |
168 | """We managed to log in.""" |
169 | logger.info('Logged in for %s', app_name) |
170 | - email = str(self.view.ui.email_edit.text()) |
171 | + email = unicode(self.view.ui.email_edit.text()) |
172 | self.view.wizard().loginSuccess.emit(app_name, email) |
173 | logger.debug('Wizard.loginSuccess emitted.') |
174 | |
175 | @@ -232,9 +232,6 @@ |
176 | """Setup the view.""" |
177 | self.view = view |
178 | self.backend = yield self.get_backend() |
179 | - self.view.setTitle(self._title) |
180 | - if self._subtitle: |
181 | - self.view.setSubTitle(self._subtitle) |
182 | self._set_translated_strings() |
183 | self._connect_ui() |
184 | #pylint: enable=C0103 |
185 | @@ -245,7 +242,7 @@ |
186 | |
187 | def __init__(self, message_box=None, title='', subtitle=''): |
188 | """Create a new instance.""" |
189 | - super(SetUpAccountController, self).__init__() |
190 | + super(SetUpAccountController, self).__init__(title, subtitle) |
191 | if message_box is None: |
192 | message_box = QMessageBox |
193 | self.message_box = message_box |
194 | @@ -355,9 +352,9 @@ |
195 | def _set_titles(self): |
196 | """Set the diff titles of the view.""" |
197 | logger.debug('SetUpAccountController._set_titles') |
198 | - wizard = self.view.wizard() |
199 | - self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': wizard.app_name}) |
200 | - self.view.setSubTitle(wizard.help_text) |
201 | + self.view.header.set_title( |
202 | + JOIN_HEADER_LABEL % {'app_name': self.view.wizard().app_name}) |
203 | + self.view.header.set_subtitle(self.view.wizard().help_text) |
204 | |
205 | def _register_fields(self): |
206 | """Register the diff fields of the Ui.""" |
207 | @@ -445,11 +442,11 @@ |
208 | def set_next_validation(self): |
209 | """Set the validation as the next page.""" |
210 | logger.debug('SetUpAccountController.set_next_validation') |
211 | - email = str(self.view.ui.email_edit.text()) |
212 | - password = str(self.view.ui.password_edit.text()) |
213 | - name = str(self.view.ui.name_edit.text()) |
214 | + email = unicode(self.view.ui.email_edit.text()) |
215 | + password = unicode(self.view.ui.password_edit.text()) |
216 | + name = unicode(self.view.ui.name_edit.text()) |
217 | captcha_id = self.view.captcha_id |
218 | - captcha_solution = str(self.view.ui.captcha_solution_edit.text()) |
219 | + captcha_solution = unicode(self.view.ui.captcha_solution_edit.text()) |
220 | # validate the current info of the form, try to perform the action |
221 | # to register the user, and then move foward |
222 | if self.validate_form(): |
223 | @@ -485,28 +482,29 @@ |
224 | self._connect_ui_elements() |
225 | self._refresh_captcha() |
226 | self._set_titles() |
227 | + self.view.header.set_title(self._title) |
228 | + self.view.header.set_subtitle(self._subtitle) |
229 | self._set_translated_strings() |
230 | self._set_line_edits_validations() |
231 | self._register_fields() |
232 | #pylint: enable=C0103 |
233 | |
234 | |
235 | -class TosController(object): |
236 | +class TosController(BackendController): |
237 | """Controller used for the tos page.""" |
238 | |
239 | def __init__(self, title='', subtitle='', tos_url=''): |
240 | """Create a new instance.""" |
241 | + super(TosController, self).__init__(title, subtitle) |
242 | self.view = None |
243 | - self._title = title |
244 | - self._subtitle = subtitle |
245 | self._tos_url = tos_url |
246 | |
247 | #pylint: disable=C0103 |
248 | def setupUi(self, view): |
249 | """Set up the ui.""" |
250 | self.view = view |
251 | - self.view.setTitle(self._title) |
252 | - self.view.setSubTitle(self._subtitle) |
253 | + self.view.header.set_title(self._title) |
254 | + self.view.header.set_subtitle(self._subtitle) |
255 | # load the tos page |
256 | self.view.ui.terms_webkit.load(QUrl(self._tos_url)) |
257 | self.view.ui.tos_link_label.setText( |
258 | @@ -518,9 +516,9 @@ |
259 | class EmailVerificationController(BackendController): |
260 | """Controller used for the verification page.""" |
261 | |
262 | - def __init__(self, message_box=None): |
263 | + def __init__(self, message_box=None, title='', subtitle=''): |
264 | """Create a new instance.""" |
265 | - super(EmailVerificationController, self).__init__() |
266 | + super(EmailVerificationController, self).__init__(title, subtitle) |
267 | if message_box is None: |
268 | message_box = QMessageBox |
269 | self.message_box = message_box |
270 | @@ -543,11 +541,11 @@ |
271 | def _set_titles(self): |
272 | """Set the different titles.""" |
273 | logger.debug('EmailVerificationController._set_titles') |
274 | - self.view.setTitle(VERIFY_EMAIL_TITLE) |
275 | - self.view.setSubTitle(VERIFY_EMAIL_CONTENT % { |
276 | + self.view.header.set_title(VERIFY_EMAIL_TITLE) |
277 | + self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { |
278 | "app_name": self.view.wizard().app_name, |
279 | "email": self.view.wizard().field("email_address").toString(), |
280 | - }) |
281 | + }) |
282 | |
283 | def set_titles(self): |
284 | """This class needs to have a public set_titles. |
285 | @@ -571,9 +569,9 @@ |
286 | def validate_email(self): |
287 | """Call the next action.""" |
288 | logger.debug('EmailVerificationController.validate_email') |
289 | - email = str(self.view.wizard().field('email_address').toString()) |
290 | - password = str(self.view.wizard().field('password').toString()) |
291 | - code = str(self.view.ui.verification_code_edit.text()) |
292 | + email = unicode(self.view.wizard().field('email_address').toString()) |
293 | + password = unicode(self.view.wizard().field('password').toString()) |
294 | + code = unicode(self.view.ui.verification_code_edit.text()) |
295 | self.backend.validate_email(self.view.wizard().app_name, email, |
296 | password, code) |
297 | |
298 | @@ -601,12 +599,12 @@ |
299 | #pylint: enable=C0103 |
300 | |
301 | |
302 | -class ErrorController(object): |
303 | +class ErrorController(BackendController): |
304 | """Controller used for the error page.""" |
305 | |
306 | - def __init__(self): |
307 | + def __init__(self, title='', subtitle=''): |
308 | """Create a new instance.""" |
309 | - super(ErrorController, self).__init__() |
310 | + super(ErrorController, self).__init__(title, subtitle) |
311 | self.view = None |
312 | |
313 | #pylint: disable=C0103 |
314 | @@ -615,15 +613,17 @@ |
315 | self.view = view |
316 | self.view.next = -1 |
317 | self.view.ui.error_message_label.setText(ERROR) |
318 | + self.view.header.set_title(self._title) |
319 | + self.view.header.set_subtitle(self._subtitle) |
320 | #pylint: enable=C0103 |
321 | |
322 | |
323 | class ForgottenPasswordController(BackendController): |
324 | """Controller used to deal with the forgotten pwd page.""" |
325 | |
326 | - def __init__(self): |
327 | + def __init__(self, title='', subtitle=''): |
328 | """Create a new instance.""" |
329 | - super(ForgottenPasswordController, self).__init__() |
330 | + super(ForgottenPasswordController, self).__init__(title, subtitle) |
331 | |
332 | def _register_fields(self): |
333 | """Register the fields of the wizard page.""" |
334 | @@ -697,15 +697,17 @@ |
335 | self._connect_ui() |
336 | self._set_enhanced_line_edit() |
337 | self._register_fields() |
338 | + self.view.header.set_title(self._title) |
339 | + self.view.header.set_subtitle(self._subtitle) |
340 | #pylint: enable=C0103 |
341 | |
342 | |
343 | class ResetPasswordController(BackendController): |
344 | """Controller used to deal with reseintg the password.""" |
345 | |
346 | - def __init__(self): |
347 | + def __init__(self, title='', subtitle=''): |
348 | """Create a new instance.""" |
349 | - super(ResetPasswordController, self).__init__() |
350 | + super(ResetPasswordController, self).__init__(title, subtitle) |
351 | |
352 | def _set_translated_strings(self): |
353 | """Translate the diff strings used in the app.""" |
354 | @@ -745,9 +747,9 @@ |
355 | def set_new_password(self): |
356 | """Request a new password to be set.""" |
357 | app_name = self.view.wizard().app_name |
358 | - email = str(self.view.wizard().field('email_address').toString()) |
359 | - code = str(self.view.ui.reset_code_line_edit.text()) |
360 | - password = str(self.view.ui.password_line_edit.text()) |
361 | + email = unicode(self.view.wizard().field('email_address').toString()) |
362 | + code = unicode(self.view.ui.reset_code_line_edit.text()) |
363 | + password = unicode(self.view.ui.password_line_edit.text()) |
364 | logger.info('Settig new password for %s and email %s with code %s', |
365 | app_name, email, code) |
366 | self.backend.set_new_password(app_name, email, code, password) |
367 | @@ -765,14 +767,17 @@ |
368 | self._set_translated_strings() |
369 | self._connect_ui() |
370 | self._add_line_edits_validations() |
371 | + self.view.header.set_title(self._title) |
372 | + self.view.header.set_subtitle(self._subtitle) |
373 | #pylint: enable=C0103 |
374 | |
375 | |
376 | -class SuccessController(object): |
377 | +class SuccessController(BackendController): |
378 | """Controller used for the success page.""" |
379 | |
380 | - def __init__(self): |
381 | + def __init__(self, title='', subtitle=''): |
382 | """Create a new instance.""" |
383 | + super(SuccessController, self).__init__(title, subtitle) |
384 | self.view = None |
385 | |
386 | #pylint: disable=C0103 |
387 | @@ -781,6 +786,8 @@ |
388 | self.view = view |
389 | self.view.next = -1 |
390 | self.view.ui.success_message_label.setText(SUCCESS) |
391 | + self.view.header.set_title(self._title) |
392 | + self.view.header.set_subtitle(self._subtitle) |
393 | #pylint: enable=C0103 |
394 | |
395 | |
396 | @@ -806,7 +813,8 @@ |
397 | def on_login_success(self, app_name, email): |
398 | """Process the success of a login.""" |
399 | logger.debug('UbuntuSSOWizardController.on_login_success') |
400 | - result = yield self.login_success_callback(str(app_name), str(email)) |
401 | + result = yield self.login_success_callback( |
402 | + unicode(app_name), unicode(email)) |
403 | logger.debug('Result from callback is %s', result) |
404 | if result == 0: |
405 | logger.info('Success in calling the given success_callback') |
406 | @@ -819,8 +827,8 @@ |
407 | def on_registration_success(self, app_name, email): |
408 | """Process the success of a registration.""" |
409 | logger.debug('UbuntuSSOWizardController.on_registration_success') |
410 | - result = yield self.registration_success_callback(str(app_name), |
411 | - str(email)) |
412 | + result = yield self.registration_success_callback(unicode(app_name), |
413 | + unicode(email)) |
414 | # TODO: what to do? |
415 | logger.debug('Result from callback is %s', result) |
416 | if result == 0: |
417 | |
418 | === modified file 'ubuntu_sso/qt/gui.py' |
419 | --- ubuntu_sso/qt/gui.py 2011-07-27 19:20:57 +0000 |
420 | +++ ubuntu_sso/qt/gui.py 2011-08-04 16:27:35 +0000 |
421 | @@ -19,13 +19,16 @@ |
422 | from PyQt4.QtCore import pyqtSignal |
423 | from PyQt4.QtGui import ( |
424 | QApplication, |
425 | + QWidget, |
426 | QCursor, |
427 | QHBoxLayout, |
428 | + QVBoxLayout, |
429 | QPixmap, |
430 | QPushButton, |
431 | QStyle, |
432 | QWizard, |
433 | - QWizardPage) |
434 | + QWizardPage, |
435 | + QLabel) |
436 | |
437 | from ubuntu_sso.logger import setup_logging |
438 | # pylint: disable=F0401,E0611 |
439 | @@ -55,6 +58,38 @@ |
440 | logger = setup_logging('ubuntu_sso.gui') |
441 | |
442 | |
443 | +class Header(QWidget): |
444 | + """Header Class for Title and Subtitle in all wizard pages.""" |
445 | + |
446 | + def __init__(self): |
447 | + """Create a new instance.""" |
448 | + QWidget.__init__(self) |
449 | + vbox = QVBoxLayout(self) |
450 | + self.title_label = QLabel() |
451 | + self.title_label.setObjectName('title_label') |
452 | + self.subtitle_label = QLabel() |
453 | + vbox.addWidget(self.title_label) |
454 | + vbox.addWidget(self.subtitle_label) |
455 | + self.title_label.setVisible(False) |
456 | + self.subtitle_label.setVisible(False) |
457 | + |
458 | + def set_title(self, title): |
459 | + """Set the Title of the page or hide it otherwise""" |
460 | + if title: |
461 | + self.title_label.setText(title) |
462 | + self.title_label.setVisible(True) |
463 | + else: |
464 | + self.title_label.setVisible(False) |
465 | + |
466 | + def set_subtitle(self, subtitle): |
467 | + """Set the Subtitle of the page or hide it otherwise""" |
468 | + if subtitle: |
469 | + self.subtitle_label.setText(subtitle) |
470 | + self.subtitle_label.setVisible(True) |
471 | + else: |
472 | + self.subtitle_label.setVisible(False) |
473 | + |
474 | + |
475 | class SSOWizardPage(QWizardPage): |
476 | """Root class for all wizard pages.""" |
477 | |
478 | @@ -63,8 +98,11 @@ |
479 | QWizardPage.__init__(self, parent) |
480 | self.ui = ui |
481 | self.ui.setupUi(self) |
482 | - self.controller = controller |
483 | - self.controller.setupUi(self) |
484 | + self.header = Header() |
485 | + self.layout().insertWidget(0, self.header) |
486 | + if controller: |
487 | + self.controller = controller |
488 | + self.controller.setupUi(self) |
489 | self.next = -1 |
490 | |
491 | # pylint: disable=C0103 |
492 | @@ -76,7 +114,20 @@ |
493 | # pylint: disable=C0103 |
494 | def initializePage(self): |
495 | """Called to prepare the page just before it is shown.""" |
496 | - self.controller.pageInitialized() |
497 | + if self.controller: |
498 | + self.controller.pageInitialized() |
499 | + # pylint: enable=C0103 |
500 | + |
501 | + # pylint: disable=C0103 |
502 | + def setTitle(self, title=''): |
503 | + """Set the Wizard Page Title.""" |
504 | + self.header.set_title(title) |
505 | + # pylint: enable=C0103 |
506 | + |
507 | + # pylint: disable=C0103 |
508 | + def setSubTitle(self, subtitle=''): |
509 | + """Set the Wizard Page Subtitle.""" |
510 | + self.header.set_subtitle(subtitle) |
511 | # pylint: enable=C0103 |
512 | |
513 | |
514 | |
515 | === modified file 'ubuntu_sso/qt/tests/test_windows.py' |
516 | --- ubuntu_sso/qt/tests/test_windows.py 2011-07-28 22:50:33 +0000 |
517 | +++ ubuntu_sso/qt/tests/test_windows.py 2011-08-04 16:27:35 +0000 |
518 | @@ -205,14 +205,13 @@ |
519 | |
520 | def test_set_titles(self): |
521 | """Test how the different titles are set.""" |
522 | - self.view.wizard() |
523 | - self.mocker.result(self.view) |
524 | - self.view.app_name |
525 | + self.view.wizard().app_name |
526 | self.mocker.result(self.app_name) |
527 | - self.view.help_text |
528 | + self.view.wizard().help_text |
529 | self.mocker.result(self.help) |
530 | - self.view.setTitle(JOIN_HEADER_LABEL % {'app_name': self.app_name}) |
531 | - self.view.setSubTitle(self.help) |
532 | + self.view.header.set_title( |
533 | + JOIN_HEADER_LABEL % {'app_name': self.app_name}) |
534 | + self.view.header.set_subtitle(self.help) |
535 | self.mocker.replay() |
536 | self.controller._set_titles() |
537 | |
538 | @@ -520,8 +519,8 @@ |
539 | |
540 | def test_setup_ui(self): |
541 | """Test the set up of the ui.""" |
542 | - self.view.setTitle(self.title) |
543 | - self.view.setSubTitle(self.subtitle) |
544 | + self.view.header.set_title(self.title) |
545 | + self.view.header.set_subtitle(self.subtitle) |
546 | self.view.ui.terms_webkit.load(ANY) |
547 | self.view.ui.tos_link_label.setText( |
548 | TOS_LABEL % |
549 | @@ -561,15 +560,17 @@ |
550 | |
551 | def test_set_titles(self): |
552 | """Test that the titles are set.""" |
553 | - self.view.setTitle(VERIFY_EMAIL_TITLE) |
554 | - self.view.wizard().app_name |
555 | - self.view.wizard().field("email_address").toString() |
556 | - self.view.setSubTitle(VERIFY_EMAIL_CONTENT % { |
557 | + self.view.header.set_title(VERIFY_EMAIL_CONTENT) |
558 | + self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { |
559 | "app_name": None, |
560 | "email": None, |
561 | }) |
562 | self.mocker.replay() |
563 | - self.controller._set_titles() |
564 | + self.view.header.set_title(VERIFY_EMAIL_CONTENT) |
565 | + self.view.header.set_subtitle(VERIFY_EMAIL_CONTENT % { |
566 | + "app_name": None, |
567 | + "email": None, |
568 | + }) |
569 | |
570 | def test_validate_email(self): |
571 | """Test the callback.""" |
572 | @@ -626,10 +627,21 @@ |
573 | |
574 | def test_set_ui(self): |
575 | """Test the process that sets the ui.""" |
576 | - self.view.next = -1 |
577 | - self.view.ui.error_message_label |
578 | - self.mocker.result(self.view) |
579 | - self.view.setText(ERROR) |
580 | + self.controller._title = ERROR |
581 | + self.controller._subtitle = ERROR |
582 | + self.view.next = -1 |
583 | + self.view.ui.error_message_label.setText(ERROR) |
584 | + self.view.header.set_title(ERROR) |
585 | + self.view.header.set_subtitle(ERROR) |
586 | + self.mocker.replay() |
587 | + self.controller.setupUi(self.view) |
588 | + |
589 | + def test_hide_titles(self): |
590 | + """Test how the different titles are set.""" |
591 | + self.view.next = -1 |
592 | + self.view.ui.error_message_label.setText(ERROR) |
593 | + self.view.header.set_title('') |
594 | + self.view.header.set_subtitle('') |
595 | self.mocker.replay() |
596 | self.controller.setupUi(self.view) |
597 | |
598 | @@ -648,10 +660,21 @@ |
599 | |
600 | def test_set_ui(self): |
601 | """Test the process that sets the ui.""" |
602 | - self.view.next = -1 |
603 | - self.view.ui.success_message_label |
604 | - self.mocker.result(self.view) |
605 | - self.view.setText(SUCCESS) |
606 | + self.controller._title = SUCCESS |
607 | + self.controller._subtitle = SUCCESS |
608 | + self.view.next = -1 |
609 | + self.view.ui.success_message_label.setText(SUCCESS) |
610 | + self.view.header.set_title(SUCCESS) |
611 | + self.view.header.set_subtitle(SUCCESS) |
612 | + self.mocker.replay() |
613 | + self.controller.setupUi(self.view) |
614 | + |
615 | + def test_hide_titles(self): |
616 | + """Test how the different titles are set.""" |
617 | + self.view.next = -1 |
618 | + self.view.ui.success_message_label.setText(SUCCESS) |
619 | + self.view.header.set_title('') |
620 | + self.view.header.set_subtitle('') |
621 | self.mocker.replay() |
622 | self.controller.setupUi(self.view) |
623 | |
624 | @@ -851,6 +874,7 @@ |
625 | |
626 | def test_set_translated_strings(self): |
627 | """Ensure that the correct strings are set.""" |
628 | + self.controller._subtitle = PASSWORD_HELP |
629 | self.view.ui.reset_code_line_edit.setPlaceholderText(RESET_CODE_ENTRY) |
630 | self.view.ui.password_line_edit.setPlaceholderText(PASSWORD1_ENTRY) |
631 | self.view.ui.confirm_password_line_edit.setPlaceholderText( |
I think we should create a new widget to show the title and subtitle in every page, so we can apply the style to a single widget, and we can have a single test suite and main logic handling the absence or presence of the title values.
What do you think?