Merge lp:~diegosarmentero/ubuntuone-windows-installer/setup-buttons into lp:ubuntuone-windows-installer

Proposed by Diego Sarmentero
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
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+73251@code.launchpad.net

Commit message

Modified setup account page to reduce the height size.

Description of the change

Modified setup account page to reduce the height size.

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

merge

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

Looks good to me.

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

* Please call super() instead of QtGui.QCheckBox.__init__(self).

* Why re you removing the overlay shown when the setup button is clicked?

        self.setup_account.ui.set_up_button.clicked.connect(
            self.overlay.show)

* 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_conditions} and {privacy_policy}"

and then call format like this:

terms = TERMS.format(terms_and_conditions=TERMS_LINK,
                     privacy_policy=PRIVACY_POLICY_LINK)
self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms)

* Why are you calling

         self.terms_checkbox.setText(
            TERMS.format(TERMS_LINK, PRIVACY_POLICY_LINK)

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_connection_setup_account, can you call self.ui.set_up_button.clicked.emit(False) instead of self.ui.button(QtGui.QWizard.CustomButton3).clicked.emit(False)?

* If you're patching self.patch(self.ui, 'wizard', FakeWizard) in every test method in SetupAccountTestCase, please add that to the setUp method to avoid duplication.

Great work on the tests for the new widget!

review: Needs Fixing
42. By Diego Sarmentero

Changes from review applied.

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

> self.setup_account.ui.set_up_button.clicked.connect(
> 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 SetupAccountTestCase, please add that to the setUp method to avoid
> 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.

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

> > * If you're patching self.patch(self.ui, 'wizard', FakeWizard) in every test
> > method in SetupAccountTestCase, please add that to the setUp method to avoid
> > 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.

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

looks good!

review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches