Merge lp:~ralsina/ubuntuone-windows-installer/add_install_option into lp:ubuntuone-windows-installer

Proposed by Roberto Alsina
Status: Merged
Approved by: Natalia Bidart
Approved revision: 61
Merged at revision: 63
Proposed branch: lp:~ralsina/ubuntuone-windows-installer/add_install_option
Merge into: lp:ubuntuone-windows-installer
Diff against target: 181 lines (+62/-12)
5 files modified
bin/ubuntuone-installer-qt (+5/-2)
ubuntuone_installer/gui/qt/gui.py (+9/-1)
ubuntuone_installer/gui/qt/main/tests/test_windows.py (+22/-0)
ubuntuone_installer/gui/qt/main/windows.py (+9/-8)
ubuntuone_installer/gui/qt/tests/test_gui.py (+17/-1)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-windows-installer/add_install_option
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+74506@code.launchpad.net

Commit message

Add --installer option to the wizard.

Description of the change

Add --installer option to the wizard.

To test IRL:

* if you run it with --installer, you get the license page.
* if you run it without arguments, you get the "choose sign in" page.

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
58. By Roberto Alsina

change name of variable from installer to installing, as suggested

59. By Roberto Alsina

merged trunk

60. By Roberto Alsina

fix test

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

- When running the installer without the --installer option, I still get the "Congratulations, Ubuntu One is installed!" legend in the first screen. I think we need to remove that?

- Also, if passing the --installer switch, I can't close the window, even if I choose 'yes I want to cancel' (on the license page).

review: Needs Fixing
61. By Roberto Alsina

Don't show 'is installed' message if not installing

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 'bin/ubuntuone-installer-qt'
2--- bin/ubuntuone-installer-qt 2011-07-29 18:30:21 +0000
3+++ bin/ubuntuone-installer-qt 2011-09-14 15:15:47 +0000
4@@ -38,11 +38,14 @@
5 """Parse command line parameters."""
6 usage = "Usage: %prog [option]"
7 result = OptionParser(usage=usage)
8- # There are no options currently
9+ result.add_option("-i", "--installer", dest="installer",
10+ action="store_true",
11+ default=False, help="To be used by the installer: "
12+ "Show license page, offer uninstall on cancel.")
13 return result
14
15
16 if __name__ == "__main__":
17 parser = parser_options()
18 (options, args) = parser.parse_args(sys.argv)
19- main.main()
20+ main.main(installing=options.installer)
21
22=== modified file 'ubuntuone_installer/gui/qt/gui.py'
23--- ubuntuone_installer/gui/qt/gui.py 2011-09-12 18:48:09 +0000
24+++ ubuntuone_installer/gui/qt/gui.py 2011-09-14 15:15:47 +0000
25@@ -265,7 +265,7 @@
26 registrationSuccess = QtCore.pyqtSignal('QString', 'QString')
27 userCancellation = QtCore.pyqtSignal('QString')
28
29- def __init__(self, close_callback=None):
30+ def __init__(self, close_callback=None, installing=False):
31 """Initialize this instance."""
32 # Used to decide the next page dynamically
33 self._next_id = None
34@@ -313,6 +313,8 @@
35 ui=choose_sign_in_ui.Ui_ChooseSignInPage(),
36 controller=self.sign_in_controller,
37 parent=self)
38+ if not installing:
39+ self.sign_in_page.ui.message_label.setText("")
40
41 self.setup_controller = SetUpAccountController(message_box=self)
42 self.setup_account = SetupAccountPage(
43@@ -381,6 +383,12 @@
44 # Set Wizard buttons style
45 self.button(QtGui.QWizard.NextButton).setDefault(True)
46
47+ if installing:
48+ self.setStartId(self.LICENSE_PAGE_ID)
49+ else:
50+ self.setStartId(self.SIGNIN_PAGE)
51+ self.restart()
52+
53 # Invalid name "closeEvent"
54 # pylint: disable=C0103
55
56
57=== modified file 'ubuntuone_installer/gui/qt/main/tests/test_windows.py'
58--- ubuntuone_installer/gui/qt/main/tests/test_windows.py 2011-08-29 12:41:02 +0000
59+++ ubuntuone_installer/gui/qt/main/tests/test_windows.py 2011-09-14 15:15:47 +0000
60@@ -126,3 +126,25 @@
61 self.assertEqual(self._called, ((), {}))
62 # Should stop the app
63 self.assertTrue(self.stopped)
64+
65+ @defer.inlineCallbacks
66+ def test_without_installed_flag(self):
67+ """Test behaviour without the installer flag."""
68+ logger = FakeLogger()
69+ self.patch(windows, "success_cb", self._set_called)
70+ yield windows.check_credentials(
71+ FakeCredentialsManagementTool,
72+ gui, logger)
73+ self.assertEqual(self._called, (('Something not false',
74+ gui, False), {}))
75+
76+ @defer.inlineCallbacks
77+ def test_with_installed_flag(self):
78+ """Test behaviour without the installer flag."""
79+ logger = FakeLogger()
80+ self.patch(windows, "success_cb", self._set_called)
81+ yield windows.check_credentials(
82+ FakeCredentialsManagementTool,
83+ gui, logger, installer=True)
84+ self.assertEqual(self._called, (('Something not false',
85+ gui, True), {}))
86
87=== modified file 'ubuntuone_installer/gui/qt/main/windows.py'
88--- ubuntuone_installer/gui/qt/main/windows.py 2011-09-08 14:18:30 +0000
89+++ ubuntuone_installer/gui/qt/main/windows.py 2011-09-14 15:15:47 +0000
90@@ -1,6 +1,7 @@
91 # -*- coding: utf-8 -*-
92
93 # Authors: Manuel de la Pena <manuel@canonical.com>
94+# Roberto Alsina <roberto.alsina@canonical.com>
95 #
96 # Copyright 2011 Canonical Ltd.
97 #
98@@ -43,14 +44,14 @@
99 stop()
100
101
102-def success_cb(creds, gui):
103+def success_cb(creds, gui, installing):
104 """Handle credentials success."""
105 if creds: # Have credentials already
106 from ubuntuone_installer.gui.qt import utils
107 utils.start_control_panel()
108 stop()
109 else: # No credentials
110- window = gui.MainWindow(close_callback=stop)
111+ window = gui.MainWindow(close_callback=stop, installing=installing)
112 # Set Application Style Sheet
113 app = QtGui.QApplication.instance()
114 qss = QtCore.QResource(":/ubuntuone.qss")
115@@ -64,7 +65,7 @@
116
117
118 @defer.inlineCallbacks
119-def check_credentials(credentials_tool, gui, logger):
120+def check_credentials(credentials_tool, gui, logger, installer=False):
121 """Check credentials and either start u1cp or show the wizard."""
122 credtool = credentials_tool()
123 # pylint: disable=W0703
124@@ -73,10 +74,10 @@
125 except Exception, exc:
126 error_cb(exc, logger)
127 else:
128- success_cb(creds, gui)
129-
130-
131-def main():
132+ success_cb(creds, gui, installer)
133+
134+
135+def main(installing=False):
136 """Perform a client request to be logged in."""
137 # pylint: disable=W0612
138 app = QtGui.QApplication(sys.argv)
139@@ -89,5 +90,5 @@
140 from ubuntuone.platform.credentials import CredentialsManagementTool
141 from ubuntuone_installer.logger import setup_logging
142 logger = setup_logging('qt.gui')
143- check_credentials(CredentialsManagementTool, gui, logger)
144+ check_credentials(CredentialsManagementTool, gui, logger, installing)
145 reactor.run()
146
147=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
148--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-12 18:49:40 +0000
149+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-14 15:15:47 +0000
150@@ -161,6 +161,19 @@
151 QtCore.Qt.WindowContextHelpButtonHint)
152 self.assertEqual(flag, 0)
153
154+ def test_with_flag(self):
155+ """test with flag activated."""
156+ win = gui.MainWindow(installing=True)
157+ self.assertEqual(win.startId(), win.LICENSE_PAGE_ID)
158+ self.assertEqual(
159+ unicode(self.ui.sign_in_page.ui.message_label.text()),
160+ u"")
161+
162+ def test_without_flag(self):
163+ """test with flag activated."""
164+ win = gui.MainWindow()
165+ self.assertEqual(win.startId(), win.SIGNIN_PAGE)
166+
167 def test_initialize_page(self):
168 """Check the initializePage to ensure proper widgets visibility."""
169 setup_page = self.ui.page(self.ui.setup_account_page_id)
170@@ -472,7 +485,10 @@
171
172 def test_continue_cancels_cancel(self):
173 """Clicking 'Continue' cancels cancellation."""
174- gui.AreYouSure.result = 1
175+ # Must not be LICENSE_PAGE not CONGRATULATIONS_PAGE
176+ self.patch(self.ui, 'currentId', lambda: self.ui.SIGNIN_PAGE)
177+ # Make AreYouSure say the user is "not sure"
178+ gui.AreYouSure.result = 0
179 self.patch(subprocess, "Popen", self._set_called)
180 self.ui.show()
181 self.addCleanup(self.ui.hide)

Subscribers

People subscribed via source and target branches