Merge lp:~diegosarmentero/ubuntuone-windows-installer/setupaccount-form-behavior into lp:ubuntuone-windows-installer
- setupaccount-form-behavior
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 54 |
Merged at revision: | 34 |
Proposed branch: | lp:~diegosarmentero/ubuntuone-windows-installer/setupaccount-form-behavior |
Merge into: | lp:ubuntuone-windows-installer |
Diff against target: |
1184 lines (+609/-148) 4 files modified
data/qt/setup_account.ui (+289/-53) data/qt/ubuntuone.qss (+8/-3) ubuntuone_installer/gui/qt/setup_account.py (+83/-26) ubuntuone_installer/gui/qt/tests/test_gui.py (+229/-66) |
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/setupaccount-form-behavior |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
- 40. By Diego Sarmentero
-
adding more tests and fixing lint issues
- 41. By Diego Sarmentero
-
link branch to bug
- 42. By Diego Sarmentero
-
fixing some issues in setup_account.ui
- 43. By Diego Sarmentero
-
connecting signal on showEvent and disconnecting signal on hideEvent.
Avoid setup account resizing on form errors. - 44. By Diego Sarmentero
-
fixing some connections in setup_account.
adding more tests to: focus_changed - 45. By Diego Sarmentero
-
fixing some issues related to focus managment.
- 46. By Diego Sarmentero
-
setting password_assistance to visible = True if the user click on confirmation password
- 47. By Diego Sarmentero
-
tests improved.
- 48. By Diego Sarmentero
-
fixing some tests to use assertIn
- 49. By Diego Sarmentero
-
fixing test to user assertNotIn
- 50. By Diego Sarmentero
-
fixing docstrings
- 51. By Diego Sarmentero
-
removing password_
assistance_ in_focus to avoid code duplication.
fixing tests related to this method. - 52. By Diego Sarmentero
-
docstring fixed.
tests modified to be more clear. - 53. By Diego Sarmentero
-
adding missing docstrings to the new methods.
- 54. By Diego Sarmentero
-
adding missing docstrings.
fixing some lint issues.
Preview Diff
1 | === modified file 'data/qt/setup_account.ui' |
2 | --- data/qt/setup_account.ui 2011-08-17 14:22:25 +0000 |
3 | +++ data/qt/setup_account.ui 2011-08-22 14:08:26 +0000 |
4 | @@ -7,7 +7,7 @@ |
5 | <x>0</x> |
6 | <y>0</y> |
7 | <width>575</width> |
8 | - <height>521</height> |
9 | + <height>573</height> |
10 | </rect> |
11 | </property> |
12 | <property name="windowTitle"> |
13 | @@ -18,7 +18,7 @@ |
14 | <number>6</number> |
15 | </property> |
16 | <item> |
17 | - <layout class="QGridLayout" name="gridLayout" columnminimumwidth="300,250"> |
18 | + <layout class="QGridLayout" name="gridLayout" columnminimumwidth="310,250"> |
19 | <item row="0" column="0"> |
20 | <widget class="QLabel" name="password_info_label"> |
21 | <property name="sizePolicy"> |
22 | @@ -55,29 +55,37 @@ |
23 | </item> |
24 | <item> |
25 | <widget class="QLineEdit" name="name_edit"> |
26 | + <property name="sizePolicy"> |
27 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
28 | + <horstretch>0</horstretch> |
29 | + <verstretch>0</verstretch> |
30 | + </sizepolicy> |
31 | + </property> |
32 | + <property name="minimumSize"> |
33 | + <size> |
34 | + <width>300</width> |
35 | + <height>0</height> |
36 | + </size> |
37 | + </property> |
38 | + <property name="maximumSize"> |
39 | + <size> |
40 | + <width>300</width> |
41 | + <height>16777215</height> |
42 | + </size> |
43 | + </property> |
44 | <property name="font"> |
45 | <font> |
46 | <pointsize>11</pointsize> |
47 | </font> |
48 | </property> |
49 | + <property name="formError" stdset="0"> |
50 | + <bool>false</bool> |
51 | + </property> |
52 | </widget> |
53 | </item> |
54 | </layout> |
55 | </item> |
56 | - <item row="1" column="1"> |
57 | - <widget class="QLabel" name="name_assistance"> |
58 | - <property name="text"> |
59 | - <string>name_assistance</string> |
60 | - </property> |
61 | - <property name="alignment"> |
62 | - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
63 | - </property> |
64 | - <property name="indent"> |
65 | - <number>20</number> |
66 | - </property> |
67 | - </widget> |
68 | - </item> |
69 | - <item row="2" column="0"> |
70 | + <item row="3" column="0"> |
71 | <layout class="QVBoxLayout" name="verticalLayout"> |
72 | <property name="spacing"> |
73 | <number>3</number> |
74 | @@ -97,6 +105,24 @@ |
75 | </item> |
76 | <item> |
77 | <widget class="QLineEdit" name="email_edit"> |
78 | + <property name="sizePolicy"> |
79 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
80 | + <horstretch>0</horstretch> |
81 | + <verstretch>0</verstretch> |
82 | + </sizepolicy> |
83 | + </property> |
84 | + <property name="minimumSize"> |
85 | + <size> |
86 | + <width>300</width> |
87 | + <height>0</height> |
88 | + </size> |
89 | + </property> |
90 | + <property name="maximumSize"> |
91 | + <size> |
92 | + <width>300</width> |
93 | + <height>16777215</height> |
94 | + </size> |
95 | + </property> |
96 | <property name="font"> |
97 | <font> |
98 | <pointsize>11</pointsize> |
99 | @@ -105,21 +131,14 @@ |
100 | <property name="placeholderText"> |
101 | <string/> |
102 | </property> |
103 | + <property name="formError" stdset="0"> |
104 | + <bool>false</bool> |
105 | + </property> |
106 | </widget> |
107 | </item> |
108 | </layout> |
109 | </item> |
110 | - <item row="2" column="1"> |
111 | - <widget class="QLabel" name="email_assistance"> |
112 | - <property name="text"> |
113 | - <string>email_assistance</string> |
114 | - </property> |
115 | - <property name="indent"> |
116 | - <number>20</number> |
117 | - </property> |
118 | - </widget> |
119 | - </item> |
120 | - <item row="3" column="0"> |
121 | + <item row="4" column="0"> |
122 | <layout class="QVBoxLayout" name="verticalLayout"> |
123 | <property name="spacing"> |
124 | <number>3</number> |
125 | @@ -139,6 +158,24 @@ |
126 | </item> |
127 | <item> |
128 | <widget class="QLineEdit" name="confirm_email_edit"> |
129 | + <property name="sizePolicy"> |
130 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
131 | + <horstretch>0</horstretch> |
132 | + <verstretch>0</verstretch> |
133 | + </sizepolicy> |
134 | + </property> |
135 | + <property name="minimumSize"> |
136 | + <size> |
137 | + <width>300</width> |
138 | + <height>0</height> |
139 | + </size> |
140 | + </property> |
141 | + <property name="maximumSize"> |
142 | + <size> |
143 | + <width>300</width> |
144 | + <height>16777215</height> |
145 | + </size> |
146 | + </property> |
147 | <property name="font"> |
148 | <font> |
149 | <pointsize>11</pointsize> |
150 | @@ -147,21 +184,14 @@ |
151 | <property name="placeholderText"> |
152 | <string/> |
153 | </property> |
154 | + <property name="formError" stdset="0"> |
155 | + <bool>false</bool> |
156 | + </property> |
157 | </widget> |
158 | </item> |
159 | </layout> |
160 | </item> |
161 | - <item row="3" column="1"> |
162 | - <widget class="QLabel" name="confirm_email_assistance"> |
163 | - <property name="text"> |
164 | - <string>confirm_email_assistance</string> |
165 | - </property> |
166 | - <property name="indent"> |
167 | - <number>20</number> |
168 | - </property> |
169 | - </widget> |
170 | - </item> |
171 | - <item row="4" column="0"> |
172 | + <item row="6" column="0"> |
173 | <layout class="QVBoxLayout" name="verticalLayout"> |
174 | <property name="spacing"> |
175 | <number>3</number> |
176 | @@ -181,6 +211,24 @@ |
177 | </item> |
178 | <item> |
179 | <widget class="QLineEdit" name="password_edit"> |
180 | + <property name="sizePolicy"> |
181 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
182 | + <horstretch>0</horstretch> |
183 | + <verstretch>0</verstretch> |
184 | + </sizepolicy> |
185 | + </property> |
186 | + <property name="minimumSize"> |
187 | + <size> |
188 | + <width>300</width> |
189 | + <height>0</height> |
190 | + </size> |
191 | + </property> |
192 | + <property name="maximumSize"> |
193 | + <size> |
194 | + <width>300</width> |
195 | + <height>16777215</height> |
196 | + </size> |
197 | + </property> |
198 | <property name="font"> |
199 | <font> |
200 | <pointsize>11</pointsize> |
201 | @@ -198,11 +246,14 @@ |
202 | <property name="placeholderText"> |
203 | <string/> |
204 | </property> |
205 | + <property name="formError" stdset="0"> |
206 | + <bool>false</bool> |
207 | + </property> |
208 | </widget> |
209 | </item> |
210 | </layout> |
211 | </item> |
212 | - <item row="5" column="0"> |
213 | + <item row="7" column="0"> |
214 | <layout class="QVBoxLayout" name="verticalLayout"> |
215 | <property name="spacing"> |
216 | <number>3</number> |
217 | @@ -222,6 +273,24 @@ |
218 | </item> |
219 | <item> |
220 | <widget class="QLineEdit" name="confirm_password_edit"> |
221 | + <property name="sizePolicy"> |
222 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
223 | + <horstretch>0</horstretch> |
224 | + <verstretch>0</verstretch> |
225 | + </sizepolicy> |
226 | + </property> |
227 | + <property name="minimumSize"> |
228 | + <size> |
229 | + <width>300</width> |
230 | + <height>0</height> |
231 | + </size> |
232 | + </property> |
233 | + <property name="maximumSize"> |
234 | + <size> |
235 | + <width>300</width> |
236 | + <height>16777215</height> |
237 | + </size> |
238 | + </property> |
239 | <property name="font"> |
240 | <font> |
241 | <pointsize>11</pointsize> |
242 | @@ -233,21 +302,14 @@ |
243 | <property name="placeholderText"> |
244 | <string/> |
245 | </property> |
246 | + <property name="formError" stdset="0"> |
247 | + <bool>false</bool> |
248 | + </property> |
249 | </widget> |
250 | </item> |
251 | </layout> |
252 | </item> |
253 | - <item row="4" column="1" rowspan="2"> |
254 | - <widget class="QLabel" name="password_assistance"> |
255 | - <property name="text"> |
256 | - <string>password_assistance</string> |
257 | - </property> |
258 | - <property name="indent"> |
259 | - <number>20</number> |
260 | - </property> |
261 | - </widget> |
262 | - </item> |
263 | - <item row="6" column="0"> |
264 | + <item row="8" column="0"> |
265 | <layout class="QVBoxLayout" name="verticalLayout"> |
266 | <property name="spacing"> |
267 | <number>3</number> |
268 | @@ -255,7 +317,7 @@ |
269 | <item> |
270 | <widget class="QLabel" name="captcha_view"> |
271 | <property name="sizePolicy"> |
272 | - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
273 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
274 | <horstretch>0</horstretch> |
275 | <verstretch>0</verstretch> |
276 | </sizepolicy> |
277 | @@ -266,6 +328,12 @@ |
278 | <height>57</height> |
279 | </size> |
280 | </property> |
281 | + <property name="maximumSize"> |
282 | + <size> |
283 | + <width>300</width> |
284 | + <height>16777215</height> |
285 | + </size> |
286 | + </property> |
287 | <property name="styleSheet"> |
288 | <string notr="true">background-color: white</string> |
289 | </property> |
290 | @@ -279,6 +347,24 @@ |
291 | </item> |
292 | <item> |
293 | <widget class="QLineEdit" name="captcha_solution_edit"> |
294 | + <property name="sizePolicy"> |
295 | + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> |
296 | + <horstretch>0</horstretch> |
297 | + <verstretch>0</verstretch> |
298 | + </sizepolicy> |
299 | + </property> |
300 | + <property name="minimumSize"> |
301 | + <size> |
302 | + <width>300</width> |
303 | + <height>0</height> |
304 | + </size> |
305 | + </property> |
306 | + <property name="maximumSize"> |
307 | + <size> |
308 | + <width>300</width> |
309 | + <height>16777215</height> |
310 | + </size> |
311 | + </property> |
312 | <property name="font"> |
313 | <font> |
314 | <pointsize>11</pointsize> |
315 | @@ -296,18 +382,27 @@ |
316 | <property name="placeholderText"> |
317 | <string/> |
318 | </property> |
319 | + <property name="formError" stdset="0"> |
320 | + <bool>false</bool> |
321 | + </property> |
322 | </widget> |
323 | </item> |
324 | </layout> |
325 | </item> |
326 | - <item row="6" column="1"> |
327 | + <item row="8" column="1"> |
328 | <widget class="QLabel" name="refresh_label"> |
329 | <property name="sizePolicy"> |
330 | - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> |
331 | + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
332 | <horstretch>0</horstretch> |
333 | <verstretch>0</verstretch> |
334 | </sizepolicy> |
335 | </property> |
336 | + <property name="maximumSize"> |
337 | + <size> |
338 | + <width>300</width> |
339 | + <height>16777215</height> |
340 | + </size> |
341 | + </property> |
342 | <property name="locale"> |
343 | <locale language="English" country="UnitedStates"/> |
344 | </property> |
345 | @@ -322,6 +417,147 @@ |
346 | </property> |
347 | </widget> |
348 | </item> |
349 | + <item row="1" column="1"> |
350 | + <layout class="QVBoxLayout" name="verticalLayout_7"> |
351 | + <property name="leftMargin"> |
352 | + <number>10</number> |
353 | + </property> |
354 | + <item> |
355 | + <widget class="QLabel" name="name_assistance"> |
356 | + <property name="sizePolicy"> |
357 | + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
358 | + <horstretch>0</horstretch> |
359 | + <verstretch>0</verstretch> |
360 | + </sizepolicy> |
361 | + </property> |
362 | + <property name="maximumSize"> |
363 | + <size> |
364 | + <width>300</width> |
365 | + <height>16777215</height> |
366 | + </size> |
367 | + </property> |
368 | + <property name="text"> |
369 | + <string>name_assistance</string> |
370 | + </property> |
371 | + <property name="alignment"> |
372 | + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> |
373 | + </property> |
374 | + </widget> |
375 | + </item> |
376 | + </layout> |
377 | + </item> |
378 | + <item row="3" column="1"> |
379 | + <layout class="QVBoxLayout" name="verticalLayout_8"> |
380 | + <property name="leftMargin"> |
381 | + <number>10</number> |
382 | + </property> |
383 | + <item> |
384 | + <widget class="QLabel" name="email_assistance"> |
385 | + <property name="sizePolicy"> |
386 | + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
387 | + <horstretch>0</horstretch> |
388 | + <verstretch>0</verstretch> |
389 | + </sizepolicy> |
390 | + </property> |
391 | + <property name="maximumSize"> |
392 | + <size> |
393 | + <width>300</width> |
394 | + <height>16777215</height> |
395 | + </size> |
396 | + </property> |
397 | + <property name="text"> |
398 | + <string>email_assistance</string> |
399 | + </property> |
400 | + <property name="alignment"> |
401 | + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> |
402 | + </property> |
403 | + </widget> |
404 | + </item> |
405 | + </layout> |
406 | + </item> |
407 | + <item row="4" column="1"> |
408 | + <layout class="QVBoxLayout" name="verticalLayout_9"> |
409 | + <property name="leftMargin"> |
410 | + <number>10</number> |
411 | + </property> |
412 | + <item> |
413 | + <widget class="QLabel" name="confirm_email_assistance"> |
414 | + <property name="sizePolicy"> |
415 | + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
416 | + <horstretch>0</horstretch> |
417 | + <verstretch>0</verstretch> |
418 | + </sizepolicy> |
419 | + </property> |
420 | + <property name="maximumSize"> |
421 | + <size> |
422 | + <width>300</width> |
423 | + <height>16777215</height> |
424 | + </size> |
425 | + </property> |
426 | + <property name="text"> |
427 | + <string>confirm_email_assistance</string> |
428 | + </property> |
429 | + <property name="alignment"> |
430 | + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> |
431 | + </property> |
432 | + </widget> |
433 | + </item> |
434 | + </layout> |
435 | + </item> |
436 | + <item row="6" column="1" rowspan="2"> |
437 | + <widget class="QLabel" name="password_assistance"> |
438 | + <property name="sizePolicy"> |
439 | + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
440 | + <horstretch>0</horstretch> |
441 | + <verstretch>0</verstretch> |
442 | + </sizepolicy> |
443 | + </property> |
444 | + <property name="maximumSize"> |
445 | + <size> |
446 | + <width>300</width> |
447 | + <height>16777215</height> |
448 | + </size> |
449 | + </property> |
450 | + <property name="text"> |
451 | + <string>password_assistance</string> |
452 | + </property> |
453 | + <property name="indent"> |
454 | + <number>20</number> |
455 | + </property> |
456 | + </widget> |
457 | + </item> |
458 | + <item row="2" column="1"> |
459 | + <spacer name="verticalSpacer"> |
460 | + <property name="orientation"> |
461 | + <enum>Qt::Vertical</enum> |
462 | + </property> |
463 | + <property name="sizeType"> |
464 | + <enum>QSizePolicy::Fixed</enum> |
465 | + </property> |
466 | + <property name="sizeHint" stdset="0"> |
467 | + <size> |
468 | + <width>20</width> |
469 | + <height>20</height> |
470 | + </size> |
471 | + </property> |
472 | + </spacer> |
473 | + </item> |
474 | + <item row="5" column="1"> |
475 | + <spacer name="verticalSpacer_2"> |
476 | + <property name="orientation"> |
477 | + <enum>Qt::Vertical</enum> |
478 | + </property> |
479 | + <property name="sizeType"> |
480 | + <enum>QSizePolicy::Fixed</enum> |
481 | + </property> |
482 | + <property name="sizeHint" stdset="0"> |
483 | + <size> |
484 | + <width>20</width> |
485 | + <height>20</height> |
486 | + </size> |
487 | + </property> |
488 | + </spacer> |
489 | + </item> |
490 | </layout> |
491 | </item> |
492 | <item> |
493 | |
494 | === modified file 'data/qt/ubuntuone.qss' |
495 | --- data/qt/ubuntuone.qss 2011-08-17 14:34:27 +0000 |
496 | +++ data/qt/ubuntuone.qss 2011-08-22 14:08:26 +0000 |
497 | @@ -18,9 +18,6 @@ |
498 | background-color: white; |
499 | } |
500 | |
501 | -QLabel#name_assistance, |
502 | -QLabel#email_assistance, |
503 | -QLabel#confirm_email_assistance, |
504 | QLabel#password_assistance, |
505 | QLabel#refresh_label{ |
506 | border-image: url(":/balloon_shape.png"); |
507 | @@ -174,3 +171,11 @@ |
508 | font: bold 14px; |
509 | color: #dd4814; |
510 | } |
511 | + |
512 | +QLineEdit[formError="true"]{ |
513 | + background-color: #ffe5e5; |
514 | +} |
515 | + |
516 | +QLineEdit[formError="false"]{ |
517 | + background-color: white; |
518 | +} |
519 | |
520 | === modified file 'ubuntuone_installer/gui/qt/setup_account.py' |
521 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-08-08 21:48:11 +0000 |
522 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-22 14:08:26 +0000 |
523 | @@ -21,15 +21,17 @@ |
524 | import gettext |
525 | import re |
526 | |
527 | -from PyQt4 import QtGui |
528 | +from PyQt4 import QtGui, QtCore |
529 | |
530 | from ubuntu_sso.qt import gui as sso_gui |
531 | |
532 | _ = gettext.gettext |
533 | |
534 | # pylint: disable=C0103 |
535 | -BAD = u'<img src=":/password_hint_warning.png" /><font color="red"> %s </font>' |
536 | -GOOD = u'<img src=":/password_hint_ok.png" /><font color="green"> %s </font>' |
537 | +BAD = u'<img src=":/password_hint_warning.png" /><font> %s </font>' |
538 | +ERROR = u'<font color="#dd4814"><b> %s </b></font>' |
539 | +GOOD = u'<img src=":/password_hint_ok.png" /><font> %s </font>' |
540 | +NORMAL = u'<font> %s </font>' |
541 | TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>" |
542 | |
543 | EMPTY_NAME = _("Please enter your name") |
544 | @@ -42,8 +44,19 @@ |
545 | |
546 | |
547 | class SetupAccountPage(sso_gui.SetupAccountPage): |
548 | + """Customized Setup Account page for SSO.""" |
549 | |
550 | - """Customized Setup Account page for SSO""" |
551 | + def __init__(self, *args, **kwargs): |
552 | + super(SetupAccountPage, self).__init__(*args, **kwargs) |
553 | + self.ui.name_edit.textEdited.connect(self.name_assistance) |
554 | + self.ui.email_edit.textEdited.connect(self.email_assistance) |
555 | + self.ui.email_edit.textEdited.connect(self.confirm_email_assistance) |
556 | + self.ui.confirm_email_edit.textEdited.connect( |
557 | + self.confirm_email_assistance) |
558 | + self.ui.password_edit.textEdited.connect( |
559 | + lambda: self.password_assistance(NORMAL)) |
560 | + self.ui.confirm_password_edit.textEdited.connect( |
561 | + self.password_assistance) |
562 | |
563 | # Invalid name "initializePage" |
564 | # pylint: disable=C0103 |
565 | @@ -73,75 +86,107 @@ |
566 | QtGui.QWizard.BackButton, |
567 | QtGui.QWizard.Stretch]) |
568 | |
569 | - self.ui.name_edit.textEdited.connect(self.name_assistance) |
570 | - self.name_assistance() |
571 | - self.ui.email_edit.textEdited.connect(self.email_assistance) |
572 | - self.ui.email_edit.textEdited.connect(self.confirm_email_assistance) |
573 | - self.email_assistance() |
574 | - self.ui.confirm_email_edit.textEdited.connect( |
575 | - self.confirm_email_assistance) |
576 | - self.confirm_email_assistance() |
577 | - self.ui.password_edit.textEdited.connect(self.password_assistance) |
578 | - self.ui.confirm_password_edit.textEdited.connect( |
579 | - self.password_assistance) |
580 | - self.password_assistance() |
581 | + self.password_default_assistance() |
582 | + # Hide assistance labels by default |
583 | + self.ui.name_assistance.setVisible(False) |
584 | + self.ui.email_assistance.setVisible(False) |
585 | + self.ui.confirm_email_assistance.setVisible(False) |
586 | + self.ui.password_assistance.setVisible(False) |
587 | + self.ui.refresh_label.setVisible(True) |
588 | + |
589 | + def focus_changed(self, old, now): |
590 | + """Check who has the focus to activate password popups if necessary.""" |
591 | + if now == self.ui.password_edit: |
592 | + self.ui.password_assistance.setVisible(True) |
593 | + elif old == self.ui.password_edit or \ |
594 | + now == self.ui.confirm_password_edit: |
595 | + self.ui.password_assistance.setVisible(True) |
596 | + self.password_assistance() |
597 | |
598 | def name_assistance(self): |
599 | """Show help for the name field.""" |
600 | text = unicode(self.ui.name_edit.text()) |
601 | if not text.strip(): |
602 | self.ui.name_assistance.setVisible(True) |
603 | - self.ui.name_assistance.setText(BAD % EMPTY_NAME) |
604 | + self.ui.name_assistance.setText(ERROR % EMPTY_NAME) |
605 | + self.check_as_invalid(self.ui.name_edit) |
606 | else: |
607 | self.ui.name_assistance.setVisible(False) |
608 | + self.check_as_valid(self.ui.name_edit) |
609 | |
610 | def email_assistance(self): |
611 | """Show help for the email field.""" |
612 | text = unicode(self.ui.email_edit.text()) |
613 | if not is_correct_email(text): |
614 | - self.ui.email_assistance.setText(BAD % INVALID_EMAIL) |
615 | + self.ui.email_assistance.setText(ERROR % INVALID_EMAIL) |
616 | self.ui.email_assistance.setVisible(True) |
617 | + self.check_as_invalid(self.ui.email_edit) |
618 | else: |
619 | self.ui.email_assistance.setVisible(False) |
620 | + self.check_as_valid(self.ui.email_edit) |
621 | |
622 | def confirm_email_assistance(self): |
623 | """Show help for the confirm email field.""" |
624 | text1 = unicode(self.ui.email_edit.text()) |
625 | text2 = unicode(self.ui.confirm_email_edit.text()) |
626 | if text1 != text2: |
627 | - self.ui.confirm_email_assistance.setText(BAD % EMAIL_MATCH) |
628 | + self.ui.confirm_email_assistance.setText(ERROR % EMAIL_MATCH) |
629 | self.ui.confirm_email_assistance.setVisible(True) |
630 | + self.check_as_invalid(self.ui.confirm_email_edit) |
631 | else: |
632 | self.ui.confirm_email_assistance.setVisible(False) |
633 | + self.check_as_valid(self.ui.confirm_email_edit) |
634 | |
635 | - def password_assistance(self): |
636 | + def password_assistance(self, icon_type=BAD): |
637 | """Show help for the password field.""" |
638 | text1 = unicode(self.ui.password_edit.text()) |
639 | text2 = unicode(self.ui.confirm_password_edit.text()) |
640 | label_text = ["<b>%s</b>" % _("Your password must contain"), ] |
641 | |
642 | if len(text1) < 8: |
643 | - sign = BAD |
644 | + sign = icon_type |
645 | else: |
646 | sign = GOOD |
647 | label_text.append(sign % PASSWORD_LENGTH) |
648 | |
649 | if re.search('[A-Z]', text1) is None: |
650 | - sign = BAD |
651 | + sign = icon_type |
652 | else: |
653 | sign = GOOD |
654 | label_text.append(sign % PASSWORD_UPPER) |
655 | |
656 | if re.search('[\d+]', text1) is None: |
657 | - sign = BAD |
658 | + sign = icon_type |
659 | else: |
660 | sign = GOOD |
661 | label_text.append(sign % PASSWORD_DIGIT) |
662 | |
663 | if text1 != text2: |
664 | - label_text.append(BAD % PASSWORD_MATCH) |
665 | - |
666 | - self.ui.password_assistance.setText("<br>".join(label_text)) |
667 | + label_text.append(icon_type % PASSWORD_MATCH) |
668 | + |
669 | + self.ui.password_assistance.setText("<br>".join(label_text)) |
670 | + |
671 | + def password_default_assistance(self): |
672 | + """Show default help for the password field.""" |
673 | + label_text = ["<b>%s</b>" % _("Your password must contain"), ] |
674 | + |
675 | + label_text.append(NORMAL % PASSWORD_LENGTH) |
676 | + label_text.append(NORMAL % PASSWORD_UPPER) |
677 | + label_text.append(NORMAL % PASSWORD_DIGIT) |
678 | + |
679 | + self.ui.password_assistance.setText("<br>".join(label_text)) |
680 | + |
681 | + def check_as_invalid(self, line_edit): |
682 | + """Set QLineEdit's formError property as True, refresh the style.""" |
683 | + line_edit.setProperty("formError", True) |
684 | + line_edit.style().unpolish(line_edit) |
685 | + line_edit.style().polish(line_edit) |
686 | + |
687 | + def check_as_valid(self, line_edit): |
688 | + """Set QLineEdit's formError property as False, refresh the style.""" |
689 | + line_edit.setProperty("formError", False) |
690 | + line_edit.style().unpolish(line_edit) |
691 | + line_edit.style().polish(line_edit) |
692 | |
693 | def showEvent(self, event): |
694 | """Set set_up_button as default button when the page is shown.""" |
695 | @@ -151,6 +196,18 @@ |
696 | self.ui.set_up_button.setProperty("DisabledState", True) |
697 | self.ui.set_up_button.style().unpolish(self.ui.set_up_button) |
698 | self.ui.set_up_button.style().polish(self.ui.set_up_button) |
699 | + self.connect(QtGui.QApplication.instance(), |
700 | + QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"), |
701 | + self.focus_changed) |
702 | + |
703 | + def hideEvent(self, event): |
704 | + """Disconnect the focusChanged signal when the page change.""" |
705 | + try: |
706 | + self.disconnect(QtGui.QApplication.instance(), |
707 | + QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"), |
708 | + self.focus_changed) |
709 | + except TypeError: |
710 | + pass |
711 | |
712 | |
713 | def is_min_required_password(password): |
714 | |
715 | === modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py' |
716 | --- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-17 13:34:23 +0000 |
717 | +++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-22 14:08:26 +0000 |
718 | @@ -371,8 +371,8 @@ |
719 | gui.sys.frozen = True |
720 | self.patch(gui.subprocess, "Popen", self._set_called) |
721 | self.ui.done(result=1) |
722 | - self.assertTrue(os.sep in self._called[0][0][0]) |
723 | - self.assertTrue('ubuntuone-control-panel-qt' in self._called[0][0][0]) |
724 | + self.assertIn(os.sep, self._called[0][0][0]) |
725 | + self.assertIn('ubuntuone-control-panel-qt', self._called[0][0][0]) |
726 | |
727 | def test_not_start_control_panel_on_cancel(self): |
728 | """Called done with result=0, control panel should NOT be called.""" |
729 | @@ -636,7 +636,7 @@ |
730 | u"Space (1337)") |
731 | |
732 | def test_add_twice(self): |
733 | - """Behaviour for adding the same folder twice: |
734 | + """Behaviour for adding the same folder twice. |
735 | |
736 | * It's added only once. |
737 | """ |
738 | @@ -649,7 +649,7 @@ |
739 | self.assertEqual(1, self.ui.ui.folder_list.topLevelItemCount()) |
740 | |
741 | def test_add_missing_folder(self): |
742 | - """Behaviour for adding a folder that doesn't exist: |
743 | + """Behaviour for adding a folder that doesn't exist. |
744 | |
745 | * It's added. |
746 | * Has size 0. |
747 | @@ -687,6 +687,21 @@ |
748 | 'see bug #824675 for reference.' |
749 | |
750 | |
751 | +class FakeWizard(object): |
752 | + """Replace wizard() function on wizard pages.""" |
753 | + |
754 | + params = None |
755 | + |
756 | + # Invalid name "setButtonLayout" |
757 | + # pylint: disable=C0103 |
758 | + |
759 | + def setButtonLayout(self, *args, **kwargs): |
760 | + """Fake the functionality of setButtonLayout on QWizard class.""" |
761 | + FakeWizard.params = (args, kwargs) |
762 | + |
763 | + # pylint: enable=C0103 |
764 | + |
765 | + |
766 | class SetupAccountTestCase(BaseTestCase): |
767 | """Test the SetupAccountPage code.""" |
768 | |
769 | @@ -701,11 +716,37 @@ |
770 | """Initialize this test instance.""" |
771 | super(SetupAccountTestCase, self).setUp() |
772 | |
773 | + def test_init(self): |
774 | + """Check the initial state of SetupAccount.""" |
775 | + self.assertEqual(self.ui.ui.name_edit.receivers( |
776 | + QtCore.SIGNAL('textEdited(QString)')), 1) |
777 | + self.assertEqual(self.ui.ui.email_edit.receivers( |
778 | + QtCore.SIGNAL('textEdited(QString)')), 2) |
779 | + self.assertEqual(self.ui.ui.confirm_email_edit.receivers( |
780 | + QtCore.SIGNAL('textEdited(QString)')), 1) |
781 | + self.assertEqual(self.ui.ui.password_edit.receivers( |
782 | + QtCore.SIGNAL('textEdited(QString)')), 1) |
783 | + self.assertEqual(self.ui.ui.confirm_password_edit.receivers( |
784 | + QtCore.SIGNAL('textEdited(QString)')), 1) |
785 | + |
786 | + def test_initialize_page(self): |
787 | + """Check the initializePage to ensure proper widgets visibility.""" |
788 | + self.ui.show() |
789 | + self.patch(self.ui, 'wizard', FakeWizard) |
790 | + self.ui.initializePage() |
791 | + self.assertEqual(FakeWizard.params, (([ |
792 | + QtGui.QWizard.BackButton, |
793 | + QtGui.QWizard.Stretch],), {})) |
794 | + self.assertFalse(self.ui.ui.name_assistance.isVisible()) |
795 | + self.assertFalse(self.ui.ui.email_assistance.isVisible()) |
796 | + self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible()) |
797 | + self.assertFalse(self.ui.ui.password_assistance.isVisible()) |
798 | + |
799 | def test_empty_name(self): |
800 | - """Status when the name field is empty: |
801 | + """Status when the name field is empty. |
802 | |
803 | - * Name Assistance label visible |
804 | - * Correct error message in it |
805 | + * Name Assistance label visible. |
806 | + * Correct error message in it. |
807 | """ |
808 | self.ui.ui.name_edit.setText("") |
809 | self.ui.name_assistance() |
810 | @@ -713,14 +754,14 @@ |
811 | self.assertEqual(self.ui.ui.name_assistance.isVisible(), True) |
812 | self.assertEqual( |
813 | unicode(self.ui.ui.name_assistance.text()), |
814 | - setup_account.BAD % setup_account.EMPTY_NAME) |
815 | + setup_account.ERROR % setup_account.EMPTY_NAME) |
816 | self.ui.hide() |
817 | |
818 | def test_blank_name(self): |
819 | - """Status when the name field is blank (spaces): |
820 | + """Status when the name field is blank (spaces). |
821 | |
822 | - * Name Assistance label visible |
823 | - * Correct error message in it |
824 | + * Name Assistance label visible. |
825 | + * Correct error message in it. |
826 | """ |
827 | self.ui.ui.name_edit.setText(" ") |
828 | self.ui.name_assistance() |
829 | @@ -728,13 +769,13 @@ |
830 | self.assertEqual(self.ui.ui.name_assistance.isVisible(), True) |
831 | self.assertEqual( |
832 | unicode(self.ui.ui.name_assistance.text()), |
833 | - setup_account.BAD % setup_account.EMPTY_NAME) |
834 | + setup_account.ERROR % setup_account.EMPTY_NAME) |
835 | self.ui.hide() |
836 | |
837 | def test_valid_name(self): |
838 | - """Status when the name field is valid: |
839 | + """Status when the name field is valid. |
840 | |
841 | - * Name Assistance label invisible |
842 | + * Name Assistance label invisible. |
843 | """ |
844 | self.ui.ui.name_edit.setText("John Doe") |
845 | self.ui.name_assistance() |
846 | @@ -743,10 +784,10 @@ |
847 | self.ui.hide() |
848 | |
849 | def test_invalid_email(self): |
850 | - """Status when the email field has no @: |
851 | + """Status when the email field has no @. |
852 | |
853 | - * Email Assistance label visible |
854 | - * Correct error message in it |
855 | + * Email Assistance label visible. |
856 | + * Correct error message in it. |
857 | """ |
858 | self.ui.ui.email_edit.setText("foobar") |
859 | self.ui.email_assistance() |
860 | @@ -754,13 +795,13 @@ |
861 | self.assertEqual(self.ui.ui.email_assistance.isVisible(), True) |
862 | self.assertEqual( |
863 | unicode(self.ui.ui.email_assistance.text()), |
864 | - setup_account.BAD % setup_account.INVALID_EMAIL) |
865 | + setup_account.ERROR % setup_account.INVALID_EMAIL) |
866 | self.ui.hide() |
867 | |
868 | def test_valid_email(self): |
869 | - """Status when the email field has a @: |
870 | + """Status when the email field has a @. |
871 | |
872 | - * Email Assistance label invisible |
873 | + * Email Assistance label invisible. |
874 | """ |
875 | self.ui.ui.email_edit.setText("foo@bar") |
876 | self.ui.email_assistance() |
877 | @@ -769,9 +810,9 @@ |
878 | self.ui.hide() |
879 | |
880 | def test_matching_emails(self): |
881 | - """Status when the email fields match: |
882 | + """Status when the email fields match. |
883 | |
884 | - * Email Assistance label invisible |
885 | + * Email Assistance label invisible. |
886 | """ |
887 | self.ui.ui.email_edit.setText("foo@bar") |
888 | self.ui.ui.confirm_email_edit.setText("foo@bar") |
889 | @@ -782,10 +823,10 @@ |
890 | self.ui.hide() |
891 | |
892 | def test_not_matching_emails(self): |
893 | - """Status when the email fields don't match: |
894 | + """Status when the email fields don't match. |
895 | |
896 | - * Email Assistance label visible |
897 | - * Correct error message |
898 | + * Email Assistance label visible. |
899 | + * Correct error message. |
900 | """ |
901 | self.ui.ui.email_edit.setText("foo@bar") |
902 | self.ui.ui.confirm_email_edit.setText("foo@baz") |
903 | @@ -794,112 +835,214 @@ |
904 | self.assertEqual(self.ui.ui.confirm_email_assistance.isVisible(), True) |
905 | self.assertEqual( |
906 | unicode(self.ui.ui.confirm_email_assistance.text()), |
907 | - setup_account.BAD % setup_account.EMAIL_MATCH) |
908 | + setup_account.ERROR % setup_account.EMAIL_MATCH) |
909 | self.ui.hide() |
910 | |
911 | def test_short_password(self): |
912 | - """Status with short password: |
913 | + """Status with short password. |
914 | |
915 | - * Password assistance contains the right message |
916 | + * Password assistance contains the right message. |
917 | """ |
918 | self.ui.ui.password_edit.setText("foobar") |
919 | self.ui.password_assistance() |
920 | - self.assertEqual( |
921 | - True, |
922 | - setup_account.BAD % setup_account.PASSWORD_LENGTH in |
923 | + self.assertIn( |
924 | + setup_account.BAD % setup_account.PASSWORD_LENGTH, |
925 | unicode(self.ui.ui.password_assistance.text()), |
926 | ) |
927 | |
928 | def test_long_password(self): |
929 | - """Status with long password: |
930 | + """Status with long password. |
931 | |
932 | - * Password assistance contains the right message |
933 | + * Password assistance contains the right message. |
934 | """ |
935 | self.ui.ui.password_edit.setText("foobarbaz") |
936 | self.ui.password_assistance() |
937 | - self.assertEqual( |
938 | - True, |
939 | - setup_account.GOOD % setup_account.PASSWORD_LENGTH in |
940 | + self.assertIn( |
941 | + setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
942 | unicode(self.ui.ui.password_assistance.text()), |
943 | ) |
944 | |
945 | def test_no_number_password(self): |
946 | - """Status with password without a number: |
947 | + """Status with password without a number. |
948 | |
949 | - * Password assistance contains the right message |
950 | + * Password assistance contains the right message. |
951 | """ |
952 | self.ui.ui.password_edit.setText("foobarbaz") |
953 | self.ui.password_assistance() |
954 | - self.assertEqual( |
955 | - True, |
956 | - setup_account.BAD % setup_account.PASSWORD_DIGIT in |
957 | + self.assertIn( |
958 | + setup_account.BAD % setup_account.PASSWORD_DIGIT, |
959 | unicode(self.ui.ui.password_assistance.text()), |
960 | ) |
961 | |
962 | def test_number_password(self): |
963 | - """Status with password with a number: |
964 | + """Status with password with a number. |
965 | |
966 | - * Password assistance contains the right message |
967 | + * Password assistance contains the right message. |
968 | """ |
969 | self.ui.ui.password_edit.setText("foobarba7") |
970 | self.ui.password_assistance() |
971 | - self.assertEqual( |
972 | - True, |
973 | - setup_account.GOOD % setup_account.PASSWORD_DIGIT in |
974 | + self.assertIn( |
975 | + setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
976 | unicode(self.ui.ui.password_assistance.text()), |
977 | ) |
978 | |
979 | def test_no_uppercase_password(self): |
980 | - """Status with password without uppercase letters: |
981 | + """Status with password without uppercase letters. |
982 | |
983 | - * Password assistance contains the right message |
984 | + * Password assistance contains the right message. |
985 | """ |
986 | self.ui.ui.password_edit.setText("foobarbaz") |
987 | self.ui.password_assistance() |
988 | - self.assertEqual( |
989 | - True, |
990 | - setup_account.BAD % setup_account.PASSWORD_UPPER in |
991 | + self.assertIn( |
992 | + setup_account.BAD % setup_account.PASSWORD_UPPER, |
993 | unicode(self.ui.ui.password_assistance.text()), |
994 | ) |
995 | |
996 | def test_upper_password(self): |
997 | - """Status with password with uppercase letters: |
998 | + """Status with password with uppercase letters. |
999 | |
1000 | - * Password assistance contains the right message |
1001 | + * Password assistance contains the right message. |
1002 | """ |
1003 | self.ui.ui.password_edit.setText("Foobarba7") |
1004 | self.ui.password_assistance() |
1005 | - self.assertEqual( |
1006 | - True, |
1007 | - setup_account.GOOD % setup_account.PASSWORD_UPPER in |
1008 | + self.assertIn( |
1009 | + setup_account.GOOD % setup_account.PASSWORD_UPPER, |
1010 | unicode(self.ui.ui.password_assistance.text()), |
1011 | ) |
1012 | |
1013 | def test_matching_passwords(self): |
1014 | - """Status when the passwords match: |
1015 | + """Status when the passwords match. |
1016 | |
1017 | - * Password assistance doesn't contain the message |
1018 | + * Password assistance doesn't contain the message. |
1019 | """ |
1020 | self.ui.ui.password_edit.setText("Foobarba7") |
1021 | self.ui.ui.confirm_password_edit.setText("Foobarba7") |
1022 | self.ui.password_assistance() |
1023 | - self.assertEqual( |
1024 | - False, |
1025 | - setup_account.PASSWORD_MATCH in |
1026 | + self.assertNotIn( |
1027 | + setup_account.PASSWORD_MATCH, |
1028 | unicode(self.ui.ui.password_assistance.text()), |
1029 | ) |
1030 | |
1031 | def test_not_matching_passwords(self): |
1032 | - """Status when the passwords not match: |
1033 | + """Status when the passwords not match. |
1034 | |
1035 | - * Password assistance contains the right message |
1036 | + * Password assistance contains the right message. |
1037 | """ |
1038 | self.ui.ui.password_edit.setText("Foobarba7") |
1039 | self.ui.ui.confirm_password_edit.setText("BazBarFo0") |
1040 | self.ui.password_assistance() |
1041 | - self.assertEqual( |
1042 | - True, |
1043 | - setup_account.BAD % setup_account.PASSWORD_MATCH in |
1044 | + self.assertIn( |
1045 | + setup_account.BAD % setup_account.PASSWORD_MATCH, |
1046 | + unicode(self.ui.ui.password_assistance.text()), |
1047 | + ) |
1048 | + |
1049 | + def test_password_default_assistance(self): |
1050 | + """Status when the password line edit receive focus and shows popup. |
1051 | + |
1052 | + * Password assistance contains the right message. |
1053 | + """ |
1054 | + self.ui.ui.password_edit.setText("") |
1055 | + self.ui.ui.confirm_password_edit.setText("") |
1056 | + self.ui.password_assistance() |
1057 | + self.ui.focus_changed(None, self.ui.ui.password_edit) |
1058 | + self.assertIn( |
1059 | + setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
1060 | + unicode(self.ui.ui.password_assistance.text()), |
1061 | + ) |
1062 | + self.assertIn( |
1063 | + setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
1064 | + unicode(self.ui.ui.password_assistance.text()), |
1065 | + ) |
1066 | + self.assertIn( |
1067 | + setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
1068 | + unicode(self.ui.ui.password_assistance.text()), |
1069 | + ) |
1070 | + |
1071 | + def test_password_assistance_in_focus_length_correct(self): |
1072 | + """Check the QLineEdit for password when the length is correct.""" |
1073 | + self.ui.ui.password_edit.setText("aaaaaaaaa") |
1074 | + self.ui.ui.confirm_password_edit.setText("") |
1075 | + self.ui.password_assistance(setup_account.NORMAL) |
1076 | + self.assertIn( |
1077 | + setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
1078 | + unicode(self.ui.ui.password_assistance.text()), |
1079 | + ) |
1080 | + self.assertIn( |
1081 | + setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
1082 | + unicode(self.ui.ui.password_assistance.text()), |
1083 | + ) |
1084 | + self.assertIn( |
1085 | + setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
1086 | + unicode(self.ui.ui.password_assistance.text()), |
1087 | + ) |
1088 | + self.assertIn( |
1089 | + setup_account.NORMAL % setup_account.PASSWORD_MATCH, |
1090 | + unicode(self.ui.ui.password_assistance.text()), |
1091 | + ) |
1092 | + |
1093 | + def test_password_assistance_in_focus_with_upper(self): |
1094 | + """Check the QLineEdit for password when it has an upper case char.""" |
1095 | + self.ui.ui.password_edit.setText("AAa") |
1096 | + self.ui.ui.confirm_password_edit.setText("") |
1097 | + self.ui.password_assistance(setup_account.NORMAL) |
1098 | + self.assertIn( |
1099 | + setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
1100 | + unicode(self.ui.ui.password_assistance.text()), |
1101 | + ) |
1102 | + self.assertIn( |
1103 | + setup_account.GOOD % setup_account.PASSWORD_UPPER, |
1104 | + unicode(self.ui.ui.password_assistance.text()), |
1105 | + ) |
1106 | + self.assertIn( |
1107 | + setup_account.NORMAL % setup_account.PASSWORD_DIGIT, |
1108 | + unicode(self.ui.ui.password_assistance.text()), |
1109 | + ) |
1110 | + self.assertIn( |
1111 | + setup_account.NORMAL % setup_account.PASSWORD_MATCH, |
1112 | + unicode(self.ui.ui.password_assistance.text()), |
1113 | + ) |
1114 | + |
1115 | + def test_password_assistance_in_focus_with_number(self): |
1116 | + """Check the QLineEdit for password when it contains numbers.""" |
1117 | + self.ui.ui.password_edit.setText("a123") |
1118 | + self.ui.ui.confirm_password_edit.setText("") |
1119 | + self.ui.password_assistance(setup_account.NORMAL) |
1120 | + self.assertIn( |
1121 | + setup_account.NORMAL % setup_account.PASSWORD_LENGTH, |
1122 | + unicode(self.ui.ui.password_assistance.text()), |
1123 | + ) |
1124 | + self.assertIn( |
1125 | + setup_account.NORMAL % setup_account.PASSWORD_UPPER, |
1126 | + unicode(self.ui.ui.password_assistance.text()), |
1127 | + ) |
1128 | + self.assertIn( |
1129 | + setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
1130 | + unicode(self.ui.ui.password_assistance.text()), |
1131 | + ) |
1132 | + self.assertIn( |
1133 | + setup_account.NORMAL % setup_account.PASSWORD_MATCH, |
1134 | + unicode(self.ui.ui.password_assistance.text()), |
1135 | + ) |
1136 | + |
1137 | + def test_password_assistance_in_focus_all_ok(self): |
1138 | + """Check the QLineEdit for password when all the condition are ok.""" |
1139 | + self.ui.ui.password_edit.setText("T3st3rqw") |
1140 | + self.ui.ui.confirm_password_edit.setText("T3st3rqw") |
1141 | + self.ui.password_assistance(setup_account.NORMAL) |
1142 | + self.assertIn( |
1143 | + setup_account.GOOD % setup_account.PASSWORD_LENGTH, |
1144 | + unicode(self.ui.ui.password_assistance.text()), |
1145 | + ) |
1146 | + self.assertIn( |
1147 | + setup_account.GOOD % setup_account.PASSWORD_UPPER, |
1148 | + unicode(self.ui.ui.password_assistance.text()), |
1149 | + ) |
1150 | + self.assertIn( |
1151 | + setup_account.GOOD % setup_account.PASSWORD_DIGIT, |
1152 | + unicode(self.ui.ui.password_assistance.text()), |
1153 | + ) |
1154 | + self.assertNotIn( |
1155 | + setup_account.NORMAL % setup_account.PASSWORD_MATCH, |
1156 | unicode(self.ui.ui.password_assistance.text()), |
1157 | ) |
1158 | |
1159 | @@ -924,6 +1067,26 @@ |
1160 | True, |
1161 | self.ui.sideWidget().ui.states_frame.isVisible()) |
1162 | |
1163 | + def test_check_valid(self): |
1164 | + """Check the propery value of a QLineEdit marked as valid.""" |
1165 | + self.ui.check_as_valid(self.ui.ui.name_edit) |
1166 | + self.assertEqual(self.ui.ui.name_edit.property("formError"), |
1167 | + False) |
1168 | + |
1169 | + def test_check_invalid(self): |
1170 | + """Check the propery value of a QLineEdit marked as invalid.""" |
1171 | + self.ui.check_as_invalid(self.ui.ui.name_edit) |
1172 | + self.assertEqual(self.ui.ui.name_edit.property("formError"), |
1173 | + True) |
1174 | + |
1175 | + def test_focus_changed(self): |
1176 | + """Check visibility changes when focus_changed() is executed.""" |
1177 | + self.ui.show() |
1178 | + self.ui.focus_changed(None, self.ui.ui.password_edit) |
1179 | + self.assertTrue(self.ui.ui.password_assistance.isVisible()) |
1180 | + self.ui.focus_changed(None, self.ui.ui.captcha_solution_edit) |
1181 | + self.assertTrue(self.ui.ui.refresh_label.isVisible()) |
1182 | + |
1183 | |
1184 | class FakeFailingCredentialsManagementTool(object): |
1185 |
Looks great!