Merge lp:~ralsina/ubuntuone-windows-installer/back-is-wrong into lp:ubuntuone-windows-installer

Proposed by Roberto Alsina
Status: Merged
Approved by: Natalia Bidart
Approved revision: 74
Merged at revision: 57
Proposed branch: lp:~ralsina/ubuntuone-windows-installer/back-is-wrong
Merge into: lp:ubuntuone-windows-installer
Diff against target: 264 lines (+93/-23)
7 files modified
ubuntuone_installer/gui/qt/folders.py (+3/-2)
ubuntuone_installer/gui/qt/local_folders.py (+14/-3)
ubuntuone_installer/gui/qt/preferences.py (+1/-4)
ubuntuone_installer/gui/qt/sync_now_or_later.py (+5/-0)
ubuntuone_installer/gui/qt/tests/test_gui.py (+31/-4)
ubuntuone_installer/gui/qt/tests/test_local_folders.py (+37/-10)
ubuntuone_installer/gui/qt/tests/test_sync_now_or_later.py (+2/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-windows-installer/back-is-wrong
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Diego Sarmentero (community) Approve
Review via email: mp+74818@code.launchpad.net

Commit message

* Enable the back buttons in cloud-to-computer and computer-to-cloud in the right circumstances
* Set the correct title/subtitle for cloud-to-computer
* Fix the workflow for the "preferences" page

Description of the change

* Enable the back buttons in cloud-to-computer and computer-to-cloud in the right circumstances
* Set the correct title/subtitle for cloud-to-computer

To post a comment you must log in.
66. By Roberto Alsina

de-lint

67. By Roberto Alsina

pep8

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

+1

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

So, I made this test:

* ran installer
* login with existent account
* chose nothing in the cloud to computer page, clicked next
* computer to cloud computer appeared, chose nothing, clicked back
* got cloud-to-computer page again (which is ok), I chose to sync a existent udf, clicked next
* I expected to have the computer-to-cloud again, but I got the IMAGE GOES HERE instead.

review: Needs Fixing
68. By Roberto Alsina

handle 'back' better

69. By Roberto Alsina

useless import

70. By Roberto Alsina

lint

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

> So, I made this test:
>
> * ran installer
> * login with existent account
> * chose nothing in the cloud to computer page, clicked next
> * computer to cloud computer appeared, chose nothing, clicked back
> * got cloud-to-computer page again (which is ok), I chose to sync a existent
> udf, clicked next
> * I expected to have the computer-to-cloud again, but I got the IMAGE GOES
> HERE instead.

Fixed in latest revno, along with a similar problem when you clicked on "Settings" on cloud-to-computer

71. By Roberto Alsina

link bug

72. By Roberto Alsina

test fixes

73. By Roberto Alsina

added test

74. By Roberto Alsina

lint

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

Looks good. I noticed some buggy behaviors, but they should be fixed in a separated branch (I filed bug #847847).

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone_installer/gui/qt/folders.py'
2--- ubuntuone_installer/gui/qt/folders.py 2011-09-07 15:25:01 +0000
3+++ ubuntuone_installer/gui/qt/folders.py 2011-09-10 01:59:23 +0000
4@@ -36,7 +36,9 @@
5
6 def __init__(self, parent=None):
7 super(FoldersPage, self).__init__(folders_ui.Ui_Form(), None, parent)
8- self.setTitle(_("Syncing your computer with the cloud"))
9+ self.setTitle(_("Syncing the cloud to your computer"))
10+ self.setSubTitle(_("These are your folders in your cloud. "
11+ "Select the ones you want to sync with this computer."))
12 self.folders_widget = folders.FoldersPanel()
13 self.layout().insertWidget(
14 self.layout().count() - 1, self.folders_widget)
15@@ -53,7 +55,6 @@
16 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
17 self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False)
18 self.wizard().setButtonLayout([
19- QtGui.QWizard.BackButton,
20 QtGui.QWizard.Stretch,
21 QtGui.QWizard.NextButton])
22 self.wizard().setButtonText(QtGui.QWizard.NextButton,
23
24=== modified file 'ubuntuone_installer/gui/qt/local_folders.py'
25--- ubuntuone_installer/gui/qt/local_folders.py 2011-09-07 15:25:01 +0000
26+++ ubuntuone_installer/gui/qt/local_folders.py 2011-09-10 01:59:23 +0000
27@@ -102,15 +102,22 @@
28 self.items = {}
29 self.folders_info = None
30 self.account_info = None
31+ self.has_back_button = True
32 self.cp_backend = backend.ControlBackend()
33
34 # initializePage is inherited
35 # pylint: disable=C0103
36 def initializePage(self):
37 """UI details."""
38- self.wizard().setButtonLayout([
39- QtGui.QWizard.Stretch,
40- QtGui.QWizard.NextButton])
41+ if self.has_back_button:
42+ self.wizard().setButtonLayout([
43+ QtGui.QWizard.BackButton,
44+ QtGui.QWizard.Stretch,
45+ QtGui.QWizard.NextButton])
46+ else:
47+ self.wizard().setButtonLayout([
48+ QtGui.QWizard.Stretch,
49+ QtGui.QWizard.NextButton])
50 self.wizard().setButtonText(QtGui.QWizard.NextButton,
51 NEXT)
52 self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE
53@@ -120,6 +127,10 @@
54 self.wizard().overlay.show()
55 self.get_info()
56
57+ def cleanupPage(self):
58+ """Initialize previous page when going back."""
59+ self.wizard().folders_page.initializePage()
60+
61 @inlineCallbacks
62 def get_info(self):
63 """Get information from CP backend and fill folder list."""
64
65=== modified file 'ubuntuone_installer/gui/qt/preferences.py'
66--- ubuntuone_installer/gui/qt/preferences.py 2011-08-11 15:02:49 +0000
67+++ ubuntuone_installer/gui/qt/preferences.py 2011-09-10 01:59:23 +0000
68@@ -85,7 +85,6 @@
69
70 # Invalid name "cleanupPage"
71 # pylint: disable=C0103
72-
73 def cleanupPage(self):
74 """Execute this cleanup function when the back button is pressed."""
75 self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
76@@ -94,7 +93,5 @@
77 QtGui.QWizard.BackButton,
78 QtGui.QWizard.Stretch,
79 QtGui.QWizard.NextButton])
80- self.wizard().setButtonText(QtGui.QWizard.NextButton, _("Sync Now!"))
81- self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE
82-
83+ self.wizard().folders_page.initializePage()
84 # pylint: enable=C0103
85
86=== modified file 'ubuntuone_installer/gui/qt/sync_now_or_later.py'
87--- ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-09-07 16:25:32 +0000
88+++ ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-09-10 01:59:23 +0000
89@@ -50,13 +50,18 @@
90 self.wizard().overlay.show()
91 self.wizard().setButtonText(QtGui.QWizard.NextButton,
92 NEXT)
93+ self.wizard().setButtonLayout([
94+ QtGui.QWizard.Stretch,
95+ QtGui.QWizard.NextButton])
96 self.get_info()
97
98 def nextId(self):
99 """Go to the next page depending on the select field."""
100 if self.has_cloud_folders:
101+ self.wizard().local_folders_page.has_back_button = True
102 return self.wizard().folders_page_id
103 else:
104+ self.wizard().local_folders_page.has_back_button = False
105 return self.wizard().local_folders_page_id
106
107 @inlineCallbacks
108
109=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
110--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-09 13:20:23 +0000
111+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-10 01:59:23 +0000
112@@ -28,6 +28,7 @@
113 from ubuntuone.platform.credentials import APP_NAME
114 from ubuntuone.controlpanel.gui import qt
115
116+from ubuntuone_installer.gui import NEXT
117 from ubuntuone_installer.gui.qt import gui, forgotten, utils
118 from ubuntuone_installer.gui.qt.tests import BaseTestCase
119
120@@ -269,12 +270,21 @@
121 preferences_page.preferences_widget.apply_button_clicked, True)
122 # for Cleanup
123 btn_pref = preferences_page.wizard().button(QtGui.QWizard.NextButton)
124- self.assertEqual(btn_pref.text(), "Sync Now!")
125- self.assertEqual(self.ui._next_id, self.ui.CONGRATULATIONS_PAGE)
126-
127- def test_folders_page(self):
128+ self.assertEqual(btn_pref.text(), NEXT)
129+ self.assertEqual(self.ui._next_id, self.ui.local_folders_page_id)
130+
131+ def test_preferences_cleanup_page(self):
132+ """cleanupPage should call folders.initializePage()."""
133+ preferences_page = self.ui.page(self.ui.preferences_page_id)
134+ self.patch(self.ui.folders_page,
135+ "initializePage", self._set_called)
136+ preferences_page.cleanupPage()
137+ self.assertEqual(self._called, ((), {}))
138+
139+ def test_folders_page_with_back(self):
140 """Check Folders Page UI."""
141 folders_page = self.ui.page(self.ui.folders_page_id)
142+ self.patch(self.ui, "setButtonLayout", self._set_called)
143
144 # Show the preferences page
145 self.ui.setStartId(self.ui.folders_page_id)
146@@ -292,6 +302,9 @@
147 self.assertEqual(tree_folders.isColumnHidden(2), True)
148 # pylint: disable=W0212
149 self.assertEqual(self.ui._next_id, self.ui.local_folders_page_id)
150+ self.assertEqual(self._called,
151+ (([QtGui.QWizard.Stretch,
152+ QtGui.QWizard.NextButton],), {}))
153
154 def test_folders_page_next_id(self):
155 """Check Folders Page UI."""
156@@ -571,6 +584,18 @@
157 self.target(*args)
158
159
160+class FakeWizardPage(object):
161+
162+ """A fake wizard page."""
163+
164+ def __init__(self, *args, **kwargs):
165+ self.has_back_button = True
166+
167+ # pylint: disable=C0103
168+ def initializePage(self):
169+ """Fake initializePage."""
170+
171+
172 class FakeMainWindow(object):
173
174 """A fake MainWindow."""
175@@ -590,6 +615,8 @@
176 self.button_layout = None
177 self.options = []
178 self.overlay = FakeOverlay()
179+ self.local_folders_page = FakeWizardPage()
180+ self.folders_page = FakeWizardPage()
181
182 def show(self):
183 """Fake method."""
184
185=== modified file 'ubuntuone_installer/gui/qt/tests/test_local_folders.py'
186--- ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-08 12:56:33 +0000
187+++ ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-10 01:59:23 +0000
188@@ -235,16 +235,36 @@
189 self.assertEqual(self.ui.items, {})
190 self.assertEqual(self.ui.ui.folder_list.topLevelItemCount(), 0)
191
192- def test_status_after_initialize(self):
193- """Test status of page components after initializePage()."""
194- self.patch(self.ui, "get_info", self._set_called)
195- self.ui.initializePage()
196- self.assertEqual(self.ui.wizard().overlay.show_counter, 1)
197- self.assertEqual(self.ui.wizard().overlay.hide_counter, 0)
198- self.assertFalse(self.ui.ui.offer_frame.isVisible())
199- self.assertEqual(self._called, ((), {}))
200- self.assertEqual(self.ui.wizard().button_texts,
201- [(QtGui.QWizard.NextButton, NEXT)])
202+ def test_status_after_initialize_with_back(self):
203+ """Test status of page components after initializePage()."""
204+ self.patch(self.ui, "get_info", self._set_called)
205+ self.ui.has_back_button = True
206+ self.ui.initializePage()
207+ self.assertEqual(self.ui.wizard().overlay.show_counter, 1)
208+ self.assertEqual(self.ui.wizard().overlay.hide_counter, 0)
209+ self.assertFalse(self.ui.ui.offer_frame.isVisible())
210+ self.assertEqual(self._called, ((), {}))
211+ self.assertEqual(self.ui.wizard().button_texts,
212+ [(QtGui.QWizard.NextButton, NEXT)])
213+ self.assertEqual(self.ui.wizard().button_layout,
214+ [QtGui.QWizard.BackButton,
215+ QtGui.QWizard.Stretch,
216+ QtGui.QWizard.NextButton])
217+
218+ def test_status_after_initialize_without_back(self):
219+ """Test status of page components after initializePage()."""
220+ self.patch(self.ui, "get_info", self._set_called)
221+ self.ui.has_back_button = False
222+ self.ui.initializePage()
223+ self.assertEqual(self.ui.wizard().overlay.show_counter, 1)
224+ self.assertEqual(self.ui.wizard().overlay.hide_counter, 0)
225+ self.assertFalse(self.ui.ui.offer_frame.isVisible())
226+ self.assertEqual(self._called, ((), {}))
227+ self.assertEqual(self.ui.wizard().button_texts,
228+ [(QtGui.QWizard.NextButton, NEXT)])
229+ self.assertEqual(self.ui.wizard().button_layout,
230+ [QtGui.QWizard.Stretch,
231+ QtGui.QWizard.NextButton])
232
233 @defer.inlineCallbacks
234 def test_status_after_get_info(self):
235@@ -549,3 +569,10 @@
236 'options': local_folders.QtGui.QFileDialog.DontUseNativeDialog,
237 'parent': self.ui,
238 }))
239+
240+ def test_cleanup_page(self):
241+ """cleanupPage should call folders.initializePage()."""
242+ self.patch(self.ui.wizard().folders_page,
243+ "initializePage", self._set_called)
244+ self.ui.cleanupPage()
245+ self.assertEqual(self._called, ((), {}))
246
247=== modified file 'ubuntuone_installer/gui/qt/tests/test_sync_now_or_later.py'
248--- ubuntuone_installer/gui/qt/tests/test_sync_now_or_later.py 2011-09-07 16:52:36 +0000
249+++ ubuntuone_installer/gui/qt/tests/test_sync_now_or_later.py 2011-09-10 01:59:23 +0000
250@@ -76,12 +76,14 @@
251 """With cloud folders, next page is folders."""
252 self.ui.has_cloud_folders = True
253 self.assertEqual(self.ui.nextId(), FakeMainWindow.folders_page_id)
254+ self.assertTrue(self.main_window.local_folders_page.has_back_button)
255
256 def test_has_no_cloud_folders_next(self):
257 """With cloud folders, next page is folders."""
258 self.ui.has_cloud_folders = False
259 self.assertEqual(self.ui.nextId(),
260 FakeMainWindow.local_folders_page_id)
261+ self.assertFalse(self.main_window.local_folders_page.has_back_button)
262
263 def test_status_after_initialize(self):
264 """Test that everything is initialized correctly."""

Subscribers

People subscribed via source and target branches