Merge lp:~diegosarmentero/ubuntuone-windows-installer/setup-buttons into lp:ubuntuone-windows-installer
- setup-buttons
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 44 |
Merged at revision: | 43 |
Proposed branch: | lp:~diegosarmentero/ubuntuone-windows-installer/setup-buttons |
Merge into: | lp:ubuntuone-windows-installer |
Diff against target: |
832 lines (+311/-253) 8 files modified
data/qt/setup_account.ui (+36/-48) ubuntuone_installer/gui/qt/enhanced_check_box.py (+50/-0) ubuntuone_installer/gui/qt/gui.py (+1/-13) ubuntuone_installer/gui/qt/setup_account.py (+29/-11) ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py (+49/-0) ubuntuone_installer/gui/qt/tests/test_gui.py (+28/-17) ubuntuone_installer/gui/qt/tests/test_setup_account.py (+118/-100) ubuntuone_installer/gui/qt/tos.py (+0/-64) |
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/setup-buttons |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart (community) | Approve | ||
Roberto Alsina (community) | Approve | ||
Review via email:
|
Commit message
Modified setup account page to reduce the height size.
Description of the change
Modified setup account page to reduce the height size.
- 41. By Diego Sarmentero
-
merge
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
* Please call super() instead of QtGui.QCheckBox
* Why re you removing the overlay shown when the setup button is clicked?
* Since we're building strings with the hope they get translated, we always try to use formatting with keywords. So, instead of this
"By signing up to Ubuntu One you agree to our {0} and {1}"
we should use:
"By signing up to Ubuntu One you agree to our {terms_
and then call format like this:
terms = TERMS.format(
self.terms_checkbox = enhanced_
* Why are you calling
again in initializePage? The terms legend was set on __init__, is there any specific issue that requires setting the text again?
* In the test_overlay_
* If you're patching self.patch(self.ui, 'wizard', FakeWizard) in every test method in SetupAccountTes
Great work on the tests for the new widget!
- 42. By Diego Sarmentero
-
Changes from review applied.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Diego Sarmentero (diegosarmentero) wrote : | # |
> self.setup_
> self.overlay.show)
Because this button doesn't exists anymore, and that signal is being connected on initializePage on SetupAccountPage
> * If you're patching self.patch(self.ui, 'wizard', FakeWizard) in every test
> method in SetupAccountTes
> duplication.
I don't need that in every tests, just in the ones i added, otherwise if i patch the wizard in the setup cause the other tests to fail.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
> > * If you're patching self.patch(self.ui, 'wizard', FakeWizard) in every test
> > method in SetupAccountTes
> > duplication.
>
> I don't need that in every tests, just in the ones i added, otherwise if i
> patch the wizard in the setup cause the other tests to fail.
If you need a subset of tests to have a specific setup, then you should unify them in another testcase.
Thanks!
- 43. By Diego Sarmentero
-
Added new TestCase.
- 44. By Diego Sarmentero
-
Removed commented code.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Natalia Bidart (nataliabidart) wrote : | # |
looks good!
Preview Diff
1 | === modified file 'data/qt/setup_account.ui' | |||
2 | --- data/qt/setup_account.ui 2011-08-25 11:32:23 +0000 | |||
3 | +++ data/qt/setup_account.ui 2011-08-30 17:19:25 +0000 | |||
4 | @@ -6,14 +6,29 @@ | |||
5 | 6 | <rect> | 6 | <rect> |
6 | 7 | <x>0</x> | 7 | <x>0</x> |
7 | 8 | <y>0</y> | 8 | <y>0</y> |
10 | 9 | <width>575</width> | 9 | <width>583</width> |
11 | 10 | <height>573</height> | 10 | <height>538</height> |
12 | 11 | </rect> | 11 | </rect> |
13 | 12 | </property> | 12 | </property> |
14 | 13 | <property name="sizePolicy"> | ||
15 | 14 | <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
16 | 15 | <horstretch>0</horstretch> | ||
17 | 16 | <verstretch>0</verstretch> | ||
18 | 17 | </sizepolicy> | ||
19 | 18 | </property> | ||
20 | 19 | <property name="maximumSize"> | ||
21 | 20 | <size> | ||
22 | 21 | <width>16777215</width> | ||
23 | 22 | <height>16777215</height> | ||
24 | 23 | </size> | ||
25 | 24 | </property> | ||
26 | 13 | <property name="windowTitle"> | 25 | <property name="windowTitle"> |
27 | 14 | <string>WizardPage</string> | 26 | <string>WizardPage</string> |
28 | 15 | </property> | 27 | </property> |
29 | 16 | <layout class="QVBoxLayout" name="verticalLayout"> | 28 | <layout class="QVBoxLayout" name="verticalLayout"> |
30 | 29 | <property name="spacing"> | ||
31 | 30 | <number>0</number> | ||
32 | 31 | </property> | ||
33 | 17 | <property name="rightMargin"> | 32 | <property name="rightMargin"> |
34 | 18 | <number>6</number> | 33 | <number>6</number> |
35 | 19 | </property> | 34 | </property> |
36 | @@ -309,7 +324,7 @@ | |||
37 | 309 | </item> | 324 | </item> |
38 | 310 | </layout> | 325 | </layout> |
39 | 311 | </item> | 326 | </item> |
41 | 312 | <item row="8" column="0"> | 327 | <item row="9" column="0"> |
42 | 313 | <layout class="QVBoxLayout" name="verticalLayout"> | 328 | <layout class="QVBoxLayout" name="verticalLayout"> |
43 | 314 | <property name="spacing"> | 329 | <property name="spacing"> |
44 | 315 | <number>3</number> | 330 | <number>3</number> |
45 | @@ -389,7 +404,7 @@ | |||
46 | 389 | </item> | 404 | </item> |
47 | 390 | </layout> | 405 | </layout> |
48 | 391 | </item> | 406 | </item> |
50 | 392 | <item row="8" column="1"> | 407 | <item row="9" column="1"> |
51 | 393 | <widget class="QLabel" name="refresh_label"> | 408 | <widget class="QLabel" name="refresh_label"> |
52 | 394 | <property name="sizePolicy"> | 409 | <property name="sizePolicy"> |
53 | 395 | <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> | 410 | <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> |
54 | @@ -558,56 +573,29 @@ | |||
55 | 558 | </property> | 573 | </property> |
56 | 559 | </spacer> | 574 | </spacer> |
57 | 560 | </item> | 575 | </item> |
58 | 576 | <item row="8" column="1"> | ||
59 | 577 | <spacer name="verticalSpacer_3"> | ||
60 | 578 | <property name="orientation"> | ||
61 | 579 | <enum>Qt::Vertical</enum> | ||
62 | 580 | </property> | ||
63 | 581 | <property name="sizeType"> | ||
64 | 582 | <enum>QSizePolicy::Fixed</enum> | ||
65 | 583 | </property> | ||
66 | 584 | <property name="sizeHint" stdset="0"> | ||
67 | 585 | <size> | ||
68 | 586 | <width>20</width> | ||
69 | 587 | <height>20</height> | ||
70 | 588 | </size> | ||
71 | 589 | </property> | ||
72 | 590 | </spacer> | ||
73 | 591 | </item> | ||
74 | 561 | </layout> | 592 | </layout> |
75 | 562 | </item> | 593 | </item> |
76 | 563 | <item> | 594 | <item> |
85 | 564 | <widget class="QCheckBox" name="terms_checkbox"> | 595 | <layout class="QHBoxLayout" name="hlayout_check"> |
78 | 565 | <property name="text"> | ||
79 | 566 | <string>By signing up you agree blah blah</string> | ||
80 | 567 | </property> | ||
81 | 568 | </widget> | ||
82 | 569 | </item> | ||
83 | 570 | <item> | ||
84 | 571 | <layout class="QHBoxLayout" name="horizontalLayout_4"> | ||
86 | 572 | <property name="spacing"> | 596 | <property name="spacing"> |
87 | 573 | <number>0</number> | 597 | <number>0</number> |
88 | 574 | </property> | 598 | </property> |
89 | 575 | <item> | ||
90 | 576 | <widget class="QPushButton" name="terms_button"> | ||
91 | 577 | <property name="text"> | ||
92 | 578 | <string>Show terms</string> | ||
93 | 579 | </property> | ||
94 | 580 | </widget> | ||
95 | 581 | </item> | ||
96 | 582 | <item> | ||
97 | 583 | <spacer name="horizontalSpacer_3"> | ||
98 | 584 | <property name="orientation"> | ||
99 | 585 | <enum>Qt::Horizontal</enum> | ||
100 | 586 | </property> | ||
101 | 587 | <property name="sizeHint" stdset="0"> | ||
102 | 588 | <size> | ||
103 | 589 | <width>40</width> | ||
104 | 590 | <height>20</height> | ||
105 | 591 | </size> | ||
106 | 592 | </property> | ||
107 | 593 | </spacer> | ||
108 | 594 | </item> | ||
109 | 595 | <item> | ||
110 | 596 | <widget class="QPushButton" name="set_up_button"> | ||
111 | 597 | <property name="enabled"> | ||
112 | 598 | <bool>false</bool> | ||
113 | 599 | </property> | ||
114 | 600 | <property name="styleSheet"> | ||
115 | 601 | <string notr="true"/> | ||
116 | 602 | </property> | ||
117 | 603 | <property name="text"> | ||
118 | 604 | <string>Set Up Account</string> | ||
119 | 605 | </property> | ||
120 | 606 | <property name="DisabledState" stdset="0"> | ||
121 | 607 | <bool>true</bool> | ||
122 | 608 | </property> | ||
123 | 609 | </widget> | ||
124 | 610 | </item> | ||
125 | 611 | </layout> | 599 | </layout> |
126 | 612 | </item> | 600 | </item> |
127 | 613 | </layout> | 601 | </layout> |
128 | 614 | 602 | ||
129 | === added file 'ubuntuone_installer/gui/qt/enhanced_check_box.py' | |||
130 | --- ubuntuone_installer/gui/qt/enhanced_check_box.py 1970-01-01 00:00:00 +0000 | |||
131 | +++ ubuntuone_installer/gui/qt/enhanced_check_box.py 2011-08-30 17:19:25 +0000 | |||
132 | @@ -0,0 +1,50 @@ | |||
133 | 1 | # -*- coding: utf-8 -*- | ||
134 | 2 | |||
135 | 3 | # Authors: Diego Sarmentero <diego.sarmentero@canonical.com> | ||
136 | 4 | # | ||
137 | 5 | # Copyright 2011 Canonical Ltd. | ||
138 | 6 | # | ||
139 | 7 | # This program is free software: you can redistribute it and/or modify it | ||
140 | 8 | # under the terms of the GNU General Public License version 3, as published | ||
141 | 9 | # by the Free Software Foundation. | ||
142 | 10 | # | ||
143 | 11 | # This program is distributed in the hope that it will be useful, but | ||
144 | 12 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
145 | 13 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
146 | 14 | # PURPOSE. See the GNU General Public License for more details. | ||
147 | 15 | # | ||
148 | 16 | # You should have received a copy of the GNU General Public License along | ||
149 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
150 | 18 | |||
151 | 19 | """Customized Check Box to support links.""" | ||
152 | 20 | |||
153 | 21 | from PyQt4 import QtGui | ||
154 | 22 | |||
155 | 23 | |||
156 | 24 | class EnhancedCheckBox(QtGui.QCheckBox): | ||
157 | 25 | """Enhanced QCheckBox to support links in the message displayed.""" | ||
158 | 26 | |||
159 | 27 | def __init__(self, text=""): | ||
160 | 28 | QtGui.QCheckBox.__init__(self) | ||
161 | 29 | hbox = QtGui.QHBoxLayout() | ||
162 | 30 | self.text_label = QtGui.QLabel(text) | ||
163 | 31 | self.text_label.setOpenExternalLinks(True) | ||
164 | 32 | padding = self.iconSize().width() | ||
165 | 33 | self.text_label.setStyleSheet("padding-left: {0}px;".format(padding)) | ||
166 | 34 | hbox.addWidget(self.text_label) | ||
167 | 35 | self.setLayout(hbox) | ||
168 | 36 | |||
169 | 37 | self.stateChanged.connect(self.text_label.setFocus) | ||
170 | 38 | |||
171 | 39 | def text(self): | ||
172 | 40 | """Return the text of this widget.""" | ||
173 | 41 | return self.text_label.text() | ||
174 | 42 | |||
175 | 43 | # Invalid name "setText" | ||
176 | 44 | # pylint: disable=C0103 | ||
177 | 45 | |||
178 | 46 | def setText(self, text): | ||
179 | 47 | """Set a new text to this widget.""" | ||
180 | 48 | self.text_label.setText(text) | ||
181 | 49 | |||
182 | 50 | # pylint: enable=C0103 | ||
183 | 0 | 51 | ||
184 | === modified file 'ubuntuone_installer/gui/qt/gui.py' | |||
185 | --- ubuntuone_installer/gui/qt/gui.py 2011-08-29 12:41:02 +0000 | |||
186 | +++ ubuntuone_installer/gui/qt/gui.py 2011-08-30 17:19:25 +0000 | |||
187 | @@ -40,7 +40,6 @@ | |||
188 | 40 | from ubuntu_sso.qt.email_verification_ui import \ | 40 | from ubuntu_sso.qt.email_verification_ui import \ |
189 | 41 | Ui_EmailVerificationPage | 41 | Ui_EmailVerificationPage |
190 | 42 | from ubuntu_sso.qt.error_message_ui import Ui_ErrorPage | 42 | from ubuntu_sso.qt.error_message_ui import Ui_ErrorPage |
191 | 43 | from ubuntu_sso.qt.terms_and_conditions_ui import Ui_TosPage | ||
192 | 44 | from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage | 43 | from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage |
193 | 45 | from ubuntu_sso.qt.forgotten_password_ui import \ | 44 | from ubuntu_sso.qt.forgotten_password_ui import \ |
194 | 46 | Ui_ForgottenPasswordPage | 45 | Ui_ForgottenPasswordPage |
195 | @@ -52,7 +51,6 @@ | |||
196 | 52 | ResetPasswordController, | 51 | ResetPasswordController, |
197 | 53 | SetUpAccountController, | 52 | SetUpAccountController, |
198 | 54 | SuccessController, | 53 | SuccessController, |
199 | 55 | TosController, | ||
200 | 56 | ) | 54 | ) |
201 | 57 | 55 | ||
202 | 58 | from ubuntuone.controlpanel.gui.qt.loadingoverlay import LoadingOverlay | 56 | from ubuntuone.controlpanel.gui.qt.loadingoverlay import LoadingOverlay |
203 | @@ -80,7 +78,6 @@ | |||
204 | 80 | from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage | 78 | from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage |
205 | 81 | from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage | 79 | from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage |
206 | 82 | from ubuntuone_installer.gui.qt.side_widget import SideWidget | 80 | from ubuntuone_installer.gui.qt.side_widget import SideWidget |
207 | 83 | from ubuntuone_installer.gui.qt.tos import TosPage | ||
208 | 84 | 81 | ||
209 | 85 | _ = gettext.gettext | 82 | _ = gettext.gettext |
210 | 86 | SIGN_IN = _("Sign in to Ubuntu One") | 83 | SIGN_IN = _("Sign in to Ubuntu One") |
211 | @@ -279,7 +276,7 @@ | |||
212 | 279 | super(MainWindow, self).__init__() | 276 | super(MainWindow, self).__init__() |
213 | 280 | 277 | ||
214 | 281 | self.setWindowTitle(APP_NAME) | 278 | self.setWindowTitle(APP_NAME) |
216 | 282 | self.setMinimumHeight(630) | 279 | self.setMinimumHeight(590) |
217 | 283 | self.setMinimumWidth(800) | 280 | self.setMinimumWidth(800) |
218 | 284 | self.setWizardStyle(self.ModernStyle) | 281 | self.setWizardStyle(self.ModernStyle) |
219 | 285 | self.close_callback = close_callback | 282 | self.close_callback = close_callback |
220 | @@ -316,14 +313,6 @@ | |||
221 | 316 | setup_account_ui.Ui_SetUpAccountPage(), | 313 | setup_account_ui.Ui_SetUpAccountPage(), |
222 | 317 | self.setup_controller, | 314 | self.setup_controller, |
223 | 318 | parent=self) | 315 | parent=self) |
224 | 319 | self.setup_account.ui.set_up_button.clicked.connect( | ||
225 | 320 | self.overlay.show) | ||
226 | 321 | |||
227 | 322 | title_page = TITLE_STYLE % _("Ubuntu One Terms of Service") | ||
228 | 323 | self.tos = TosPage(Ui_TosPage(), | ||
229 | 324 | TosController(tos_url=TC_URL, | ||
230 | 325 | title=title_page), | ||
231 | 326 | parent=self) | ||
232 | 327 | 316 | ||
233 | 328 | self.email_verification = EmailVerificationPage( | 317 | self.email_verification = EmailVerificationPage( |
234 | 329 | Ui_EmailVerificationPage(), | 318 | Ui_EmailVerificationPage(), |
235 | @@ -363,7 +352,6 @@ | |||
236 | 363 | 352 | ||
237 | 364 | self.SIGNIN_PAGE = self.addPage(self.sign_in_page) | 353 | self.SIGNIN_PAGE = self.addPage(self.sign_in_page) |
238 | 365 | self.setup_account_page_id = self.addPage(self.setup_account) | 354 | self.setup_account_page_id = self.addPage(self.setup_account) |
239 | 366 | self.tos_page_id = self.addPage(self.tos) | ||
240 | 367 | self.email_verification_page_id = self.addPage(self.email_verification) | 355 | self.email_verification_page_id = self.addPage(self.email_verification) |
241 | 368 | self.current_user_page_id = self.addPage(self.current_user) | 356 | self.current_user_page_id = self.addPage(self.current_user) |
242 | 369 | self.SUCCESS_PAGE = self.addPage(self.success) | 357 | self.SUCCESS_PAGE = self.addPage(self.success) |
243 | 370 | 358 | ||
244 | === modified file 'ubuntuone_installer/gui/qt/setup_account.py' | |||
245 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-08-25 17:07:42 +0000 | |||
246 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-30 17:19:25 +0000 | |||
247 | @@ -25,6 +25,8 @@ | |||
248 | 25 | 25 | ||
249 | 26 | from ubuntu_sso.qt import gui as sso_gui | 26 | from ubuntu_sso.qt import gui as sso_gui |
250 | 27 | 27 | ||
251 | 28 | from ubuntuone_installer.gui.qt import enhanced_check_box | ||
252 | 29 | |||
253 | 28 | _ = gettext.gettext | 30 | _ = gettext.gettext |
254 | 29 | 31 | ||
255 | 30 | # pylint: disable=C0103 | 32 | # pylint: disable=C0103 |
256 | @@ -47,11 +49,15 @@ | |||
257 | 47 | PASSWORD_MUST_CONTAIN = _("Your password must contain") | 49 | PASSWORD_MUST_CONTAIN = _("Your password must contain") |
258 | 48 | RETYPE_EMAIL = _("Retype email") | 50 | RETYPE_EMAIL = _("Retype email") |
259 | 49 | RETYPE_PASSWORD = _("Retype password") | 51 | RETYPE_PASSWORD = _("Retype password") |
262 | 50 | SHOW_TERMS = _("Show Terms of Service") | 52 | SUBTITLE = _("You only need to set up your account " |
261 | 51 | SUBTITLE = _("You only need to set up your account " \ | ||
263 | 52 | "once to get access to Ubuntu One across your devices.") | 53 | "once to get access to Ubuntu One across your devices.") |
266 | 53 | TERMS = _("By signing up to Ubuntu One you agree to our Terms " | 54 | TERMS = _("By signing up to Ubuntu One you agree to our " |
267 | 54 | "of Service and Privacy Policy") | 55 | "{terms_and_conditions} and {privacy_policy}") |
268 | 56 | TERMS_LINK = _("<a href='https://one.ubuntu.com/terms/'>" | ||
269 | 57 | "<span style='color:#df2d1f;'>Terms of Service</span></a>") | ||
270 | 58 | PRIVACY_POLICY_LINK = _("<a href='https://one.ubuntu.com/privacy/'>" | ||
271 | 59 | "<span style='color:#df2d1f;'>Privacy Policy" | ||
272 | 60 | "</span></a></font>") | ||
273 | 55 | TITLE = _("Sign Up to Ubuntu One") | 61 | TITLE = _("Sign Up to Ubuntu One") |
274 | 56 | 62 | ||
275 | 57 | 63 | ||
276 | @@ -62,6 +68,10 @@ | |||
277 | 62 | super(SetupAccountPage, self).__init__(*args, **kwargs) | 68 | super(SetupAccountPage, self).__init__(*args, **kwargs) |
278 | 63 | self.ui.password_edit.textEdited.connect( | 69 | self.ui.password_edit.textEdited.connect( |
279 | 64 | lambda: self.password_assistance(NORMAL)) | 70 | lambda: self.password_assistance(NORMAL)) |
280 | 71 | terms = TERMS.format(terms_and_conditions=TERMS_LINK, | ||
281 | 72 | privacy_policy=PRIVACY_POLICY_LINK) | ||
282 | 73 | self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms) | ||
283 | 74 | self.ui.hlayout_check.addWidget(self.terms_checkbox) | ||
284 | 65 | 75 | ||
285 | 66 | # The functions are placed based on the focus order of the widgets. | 76 | # The functions are placed based on the focus order of the widgets. |
286 | 67 | self.validation_functions = [ | 77 | self.validation_functions = [ |
287 | @@ -80,20 +90,28 @@ | |||
288 | 80 | title_page = TITLE_STYLE % TITLE | 90 | title_page = TITLE_STYLE % TITLE |
289 | 81 | self.setTitle(title_page) | 91 | self.setTitle(title_page) |
290 | 82 | self.setSubTitle(SUBTITLE) | 92 | self.setSubTitle(SUBTITLE) |
291 | 93 | # Set Setup Account button | ||
292 | 94 | self.wizard().setOption(QtGui.QWizard.HaveCustomButton3, True) | ||
293 | 95 | try: | ||
294 | 96 | self.wizard().customButtonClicked.disconnect() | ||
295 | 97 | except TypeError: | ||
296 | 98 | pass | ||
297 | 99 | self.setButtonText(QtGui.QWizard.CustomButton3, _('Set Up Account')) | ||
298 | 100 | self.set_up_button = self.wizard().button(QtGui.QWizard.CustomButton3) | ||
299 | 101 | self.set_up_button.clicked.connect(self.wizard().overlay.show) | ||
300 | 83 | 102 | ||
301 | 84 | self.ui.name_label.setText(NAME) | 103 | self.ui.name_label.setText(NAME) |
302 | 85 | self.ui.email_label.setText(EMAIL) | 104 | self.ui.email_label.setText(EMAIL) |
303 | 86 | self.ui.confirm_email_label.setText(RETYPE_EMAIL) | 105 | self.ui.confirm_email_label.setText(RETYPE_EMAIL) |
304 | 87 | self.ui.password_label.setText(PASSWORD) | 106 | self.ui.password_label.setText(PASSWORD) |
305 | 88 | self.ui.confirm_password_label.setText(RETYPE_PASSWORD) | 107 | self.ui.confirm_password_label.setText(RETYPE_PASSWORD) |
306 | 89 | self.ui.terms_checkbox.setText(TERMS) | ||
307 | 90 | self.ui.terms_button.setText(SHOW_TERMS) | ||
308 | 91 | self.ui.password_info_label.hide() | 108 | self.ui.password_info_label.hide() |
309 | 92 | 109 | ||
310 | 93 | # Button setup | 110 | # Button setup |
311 | 94 | self.wizard().setButtonLayout([ | 111 | self.wizard().setButtonLayout([ |
312 | 95 | QtGui.QWizard.BackButton, | 112 | QtGui.QWizard.BackButton, |
314 | 96 | QtGui.QWizard.Stretch]) | 113 | QtGui.QWizard.Stretch, |
315 | 114 | QtGui.QWizard.CustomButton3]) | ||
316 | 97 | 115 | ||
317 | 98 | self.password_default_assistance() | 116 | self.password_default_assistance() |
318 | 99 | # Hide assistance labels by default | 117 | # Hide assistance labels by default |
319 | @@ -215,10 +233,10 @@ | |||
320 | 215 | """Set set_up_button as default button when the page is shown.""" | 233 | """Set set_up_button as default button when the page is shown.""" |
321 | 216 | # This method should stays here because if we move it to initializePage | 234 | # This method should stays here because if we move it to initializePage |
322 | 217 | # set_up_button won't take the proper style for hover and press | 235 | # set_up_button won't take the proper style for hover and press |
327 | 218 | self.ui.set_up_button.setDefault(True) | 236 | self.set_up_button.setDefault(True) |
328 | 219 | self.ui.set_up_button.setProperty("DisabledState", True) | 237 | self.set_up_button.setProperty("DisabledState", True) |
329 | 220 | self.ui.set_up_button.style().unpolish(self.ui.set_up_button) | 238 | self.set_up_button.style().unpolish(self.set_up_button) |
330 | 221 | self.ui.set_up_button.style().polish(self.ui.set_up_button) | 239 | self.set_up_button.style().polish(self.set_up_button) |
331 | 222 | self.connect(QtGui.QApplication.instance(), | 240 | self.connect(QtGui.QApplication.instance(), |
332 | 223 | QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"), | 241 | QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"), |
333 | 224 | self.focus_changed) | 242 | self.focus_changed) |
334 | 225 | 243 | ||
335 | === added file 'ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py' | |||
336 | --- ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py 1970-01-01 00:00:00 +0000 | |||
337 | +++ ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py 2011-08-30 17:19:25 +0000 | |||
338 | @@ -0,0 +1,49 @@ | |||
339 | 1 | # -*- coding: utf-8 -*- | ||
340 | 2 | |||
341 | 3 | # Authors: Diego Sarmentero <diego.sarmentero@canonical.com> | ||
342 | 4 | # | ||
343 | 5 | # Copyright 2011 Canonical Ltd. | ||
344 | 6 | # | ||
345 | 7 | # This program is free software: you can redistribute it and/or modify it | ||
346 | 8 | # under the terms of the GNU General Public License version 3, as published | ||
347 | 9 | # by the Free Software Foundation. | ||
348 | 10 | # | ||
349 | 11 | # This program is distributed in the hope that it will be useful, but | ||
350 | 12 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
351 | 13 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
352 | 14 | # PURPOSE. See the GNU General Public License for more details. | ||
353 | 15 | # | ||
354 | 16 | # You should have received a copy of the GNU General Public License along | ||
355 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
356 | 18 | |||
357 | 19 | """Tests for the EnhancedCheckBox widget.""" | ||
358 | 20 | |||
359 | 21 | import re | ||
360 | 22 | |||
361 | 23 | from PyQt4 import QtCore | ||
362 | 24 | |||
363 | 25 | from ubuntuone_installer.gui.qt import enhanced_check_box | ||
364 | 26 | from ubuntuone_installer.gui.qt.tests import BaseTestCase | ||
365 | 27 | |||
366 | 28 | |||
367 | 29 | class EnhancedCheckBoxTestCase(BaseTestCase): | ||
368 | 30 | """Test the EnhancedCheckBox code.""" | ||
369 | 31 | |||
370 | 32 | def test_init(self): | ||
371 | 33 | """Check the initial state of EnhancedCheckBox.""" | ||
372 | 34 | check = enhanced_check_box.EnhancedCheckBox("text") | ||
373 | 35 | self.assertEqual(check.text(), "text") | ||
374 | 36 | self.assertTrue(check.text_label.openExternalLinks()) | ||
375 | 37 | style_sheet = unicode(check.text_label.styleSheet()) | ||
376 | 38 | size = re.sub("\D", "", style_sheet) | ||
377 | 39 | self.assertEqual(check.iconSize().width(), int(size)) | ||
378 | 40 | self.assertEqual(check.receivers( | ||
379 | 41 | QtCore.SIGNAL('stateChanged(int)')), 1) | ||
380 | 42 | |||
381 | 43 | def test_set_text(self): | ||
382 | 44 | """Check if override setText and text methods works properly.""" | ||
383 | 45 | check = enhanced_check_box.EnhancedCheckBox() | ||
384 | 46 | self.assertEqual(check.text_label.text(), "") | ||
385 | 47 | check.setText("text") | ||
386 | 48 | self.assertEqual(check.text(), "text") | ||
387 | 49 | self.assertEqual(check.text(), check.text_label.text()) | ||
388 | 0 | 50 | ||
389 | === modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py' | |||
390 | --- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-26 17:25:18 +0000 | |||
391 | +++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-30 17:19:25 +0000 | |||
392 | @@ -21,7 +21,6 @@ | |||
393 | 21 | 21 | ||
394 | 22 | import os | 22 | import os |
395 | 23 | 23 | ||
396 | 24 | from twisted.internet import defer | ||
397 | 25 | from PyQt4 import QtGui, QtCore | 24 | from PyQt4 import QtGui, QtCore |
398 | 26 | from ubuntuone.devtools.testcase import skipIfOS | 25 | from ubuntuone.devtools.testcase import skipIfOS |
399 | 27 | from ubuntuone.platform.credentials import APP_NAME | 26 | from ubuntuone.platform.credentials import APP_NAME |
400 | @@ -138,7 +137,6 @@ | |||
401 | 138 | # Faking each SSO object instead of doing it lower | 137 | # Faking each SSO object instead of doing it lower |
402 | 139 | # so we don't rely on any SSO behaviour | 138 | # so we don't rely on any SSO behaviour |
403 | 140 | self.patch(gui, "SetUpAccountController", FakeController) | 139 | self.patch(gui, "SetUpAccountController", FakeController) |
404 | 141 | self.patch(gui, "TosController", FakeController) | ||
405 | 142 | self.patch(gui, "EmailVerificationController", FakeController) | 140 | self.patch(gui, "EmailVerificationController", FakeController) |
406 | 143 | self.patch(gui, "CurrentUserController", FakeController) | 141 | self.patch(gui, "CurrentUserController", FakeController) |
407 | 144 | self.patch(gui, "SuccessController", FakeController) | 142 | self.patch(gui, "SuccessController", FakeController) |
408 | @@ -151,6 +149,18 @@ | |||
409 | 151 | self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel) | 149 | self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel) |
410 | 152 | super(MainWindowTestCase, self).setUp() | 150 | super(MainWindowTestCase, self).setUp() |
411 | 153 | 151 | ||
412 | 152 | def test_initialize_page(self): | ||
413 | 153 | """Check the initializePage to ensure proper widgets visibility.""" | ||
414 | 154 | setup_page = self.ui.page(self.ui.setup_account_page_id) | ||
415 | 155 | self.ui.setStartId(self.ui.setup_account_page_id) | ||
416 | 156 | self.ui.restart() | ||
417 | 157 | self.ui.show() | ||
418 | 158 | self.addCleanup(self.ui.hide) | ||
419 | 159 | self.assertFalse(setup_page.ui.name_assistance.isVisible()) | ||
420 | 160 | self.assertFalse(setup_page.ui.email_assistance.isVisible()) | ||
421 | 161 | self.assertFalse(setup_page.ui.confirm_email_assistance.isVisible()) | ||
422 | 162 | self.assertFalse(setup_page.ui.password_assistance.isVisible()) | ||
423 | 163 | |||
424 | 154 | def test_execute_uninstall_on_licence_cancel(self): | 164 | def test_execute_uninstall_on_licence_cancel(self): |
425 | 155 | """Pressing Disagree button from license page the uninstall is exec.""" | 165 | """Pressing Disagree button from license page the uninstall is exec.""" |
426 | 156 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) | 166 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) |
427 | @@ -280,11 +290,17 @@ | |||
428 | 280 | 290 | ||
429 | 281 | def test_overlay_connection_setup_account(self): | 291 | def test_overlay_connection_setup_account(self): |
430 | 282 | """Make sure we don't lose connections to the overlay.""" | 292 | """Make sure we don't lose connections to the overlay.""" |
431 | 293 | # Show the setup account page | ||
432 | 294 | setup_page = self.ui.page(self.ui.setup_account_page_id) | ||
433 | 295 | self.ui.setStartId(self.ui.setup_account_page_id) | ||
434 | 296 | self.ui.restart() | ||
435 | 297 | self.ui.show() | ||
436 | 298 | self.addCleanup(self.ui.hide) | ||
437 | 283 | self.assertEqual(self.ui.overlay.show_counter, 0) | 299 | self.assertEqual(self.ui.overlay.show_counter, 0) |
438 | 284 | # This test is different from the ones below. | 300 | # This test is different from the ones below. |
439 | 285 | # For some reason, click() doesn't trigger the connected | 301 | # For some reason, click() doesn't trigger the connected |
440 | 286 | # slot, but clicked.emit() does. The reason is unknown. | 302 | # slot, but clicked.emit() does. The reason is unknown. |
442 | 287 | self.ui.setup_account.ui.set_up_button.clicked.emit(False) | 303 | setup_page.set_up_button.clicked.emit(False) |
443 | 288 | self.assertEqual(self.ui.overlay.show_counter, 1) | 304 | self.assertEqual(self.ui.overlay.show_counter, 1) |
444 | 289 | 305 | ||
445 | 290 | def test_overlay_connection_email_verification(self): | 306 | def test_overlay_connection_email_verification(self): |
446 | @@ -494,51 +510,46 @@ | |||
447 | 494 | 510 | ||
448 | 495 | def test_stage_progression_4(self): | 511 | def test_stage_progression_4(self): |
449 | 496 | """Check that each page in the wizard sets the correct stage.""" | 512 | """Check that each page in the wizard sets the correct stage.""" |
451 | 497 | self.ui.on_currentIdChanged(self.ui.tos_page_id) | 513 | self.ui.on_currentIdChanged(self.ui.email_verification_page_id) |
452 | 498 | self.assertEqual(self.ui.sideWidget().stage, 1) | 514 | self.assertEqual(self.ui.sideWidget().stage, 1) |
453 | 499 | 515 | ||
454 | 500 | def test_stage_progression_5(self): | 516 | def test_stage_progression_5(self): |
455 | 501 | """Check that each page in the wizard sets the correct stage.""" | 517 | """Check that each page in the wizard sets the correct stage.""" |
457 | 502 | self.ui.on_currentIdChanged(self.ui.email_verification_page_id) | 518 | self.ui.on_currentIdChanged(self.ui.current_user_page_id) |
458 | 503 | self.assertEqual(self.ui.sideWidget().stage, 1) | 519 | self.assertEqual(self.ui.sideWidget().stage, 1) |
459 | 504 | 520 | ||
460 | 505 | def test_stage_progression_6(self): | 521 | def test_stage_progression_6(self): |
461 | 506 | """Check that each page in the wizard sets the correct stage.""" | 522 | """Check that each page in the wizard sets the correct stage.""" |
463 | 507 | self.ui.on_currentIdChanged(self.ui.current_user_page_id) | 523 | self.ui.on_currentIdChanged(self.ui.SUCCESS_PAGE) |
464 | 508 | self.assertEqual(self.ui.sideWidget().stage, 1) | 524 | self.assertEqual(self.ui.sideWidget().stage, 1) |
465 | 509 | 525 | ||
466 | 510 | def test_stage_progression_7(self): | 526 | def test_stage_progression_7(self): |
467 | 511 | """Check that each page in the wizard sets the correct stage.""" | 527 | """Check that each page in the wizard sets the correct stage.""" |
469 | 512 | self.ui.on_currentIdChanged(self.ui.SUCCESS_PAGE) | 528 | self.ui.on_currentIdChanged(self.ui.ERROR_PAGE) |
470 | 513 | self.assertEqual(self.ui.sideWidget().stage, 1) | 529 | self.assertEqual(self.ui.sideWidget().stage, 1) |
471 | 514 | 530 | ||
472 | 515 | def test_stage_progression_8(self): | 531 | def test_stage_progression_8(self): |
473 | 516 | """Check that each page in the wizard sets the correct stage.""" | 532 | """Check that each page in the wizard sets the correct stage.""" |
475 | 517 | self.ui.on_currentIdChanged(self.ui.ERROR_PAGE) | 533 | self.ui.on_currentIdChanged(self.ui.forgotten_password_page_id) |
476 | 518 | self.assertEqual(self.ui.sideWidget().stage, 1) | 534 | self.assertEqual(self.ui.sideWidget().stage, 1) |
477 | 519 | 535 | ||
478 | 520 | def test_stage_progression_9(self): | 536 | def test_stage_progression_9(self): |
479 | 521 | """Check that each page in the wizard sets the correct stage.""" | 537 | """Check that each page in the wizard sets the correct stage.""" |
481 | 522 | self.ui.on_currentIdChanged(self.ui.forgotten_password_page_id) | 538 | self.ui.on_currentIdChanged(self.ui.reset_password_page_id) |
482 | 523 | self.assertEqual(self.ui.sideWidget().stage, 1) | 539 | self.assertEqual(self.ui.sideWidget().stage, 1) |
483 | 524 | 540 | ||
484 | 525 | def test_stage_progression_10(self): | 541 | def test_stage_progression_10(self): |
485 | 526 | """Check that each page in the wizard sets the correct stage.""" | 542 | """Check that each page in the wizard sets the correct stage.""" |
488 | 527 | self.ui.on_currentIdChanged(self.ui.reset_password_page_id) | 543 | self.ui.on_currentIdChanged(self.ui.local_folders_page_id) |
489 | 528 | self.assertEqual(self.ui.sideWidget().stage, 1) | 544 | self.assertEqual(self.ui.sideWidget().stage, 3) |
490 | 529 | 545 | ||
491 | 530 | def test_stage_progression_11(self): | 546 | def test_stage_progression_11(self): |
492 | 531 | """Check that each page in the wizard sets the correct stage.""" | 547 | """Check that each page in the wizard sets the correct stage.""" |
494 | 532 | self.ui.on_currentIdChanged(self.ui.local_folders_page_id) | 548 | self.ui.on_currentIdChanged(self.ui.SYNC_NOW_OR_LATER_PAGE) |
495 | 533 | self.assertEqual(self.ui.sideWidget().stage, 3) | 549 | self.assertEqual(self.ui.sideWidget().stage, 3) |
496 | 534 | 550 | ||
497 | 535 | def test_stage_progression_12(self): | 551 | def test_stage_progression_12(self): |
498 | 536 | """Check that each page in the wizard sets the correct stage.""" | 552 | """Check that each page in the wizard sets the correct stage.""" |
499 | 537 | self.ui.on_currentIdChanged(self.ui.SYNC_NOW_OR_LATER_PAGE) | ||
500 | 538 | self.assertEqual(self.ui.sideWidget().stage, 3) | ||
501 | 539 | |||
502 | 540 | def test_stage_progression_13(self): | ||
503 | 541 | """Check that each page in the wizard sets the correct stage.""" | ||
504 | 542 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) | 553 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) |
505 | 543 | self.assertEqual(self.ui.sideWidget().stage, 4) | 554 | self.assertEqual(self.ui.sideWidget().stage, 4) |
506 | 544 | 555 | ||
507 | 545 | 556 | ||
508 | === modified file 'ubuntuone_installer/gui/qt/tests/test_setup_account.py' | |||
509 | --- ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-08-25 19:44:35 +0000 | |||
510 | +++ ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-08-30 17:19:25 +0000 | |||
511 | @@ -45,6 +45,8 @@ | |||
512 | 45 | class FakeWizard(object): | 45 | class FakeWizard(object): |
513 | 46 | """Replace wizard() function on wizard pages.""" | 46 | """Replace wizard() function on wizard pages.""" |
514 | 47 | 47 | ||
515 | 48 | customButtonClicked = QtCore.QObject() | ||
516 | 49 | overlay = None | ||
517 | 48 | params = None | 50 | params = None |
518 | 49 | 51 | ||
519 | 50 | # Invalid name "setButtonLayout" | 52 | # Invalid name "setButtonLayout" |
520 | @@ -56,6 +58,19 @@ | |||
521 | 56 | 58 | ||
522 | 57 | # pylint: enable=C0103 | 59 | # pylint: enable=C0103 |
523 | 58 | 60 | ||
524 | 61 | # Invalid name "setOption" | ||
525 | 62 | # pylint: disable=C0103 | ||
526 | 63 | |||
527 | 64 | def setOption(self, *args, **kwargs): | ||
528 | 65 | """Fake the functionality of setOption on QWizard class.""" | ||
529 | 66 | FakeWizard.params = (args, kwargs) | ||
530 | 67 | |||
531 | 68 | # pylint: enable=C0103 | ||
532 | 69 | |||
533 | 70 | def button(self, *args, **kwargs): | ||
534 | 71 | """Fake the functionality of button on QWizard class.""" | ||
535 | 72 | return QtGui.QPushButton() | ||
536 | 73 | |||
537 | 59 | 74 | ||
538 | 60 | class FakeValidationDict(object): | 75 | class FakeValidationDict(object): |
539 | 61 | """A Fake dictionary to replace validation_functions on Setup Account.""" | 76 | """A Fake dictionary to replace validation_functions on Setup Account.""" |
540 | @@ -104,20 +119,6 @@ | |||
541 | 104 | QtCore.SIGNAL('textEdited(QString)')), 1) | 119 | QtCore.SIGNAL('textEdited(QString)')), 1) |
542 | 105 | self.assertTrue(self.ui.validation_functions) | 120 | self.assertTrue(self.ui.validation_functions) |
543 | 106 | 121 | ||
544 | 107 | def test_initialize_page(self): | ||
545 | 108 | """Check the initializePage to ensure proper widgets visibility.""" | ||
546 | 109 | self.ui.show() | ||
547 | 110 | self.addCleanup(self.ui.hide) | ||
548 | 111 | self.patch(self.ui, 'wizard', FakeWizard) | ||
549 | 112 | self.ui.initializePage() | ||
550 | 113 | self.assertEqual(FakeWizard.params, (([ | ||
551 | 114 | QtGui.QWizard.BackButton, | ||
552 | 115 | QtGui.QWizard.Stretch],), {})) | ||
553 | 116 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) | ||
554 | 117 | self.assertFalse(self.ui.ui.email_assistance.isVisible()) | ||
555 | 118 | self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible()) | ||
556 | 119 | self.assertFalse(self.ui.ui.password_assistance.isVisible()) | ||
557 | 120 | |||
558 | 121 | def test_empty_name(self): | 122 | def test_empty_name(self): |
559 | 122 | """Status when the name field is empty. | 123 | """Status when the name field is empty. |
560 | 123 | 124 | ||
561 | @@ -134,92 +135,6 @@ | |||
562 | 134 | setup_account.ERROR % setup_account.EMPTY_NAME) | 135 | setup_account.ERROR % setup_account.EMPTY_NAME) |
563 | 135 | self.ui.hide() | 136 | self.ui.hide() |
564 | 136 | 137 | ||
565 | 137 | def test_blank_name(self): | ||
566 | 138 | """Status when the name field is blank (spaces). | ||
567 | 139 | |||
568 | 140 | * Name Assistance label visible. | ||
569 | 141 | * Correct error message in it. | ||
570 | 142 | """ | ||
571 | 143 | self.ui.ui.name_edit.setText(" ") | ||
572 | 144 | self.ui.name_assistance() | ||
573 | 145 | self.ui.show() | ||
574 | 146 | self.addCleanup(self.ui.hide) | ||
575 | 147 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) | ||
576 | 148 | self.assertEqual( | ||
577 | 149 | unicode(self.ui.ui.name_assistance.text()), | ||
578 | 150 | setup_account.ERROR % setup_account.EMPTY_NAME) | ||
579 | 151 | self.ui.hide() | ||
580 | 152 | |||
581 | 153 | def test_valid_name(self): | ||
582 | 154 | """Status when the name field is valid. | ||
583 | 155 | |||
584 | 156 | * Name Assistance label invisible. | ||
585 | 157 | """ | ||
586 | 158 | self.ui.ui.name_edit.setText("John Doe") | ||
587 | 159 | self.ui.name_assistance() | ||
588 | 160 | self.ui.show() | ||
589 | 161 | self.addCleanup(self.ui.hide) | ||
590 | 162 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) | ||
591 | 163 | self.ui.hide() | ||
592 | 164 | |||
593 | 165 | def test_invalid_email(self): | ||
594 | 166 | """Status when the email field has no @. | ||
595 | 167 | |||
596 | 168 | * Email Assistance label visible. | ||
597 | 169 | * Correct error message in it. | ||
598 | 170 | """ | ||
599 | 171 | self.ui.ui.email_edit.setText("foobar") | ||
600 | 172 | self.ui.email_assistance() | ||
601 | 173 | self.ui.show() | ||
602 | 174 | self.addCleanup(self.ui.hide) | ||
603 | 175 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) | ||
604 | 176 | self.assertEqual( | ||
605 | 177 | unicode(self.ui.ui.email_assistance.text()), | ||
606 | 178 | setup_account.ERROR % setup_account.INVALID_EMAIL) | ||
607 | 179 | self.ui.hide() | ||
608 | 180 | |||
609 | 181 | def test_valid_email(self): | ||
610 | 182 | """Status when the email field has a @. | ||
611 | 183 | |||
612 | 184 | * Email Assistance label invisible. | ||
613 | 185 | """ | ||
614 | 186 | self.ui.ui.email_edit.setText("foo@bar") | ||
615 | 187 | self.ui.email_assistance() | ||
616 | 188 | self.ui.show() | ||
617 | 189 | self.addCleanup(self.ui.hide) | ||
618 | 190 | self.assertFalse(self.ui.ui.email_assistance.isVisible()) | ||
619 | 191 | self.ui.hide() | ||
620 | 192 | |||
621 | 193 | def test_matching_emails(self): | ||
622 | 194 | """Status when the email fields match. | ||
623 | 195 | |||
624 | 196 | * Email Assistance label invisible. | ||
625 | 197 | """ | ||
626 | 198 | self.ui.ui.email_edit.setText("foo@bar") | ||
627 | 199 | self.ui.ui.confirm_email_edit.setText("foo@bar") | ||
628 | 200 | self.ui.confirm_email_assistance() | ||
629 | 201 | self.ui.show() | ||
630 | 202 | self.addCleanup(self.ui.hide) | ||
631 | 203 | self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible()) | ||
632 | 204 | self.ui.hide() | ||
633 | 205 | |||
634 | 206 | def test_not_matching_emails(self): | ||
635 | 207 | """Status when the email fields don't match. | ||
636 | 208 | |||
637 | 209 | * Email Assistance label visible. | ||
638 | 210 | * Correct error message. | ||
639 | 211 | """ | ||
640 | 212 | self.ui.ui.email_edit.setText("foo@bar") | ||
641 | 213 | self.ui.ui.confirm_email_edit.setText("foo@baz") | ||
642 | 214 | self.ui.confirm_email_assistance() | ||
643 | 215 | self.ui.show() | ||
644 | 216 | self.addCleanup(self.ui.hide) | ||
645 | 217 | self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible()) | ||
646 | 218 | self.assertEqual( | ||
647 | 219 | unicode(self.ui.ui.confirm_email_assistance.text()), | ||
648 | 220 | setup_account.ERROR % setup_account.EMAIL_MATCH) | ||
649 | 221 | self.ui.hide() | ||
650 | 222 | |||
651 | 223 | def test_short_password(self): | 138 | def test_short_password(self): |
652 | 224 | """Status with short password. | 139 | """Status with short password. |
653 | 225 | 140 | ||
654 | @@ -474,6 +389,109 @@ | |||
655 | 474 | self.assertTrue(getattr(FakeValidationDict, "valid2")) | 389 | self.assertTrue(getattr(FakeValidationDict, "valid2")) |
656 | 475 | self.assertTrue(getattr(FakeValidationDict, "valid3")) | 390 | self.assertTrue(getattr(FakeValidationDict, "valid3")) |
657 | 476 | 391 | ||
658 | 392 | |||
659 | 393 | class SetupAccountFakeWizardTestCase(BaseTestCase): | ||
660 | 394 | """Test the SetupAccountPage code.""" | ||
661 | 395 | |||
662 | 396 | class_ui = setup_account.SetupAccountPage | ||
663 | 397 | kwargs = dict( | ||
664 | 398 | ui=setup_account_ui.Ui_SetUpAccountPage(), | ||
665 | 399 | controller=FakeController(), | ||
666 | 400 | parent=None, | ||
667 | 401 | ) | ||
668 | 402 | |||
669 | 403 | def setUp(self): | ||
670 | 404 | """Initialize this test instance.""" | ||
671 | 405 | # Faking each SSO object instead of doing it lower | ||
672 | 406 | # so we don't rely on any SSO behaviour | ||
673 | 407 | super(SetupAccountFakeWizardTestCase, self).setUp() | ||
674 | 408 | self.patch(self.ui, 'wizard', FakeWizard) | ||
675 | 409 | |||
676 | 410 | def test_blank_name(self): | ||
677 | 411 | """Status when the name field is blank (spaces). | ||
678 | 412 | |||
679 | 413 | * Name Assistance label visible. | ||
680 | 414 | * Correct error message in it. | ||
681 | 415 | """ | ||
682 | 416 | self.ui.ui.name_edit.setText(" ") | ||
683 | 417 | self.ui.name_assistance() | ||
684 | 418 | self.ui.show() | ||
685 | 419 | self.addCleanup(self.ui.hide) | ||
686 | 420 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) | ||
687 | 421 | self.assertEqual( | ||
688 | 422 | unicode(self.ui.ui.name_assistance.text()), | ||
689 | 423 | setup_account.ERROR % setup_account.EMPTY_NAME) | ||
690 | 424 | self.ui.hide() | ||
691 | 425 | |||
692 | 426 | def test_valid_name(self): | ||
693 | 427 | """Status when the name field is valid. | ||
694 | 428 | |||
695 | 429 | * Name Assistance label invisible. | ||
696 | 430 | """ | ||
697 | 431 | self.ui.ui.name_edit.setText("John Doe") | ||
698 | 432 | self.ui.name_assistance() | ||
699 | 433 | self.ui.show() | ||
700 | 434 | self.addCleanup(self.ui.hide) | ||
701 | 435 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) | ||
702 | 436 | self.ui.hide() | ||
703 | 437 | |||
704 | 438 | def test_invalid_email(self): | ||
705 | 439 | """Status when the email field has no @. | ||
706 | 440 | |||
707 | 441 | * Email Assistance label visible. | ||
708 | 442 | * Correct error message in it. | ||
709 | 443 | """ | ||
710 | 444 | self.ui.ui.email_edit.setText("foobar") | ||
711 | 445 | self.ui.email_assistance() | ||
712 | 446 | self.ui.show() | ||
713 | 447 | self.addCleanup(self.ui.hide) | ||
714 | 448 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) | ||
715 | 449 | self.assertEqual( | ||
716 | 450 | unicode(self.ui.ui.email_assistance.text()), | ||
717 | 451 | setup_account.ERROR % setup_account.INVALID_EMAIL) | ||
718 | 452 | |||
719 | 453 | def test_valid_email(self): | ||
720 | 454 | """Status when the email field has a @. | ||
721 | 455 | |||
722 | 456 | * Email Assistance label invisible. | ||
723 | 457 | """ | ||
724 | 458 | self.ui.ui.email_edit.setText("foo@bar") | ||
725 | 459 | self.ui.email_assistance() | ||
726 | 460 | self.ui.show() | ||
727 | 461 | self.addCleanup(self.ui.hide) | ||
728 | 462 | self.assertFalse(self.ui.ui.email_assistance.isVisible()) | ||
729 | 463 | self.ui.hide() | ||
730 | 464 | |||
731 | 465 | def test_matching_emails(self): | ||
732 | 466 | """Status when the email fields match. | ||
733 | 467 | |||
734 | 468 | * Email Assistance label invisible. | ||
735 | 469 | """ | ||
736 | 470 | self.ui.ui.email_edit.setText("foo@bar") | ||
737 | 471 | self.ui.ui.confirm_email_edit.setText("foo@bar") | ||
738 | 472 | self.ui.confirm_email_assistance() | ||
739 | 473 | self.ui.show() | ||
740 | 474 | self.addCleanup(self.ui.hide) | ||
741 | 475 | self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible()) | ||
742 | 476 | self.ui.hide() | ||
743 | 477 | |||
744 | 478 | def test_not_matching_emails(self): | ||
745 | 479 | """Status when the email fields don't match. | ||
746 | 480 | |||
747 | 481 | * Email Assistance label visible. | ||
748 | 482 | * Correct error message. | ||
749 | 483 | """ | ||
750 | 484 | self.ui.ui.email_edit.setText("foo@bar") | ||
751 | 485 | self.ui.ui.confirm_email_edit.setText("foo@baz") | ||
752 | 486 | self.ui.confirm_email_assistance() | ||
753 | 487 | self.ui.show() | ||
754 | 488 | self.addCleanup(self.ui.hide) | ||
755 | 489 | self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible()) | ||
756 | 490 | self.assertEqual( | ||
757 | 491 | unicode(self.ui.ui.confirm_email_assistance.text()), | ||
758 | 492 | setup_account.ERROR % setup_account.EMAIL_MATCH) | ||
759 | 493 | self.ui.hide() | ||
760 | 494 | |||
761 | 477 | def test_focus_changed_password_visibility(self): | 495 | def test_focus_changed_password_visibility(self): |
762 | 478 | """Check visibility changes when focus_changed() is executed.""" | 496 | """Check visibility changes when focus_changed() is executed.""" |
763 | 479 | self.ui.show() | 497 | self.ui.show() |
764 | 480 | 498 | ||
765 | === removed file 'ubuntuone_installer/gui/qt/tos.py' | |||
766 | --- ubuntuone_installer/gui/qt/tos.py 2011-07-28 18:24:58 +0000 | |||
767 | +++ ubuntuone_installer/gui/qt/tos.py 1970-01-01 00:00:00 +0000 | |||
768 | @@ -1,64 +0,0 @@ | |||
769 | 1 | # -*- coding: utf-8 -*- | ||
770 | 2 | |||
771 | 3 | # Authors: Roberto Alsina <roberto.alsina@canonical.com> | ||
772 | 4 | # | ||
773 | 5 | # Copyright 2011 Canonical Ltd. | ||
774 | 6 | # | ||
775 | 7 | # This program is free software: you can redistribute it and/or modify it | ||
776 | 8 | # under the terms of the GNU General Public License version 3, as published | ||
777 | 9 | # by the Free Software Foundation. | ||
778 | 10 | # | ||
779 | 11 | # This program is distributed in the hope that it will be useful, but | ||
780 | 12 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
781 | 13 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
782 | 14 | # PURPOSE. See the GNU General Public License for more details. | ||
783 | 15 | # | ||
784 | 16 | # You should have received a copy of the GNU General Public License along | ||
785 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
786 | 18 | |||
787 | 19 | """Widget to view the Terms Of Service.""" | ||
788 | 20 | |||
789 | 21 | import gettext | ||
790 | 22 | |||
791 | 23 | from PyQt4 import QtGui | ||
792 | 24 | |||
793 | 25 | import ubuntu_sso.qt.gui as sso_gui | ||
794 | 26 | |||
795 | 27 | _ = gettext.gettext | ||
796 | 28 | |||
797 | 29 | |||
798 | 30 | class TosPage(sso_gui.TosPage): | ||
799 | 31 | |||
800 | 32 | """Page to display the Terms of Service.""" | ||
801 | 33 | |||
802 | 34 | # initializePage is inherited | ||
803 | 35 | # pylint: disable=C0103 | ||
804 | 36 | def initializePage(self): | ||
805 | 37 | """Setup UI details.""" | ||
806 | 38 | # Set the right texts and connections for buttons | ||
807 | 39 | self.setButtonText(QtGui.QWizard.NextButton, _("Agree && Install")) | ||
808 | 40 | self.setButtonText(QtGui.QWizard.CancelButton, | ||
809 | 41 | _("Disagree && Cancel")) | ||
810 | 42 | self.setButtonText(QtGui.QWizard.CustomButton1, _("&Print")) | ||
811 | 43 | |||
812 | 44 | # This is just to catch an exception thrown when nothing | ||
813 | 45 | # is connected to the signal. It's not an exceptional | ||
814 | 46 | # condition at all. | ||
815 | 47 | try: | ||
816 | 48 | self.wizard().customButtonClicked.disconnect() | ||
817 | 49 | except TypeError: | ||
818 | 50 | pass | ||
819 | 51 | |||
820 | 52 | self.wizard().customButtonClicked.connect(self.print_document) | ||
821 | 53 | |||
822 | 54 | self.wizard().setButtonLayout([ | ||
823 | 55 | QtGui.QWizard.CustomButton1, | ||
824 | 56 | QtGui.QWizard.BackButton, | ||
825 | 57 | QtGui.QWizard.Stretch]) | ||
826 | 58 | |||
827 | 59 | def print_document(self, button_id): | ||
828 | 60 | """Print the document displayed in textBrowser.""" | ||
829 | 61 | if button_id == QtGui.QWizard.CustomButton1: | ||
830 | 62 | previewer = QtGui.QPrintPreviewDialog( | ||
831 | 63 | paintRequested=self.ui.terms_webkit.print_) | ||
832 | 64 | previewer.exec_() |
Looks good to me.