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
=== modified file 'data/qt/setup_account.ui'
--- data/qt/setup_account.ui 2011-08-25 11:32:23 +0000
+++ data/qt/setup_account.ui 2011-08-30 17:19:25 +0000
@@ -6,14 +6,29 @@
6 <rect>6 <rect>
7 <x>0</x>7 <x>0</x>
8 <y>0</y>8 <y>0</y>
9 <width>575</width>9 <width>583</width>
10 <height>573</height>10 <height>538</height>
11 </rect>11 </rect>
12 </property>12 </property>
13 <property name="sizePolicy">
14 <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
15 <horstretch>0</horstretch>
16 <verstretch>0</verstretch>
17 </sizepolicy>
18 </property>
19 <property name="maximumSize">
20 <size>
21 <width>16777215</width>
22 <height>16777215</height>
23 </size>
24 </property>
13 <property name="windowTitle">25 <property name="windowTitle">
14 <string>WizardPage</string>26 <string>WizardPage</string>
15 </property>27 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">28 <layout class="QVBoxLayout" name="verticalLayout">
29 <property name="spacing">
30 <number>0</number>
31 </property>
17 <property name="rightMargin">32 <property name="rightMargin">
18 <number>6</number>33 <number>6</number>
19 </property>34 </property>
@@ -309,7 +324,7 @@
309 </item>324 </item>
310 </layout>325 </layout>
311 </item>326 </item>
312 <item row="8" column="0">327 <item row="9" column="0">
313 <layout class="QVBoxLayout" name="verticalLayout">328 <layout class="QVBoxLayout" name="verticalLayout">
314 <property name="spacing">329 <property name="spacing">
315 <number>3</number>330 <number>3</number>
@@ -389,7 +404,7 @@
389 </item>404 </item>
390 </layout>405 </layout>
391 </item>406 </item>
392 <item row="8" column="1">407 <item row="9" column="1">
393 <widget class="QLabel" name="refresh_label">408 <widget class="QLabel" name="refresh_label">
394 <property name="sizePolicy">409 <property name="sizePolicy">
395 <sizepolicy hsizetype="Maximum" vsizetype="Preferred">410 <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
@@ -558,56 +573,29 @@
558 </property>573 </property>
559 </spacer>574 </spacer>
560 </item>575 </item>
576 <item row="8" column="1">
577 <spacer name="verticalSpacer_3">
578 <property name="orientation">
579 <enum>Qt::Vertical</enum>
580 </property>
581 <property name="sizeType">
582 <enum>QSizePolicy::Fixed</enum>
583 </property>
584 <property name="sizeHint" stdset="0">
585 <size>
586 <width>20</width>
587 <height>20</height>
588 </size>
589 </property>
590 </spacer>
591 </item>
561 </layout>592 </layout>
562 </item>593 </item>
563 <item>594 <item>
564 <widget class="QCheckBox" name="terms_checkbox">595 <layout class="QHBoxLayout" name="hlayout_check">
565 <property name="text">
566 <string>By signing up you agree blah blah</string>
567 </property>
568 </widget>
569 </item>
570 <item>
571 <layout class="QHBoxLayout" name="horizontalLayout_4">
572 <property name="spacing">596 <property name="spacing">
573 <number>0</number>597 <number>0</number>
574 </property>598 </property>
575 <item>
576 <widget class="QPushButton" name="terms_button">
577 <property name="text">
578 <string>Show terms</string>
579 </property>
580 </widget>
581 </item>
582 <item>
583 <spacer name="horizontalSpacer_3">
584 <property name="orientation">
585 <enum>Qt::Horizontal</enum>
586 </property>
587 <property name="sizeHint" stdset="0">
588 <size>
589 <width>40</width>
590 <height>20</height>
591 </size>
592 </property>
593 </spacer>
594 </item>
595 <item>
596 <widget class="QPushButton" name="set_up_button">
597 <property name="enabled">
598 <bool>false</bool>
599 </property>
600 <property name="styleSheet">
601 <string notr="true"/>
602 </property>
603 <property name="text">
604 <string>Set Up Account</string>
605 </property>
606 <property name="DisabledState" stdset="0">
607 <bool>true</bool>
608 </property>
609 </widget>
610 </item>
611 </layout>599 </layout>
612 </item>600 </item>
613 </layout>601 </layout>
614602
=== added file 'ubuntuone_installer/gui/qt/enhanced_check_box.py'
--- ubuntuone_installer/gui/qt/enhanced_check_box.py 1970-01-01 00:00:00 +0000
+++ ubuntuone_installer/gui/qt/enhanced_check_box.py 2011-08-30 17:19:25 +0000
@@ -0,0 +1,50 @@
1# -*- coding: utf-8 -*-
2
3# Authors: Diego Sarmentero <diego.sarmentero@canonical.com>
4#
5# Copyright 2011 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published
9# by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranties of
13# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14# PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.
18
19"""Customized Check Box to support links."""
20
21from PyQt4 import QtGui
22
23
24class EnhancedCheckBox(QtGui.QCheckBox):
25 """Enhanced QCheckBox to support links in the message displayed."""
26
27 def __init__(self, text=""):
28 QtGui.QCheckBox.__init__(self)
29 hbox = QtGui.QHBoxLayout()
30 self.text_label = QtGui.QLabel(text)
31 self.text_label.setOpenExternalLinks(True)
32 padding = self.iconSize().width()
33 self.text_label.setStyleSheet("padding-left: {0}px;".format(padding))
34 hbox.addWidget(self.text_label)
35 self.setLayout(hbox)
36
37 self.stateChanged.connect(self.text_label.setFocus)
38
39 def text(self):
40 """Return the text of this widget."""
41 return self.text_label.text()
42
43 # Invalid name "setText"
44 # pylint: disable=C0103
45
46 def setText(self, text):
47 """Set a new text to this widget."""
48 self.text_label.setText(text)
49
50 # pylint: enable=C0103
051
=== modified file 'ubuntuone_installer/gui/qt/gui.py'
--- ubuntuone_installer/gui/qt/gui.py 2011-08-29 12:41:02 +0000
+++ ubuntuone_installer/gui/qt/gui.py 2011-08-30 17:19:25 +0000
@@ -40,7 +40,6 @@
40from ubuntu_sso.qt.email_verification_ui import \40from ubuntu_sso.qt.email_verification_ui import \
41 Ui_EmailVerificationPage41 Ui_EmailVerificationPage
42from ubuntu_sso.qt.error_message_ui import Ui_ErrorPage42from ubuntu_sso.qt.error_message_ui import Ui_ErrorPage
43from ubuntu_sso.qt.terms_and_conditions_ui import Ui_TosPage
44from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage43from ubuntu_sso.qt.success_message_ui import Ui_SuccessPage
45from ubuntu_sso.qt.forgotten_password_ui import \44from ubuntu_sso.qt.forgotten_password_ui import \
46 Ui_ForgottenPasswordPage45 Ui_ForgottenPasswordPage
@@ -52,7 +51,6 @@
52 ResetPasswordController,51 ResetPasswordController,
53 SetUpAccountController,52 SetUpAccountController,
54 SuccessController,53 SuccessController,
55 TosController,
56)54)
5755
58from ubuntuone.controlpanel.gui.qt.loadingoverlay import LoadingOverlay56from ubuntuone.controlpanel.gui.qt.loadingoverlay import LoadingOverlay
@@ -80,7 +78,6 @@
80from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage78from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage
81from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage79from ubuntuone_installer.gui.qt.setup_account import SetupAccountPage
82from ubuntuone_installer.gui.qt.side_widget import SideWidget80from ubuntuone_installer.gui.qt.side_widget import SideWidget
83from ubuntuone_installer.gui.qt.tos import TosPage
8481
85_ = gettext.gettext82_ = gettext.gettext
86SIGN_IN = _("Sign in to Ubuntu One")83SIGN_IN = _("Sign in to Ubuntu One")
@@ -279,7 +276,7 @@
279 super(MainWindow, self).__init__()276 super(MainWindow, self).__init__()
280277
281 self.setWindowTitle(APP_NAME)278 self.setWindowTitle(APP_NAME)
282 self.setMinimumHeight(630)279 self.setMinimumHeight(590)
283 self.setMinimumWidth(800)280 self.setMinimumWidth(800)
284 self.setWizardStyle(self.ModernStyle)281 self.setWizardStyle(self.ModernStyle)
285 self.close_callback = close_callback282 self.close_callback = close_callback
@@ -316,14 +313,6 @@
316 setup_account_ui.Ui_SetUpAccountPage(),313 setup_account_ui.Ui_SetUpAccountPage(),
317 self.setup_controller,314 self.setup_controller,
318 parent=self)315 parent=self)
319 self.setup_account.ui.set_up_button.clicked.connect(
320 self.overlay.show)
321
322 title_page = TITLE_STYLE % _("Ubuntu One Terms of Service")
323 self.tos = TosPage(Ui_TosPage(),
324 TosController(tos_url=TC_URL,
325 title=title_page),
326 parent=self)
327316
328 self.email_verification = EmailVerificationPage(317 self.email_verification = EmailVerificationPage(
329 Ui_EmailVerificationPage(),318 Ui_EmailVerificationPage(),
@@ -363,7 +352,6 @@
363352
364 self.SIGNIN_PAGE = self.addPage(self.sign_in_page)353 self.SIGNIN_PAGE = self.addPage(self.sign_in_page)
365 self.setup_account_page_id = self.addPage(self.setup_account)354 self.setup_account_page_id = self.addPage(self.setup_account)
366 self.tos_page_id = self.addPage(self.tos)
367 self.email_verification_page_id = self.addPage(self.email_verification)355 self.email_verification_page_id = self.addPage(self.email_verification)
368 self.current_user_page_id = self.addPage(self.current_user)356 self.current_user_page_id = self.addPage(self.current_user)
369 self.SUCCESS_PAGE = self.addPage(self.success)357 self.SUCCESS_PAGE = self.addPage(self.success)
370358
=== modified file 'ubuntuone_installer/gui/qt/setup_account.py'
--- ubuntuone_installer/gui/qt/setup_account.py 2011-08-25 17:07:42 +0000
+++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-30 17:19:25 +0000
@@ -25,6 +25,8 @@
2525
26from ubuntu_sso.qt import gui as sso_gui26from ubuntu_sso.qt import gui as sso_gui
2727
28from ubuntuone_installer.gui.qt import enhanced_check_box
29
28_ = gettext.gettext30_ = gettext.gettext
2931
30# pylint: disable=C010332# pylint: disable=C0103
@@ -47,11 +49,15 @@
47PASSWORD_MUST_CONTAIN = _("Your password must contain")49PASSWORD_MUST_CONTAIN = _("Your password must contain")
48RETYPE_EMAIL = _("Retype email")50RETYPE_EMAIL = _("Retype email")
49RETYPE_PASSWORD = _("Retype password")51RETYPE_PASSWORD = _("Retype password")
50SHOW_TERMS = _("Show Terms of Service")52SUBTITLE = _("You only need to set up your account "
51SUBTITLE = _("You only need to set up your account " \
52 "once to get access to Ubuntu One across your devices.")53 "once to get access to Ubuntu One across your devices.")
53TERMS = _("By signing up to Ubuntu One you agree to our Terms "54TERMS = _("By signing up to Ubuntu One you agree to our "
54 "of Service and Privacy Policy")55 "{terms_and_conditions} and {privacy_policy}")
56TERMS_LINK = _("<a href='https://one.ubuntu.com/terms/'>"
57 "<span style='color:#df2d1f;'>Terms of Service</span></a>")
58PRIVACY_POLICY_LINK = _("<a href='https://one.ubuntu.com/privacy/'>"
59 "<span style='color:#df2d1f;'>Privacy Policy"
60 "</span></a></font>")
55TITLE = _("Sign Up to Ubuntu One")61TITLE = _("Sign Up to Ubuntu One")
5662
5763
@@ -62,6 +68,10 @@
62 super(SetupAccountPage, self).__init__(*args, **kwargs)68 super(SetupAccountPage, self).__init__(*args, **kwargs)
63 self.ui.password_edit.textEdited.connect(69 self.ui.password_edit.textEdited.connect(
64 lambda: self.password_assistance(NORMAL))70 lambda: self.password_assistance(NORMAL))
71 terms = TERMS.format(terms_and_conditions=TERMS_LINK,
72 privacy_policy=PRIVACY_POLICY_LINK)
73 self.terms_checkbox = enhanced_check_box.EnhancedCheckBox(terms)
74 self.ui.hlayout_check.addWidget(self.terms_checkbox)
6575
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.
67 self.validation_functions = [77 self.validation_functions = [
@@ -80,20 +90,28 @@
80 title_page = TITLE_STYLE % TITLE90 title_page = TITLE_STYLE % TITLE
81 self.setTitle(title_page)91 self.setTitle(title_page)
82 self.setSubTitle(SUBTITLE)92 self.setSubTitle(SUBTITLE)
93 # Set Setup Account button
94 self.wizard().setOption(QtGui.QWizard.HaveCustomButton3, True)
95 try:
96 self.wizard().customButtonClicked.disconnect()
97 except TypeError:
98 pass
99 self.setButtonText(QtGui.QWizard.CustomButton3, _('Set Up Account'))
100 self.set_up_button = self.wizard().button(QtGui.QWizard.CustomButton3)
101 self.set_up_button.clicked.connect(self.wizard().overlay.show)
83102
84 self.ui.name_label.setText(NAME)103 self.ui.name_label.setText(NAME)
85 self.ui.email_label.setText(EMAIL)104 self.ui.email_label.setText(EMAIL)
86 self.ui.confirm_email_label.setText(RETYPE_EMAIL)105 self.ui.confirm_email_label.setText(RETYPE_EMAIL)
87 self.ui.password_label.setText(PASSWORD)106 self.ui.password_label.setText(PASSWORD)
88 self.ui.confirm_password_label.setText(RETYPE_PASSWORD)107 self.ui.confirm_password_label.setText(RETYPE_PASSWORD)
89 self.ui.terms_checkbox.setText(TERMS)
90 self.ui.terms_button.setText(SHOW_TERMS)
91 self.ui.password_info_label.hide()108 self.ui.password_info_label.hide()
92109
93 # Button setup110 # Button setup
94 self.wizard().setButtonLayout([111 self.wizard().setButtonLayout([
95 QtGui.QWizard.BackButton,112 QtGui.QWizard.BackButton,
96 QtGui.QWizard.Stretch])113 QtGui.QWizard.Stretch,
114 QtGui.QWizard.CustomButton3])
97115
98 self.password_default_assistance()116 self.password_default_assistance()
99 # Hide assistance labels by default117 # Hide assistance labels by default
@@ -215,10 +233,10 @@
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."""
216 # This method should stays here because if we move it to initializePage234 # This method should stays here because if we move it to initializePage
217 # set_up_button won't take the proper style for hover and press235 # set_up_button won't take the proper style for hover and press
218 self.ui.set_up_button.setDefault(True)236 self.set_up_button.setDefault(True)
219 self.ui.set_up_button.setProperty("DisabledState", True)237 self.set_up_button.setProperty("DisabledState", True)
220 self.ui.set_up_button.style().unpolish(self.ui.set_up_button)238 self.set_up_button.style().unpolish(self.set_up_button)
221 self.ui.set_up_button.style().polish(self.ui.set_up_button)239 self.set_up_button.style().polish(self.set_up_button)
222 self.connect(QtGui.QApplication.instance(),240 self.connect(QtGui.QApplication.instance(),
223 QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"),241 QtCore.SIGNAL("focusChanged(QWidget*, QWidget*)"),
224 self.focus_changed)242 self.focus_changed)
225243
=== added file 'ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py'
--- ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py 1970-01-01 00:00:00 +0000
+++ ubuntuone_installer/gui/qt/tests/test_enhanced_check_box.py 2011-08-30 17:19:25 +0000
@@ -0,0 +1,49 @@
1# -*- coding: utf-8 -*-
2
3# Authors: Diego Sarmentero <diego.sarmentero@canonical.com>
4#
5# Copyright 2011 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published
9# by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranties of
13# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14# PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.
18
19"""Tests for the EnhancedCheckBox widget."""
20
21import re
22
23from PyQt4 import QtCore
24
25from ubuntuone_installer.gui.qt import enhanced_check_box
26from ubuntuone_installer.gui.qt.tests import BaseTestCase
27
28
29class EnhancedCheckBoxTestCase(BaseTestCase):
30 """Test the EnhancedCheckBox code."""
31
32 def test_init(self):
33 """Check the initial state of EnhancedCheckBox."""
34 check = enhanced_check_box.EnhancedCheckBox("text")
35 self.assertEqual(check.text(), "text")
36 self.assertTrue(check.text_label.openExternalLinks())
37 style_sheet = unicode(check.text_label.styleSheet())
38 size = re.sub("\D", "", style_sheet)
39 self.assertEqual(check.iconSize().width(), int(size))
40 self.assertEqual(check.receivers(
41 QtCore.SIGNAL('stateChanged(int)')), 1)
42
43 def test_set_text(self):
44 """Check if override setText and text methods works properly."""
45 check = enhanced_check_box.EnhancedCheckBox()
46 self.assertEqual(check.text_label.text(), "")
47 check.setText("text")
48 self.assertEqual(check.text(), "text")
49 self.assertEqual(check.text(), check.text_label.text())
050
=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-26 17:25:18 +0000
+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-30 17:19:25 +0000
@@ -21,7 +21,6 @@
2121
22import os22import os
2323
24from twisted.internet import defer
25from PyQt4 import QtGui, QtCore24from PyQt4 import QtGui, QtCore
26from ubuntuone.devtools.testcase import skipIfOS25from ubuntuone.devtools.testcase import skipIfOS
27from ubuntuone.platform.credentials import APP_NAME26from ubuntuone.platform.credentials import APP_NAME
@@ -138,7 +137,6 @@
138 # Faking each SSO object instead of doing it lower137 # Faking each SSO object instead of doing it lower
139 # so we don't rely on any SSO behaviour138 # so we don't rely on any SSO behaviour
140 self.patch(gui, "SetUpAccountController", FakeController)139 self.patch(gui, "SetUpAccountController", FakeController)
141 self.patch(gui, "TosController", FakeController)
142 self.patch(gui, "EmailVerificationController", FakeController)140 self.patch(gui, "EmailVerificationController", FakeController)
143 self.patch(gui, "CurrentUserController", FakeController)141 self.patch(gui, "CurrentUserController", FakeController)
144 self.patch(gui, "SuccessController", FakeController)142 self.patch(gui, "SuccessController", FakeController)
@@ -151,6 +149,18 @@
151 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)149 self.patch(qt.folders, "FoldersPanel", FakeFoldersPanel)
152 super(MainWindowTestCase, self).setUp()150 super(MainWindowTestCase, self).setUp()
153151
152 def test_initialize_page(self):
153 """Check the initializePage to ensure proper widgets visibility."""
154 setup_page = self.ui.page(self.ui.setup_account_page_id)
155 self.ui.setStartId(self.ui.setup_account_page_id)
156 self.ui.restart()
157 self.ui.show()
158 self.addCleanup(self.ui.hide)
159 self.assertFalse(setup_page.ui.name_assistance.isVisible())
160 self.assertFalse(setup_page.ui.email_assistance.isVisible())
161 self.assertFalse(setup_page.ui.confirm_email_assistance.isVisible())
162 self.assertFalse(setup_page.ui.password_assistance.isVisible())
163
154 def test_execute_uninstall_on_licence_cancel(self):164 def test_execute_uninstall_on_licence_cancel(self):
155 """Pressing Disagree button from license page the uninstall is exec."""165 """Pressing Disagree button from license page the uninstall is exec."""
156 self.ui.setStartId(self.ui.LICENSE_PAGE_ID)166 self.ui.setStartId(self.ui.LICENSE_PAGE_ID)
@@ -280,11 +290,17 @@
280290
281 def test_overlay_connection_setup_account(self):291 def test_overlay_connection_setup_account(self):
282 """Make sure we don't lose connections to the overlay."""292 """Make sure we don't lose connections to the overlay."""
293 # Show the setup account page
294 setup_page = self.ui.page(self.ui.setup_account_page_id)
295 self.ui.setStartId(self.ui.setup_account_page_id)
296 self.ui.restart()
297 self.ui.show()
298 self.addCleanup(self.ui.hide)
283 self.assertEqual(self.ui.overlay.show_counter, 0)299 self.assertEqual(self.ui.overlay.show_counter, 0)
284 # This test is different from the ones below.300 # This test is different from the ones below.
285 # For some reason, click() doesn't trigger the connected301 # For some reason, click() doesn't trigger the connected
286 # slot, but clicked.emit() does. The reason is unknown.302 # slot, but clicked.emit() does. The reason is unknown.
287 self.ui.setup_account.ui.set_up_button.clicked.emit(False)303 setup_page.set_up_button.clicked.emit(False)
288 self.assertEqual(self.ui.overlay.show_counter, 1)304 self.assertEqual(self.ui.overlay.show_counter, 1)
289305
290 def test_overlay_connection_email_verification(self):306 def test_overlay_connection_email_verification(self):
@@ -494,51 +510,46 @@
494510
495 def test_stage_progression_4(self):511 def test_stage_progression_4(self):
496 """Check that each page in the wizard sets the correct stage."""512 """Check that each page in the wizard sets the correct stage."""
497 self.ui.on_currentIdChanged(self.ui.tos_page_id)513 self.ui.on_currentIdChanged(self.ui.email_verification_page_id)
498 self.assertEqual(self.ui.sideWidget().stage, 1)514 self.assertEqual(self.ui.sideWidget().stage, 1)
499515
500 def test_stage_progression_5(self):516 def test_stage_progression_5(self):
501 """Check that each page in the wizard sets the correct stage."""517 """Check that each page in the wizard sets the correct stage."""
502 self.ui.on_currentIdChanged(self.ui.email_verification_page_id)518 self.ui.on_currentIdChanged(self.ui.current_user_page_id)
503 self.assertEqual(self.ui.sideWidget().stage, 1)519 self.assertEqual(self.ui.sideWidget().stage, 1)
504520
505 def test_stage_progression_6(self):521 def test_stage_progression_6(self):
506 """Check that each page in the wizard sets the correct stage."""522 """Check that each page in the wizard sets the correct stage."""
507 self.ui.on_currentIdChanged(self.ui.current_user_page_id)523 self.ui.on_currentIdChanged(self.ui.SUCCESS_PAGE)
508 self.assertEqual(self.ui.sideWidget().stage, 1)524 self.assertEqual(self.ui.sideWidget().stage, 1)
509525
510 def test_stage_progression_7(self):526 def test_stage_progression_7(self):
511 """Check that each page in the wizard sets the correct stage."""527 """Check that each page in the wizard sets the correct stage."""
512 self.ui.on_currentIdChanged(self.ui.SUCCESS_PAGE)528 self.ui.on_currentIdChanged(self.ui.ERROR_PAGE)
513 self.assertEqual(self.ui.sideWidget().stage, 1)529 self.assertEqual(self.ui.sideWidget().stage, 1)
514530
515 def test_stage_progression_8(self):531 def test_stage_progression_8(self):
516 """Check that each page in the wizard sets the correct stage."""532 """Check that each page in the wizard sets the correct stage."""
517 self.ui.on_currentIdChanged(self.ui.ERROR_PAGE)533 self.ui.on_currentIdChanged(self.ui.forgotten_password_page_id)
518 self.assertEqual(self.ui.sideWidget().stage, 1)534 self.assertEqual(self.ui.sideWidget().stage, 1)
519535
520 def test_stage_progression_9(self):536 def test_stage_progression_9(self):
521 """Check that each page in the wizard sets the correct stage."""537 """Check that each page in the wizard sets the correct stage."""
522 self.ui.on_currentIdChanged(self.ui.forgotten_password_page_id)538 self.ui.on_currentIdChanged(self.ui.reset_password_page_id)
523 self.assertEqual(self.ui.sideWidget().stage, 1)539 self.assertEqual(self.ui.sideWidget().stage, 1)
524540
525 def test_stage_progression_10(self):541 def test_stage_progression_10(self):
526 """Check that each page in the wizard sets the correct stage."""542 """Check that each page in the wizard sets the correct stage."""
527 self.ui.on_currentIdChanged(self.ui.reset_password_page_id)543 self.ui.on_currentIdChanged(self.ui.local_folders_page_id)
528 self.assertEqual(self.ui.sideWidget().stage, 1)544 self.assertEqual(self.ui.sideWidget().stage, 3)
529545
530 def test_stage_progression_11(self):546 def test_stage_progression_11(self):
531 """Check that each page in the wizard sets the correct stage."""547 """Check that each page in the wizard sets the correct stage."""
532 self.ui.on_currentIdChanged(self.ui.local_folders_page_id)548 self.ui.on_currentIdChanged(self.ui.SYNC_NOW_OR_LATER_PAGE)
533 self.assertEqual(self.ui.sideWidget().stage, 3)549 self.assertEqual(self.ui.sideWidget().stage, 3)
534550
535 def test_stage_progression_12(self):551 def test_stage_progression_12(self):
536 """Check that each page in the wizard sets the correct stage."""552 """Check that each page in the wizard sets the correct stage."""
537 self.ui.on_currentIdChanged(self.ui.SYNC_NOW_OR_LATER_PAGE)
538 self.assertEqual(self.ui.sideWidget().stage, 3)
539
540 def test_stage_progression_13(self):
541 """Check that each page in the wizard sets the correct stage."""
542 self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE)553 self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE)
543 self.assertEqual(self.ui.sideWidget().stage, 4)554 self.assertEqual(self.ui.sideWidget().stage, 4)
544555
545556
=== modified file 'ubuntuone_installer/gui/qt/tests/test_setup_account.py'
--- ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-08-25 19:44:35 +0000
+++ ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-08-30 17:19:25 +0000
@@ -45,6 +45,8 @@
45class FakeWizard(object):45class FakeWizard(object):
46 """Replace wizard() function on wizard pages."""46 """Replace wizard() function on wizard pages."""
4747
48 customButtonClicked = QtCore.QObject()
49 overlay = None
48 params = None50 params = None
4951
50 # Invalid name "setButtonLayout"52 # Invalid name "setButtonLayout"
@@ -56,6 +58,19 @@
5658
57 # pylint: enable=C010359 # pylint: enable=C0103
5860
61 # Invalid name "setOption"
62 # pylint: disable=C0103
63
64 def setOption(self, *args, **kwargs):
65 """Fake the functionality of setOption on QWizard class."""
66 FakeWizard.params = (args, kwargs)
67
68 # pylint: enable=C0103
69
70 def button(self, *args, **kwargs):
71 """Fake the functionality of button on QWizard class."""
72 return QtGui.QPushButton()
73
5974
60class FakeValidationDict(object):75class FakeValidationDict(object):
61 """A Fake dictionary to replace validation_functions on Setup Account."""76 """A Fake dictionary to replace validation_functions on Setup Account."""
@@ -104,20 +119,6 @@
104 QtCore.SIGNAL('textEdited(QString)')), 1)119 QtCore.SIGNAL('textEdited(QString)')), 1)
105 self.assertTrue(self.ui.validation_functions)120 self.assertTrue(self.ui.validation_functions)
106121
107 def test_initialize_page(self):
108 """Check the initializePage to ensure proper widgets visibility."""
109 self.ui.show()
110 self.addCleanup(self.ui.hide)
111 self.patch(self.ui, 'wizard', FakeWizard)
112 self.ui.initializePage()
113 self.assertEqual(FakeWizard.params, (([
114 QtGui.QWizard.BackButton,
115 QtGui.QWizard.Stretch],), {}))
116 self.assertFalse(self.ui.ui.name_assistance.isVisible())
117 self.assertFalse(self.ui.ui.email_assistance.isVisible())
118 self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible())
119 self.assertFalse(self.ui.ui.password_assistance.isVisible())
120
121 def test_empty_name(self):122 def test_empty_name(self):
122 """Status when the name field is empty.123 """Status when the name field is empty.
123124
@@ -134,92 +135,6 @@
134 setup_account.ERROR % setup_account.EMPTY_NAME)135 setup_account.ERROR % setup_account.EMPTY_NAME)
135 self.ui.hide()136 self.ui.hide()
136137
137 def test_blank_name(self):
138 """Status when the name field is blank (spaces).
139
140 * Name Assistance label visible.
141 * Correct error message in it.
142 """
143 self.ui.ui.name_edit.setText(" ")
144 self.ui.name_assistance()
145 self.ui.show()
146 self.addCleanup(self.ui.hide)
147 self.assertTrue(self.ui.ui.name_assistance.isVisible())
148 self.assertEqual(
149 unicode(self.ui.ui.name_assistance.text()),
150 setup_account.ERROR % setup_account.EMPTY_NAME)
151 self.ui.hide()
152
153 def test_valid_name(self):
154 """Status when the name field is valid.
155
156 * Name Assistance label invisible.
157 """
158 self.ui.ui.name_edit.setText("John Doe")
159 self.ui.name_assistance()
160 self.ui.show()
161 self.addCleanup(self.ui.hide)
162 self.assertFalse(self.ui.ui.name_assistance.isVisible())
163 self.ui.hide()
164
165 def test_invalid_email(self):
166 """Status when the email field has no @.
167
168 * Email Assistance label visible.
169 * Correct error message in it.
170 """
171 self.ui.ui.email_edit.setText("foobar")
172 self.ui.email_assistance()
173 self.ui.show()
174 self.addCleanup(self.ui.hide)
175 self.assertTrue(self.ui.ui.email_assistance.isVisible())
176 self.assertEqual(
177 unicode(self.ui.ui.email_assistance.text()),
178 setup_account.ERROR % setup_account.INVALID_EMAIL)
179 self.ui.hide()
180
181 def test_valid_email(self):
182 """Status when the email field has a @.
183
184 * Email Assistance label invisible.
185 """
186 self.ui.ui.email_edit.setText("foo@bar")
187 self.ui.email_assistance()
188 self.ui.show()
189 self.addCleanup(self.ui.hide)
190 self.assertFalse(self.ui.ui.email_assistance.isVisible())
191 self.ui.hide()
192
193 def test_matching_emails(self):
194 """Status when the email fields match.
195
196 * Email Assistance label invisible.
197 """
198 self.ui.ui.email_edit.setText("foo@bar")
199 self.ui.ui.confirm_email_edit.setText("foo@bar")
200 self.ui.confirm_email_assistance()
201 self.ui.show()
202 self.addCleanup(self.ui.hide)
203 self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible())
204 self.ui.hide()
205
206 def test_not_matching_emails(self):
207 """Status when the email fields don't match.
208
209 * Email Assistance label visible.
210 * Correct error message.
211 """
212 self.ui.ui.email_edit.setText("foo@bar")
213 self.ui.ui.confirm_email_edit.setText("foo@baz")
214 self.ui.confirm_email_assistance()
215 self.ui.show()
216 self.addCleanup(self.ui.hide)
217 self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible())
218 self.assertEqual(
219 unicode(self.ui.ui.confirm_email_assistance.text()),
220 setup_account.ERROR % setup_account.EMAIL_MATCH)
221 self.ui.hide()
222
223 def test_short_password(self):138 def test_short_password(self):
224 """Status with short password.139 """Status with short password.
225140
@@ -474,6 +389,109 @@
474 self.assertTrue(getattr(FakeValidationDict, "valid2"))389 self.assertTrue(getattr(FakeValidationDict, "valid2"))
475 self.assertTrue(getattr(FakeValidationDict, "valid3"))390 self.assertTrue(getattr(FakeValidationDict, "valid3"))
476391
392
393class SetupAccountFakeWizardTestCase(BaseTestCase):
394 """Test the SetupAccountPage code."""
395
396 class_ui = setup_account.SetupAccountPage
397 kwargs = dict(
398 ui=setup_account_ui.Ui_SetUpAccountPage(),
399 controller=FakeController(),
400 parent=None,
401 )
402
403 def setUp(self):
404 """Initialize this test instance."""
405 # Faking each SSO object instead of doing it lower
406 # so we don't rely on any SSO behaviour
407 super(SetupAccountFakeWizardTestCase, self).setUp()
408 self.patch(self.ui, 'wizard', FakeWizard)
409
410 def test_blank_name(self):
411 """Status when the name field is blank (spaces).
412
413 * Name Assistance label visible.
414 * Correct error message in it.
415 """
416 self.ui.ui.name_edit.setText(" ")
417 self.ui.name_assistance()
418 self.ui.show()
419 self.addCleanup(self.ui.hide)
420 self.assertTrue(self.ui.ui.name_assistance.isVisible())
421 self.assertEqual(
422 unicode(self.ui.ui.name_assistance.text()),
423 setup_account.ERROR % setup_account.EMPTY_NAME)
424 self.ui.hide()
425
426 def test_valid_name(self):
427 """Status when the name field is valid.
428
429 * Name Assistance label invisible.
430 """
431 self.ui.ui.name_edit.setText("John Doe")
432 self.ui.name_assistance()
433 self.ui.show()
434 self.addCleanup(self.ui.hide)
435 self.assertFalse(self.ui.ui.name_assistance.isVisible())
436 self.ui.hide()
437
438 def test_invalid_email(self):
439 """Status when the email field has no @.
440
441 * Email Assistance label visible.
442 * Correct error message in it.
443 """
444 self.ui.ui.email_edit.setText("foobar")
445 self.ui.email_assistance()
446 self.ui.show()
447 self.addCleanup(self.ui.hide)
448 self.assertTrue(self.ui.ui.email_assistance.isVisible())
449 self.assertEqual(
450 unicode(self.ui.ui.email_assistance.text()),
451 setup_account.ERROR % setup_account.INVALID_EMAIL)
452
453 def test_valid_email(self):
454 """Status when the email field has a @.
455
456 * Email Assistance label invisible.
457 """
458 self.ui.ui.email_edit.setText("foo@bar")
459 self.ui.email_assistance()
460 self.ui.show()
461 self.addCleanup(self.ui.hide)
462 self.assertFalse(self.ui.ui.email_assistance.isVisible())
463 self.ui.hide()
464
465 def test_matching_emails(self):
466 """Status when the email fields match.
467
468 * Email Assistance label invisible.
469 """
470 self.ui.ui.email_edit.setText("foo@bar")
471 self.ui.ui.confirm_email_edit.setText("foo@bar")
472 self.ui.confirm_email_assistance()
473 self.ui.show()
474 self.addCleanup(self.ui.hide)
475 self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible())
476 self.ui.hide()
477
478 def test_not_matching_emails(self):
479 """Status when the email fields don't match.
480
481 * Email Assistance label visible.
482 * Correct error message.
483 """
484 self.ui.ui.email_edit.setText("foo@bar")
485 self.ui.ui.confirm_email_edit.setText("foo@baz")
486 self.ui.confirm_email_assistance()
487 self.ui.show()
488 self.addCleanup(self.ui.hide)
489 self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible())
490 self.assertEqual(
491 unicode(self.ui.ui.confirm_email_assistance.text()),
492 setup_account.ERROR % setup_account.EMAIL_MATCH)
493 self.ui.hide()
494
477 def test_focus_changed_password_visibility(self):495 def test_focus_changed_password_visibility(self):
478 """Check visibility changes when focus_changed() is executed."""496 """Check visibility changes when focus_changed() is executed."""
479 self.ui.show()497 self.ui.show()
480498
=== removed file 'ubuntuone_installer/gui/qt/tos.py'
--- ubuntuone_installer/gui/qt/tos.py 2011-07-28 18:24:58 +0000
+++ ubuntuone_installer/gui/qt/tos.py 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
1# -*- coding: utf-8 -*-
2
3# Authors: Roberto Alsina <roberto.alsina@canonical.com>
4#
5# Copyright 2011 Canonical Ltd.
6#
7# This program is free software: you can redistribute it and/or modify it
8# under the terms of the GNU General Public License version 3, as published
9# by the Free Software Foundation.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranties of
13# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
14# PURPOSE. See the GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.
18
19"""Widget to view the Terms Of Service."""
20
21import gettext
22
23from PyQt4 import QtGui
24
25import ubuntu_sso.qt.gui as sso_gui
26
27_ = gettext.gettext
28
29
30class TosPage(sso_gui.TosPage):
31
32 """Page to display the Terms of Service."""
33
34 # initializePage is inherited
35 # pylint: disable=C0103
36 def initializePage(self):
37 """Setup UI details."""
38 # Set the right texts and connections for buttons
39 self.setButtonText(QtGui.QWizard.NextButton, _("Agree && Install"))
40 self.setButtonText(QtGui.QWizard.CancelButton,
41 _("Disagree && Cancel"))
42 self.setButtonText(QtGui.QWizard.CustomButton1, _("&Print"))
43
44 # This is just to catch an exception thrown when nothing
45 # is connected to the signal. It's not an exceptional
46 # condition at all.
47 try:
48 self.wizard().customButtonClicked.disconnect()
49 except TypeError:
50 pass
51
52 self.wizard().customButtonClicked.connect(self.print_document)
53
54 self.wizard().setButtonLayout([
55 QtGui.QWizard.CustomButton1,
56 QtGui.QWizard.BackButton,
57 QtGui.QWizard.Stretch])
58
59 def print_document(self, button_id):
60 """Print the document displayed in textBrowser."""
61 if button_id == QtGui.QWizard.CustomButton1:
62 previewer = QtGui.QPrintPreviewDialog(
63 paintRequested=self.ui.terms_webkit.print_)
64 previewer.exec_()

Subscribers

People subscribed via source and target branches