Merge lp:~diegosarmentero/ubuntuone-windows-installer/titles-on-pages into lp:ubuntuone-windows-installer
- titles-on-pages
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~diegosarmentero/ubuntuone-windows-installer/titles-on-pages | ||||
Merge into: | lp:ubuntuone-windows-installer | ||||
Diff against target: |
1229 lines (+473/-393) 15 files modified
bin/ubuntuone-installer-qt (+0/-3) data/qt/choose_sign_in.ui (+31/-16) data/qt/local_folders.ui (+95/-34) data/qt/setup_account.ui (+37/-3) ubuntuone_installer/gui/qt/currentuser.py (+48/-0) ubuntuone_installer/gui/qt/embedded_sso.py (+0/-61) ubuntuone_installer/gui/qt/forgotten.py (+34/-34) ubuntuone_installer/gui/qt/gui.py (+30/-5) ubuntuone_installer/gui/qt/local_folders.py (+9/-3) ubuntuone_installer/gui/qt/main/tests/test_main.py (+0/-97) ubuntuone_installer/gui/qt/main/windows.py (+20/-29) ubuntuone_installer/gui/qt/setup_account.py (+0/-5) ubuntuone_installer/gui/qt/sync_now_or_later.py (+44/-44) ubuntuone_installer/gui/qt/tests/test_currentuser.py (+90/-0) ubuntuone_installer/gui/qt/tests/test_gui.py (+35/-59) |
||||
To merge this branch: | bzr merge lp:~diegosarmentero/ubuntuone-windows-installer/titles-on-pages | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Natalia Bidart | Pending | ||
Review via email: mp+70156@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-08-02.
Commit message
Move all the Titles and Subtitles into the Wizard Pages
Description of the change
Move all the Titles and Subtitles into the Wizard Pages
Diego Sarmentero (diegosarmentero) wrote : | # |
John Lenton (chipaca) wrote : | # |
are the changes to 'bin/ubuntuone-
Diego Sarmentero (diegosarmentero) wrote : | # |
That changes are really from Roberto's branch, but his branch is already merge with mine because they are related.
I'm waiting for his branch to be approved to merge mine.
John Lenton (chipaca) wrote : | # |
On Tue, 02 Aug 2011 14:24:34 -0000, Diego Sarmentero <email address hidden> wrote:
> That changes are really from Roberto's branch, but his branch is already merge with mine because they are related.
> I'm waiting for his branch to be approved to merge mine.
that's what the 'prerequisite branch' field is for in merge
proposals :)
- 26. By Diego Sarmentero
-
adding word wrap mode to title and subtitles.
- 27. By Diego Sarmentero
-
Installer modified to allow the pages to work with setTitle and setSubTitle.
- 28. By Diego Sarmentero
-
tests modified to use the new setTitle and setSubtitle
- 29. By Diego Sarmentero
-
modifying ui to add a header in all the pages dinamically.
- 30. By Diego Sarmentero
-
merge
- 31. By Diego Sarmentero
-
removing __init__ with just super.
- 32. By Diego Sarmentero
-
reverting changes in setup_account.py
Unmerged revisions
Preview Diff
1 | === modified file 'bin/ubuntuone-installer-qt' |
2 | --- bin/ubuntuone-installer-qt 2011-07-13 20:21:48 +0000 |
3 | +++ bin/ubuntuone-installer-qt 2011-08-02 12:48:37 +0000 |
4 | @@ -27,8 +27,6 @@ |
5 | |
6 | from optparse import OptionParser |
7 | |
8 | -from twisted.internet import reactor |
9 | - |
10 | from ubuntuone_installer import TRANSLATION_DOMAIN |
11 | |
12 | gettext.textdomain(TRANSLATION_DOMAIN) |
13 | @@ -48,4 +46,3 @@ |
14 | parser = parser_options() |
15 | (options, args) = parser.parse_args(sys.argv) |
16 | main.main() |
17 | - reactor.run() |
18 | |
19 | === modified file 'data/qt/choose_sign_in.ui' |
20 | --- data/qt/choose_sign_in.ui 2011-07-27 15:17:31 +0000 |
21 | +++ data/qt/choose_sign_in.ui 2011-08-02 12:48:37 +0000 |
22 | @@ -6,8 +6,8 @@ |
23 | <rect> |
24 | <x>0</x> |
25 | <y>0</y> |
26 | - <width>541</width> |
27 | - <height>365</height> |
28 | + <width>432</width> |
29 | + <height>393</height> |
30 | </rect> |
31 | </property> |
32 | <property name="windowTitle"> |
33 | @@ -15,20 +15,35 @@ |
34 | </property> |
35 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
36 | <item> |
37 | - <spacer name="verticalSpacer"> |
38 | - <property name="orientation"> |
39 | - <enum>Qt::Vertical</enum> |
40 | - </property> |
41 | - <property name="sizeType"> |
42 | - <enum>QSizePolicy::Preferred</enum> |
43 | - </property> |
44 | - <property name="sizeHint" stdset="0"> |
45 | - <size> |
46 | - <width>10</width> |
47 | - <height>30</height> |
48 | - </size> |
49 | - </property> |
50 | - </spacer> |
51 | + <layout class="QVBoxLayout" name="verticalLayout_4"> |
52 | + <property name="spacing"> |
53 | + <number>15</number> |
54 | + </property> |
55 | + <property name="bottomMargin"> |
56 | + <number>15</number> |
57 | + </property> |
58 | + <item> |
59 | + <widget class="QLabel" name="title_label"> |
60 | + <property name="font"> |
61 | + <font> |
62 | + <pointsize>24</pointsize> |
63 | + <weight>75</weight> |
64 | + <bold>true</bold> |
65 | + </font> |
66 | + </property> |
67 | + <property name="text"> |
68 | + <string>title_label</string> |
69 | + </property> |
70 | + </widget> |
71 | + </item> |
72 | + <item> |
73 | + <widget class="QLabel" name="subtitle_label"> |
74 | + <property name="text"> |
75 | + <string>subtitle_label</string> |
76 | + </property> |
77 | + </widget> |
78 | + </item> |
79 | + </layout> |
80 | </item> |
81 | <item> |
82 | <layout class="QHBoxLayout" name="horizontalLayout_2"> |
83 | |
84 | === modified file 'data/qt/local_folders.ui' |
85 | --- data/qt/local_folders.ui 2011-06-28 15:46:02 +0000 |
86 | +++ data/qt/local_folders.ui 2011-08-02 12:48:37 +0000 |
87 | @@ -6,7 +6,7 @@ |
88 | <rect> |
89 | <x>0</x> |
90 | <y>0</y> |
91 | - <width>460</width> |
92 | + <width>519</width> |
93 | <height>536</height> |
94 | </rect> |
95 | </property> |
96 | @@ -15,13 +15,44 @@ |
97 | </property> |
98 | <layout class="QVBoxLayout" name="verticalLayout_2"> |
99 | <item> |
100 | + <layout class="QVBoxLayout" name="verticalLayout_4"> |
101 | + <property name="spacing"> |
102 | + <number>15</number> |
103 | + </property> |
104 | + <property name="bottomMargin"> |
105 | + <number>15</number> |
106 | + </property> |
107 | + <item> |
108 | + <widget class="QLabel" name="title_label"> |
109 | + <property name="font"> |
110 | + <font> |
111 | + <pointsize>24</pointsize> |
112 | + <weight>75</weight> |
113 | + <bold>true</bold> |
114 | + </font> |
115 | + </property> |
116 | + <property name="text"> |
117 | + <string>title_label</string> |
118 | + </property> |
119 | + </widget> |
120 | + </item> |
121 | + <item> |
122 | + <widget class="QLabel" name="subtitle_label"> |
123 | + <property name="text"> |
124 | + <string>subtitle_label</string> |
125 | + </property> |
126 | + </widget> |
127 | + </item> |
128 | + </layout> |
129 | + </item> |
130 | + <item> |
131 | <widget class="QLabel" name="label"> |
132 | <property name="text"> |
133 | - <string>Ok! Now it's time to choose wich folder sync to the cloud from this computer. |
134 | -We started by suggesting a few</string> |
135 | + <string>Let's get started! First choose which folder you want to sync to your Ubuntu One personal cloud from this computer. |
136 | +To help you get going we have suggested a few.</string> |
137 | </property> |
138 | <property name="textFormat"> |
139 | - <enum>Qt::RichText</enum> |
140 | + <enum>Qt::PlainText</enum> |
141 | </property> |
142 | <property name="wordWrap"> |
143 | <bool>true</bool> |
144 | @@ -50,23 +81,28 @@ |
145 | </property> |
146 | </spacer> |
147 | </item> |
148 | - <item> |
149 | - <widget class="QPushButton" name="pushButton_2"> |
150 | - <property name="text"> |
151 | - <string>Add a folder</string> |
152 | - </property> |
153 | - </widget> |
154 | - </item> |
155 | </layout> |
156 | </item> |
157 | <item> |
158 | <widget class="QTreeWidget" name="folder_list"> |
159 | + <property name="indentation"> |
160 | + <number>0</number> |
161 | + </property> |
162 | + <property name="rootIsDecorated"> |
163 | + <bool>false</bool> |
164 | + </property> |
165 | + <property name="uniformRowHeights"> |
166 | + <bool>true</bool> |
167 | + </property> |
168 | + <property name="allColumnsShowFocus"> |
169 | + <bool>true</bool> |
170 | + </property> |
171 | <attribute name="headerStretchLastSection"> |
172 | <bool>false</bool> |
173 | </attribute> |
174 | <column> |
175 | <property name="text"> |
176 | - <string>My Folders</string> |
177 | + <string>Sync these folders on my computer</string> |
178 | </property> |
179 | </column> |
180 | <column> |
181 | @@ -74,26 +110,44 @@ |
182 | <string>Space (Total)</string> |
183 | </property> |
184 | </column> |
185 | - <column> |
186 | - <property name="text"> |
187 | - <string>Remove</string> |
188 | - </property> |
189 | - </column> |
190 | - </widget> |
191 | - </item> |
192 | - <item> |
193 | - <widget class="QCheckBox" name="checkBox"> |
194 | - <property name="text"> |
195 | - <string>Connect automatically when computer starts</string> |
196 | - </property> |
197 | - </widget> |
198 | - </item> |
199 | - <item> |
200 | - <widget class="QCheckBox" name="checkBox_2"> |
201 | - <property name="text"> |
202 | - <string>Automatically sync all selected folders from this computer to the cloud</string> |
203 | - </property> |
204 | - </widget> |
205 | + </widget> |
206 | + </item> |
207 | + <item> |
208 | + <layout class="QHBoxLayout" name="horizontalLayout_3"> |
209 | + <item> |
210 | + <spacer name="horizontalSpacer_4"> |
211 | + <property name="orientation"> |
212 | + <enum>Qt::Horizontal</enum> |
213 | + </property> |
214 | + <property name="sizeHint" stdset="0"> |
215 | + <size> |
216 | + <width>40</width> |
217 | + <height>20</height> |
218 | + </size> |
219 | + </property> |
220 | + </spacer> |
221 | + </item> |
222 | + <item> |
223 | + <widget class="AddFolderButton" name="add_folder_button"> |
224 | + <property name="text"> |
225 | + <string>Add a folder</string> |
226 | + </property> |
227 | + </widget> |
228 | + </item> |
229 | + <item> |
230 | + <spacer name="horizontalSpacer_5"> |
231 | + <property name="orientation"> |
232 | + <enum>Qt::Horizontal</enum> |
233 | + </property> |
234 | + <property name="sizeHint" stdset="0"> |
235 | + <size> |
236 | + <width>40</width> |
237 | + <height>20</height> |
238 | + </size> |
239 | + </property> |
240 | + </spacer> |
241 | + </item> |
242 | + </layout> |
243 | </item> |
244 | <item> |
245 | <widget class="QFrame" name="offer_frame"> |
246 | @@ -113,7 +167,7 @@ |
247 | <item> |
248 | <widget class="QLabel" name="offer_label"> |
249 | <property name="text"> |
250 | - <string>The folders you have selected to sync take over your 2GB space. You can remove some folders or add some extra space</string> |
251 | + <string>The folders you have selected to sync take over your 5GB storage space by 6.5GB. You can remove some folders or add some extra storage now.</string> |
252 | </property> |
253 | <property name="wordWrap"> |
254 | <bool>true</bool> |
255 | @@ -138,7 +192,7 @@ |
256 | <item> |
257 | <widget class="QPushButton" name="pushButton"> |
258 | <property name="text"> |
259 | - <string>add more space</string> |
260 | + <string>Add more storage</string> |
261 | </property> |
262 | </widget> |
263 | </item> |
264 | @@ -162,6 +216,13 @@ |
265 | </item> |
266 | </layout> |
267 | </widget> |
268 | + <customwidgets> |
269 | + <customwidget> |
270 | + <class>AddFolderButton</class> |
271 | + <extends>QPushButton</extends> |
272 | + <header>ubuntuone.controlpanel.gui.qt.addfolder</header> |
273 | + </customwidget> |
274 | + </customwidgets> |
275 | <resources/> |
276 | <connections/> |
277 | </ui> |
278 | |
279 | === modified file 'data/qt/setup_account.ui' |
280 | --- data/qt/setup_account.ui 2011-07-28 18:24:58 +0000 |
281 | +++ data/qt/setup_account.ui 2011-08-02 12:48:37 +0000 |
282 | @@ -6,8 +6,8 @@ |
283 | <rect> |
284 | <x>0</x> |
285 | <y>0</y> |
286 | - <width>569</width> |
287 | - <height>521</height> |
288 | + <width>575</width> |
289 | + <height>612</height> |
290 | </rect> |
291 | </property> |
292 | <property name="windowTitle"> |
293 | @@ -15,9 +15,43 @@ |
294 | </property> |
295 | <layout class="QVBoxLayout" name="verticalLayout"> |
296 | <property name="rightMargin"> |
297 | - <number>0</number> |
298 | + <number>6</number> |
299 | </property> |
300 | <item> |
301 | + <layout class="QVBoxLayout" name="verticalLayout_2"> |
302 | + <property name="spacing"> |
303 | + <number>15</number> |
304 | + </property> |
305 | + <property name="bottomMargin"> |
306 | + <number>15</number> |
307 | + </property> |
308 | + <item> |
309 | + <widget class="QLabel" name="title_label"> |
310 | + <property name="font"> |
311 | + <font> |
312 | + <pointsize>18</pointsize> |
313 | + <weight>75</weight> |
314 | + <bold>true</bold> |
315 | + </font> |
316 | + </property> |
317 | + <property name="text"> |
318 | + <string>title_label</string> |
319 | + </property> |
320 | + </widget> |
321 | + </item> |
322 | + <item> |
323 | + <widget class="QLabel" name="subtitle_label"> |
324 | + <property name="text"> |
325 | + <string>subtitle_label</string> |
326 | + </property> |
327 | + <property name="wordWrap"> |
328 | + <bool>true</bool> |
329 | + </property> |
330 | + </widget> |
331 | + </item> |
332 | + </layout> |
333 | + </item> |
334 | + <item> |
335 | <layout class="QGridLayout" name="gridLayout" columnminimumwidth="300,250"> |
336 | <item row="0" column="0"> |
337 | <widget class="QLabel" name="password_info_label"> |
338 | |
339 | === added file 'ubuntuone_installer/gui/qt/currentuser.py' |
340 | --- ubuntuone_installer/gui/qt/currentuser.py 1970-01-01 00:00:00 +0000 |
341 | +++ ubuntuone_installer/gui/qt/currentuser.py 2011-08-02 12:48:37 +0000 |
342 | @@ -0,0 +1,48 @@ |
343 | +# -*- coding: utf-8 -*- |
344 | + |
345 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
346 | +# |
347 | +# Copyright 2011 Canonical Ltd. |
348 | +# |
349 | +# This program is free software: you can redistribute it and/or modify it |
350 | +# under the terms of the GNU General Public License version 3, as published |
351 | +# by the Free Software Foundation. |
352 | +# |
353 | +# This program is distributed in the hope that it will be useful, but |
354 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
355 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
356 | +# PURPOSE. See the GNU General Public License for more details. |
357 | +# |
358 | +# You should have received a copy of the GNU General Public License along |
359 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
360 | + |
361 | +"""Custom controller for current user page.""" |
362 | + |
363 | +from twisted.internet.defer import inlineCallbacks |
364 | + |
365 | +from ubuntu_sso.qt import controllers |
366 | + |
367 | +from ubuntuone.platform.credentials import ( |
368 | + CredentialsManagementTool, |
369 | + CredentialsError, |
370 | +) |
371 | + |
372 | + |
373 | +class CurrentUserController(controllers.CurrentUserController): |
374 | + """Custom controller for current user page.""" |
375 | + |
376 | + @inlineCallbacks |
377 | + def login(self, *args): |
378 | + """Perform the login using the self.backend.""" |
379 | + email = str(self.view.ui.email_edit.text()) |
380 | + password = str(self.view.ui.password_edit.text()) |
381 | + credtool = CredentialsManagementTool() |
382 | + try: |
383 | + d = yield credtool.login_email_password( |
384 | + email=email, |
385 | + password=password, |
386 | + ) |
387 | + self.on_logged_in(self.view.wizard().app_name, d) |
388 | + except CredentialsError, e: |
389 | + print e, type(e), repr(e) |
390 | + self.on_login_error(e.args[0]) |
391 | |
392 | === removed file 'ubuntuone_installer/gui/qt/embedded_sso.py' |
393 | --- ubuntuone_installer/gui/qt/embedded_sso.py 2011-07-27 14:53:56 +0000 |
394 | +++ ubuntuone_installer/gui/qt/embedded_sso.py 1970-01-01 00:00:00 +0000 |
395 | @@ -1,61 +0,0 @@ |
396 | -# -*- coding: utf-8 -*- |
397 | - |
398 | -# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
399 | -# |
400 | -# Copyright 2011 Canonical Ltd. |
401 | -# |
402 | -# This program is free software: you can redistribute it and/or modify it |
403 | -# under the terms of the GNU General Public License version 3, as published |
404 | -# by the Free Software Foundation. |
405 | -# |
406 | -# This program is distributed in the hope that it will be useful, but |
407 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
408 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
409 | -# PURPOSE. See the GNU General Public License for more details. |
410 | -# |
411 | -# You should have received a copy of the GNU General Public License along |
412 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
413 | - |
414 | -"""The user interface for the Ubuntu One Installer's SSO client.""" |
415 | - |
416 | -import ubuntu_sso.qt.gui as sso_gui |
417 | - |
418 | -from ubuntuone_installer.gui.qt.gui import MainWindow |
419 | - |
420 | - |
421 | -class UbuntuSSOClientGUI(object): |
422 | - """A custom Client GUI for SSO.""" |
423 | - |
424 | - def __init__(self, app_name, tc_url, help_text, |
425 | - window_id=0, login_only=False): |
426 | - """Create a new instance.""" |
427 | - |
428 | - # create the controller and the ui, then set the cb and call the show |
429 | - # method so that we can work |
430 | - self.controller = sso_gui.UbuntuSSOWizardController( |
431 | - app_name, |
432 | - user_cancellation_callback=self._user_cancellation_callback) |
433 | - self.view = MainWindow() |
434 | - |
435 | - self.login_success_callback = lambda x, y: None |
436 | - self.registration_success_callback = lambda x, y: None |
437 | - self.user_cancellation_callback = lambda x: None |
438 | - |
439 | - self.view.loginSuccess.connect(self._login_success_callback) |
440 | - self.view.registrationSuccess.connect( |
441 | - self._registration_success_callback) |
442 | - self.view.userCancellation.connect(self._user_cancellation_callback) |
443 | - |
444 | - self.view.show() |
445 | - |
446 | - def _login_success_callback(self, app_name, email): |
447 | - """Call the real callback, set by the Credentials object""" |
448 | - self.login_success_callback(str(app_name), str(email)) |
449 | - |
450 | - def _registration_success_callback(self, app_name, email): |
451 | - """Call the real callback, set by the Credentials object""" |
452 | - self.registration_success_callback(str(app_name), str(email)) |
453 | - |
454 | - def _user_cancellation_callback(self, app_name): |
455 | - """Call the real callback, set by the Credentials object""" |
456 | - self.user_cancellation_callback(str(app_name)) |
457 | |
458 | === modified file 'ubuntuone_installer/gui/qt/forgotten.py' |
459 | --- ubuntuone_installer/gui/qt/forgotten.py 2011-07-19 21:06:06 +0000 |
460 | +++ ubuntuone_installer/gui/qt/forgotten.py 2011-08-02 12:48:37 +0000 |
461 | @@ -1,34 +1,34 @@ |
462 | -# -*- coding: utf-8 -*- |
463 | - |
464 | -# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
465 | -# |
466 | -# Copyright 2011 Canonical Ltd. |
467 | -# |
468 | -# This program is free software: you can redistribute it and/or modify it |
469 | -# under the terms of the GNU General Public License version 3, as published |
470 | -# by the Free Software Foundation. |
471 | -# |
472 | -# This program is distributed in the hope that it will be useful, but |
473 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
474 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
475 | -# PURPOSE. See the GNU General Public License for more details. |
476 | -# |
477 | -# You should have received a copy of the GNU General Public License along |
478 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
479 | - |
480 | -"""Custom forgotten password controller.""" |
481 | - |
482 | -from ubuntu_sso.qt import controllers |
483 | - |
484 | - |
485 | -class ForgottenPasswordController(controllers.ForgottenPasswordController): |
486 | - """A custom forgotten password controller. |
487 | - |
488 | - This controller hides the overlay as needed. |
489 | - """ |
490 | - |
491 | - def on_password_reset_error(self, app_name, error): |
492 | - """Hide the overlay, then do as the default controller does.""" |
493 | - self.view.wizard().overlay.hide() |
494 | - super(ForgottenPasswordController, |
495 | - self).on_password_reset_error(app_name, error) |
496 | +# -*- coding: utf-8 -*- |
497 | + |
498 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
499 | +# |
500 | +# Copyright 2011 Canonical Ltd. |
501 | +# |
502 | +# This program is free software: you can redistribute it and/or modify it |
503 | +# under the terms of the GNU General Public License version 3, as published |
504 | +# by the Free Software Foundation. |
505 | +# |
506 | +# This program is distributed in the hope that it will be useful, but |
507 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
508 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
509 | +# PURPOSE. See the GNU General Public License for more details. |
510 | +# |
511 | +# You should have received a copy of the GNU General Public License along |
512 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
513 | + |
514 | +"""Custom forgotten password controller.""" |
515 | + |
516 | +from ubuntu_sso.qt import controllers |
517 | + |
518 | + |
519 | +class ForgottenPasswordController(controllers.ForgottenPasswordController): |
520 | + """A custom forgotten password controller. |
521 | + |
522 | + This controller hides the overlay as needed. |
523 | + """ |
524 | + |
525 | + def on_password_reset_error(self, app_name, error): |
526 | + """Hide the overlay, then do as the default controller does.""" |
527 | + self.view.wizard().overlay.hide() |
528 | + super(ForgottenPasswordController, |
529 | + self).on_password_reset_error(app_name, error) |
530 | |
531 | === modified file 'ubuntuone_installer/gui/qt/gui.py' |
532 | --- ubuntuone_installer/gui/qt/gui.py 2011-07-28 18:24:58 +0000 |
533 | +++ ubuntuone_installer/gui/qt/gui.py 2011-08-02 12:48:37 +0000 |
534 | @@ -23,6 +23,8 @@ |
535 | |
536 | import gettext |
537 | |
538 | +from twisted.internet.defer import inlineCallbacks, returnValue |
539 | + |
540 | from PyQt4 import QtGui, QtCore |
541 | |
542 | from ubuntu_sso.qt.gui import ( |
543 | @@ -43,7 +45,6 @@ |
544 | from ubuntu_sso.qt.reset_password_ui import Ui_ResetPasswordPage |
545 | from ubuntu_sso.qt.controllers import ( |
546 | ChooseSignInController, |
547 | - CurrentUserController, |
548 | EmailVerificationController, |
549 | ErrorController, |
550 | ResetPasswordController, |
551 | @@ -58,6 +59,7 @@ |
552 | APP_NAME, |
553 | TC_URL, |
554 | ) |
555 | +from ubuntuone.platform.credentials import CredentialsManagementTool |
556 | |
557 | from ubuntuone_installer.logger import setup_logging |
558 | from ubuntuone_installer.gui.qt.ui import ( |
559 | @@ -73,6 +75,7 @@ |
560 | # pylint: enable=W0611 |
561 | |
562 | from ubuntuone_installer.gui.qt.are_you_sure import AreYouSure |
563 | +from ubuntuone_installer.gui.qt.currentuser import CurrentUserController |
564 | from ubuntuone_installer.gui.qt.forgotten import ForgottenPasswordController |
565 | from ubuntuone_installer.gui.qt.local_folders import LocalFoldersPage |
566 | from ubuntuone_installer.gui.qt.sync_now_or_later import SyncNowOrLaterPage |
567 | @@ -99,6 +102,7 @@ |
568 | super(LicensePage, self).__init__(parent) |
569 | self.ui = license_ui.Ui_Form() |
570 | self.ui.setupUi(self) |
571 | + self._next_id = None |
572 | |
573 | # Invalid names of Qt-inherited methods |
574 | # pylint: disable=C0103 |
575 | @@ -144,6 +148,12 @@ |
576 | printer.setPageSize(QtGui.QPrinter.A4) |
577 | document.print_(printer) |
578 | |
579 | + def nextId(self): |
580 | + """Return next page's ID.""" |
581 | + if self._next_id is None: |
582 | + return super(LicensePage, self).nextId() |
583 | + return self._next_id |
584 | + |
585 | |
586 | class SignInPage(QtGui.QWizardPage): |
587 | """Wizard Page that lets the user Sign into Ubuntu One.""" |
588 | @@ -314,8 +324,7 @@ |
589 | |
590 | self.setWindowTitle(APP_NAME) |
591 | self.setMinimumHeight(630) |
592 | - self.setMinimumWidth(820) |
593 | - self.setTitleFormat(QtCore.Qt.RichText) |
594 | + self.setMinimumWidth(800) |
595 | self.setWizardStyle(self.ModernStyle) |
596 | self.close_callback = close_callback |
597 | |
598 | @@ -328,7 +337,9 @@ |
599 | # PyQt doesn't support the (int, page) version of addPage, so |
600 | # Add the pages in the right order |
601 | # pylint: disable=C0103 |
602 | - self.LICENSE_PAGE = self.addPage(LicensePage()) |
603 | + |
604 | + self.LICENSE_PAGE = LicensePage() |
605 | + self.LICENSE_PAGE_ID = self.addPage(self.LICENSE_PAGE) |
606 | |
607 | #SSO Pages |
608 | title_page = TITLE_STYLE % SIGN_IN |
609 | @@ -339,7 +350,11 @@ |
610 | controller=self.sign_in_controller, |
611 | parent=self) |
612 | |
613 | - self.setup_controller = SetUpAccountController(message_box=self) |
614 | + title_page = TITLE_STYLE % _("Sign Up to Ubuntu One") |
615 | + subtitle = _("You only need to set up your account " |
616 | + "once to get access to Ubuntu One across your devices.") |
617 | + self.setup_controller = SetUpAccountController( |
618 | + message_box=self, title=title_page, subtitle=subtitle) |
619 | self.setup_account = SetupAccountPage( |
620 | setup_account_ui.Ui_SetUpAccountPage(), |
621 | self.setup_controller, |
622 | @@ -422,10 +437,20 @@ |
623 | # Apply font to the entire application |
624 | QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-R.ttf') |
625 | QtGui.QFontDatabase.addApplicationFont(':/Ubuntu-B.ttf') |
626 | + credtool = CredentialsManagementTool() |
627 | + d = credtool.find_credentials() |
628 | + d.addCallback(self.creds_cb) |
629 | |
630 | # Invalid name "closeEvent" |
631 | # pylint: disable=C0103 |
632 | |
633 | + def creds_cb(self, token): |
634 | + """Change wizard flow if we have credentials.""" |
635 | + if not token: |
636 | + self.LICENSE_PAGE._next_id = self.SIGNIN_PAGE |
637 | + else: |
638 | + self.LICENSE_PAGE._next_id = self.local_folders_page_id |
639 | + |
640 | def critical(self, *args, **kwargs): |
641 | """Wrapper for QMessageBox.critical that hides the overlay.""" |
642 | self.overlay.hide() |
643 | |
644 | === modified file 'ubuntuone_installer/gui/qt/local_folders.py' |
645 | --- ubuntuone_installer/gui/qt/local_folders.py 2011-07-22 16:32:35 +0000 |
646 | +++ ubuntuone_installer/gui/qt/local_folders.py 2011-08-02 12:48:37 +0000 |
647 | @@ -70,9 +70,10 @@ |
648 | |
649 | def __init__(self, parent=None): |
650 | super(LocalFoldersPage, self).__init__(parent) |
651 | - self.setTitle(LOCAL_FOLDERS_TITLE) |
652 | self.ui = local_folders_ui.Ui_Form() |
653 | self.ui.setupUi(self) |
654 | + self.ui.title_label.setText(LOCAL_FOLDERS_TITLE) |
655 | + self.ui.subtitle_label.setVisible(False) |
656 | |
657 | header_view = self.ui.folder_list.header() |
658 | header_view.setResizeMode(0, header_view.Stretch) |
659 | @@ -103,8 +104,13 @@ |
660 | # Special Folder "My Documents" |
661 | dll = ctypes.windll.shell32 |
662 | buf = ctypes.create_string_buffer(300) |
663 | - dll.SHGetSpecialFolderPathA(None, buf, 0x0005, False) |
664 | - result = [buf.value, ] |
665 | + dll.SHGetSpecialFolderPathA(None, buf, 5, False) |
666 | + docs = buf.value |
667 | + dll.SHGetSpecialFolderPathA(None, buf, 13, False) |
668 | + music = buf.value |
669 | + dll.SHGetSpecialFolderPathA(None, buf, 39, False) |
670 | + pictures = buf.value |
671 | + return [docs, music, pictures] |
672 | else: |
673 | result = ['To be implemented'] |
674 | return result |
675 | |
676 | === removed file 'ubuntuone_installer/gui/qt/main/tests/test_main.py' |
677 | --- ubuntuone_installer/gui/qt/main/tests/test_main.py 2011-07-27 15:09:28 +0000 |
678 | +++ ubuntuone_installer/gui/qt/main/tests/test_main.py 1970-01-01 00:00:00 +0000 |
679 | @@ -1,97 +0,0 @@ |
680 | -# -*- coding: utf-8 -*- |
681 | - |
682 | -# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
683 | -# |
684 | -# Copyright 2011 Canonical Ltd. |
685 | -# |
686 | -# This program is free software: you can redistribute it and/or modify it |
687 | -# under the terms of the GNU General Public License version 3, as published |
688 | -# by the Free Software Foundation. |
689 | -# |
690 | -# This program is distributed in the hope that it will be useful, but |
691 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
692 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
693 | -# PURPOSE. See the GNU General Public License for more details. |
694 | -# |
695 | -# You should have received a copy of the GNU General Public License along |
696 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
697 | - |
698 | -"""The test suite for the Qt UI of the Ubuntu One Installer.""" |
699 | - |
700 | -from ubuntuone_installer.tests import TestCase |
701 | - |
702 | -import ubuntuone_installer.gui.qt.main.windows as main_module |
703 | - |
704 | -# pylint: disable=W0212 |
705 | - |
706 | -from ubuntuone.platform.credentials import ( |
707 | - APP_NAME, |
708 | - DESCRIPTION, |
709 | - TC_URL, |
710 | -) |
711 | - |
712 | - |
713 | -class FakeSSOCred(object): |
714 | - """A fake sso_cred.""" |
715 | - |
716 | - _registered_to_signal = False |
717 | - _login_args = () |
718 | - on_credentials_found = None |
719 | - |
720 | - def register_to_signals(self): |
721 | - """Fake method.""" |
722 | - self._registered_to_signal = True |
723 | - |
724 | - def login_or_register_to_get_credentials(self, *args, **kwargs): |
725 | - """Fake method.""" |
726 | - self._login_args = (args, kwargs) |
727 | - |
728 | - |
729 | -class FakeSSOClient(object): |
730 | - |
731 | - """Fake UbuntuSSOClient.""" |
732 | - |
733 | - sso_cred = FakeSSOCred() |
734 | - testcase = None |
735 | - |
736 | - def connect(self): |
737 | - """Fake method.""" |
738 | - self.testcase._connected = True |
739 | - return self |
740 | - |
741 | - |
742 | -class MainTestCase(TestCase): |
743 | - |
744 | - """Tests for the main() function.""" |
745 | - |
746 | - _connected = False |
747 | - |
748 | - def setUp(self): |
749 | - """Prepare tests.""" |
750 | - self.patch(main_module, "UbuntuSSOClient", FakeSSOClient) |
751 | - main_module.UbuntuSSOClient.testcase = self |
752 | - |
753 | - def test_connect(self): |
754 | - """Test that we instantiate the SSO Client and connect.""" |
755 | - main_module.main() |
756 | - self.assertEqual(FakeSSOClient.testcase._connected, True) |
757 | - |
758 | - def test_credentials_found_cb(self): |
759 | - """Test that the credentials found signal is connected.""" |
760 | - main_module.main() |
761 | - self.assertEqual( |
762 | - FakeSSOClient.sso_cred.on_credentials_found_cb.__name__, |
763 | - "stop") |
764 | - |
765 | - def test_registered(self): |
766 | - """Test that the credentials registers to signals.""" |
767 | - main_module.main() |
768 | - self.assertEqual(FakeSSOClient.sso_cred._registered_to_signal, |
769 | - True) |
770 | - |
771 | - def test_check_register_args(self): |
772 | - """Test that the credentials registers to signals.""" |
773 | - main_module.main() |
774 | - self.assertEqual(FakeSSOClient.sso_cred._login_args, |
775 | - ((APP_NAME, TC_URL, DESCRIPTION, 0), |
776 | - {'ui_module': 'ubuntuone_installer.gui.qt.embedded_sso'})) |
777 | |
778 | === modified file 'ubuntuone_installer/gui/qt/main/windows.py' |
779 | --- ubuntuone_installer/gui/qt/main/windows.py 2011-07-27 14:53:56 +0000 |
780 | +++ ubuntuone_installer/gui/qt/main/windows.py 2011-08-02 12:48:37 +0000 |
781 | @@ -19,34 +19,25 @@ |
782 | |
783 | # pylint: disable=E1101, F0401, W0404 |
784 | |
785 | -from twisted.internet.defer import inlineCallbacks |
786 | -from ubuntu_sso.main.windows import UbuntuSSOClient |
787 | - |
788 | -from ubuntuone.platform.credentials import ( |
789 | - APP_NAME, |
790 | - DESCRIPTION, |
791 | - TC_URL, |
792 | -) |
793 | - |
794 | - |
795 | -@inlineCallbacks |
796 | +import sys |
797 | +from PyQt4 import QtGui |
798 | + |
799 | + |
800 | +def stop(*args): |
801 | + """End the process.""" |
802 | + from twisted.internet import reactor |
803 | + reactor.stop() |
804 | + |
805 | + |
806 | def main(): |
807 | """Perform a client request to be logged in.""" |
808 | - client = UbuntuSSOClient() |
809 | - client = yield client.connect() |
810 | - |
811 | - @inlineCallbacks |
812 | - def stop(*args): |
813 | - """End the process.""" |
814 | - from twisted.internet import reactor |
815 | - yield client.sso_cred.unregister_to_signals() |
816 | - reactor.stop() |
817 | - |
818 | - client.sso_cred.on_credentials_found_cb = stop |
819 | - client.sso_cred.on_authorization_denied_cb = stop |
820 | - client.sso_cred.on_credentials_error_cb = stop |
821 | - yield client.sso_cred.register_to_signals() |
822 | - yield client.sso_cred.login_or_register_to_get_credentials(APP_NAME, |
823 | - TC_URL, |
824 | - DESCRIPTION, 0, |
825 | - ui_module="ubuntuone_installer.gui.qt.embedded_sso") |
826 | + |
827 | + app = QtGui.QApplication(sys.argv) |
828 | + import qtreactor.qt4reactor |
829 | + qtreactor.qt4reactor.install() |
830 | + from ubuntuone_installer.gui.qt.gui import MainWindow |
831 | + from twisted.internet import reactor |
832 | + window = MainWindow(close_callback=stop) |
833 | + app.window = window |
834 | + window.show() |
835 | + reactor.run() |
836 | |
837 | === modified file 'ubuntuone_installer/gui/qt/setup_account.py' |
838 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-07-28 18:24:58 +0000 |
839 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-08-02 12:48:37 +0000 |
840 | @@ -31,7 +31,6 @@ |
841 | # pylint: disable=C0103 |
842 | BAD = u'<img src=":/password_hint_warning.png" /><font color="red"> %s </font>' |
843 | GOOD = u'<img src=":/password_hint_ok.png" /><font color="green"> %s </font>' |
844 | -TITLE_STYLE = "<span style=\"font-size:24px\">%s</span>" |
845 | |
846 | EMPTY_NAME = _("Please enter your name") |
847 | INVALID_EMAIL = _("Please enter a valid email address") |
848 | @@ -53,10 +52,6 @@ |
849 | """Setup UI details.""" |
850 | # We need to override some texts from SSO |
851 | # to match our spec |
852 | - title_page = TITLE_STYLE % _("Sign Up to Ubuntu One") |
853 | - self.setTitle(title_page) |
854 | - self.setSubTitle(_("You only need to set up your account " |
855 | - "once to get access to Ubuntu One across your devices.")) |
856 | |
857 | self.ui.name_label.setText(_("Name")) |
858 | self.ui.email_label.setText(_("Email")) |
859 | |
860 | === modified file 'ubuntuone_installer/gui/qt/sync_now_or_later.py' |
861 | --- ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-06-29 11:44:23 +0000 |
862 | +++ ubuntuone_installer/gui/qt/sync_now_or_later.py 2011-08-02 12:48:37 +0000 |
863 | @@ -1,44 +1,44 @@ |
864 | -# -*- coding: utf-8 -*- |
865 | - |
866 | -# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
867 | -# |
868 | -# Copyright 2011 Canonical Ltd. |
869 | -# |
870 | -# This program is free software: you can redistribute it and/or modify it |
871 | -# under the terms of the GNU General Public License version 3, as published |
872 | -# by the Free Software Foundation. |
873 | -# |
874 | -# This program is distributed in the hope that it will be useful, but |
875 | -# WITHOUT ANY WARRANTY; without even the implied warranties of |
876 | -# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
877 | -# PURPOSE. See the GNU General Public License for more details. |
878 | -# |
879 | -# You should have received a copy of the GNU General Public License along |
880 | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
881 | - |
882 | -"""The user interface for the Ubuntu One Installer.""" |
883 | - |
884 | -from PyQt4 import QtGui |
885 | - |
886 | -from ubuntuone_installer.gui.qt.ui import sync_now_or_later_ui |
887 | - |
888 | - |
889 | -class SyncNowOrLaterPage(QtGui.QWizardPage): |
890 | - """User can choose whether to sync now, later, or selectively""" |
891 | - |
892 | - def __init__(self, parent=None): |
893 | - QtGui.QWizardPage.__init__(self, parent) |
894 | - self.ui = sync_now_or_later_ui.Ui_Form() |
895 | - self.ui.setupUi(self) |
896 | - self.registerField("sync_now", self.ui.sync_now) |
897 | - self.registerField("sync_later", self.ui.sync_later) |
898 | - self.registerField("sync_custom", self.ui.sync_custom) |
899 | - |
900 | - # Invalid names of Qt-inherited methods |
901 | - # pylint: disable=C0103 |
902 | - |
903 | - def initializePage(self): |
904 | - """Setup UI details""" |
905 | - self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False) |
906 | - self.wizard().setOption(QtGui.QWizard.NoCancelButton, True) |
907 | - self.wizard()._next_id = None |
908 | +# -*- coding: utf-8 -*- |
909 | + |
910 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
911 | +# |
912 | +# Copyright 2011 Canonical Ltd. |
913 | +# |
914 | +# This program is free software: you can redistribute it and/or modify it |
915 | +# under the terms of the GNU General Public License version 3, as published |
916 | +# by the Free Software Foundation. |
917 | +# |
918 | +# This program is distributed in the hope that it will be useful, but |
919 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
920 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
921 | +# PURPOSE. See the GNU General Public License for more details. |
922 | +# |
923 | +# You should have received a copy of the GNU General Public License along |
924 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
925 | + |
926 | +"""The user interface for the Ubuntu One Installer.""" |
927 | + |
928 | +from PyQt4 import QtGui |
929 | + |
930 | +from ubuntuone_installer.gui.qt.ui import sync_now_or_later_ui |
931 | + |
932 | + |
933 | +class SyncNowOrLaterPage(QtGui.QWizardPage): |
934 | + """User can choose whether to sync now, later, or selectively""" |
935 | + |
936 | + def __init__(self, parent=None): |
937 | + QtGui.QWizardPage.__init__(self, parent) |
938 | + self.ui = sync_now_or_later_ui.Ui_Form() |
939 | + self.ui.setupUi(self) |
940 | + self.registerField("sync_now", self.ui.sync_now) |
941 | + self.registerField("sync_later", self.ui.sync_later) |
942 | + self.registerField("sync_custom", self.ui.sync_custom) |
943 | + |
944 | + # Invalid names of Qt-inherited methods |
945 | + # pylint: disable=C0103 |
946 | + |
947 | + def initializePage(self): |
948 | + """Setup UI details""" |
949 | + self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False) |
950 | + self.wizard().setOption(QtGui.QWizard.NoCancelButton, True) |
951 | + self.wizard()._next_id = None |
952 | |
953 | === added file 'ubuntuone_installer/gui/qt/tests/test_currentuser.py' |
954 | --- ubuntuone_installer/gui/qt/tests/test_currentuser.py 1970-01-01 00:00:00 +0000 |
955 | +++ ubuntuone_installer/gui/qt/tests/test_currentuser.py 2011-08-02 12:48:37 +0000 |
956 | @@ -0,0 +1,90 @@ |
957 | +# -*- coding: utf-8 -*- |
958 | + |
959 | +# Authors: Roberto Alsina <roberto.alsina@canonical.com> |
960 | +# |
961 | +# Copyright 2011 Canonical Ltd. |
962 | +# |
963 | +# This program is free software: you can redistribute it and/or modify it |
964 | +# under the terms of the GNU General Public License version 3, as published |
965 | +# by the Free Software Foundation. |
966 | +# |
967 | +# This program is distributed in the hope that it will be useful, but |
968 | +# WITHOUT ANY WARRANTY; without even the implied warranties of |
969 | +# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
970 | +# PURPOSE. See the GNU General Public License for more details. |
971 | +# |
972 | +# You should have received a copy of the GNU General Public License along |
973 | +# with this program. If not, see <http://www.gnu.org/licenses/>. |
974 | + |
975 | +"""Tests for the CurrentUserController.""" |
976 | + |
977 | +from ubuntuone_installer.gui.qt import currentuser |
978 | +from ubuntuone_installer.gui.qt.tests import BaseTestCase |
979 | + |
980 | + |
981 | +class FakeView(object): |
982 | + |
983 | + """A Fake view for the controller.""" |
984 | + |
985 | + def __init__(self): |
986 | + """Setup.""" |
987 | + self.view = self |
988 | + self.ui = self |
989 | + self.email_edit = self |
990 | + self.password_edit = self |
991 | + self.app_name = "APP" |
992 | + |
993 | + def text(self): |
994 | + """Return some text.""" |
995 | + return "text" |
996 | + |
997 | + def wizard(self): |
998 | + """"Fake the wizard() method of QWizardPage.""" |
999 | + return self |
1000 | + |
1001 | + |
1002 | +class FakeCredentialsManagementToolSuccess(object): |
1003 | + |
1004 | + """A fake CredentialsManagementTool where login succeeds.""" |
1005 | + |
1006 | + def login_email_password(self, *args, **kwargs): |
1007 | + """Fake credentials.""" |
1008 | + return {"x": "y"} |
1009 | + |
1010 | + |
1011 | +class FakeCredentialsManagementToolFailure(object): |
1012 | + |
1013 | + """A fake CredentialsManagementTool where login fails.""" |
1014 | + |
1015 | + def login_email_password(self, *args, **kwargs): |
1016 | + """Raises a credentials exception.""" |
1017 | + raise currentuser.CredentialsError("Failure") |
1018 | + |
1019 | + |
1020 | +class CurrentUserTestCase(BaseTestCase): |
1021 | + |
1022 | + """Test the CurrentUserController.""" |
1023 | + |
1024 | + class_ui = FakeView |
1025 | + |
1026 | + def setUp(self): |
1027 | + """Initialize this test instance.""" |
1028 | + self.controller = currentuser.CurrentUserController() |
1029 | + self.controller.view = FakeView() |
1030 | + super(CurrentUserTestCase, self).setUp() |
1031 | + |
1032 | + def test_login_success(self): |
1033 | + """Check that login works correctly.""" |
1034 | + self.patch(currentuser, 'CredentialsManagementTool', |
1035 | + FakeCredentialsManagementToolSuccess) |
1036 | + self.patch(self.controller, 'on_logged_in', self._set_called) |
1037 | + self.controller.login() |
1038 | + self.assertEqual(self._called, (('APP', {'x': 'y'}), {})) |
1039 | + |
1040 | + def test_login_failure(self): |
1041 | + """Check that login fails correctly.""" |
1042 | + self.patch(currentuser, 'CredentialsManagementTool', |
1043 | + FakeCredentialsManagementToolFailure) |
1044 | + self.patch(self.controller, 'on_login_error', self._set_called) |
1045 | + self.controller.login() |
1046 | + self.assertEqual(self._called, (('Failure',), {})) |
1047 | |
1048 | === modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py' |
1049 | --- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-07-27 15:09:28 +0000 |
1050 | +++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-08-02 12:48:37 +0000 |
1051 | @@ -24,6 +24,8 @@ |
1052 | import shutil |
1053 | import tempfile |
1054 | |
1055 | +from twisted.internet import reactor, defer |
1056 | + |
1057 | from PyQt4 import QtCore |
1058 | |
1059 | from ubuntuone.platform.credentials import ( |
1060 | @@ -35,7 +37,6 @@ |
1061 | |
1062 | from ubuntuone_installer.gui.qt import gui |
1063 | from ubuntuone_installer.gui.qt.tests import BaseTestCase |
1064 | -from ubuntuone_installer.gui.qt import embedded_sso |
1065 | from ubuntuone_installer.gui.qt import forgotten |
1066 | from ubuntuone_installer.gui.qt import local_folders |
1067 | from ubuntuone_installer.gui.qt import setup_account |
1068 | @@ -51,6 +52,16 @@ |
1069 | u'token_secret': u'qFYImEtlczPbsCnYyuwLoPDlPEnvNcIktZphPQklAWrvyfFMV'} |
1070 | |
1071 | |
1072 | +class FakeFailureCredentialsManagementTool(object): |
1073 | + |
1074 | + """A fake CredentialsManagementTool that fails.""" |
1075 | + |
1076 | + def find_credentials(self): |
1077 | + """Return a deferred that never triggers callback.""" |
1078 | + d = defer.Deferred() |
1079 | + return d |
1080 | + |
1081 | + |
1082 | class FakeController(object): |
1083 | |
1084 | """A fake controller for the tests.""" |
1085 | @@ -99,6 +110,9 @@ |
1086 | """Fake hide.""" |
1087 | self.hide_counter += 1 |
1088 | |
1089 | + def resize(self, *args): |
1090 | + """Fake resize.""" |
1091 | + |
1092 | |
1093 | class MainWindowTestCase(BaseTestCase): |
1094 | """Test the qt main window.""" |
1095 | @@ -118,6 +132,8 @@ |
1096 | self.patch(gui, "ResetPasswordController", FakeController) |
1097 | self.patch(gui, "AreYouSure", FakeAreYouSure) |
1098 | self.patch(gui, "LoadingOverlay", FakeOverlay) |
1099 | + self.patch(gui, "CredentialsManagementTool", |
1100 | + FakeFailureCredentialsManagementTool) |
1101 | super(MainWindowTestCase, self).setUp() |
1102 | |
1103 | def test_critical(self): |
1104 | @@ -276,7 +292,7 @@ |
1105 | |
1106 | def test_stage_progression_1(self): |
1107 | """Check that each page in the wizard sets the correct stage.""" |
1108 | - self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE) |
1109 | + self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE_ID) |
1110 | self.assertEqual(self.ui.sideWidget().stage, 0) |
1111 | |
1112 | def test_stage_progression_2(self): |
1113 | @@ -345,6 +361,16 @@ |
1114 | QtCore.QCoreApplication.instance().processEvents() |
1115 | self.assertEqual(self.ui.result(), self.ui.Rejected) |
1116 | |
1117 | + def test_license_next(self): |
1118 | + """Test what's the license page's nextID.""" |
1119 | + self.assertEqual(self.ui.LICENSE_PAGE.nextId(), self.ui.SIGNIN_PAGE) |
1120 | + |
1121 | + def test_license_next(self): |
1122 | + """Test what's the license page's nextID.""" |
1123 | + self.ui.creds_cb("fakecreds") |
1124 | + self.assertEqual(self.ui.LICENSE_PAGE.nextId(), |
1125 | + self.ui.local_folders_page_id) |
1126 | + |
1127 | |
1128 | class FakeSignal(object): |
1129 | |
1130 | @@ -373,51 +399,6 @@ |
1131 | self.shown = True |
1132 | |
1133 | |
1134 | -class SSOGuiTestCase(BaseTestCase): |
1135 | - """Test the custom SSO GUI.""" |
1136 | - |
1137 | - class_ui = embedded_sso.UbuntuSSOClientGUI |
1138 | - |
1139 | - def setUp(self): |
1140 | - """Initialize this test instance.""" |
1141 | - self.kwargs = { |
1142 | - 'app_name': APP_NAME, |
1143 | - 'tc_url': TC_URL, |
1144 | - 'help_text': '', |
1145 | - } |
1146 | - self.patch(embedded_sso, "MainWindow", FakeMainWindow) |
1147 | - super(SSOGuiTestCase, self).setUp() |
1148 | - |
1149 | - def test_sso_client_gui(self): |
1150 | - """Ensure the class instantiates correctly.""" |
1151 | - self.assertIsInstance( |
1152 | - self.ui.controller, |
1153 | - ubuntu_sso.qt.controllers.UbuntuSSOWizardController) |
1154 | - self.assertIsInstance(self.ui.view, FakeMainWindow) |
1155 | - |
1156 | - def test_login_callback(self): |
1157 | - """Test that the login success callback is correctly handled.""" |
1158 | - self.ui.login_success_callback = self._set_called |
1159 | - self.ui.view.loginSuccess.emit("app", "email") |
1160 | - self.assertEqual(self._called, (('app', 'email'), {})) |
1161 | - |
1162 | - def test_registration_callback(self): |
1163 | - """Test that the registration success callback is correctly handled.""" |
1164 | - self.ui.registration_success_callback = self._set_called |
1165 | - self.ui.view.registrationSuccess.emit("app", "email") |
1166 | - self.assertEqual(self._called, (('app', 'email'), {})) |
1167 | - |
1168 | - def test_cancellation_callback(self): |
1169 | - """Test that the cancellation callback is called right.""" |
1170 | - self.ui.user_cancellation_callback = self._set_called |
1171 | - self.ui.view.userCancellation.emit("app") |
1172 | - self.assertEqual(self._called, (('app',), {})) |
1173 | - |
1174 | - def test_view_is_shown(self): |
1175 | - """Test that the view is actually shown.""" |
1176 | - self.assertTrue(self.ui.view.shown) |
1177 | - |
1178 | - |
1179 | class LocalFoldersTestCase(BaseTestCase): |
1180 | """Test the LocalFoldersPage code.""" |
1181 | |
1182 | @@ -450,16 +431,10 @@ |
1183 | self.assertEqual(path, self.tmpdir) |
1184 | self.assertEqual(size, 1337) |
1185 | |
1186 | - def test_item_addition_removal(self): |
1187 | + def test_item_addition(self): |
1188 | """Add an item (plus the default one), then remove them.""" |
1189 | self.ui.add_folder(self.tmpdir) |
1190 | - self.assertEqual(2, self.ui.ui.folder_list.topLevelItemCount()) |
1191 | - self.ui.on_folder_list_itemClicked( |
1192 | - self.ui.ui.folder_list.topLevelItem(0), 2) |
1193 | - self.ui.on_folder_list_itemClicked( |
1194 | - self.ui.ui.folder_list.topLevelItem(0), 2) |
1195 | - self.assertEqual(0, self.ui.ui.folder_list.topLevelItemCount()) |
1196 | - self.assertEqual({}, self.ui.items) |
1197 | + self.assertEqual(4, self.ui.ui.folder_list.topLevelItemCount()) |
1198 | |
1199 | def test_total_size(self): |
1200 | """Test that the header reflects the change in item sizes.""" |
1201 | @@ -500,6 +475,7 @@ |
1202 | item = self.ui.add_folder(os.path.join("xyzzy", "xyzzy", "xyzzy")) |
1203 | self.assertEqual(1, self.ui.ui.folder_list.topLevelItemCount()) |
1204 | item.thread.run() |
1205 | + item.thread.join() |
1206 | self.ui.update_sizes() |
1207 | self.assertEqual(0, item.size) |
1208 | # world did not explode |
1209 | @@ -743,16 +719,16 @@ |
1210 | self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE) |
1211 | self.assertEqual( |
1212 | True, |
1213 | - sideWidget().ui.states_frame.isVisible()) |
1214 | + self.ui.sideWidget().ui.states_frame.isVisible()) |
1215 | self.ui.on_currentIdChanged(self.ui.SIGNIN_PAGE) |
1216 | self.assertEqual( |
1217 | True, |
1218 | - sideWidget().ui.states_frame.isVisible()) |
1219 | + self.ui.sideWidget().ui.states_frame.isVisible()) |
1220 | self.ui.on_currentIdChanged(self.ui.local_folders_page_id) |
1221 | self.assertEqual( |
1222 | True, |
1223 | - sideWidget().ui.states_frame.isVisible()) |
1224 | + self.ui.sideWidget().ui.states_frame.isVisible()) |
1225 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) |
1226 | self.assertEqual( |
1227 | True, |
1228 | - sideWidget().ui.states_frame.isVisible()) |
1229 | + self.ui.sideWidget().ui.states_frame.isVisible()) |
Both of the revisions says merge, but the first one is:
"Add Title and Subtitle labels into the UI to avoid the resizing of the SideWidget"