Merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel
- cloud-to-computer-page
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 296 |
Merged at revision: | 289 |
Proposed branch: | lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page |
Merge into: | lp:ubuntuone-control-panel |
Diff against target: |
1455 lines (+810/-180) 9 files modified
data/qt/are_you_sure.ui (+153/-0) data/qt/folders.ui (+10/-3) ubuntuone/controlpanel/gui/__init__.py (+15/-0) ubuntuone/controlpanel/gui/qt/controlpanel.py (+3/-1) ubuntuone/controlpanel/gui/qt/folders.py (+46/-19) ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+5/-0) ubuntuone/controlpanel/gui/qt/tests/test_folders.py (+164/-91) ubuntuone/controlpanel/gui/qt/tests/test_wizard.py (+240/-49) ubuntuone/controlpanel/gui/qt/wizard.py (+174/-17) |
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Roberto Alsina (community) | Approve | ||
Eric Casteleijn (community) | Approve | ||
Review via email: mp+97990@code.launchpad.net |
Description of the change
To test IRL, please have nightlies installed and up to date. Then, from this branch, please run:
./setup.py clean build; U1_DEBUG=True PYTHONPATH=. bin/ubuntuone-
Assuming you already have U1 credentials, go to the devices tab and remove the current device. You will be presented with the initial screen, where you can play with:
- closing from the button in the right bottom corner, you should get a confirmation dialog
- after login/register you should be presented with a screen to choose cloud folders to sync from your cloud to your desktop
- optionally, you can play with settings clicking on the button at the end of the folder listing
Roberto Alsina (ralsina) wrote : | # |
In the confirmation dialog, the texts in the buttons appear cutoff (to force it, make the dialog smaller). I can't quite figure out why, let's ask Diego. In any case, not a blocker for the branch.
Roberto Alsina (ralsina) wrote : | # |
If the user has subscribed UDFs, it should not be shown the cloud-to-computer page (or the computer-to-cloud page when it's added).
Those pages are only meant for new users, and those who have subscribed UDFs don't fit that description.
Also, it's a UX change from the windows behaviour.
Aditionally, the behviour where this page shows the remote folders, and when you click on one it disappears is a UX change from the windows behaviour, and just strange. The changes should only be applied when the user moves to the next page.
Roberto Alsina (ralsina) wrote : | # |
Perhaps we should just:
a) check if the user has any subscribed folders
b) if no -> move onto next page
c) if yes -> show the "real" folders page. That way a tentative user, who subscribes to a UDF and then decides he didn't really want to do it, can undo it.
That should not involve huge changes to the code, right?
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
BackendAccoun
test_
test_
test_
test_
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendBasicT
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendCreden
test_
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
BackendAccoun
test_
test_
test_
test_
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendBasicT
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendCreden
test_
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
BackendAccoun
test_
test_
test_
test_
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendBasicT
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendCreden
test_
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
BackendAccoun
test_
test_
test_
test_
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendBasicT
test_
test_
test_get_token ... [OK]
test_
test_
test_
test_
test_
BackendCreden
test_
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-control-panel/cloud-to-computer-page into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
Traceback (most recent call last):
File "/usr/bin/u1trial", line 325, in <module>
main()
File "/usr/bin/u1trial", line 305, in main
suite = trial_runner.
File "/usr/bin/u1trial", line 184, in get_suite
config[
File "/usr/bin/u1trial", line 168, in _collect_tests
module_suite = self._load_
File "/usr/bin/u1trial", line 108, in _load_unittest
module = __import__(modpath, None, None, [""])
File "/mnt/tarmac/
from ubuntuone.
File "/mnt/tarmac/
from ubuntuone.platform import is_link
ImportError: No module named platform
Preview Diff
1 | === added file 'data/qt/are_you_sure.ui' | |||
2 | --- data/qt/are_you_sure.ui 1970-01-01 00:00:00 +0000 | |||
3 | +++ data/qt/are_you_sure.ui 2012-03-19 14:00:47 +0000 | |||
4 | @@ -0,0 +1,153 @@ | |||
5 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
6 | 2 | <ui version="4.0"> | ||
7 | 3 | <class>Dialog</class> | ||
8 | 4 | <widget class="QDialog" name="Dialog"> | ||
9 | 5 | <property name="geometry"> | ||
10 | 6 | <rect> | ||
11 | 7 | <x>0</x> | ||
12 | 8 | <y>0</y> | ||
13 | 9 | <width>409</width> | ||
14 | 10 | <height>196</height> | ||
15 | 11 | </rect> | ||
16 | 12 | </property> | ||
17 | 13 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
18 | 14 | <item> | ||
19 | 15 | <widget class="QLabel" name="title_label"> | ||
20 | 16 | <property name="text"> | ||
21 | 17 | <string notr="true">Are you sure?</string> | ||
22 | 18 | </property> | ||
23 | 19 | <property name="textFormat"> | ||
24 | 20 | <enum>Qt::PlainText</enum> | ||
25 | 21 | </property> | ||
26 | 22 | </widget> | ||
27 | 23 | </item> | ||
28 | 24 | <item> | ||
29 | 25 | <widget class="QLabel" name="message_label"> | ||
30 | 26 | <property name="text"> | ||
31 | 27 | <string notr="true">more explanation</string> | ||
32 | 28 | </property> | ||
33 | 29 | <property name="textFormat"> | ||
34 | 30 | <enum>Qt::AutoText</enum> | ||
35 | 31 | </property> | ||
36 | 32 | <property name="wordWrap"> | ||
37 | 33 | <bool>true</bool> | ||
38 | 34 | </property> | ||
39 | 35 | <property name="openExternalLinks"> | ||
40 | 36 | <bool>true</bool> | ||
41 | 37 | </property> | ||
42 | 38 | </widget> | ||
43 | 39 | </item> | ||
44 | 40 | <item> | ||
45 | 41 | <spacer name="verticalSpacer"> | ||
46 | 42 | <property name="orientation"> | ||
47 | 43 | <enum>Qt::Vertical</enum> | ||
48 | 44 | </property> | ||
49 | 45 | <property name="sizeHint" stdset="0"> | ||
50 | 46 | <size> | ||
51 | 47 | <width>20</width> | ||
52 | 48 | <height>40</height> | ||
53 | 49 | </size> | ||
54 | 50 | </property> | ||
55 | 51 | </spacer> | ||
56 | 52 | </item> | ||
57 | 53 | <item> | ||
58 | 54 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
59 | 55 | <item> | ||
60 | 56 | <spacer name="horizontalSpacer"> | ||
61 | 57 | <property name="orientation"> | ||
62 | 58 | <enum>Qt::Horizontal</enum> | ||
63 | 59 | </property> | ||
64 | 60 | <property name="sizeHint" stdset="0"> | ||
65 | 61 | <size> | ||
66 | 62 | <width>40</width> | ||
67 | 63 | <height>20</height> | ||
68 | 64 | </size> | ||
69 | 65 | </property> | ||
70 | 66 | </spacer> | ||
71 | 67 | </item> | ||
72 | 68 | <item> | ||
73 | 69 | <widget class="QPushButton" name="yes_button"> | ||
74 | 70 | <property name="text"> | ||
75 | 71 | <string notr="true">Yeah</string> | ||
76 | 72 | </property> | ||
77 | 73 | <property name="autoDefault"> | ||
78 | 74 | <bool>false</bool> | ||
79 | 75 | </property> | ||
80 | 76 | </widget> | ||
81 | 77 | </item> | ||
82 | 78 | <item> | ||
83 | 79 | <spacer name="horizontalSpacer_2"> | ||
84 | 80 | <property name="orientation"> | ||
85 | 81 | <enum>Qt::Horizontal</enum> | ||
86 | 82 | </property> | ||
87 | 83 | <property name="sizeHint" stdset="0"> | ||
88 | 84 | <size> | ||
89 | 85 | <width>40</width> | ||
90 | 86 | <height>20</height> | ||
91 | 87 | </size> | ||
92 | 88 | </property> | ||
93 | 89 | </spacer> | ||
94 | 90 | </item> | ||
95 | 91 | <item> | ||
96 | 92 | <widget class="QPushButton" name="no_button"> | ||
97 | 93 | <property name="text"> | ||
98 | 94 | <string notr="true">Nopes</string> | ||
99 | 95 | </property> | ||
100 | 96 | <property name="default"> | ||
101 | 97 | <bool>true</bool> | ||
102 | 98 | </property> | ||
103 | 99 | </widget> | ||
104 | 100 | </item> | ||
105 | 101 | <item> | ||
106 | 102 | <spacer name="horizontalSpacer_3"> | ||
107 | 103 | <property name="orientation"> | ||
108 | 104 | <enum>Qt::Horizontal</enum> | ||
109 | 105 | </property> | ||
110 | 106 | <property name="sizeHint" stdset="0"> | ||
111 | 107 | <size> | ||
112 | 108 | <width>40</width> | ||
113 | 109 | <height>20</height> | ||
114 | 110 | </size> | ||
115 | 111 | </property> | ||
116 | 112 | </spacer> | ||
117 | 113 | </item> | ||
118 | 114 | </layout> | ||
119 | 115 | </item> | ||
120 | 116 | </layout> | ||
121 | 117 | </widget> | ||
122 | 118 | <resources/> | ||
123 | 119 | <connections> | ||
124 | 120 | <connection> | ||
125 | 121 | <sender>no_button</sender> | ||
126 | 122 | <signal>clicked()</signal> | ||
127 | 123 | <receiver>Dialog</receiver> | ||
128 | 124 | <slot>reject()</slot> | ||
129 | 125 | <hints> | ||
130 | 126 | <hint type="sourcelabel"> | ||
131 | 127 | <x>272</x> | ||
132 | 128 | <y>174</y> | ||
133 | 129 | </hint> | ||
134 | 130 | <hint type="destinationlabel"> | ||
135 | 131 | <x>330</x> | ||
136 | 132 | <y>129</y> | ||
137 | 133 | </hint> | ||
138 | 134 | </hints> | ||
139 | 135 | </connection> | ||
140 | 136 | <connection> | ||
141 | 137 | <sender>yes_button</sender> | ||
142 | 138 | <signal>clicked()</signal> | ||
143 | 139 | <receiver>Dialog</receiver> | ||
144 | 140 | <slot>accept()</slot> | ||
145 | 141 | <hints> | ||
146 | 142 | <hint type="sourcelabel"> | ||
147 | 143 | <x>118</x> | ||
148 | 144 | <y>167</y> | ||
149 | 145 | </hint> | ||
150 | 146 | <hint type="destinationlabel"> | ||
151 | 147 | <x>163</x> | ||
152 | 148 | <y>122</y> | ||
153 | 149 | </hint> | ||
154 | 150 | </hints> | ||
155 | 151 | </connection> | ||
156 | 152 | </connections> | ||
157 | 153 | </ui> | ||
158 | 0 | 154 | ||
159 | === modified file 'data/qt/folders.ui' | |||
160 | --- data/qt/folders.ui 2012-03-02 13:53:24 +0000 | |||
161 | +++ data/qt/folders.ui 2012-03-19 14:00:47 +0000 | |||
162 | @@ -6,7 +6,7 @@ | |||
163 | 6 | <rect> | 6 | <rect> |
164 | 7 | <x>0</x> | 7 | <x>0</x> |
165 | 8 | <y>0</y> | 8 | <y>0</y> |
167 | 9 | <width>345</width> | 9 | <width>393</width> |
168 | 10 | <height>279</height> | 10 | <height>279</height> |
169 | 11 | </rect> | 11 | </rect> |
170 | 12 | </property> | 12 | </property> |
171 | @@ -97,7 +97,7 @@ | |||
172 | 97 | <bool>false</bool> | 97 | <bool>false</bool> |
173 | 98 | </attribute> | 98 | </attribute> |
174 | 99 | <attribute name="headerStretchLastSection"> | 99 | <attribute name="headerStretchLastSection"> |
176 | 100 | <bool>true</bool> | 100 | <bool>false</bool> |
177 | 101 | </attribute> | 101 | </attribute> |
178 | 102 | <column> | 102 | <column> |
179 | 103 | <property name="text"> | 103 | <property name="text"> |
180 | @@ -153,7 +153,7 @@ | |||
181 | 153 | </sizepolicy> | 153 | </sizepolicy> |
182 | 154 | </property> | 154 | </property> |
183 | 155 | <property name="text"> | 155 | <property name="text"> |
185 | 156 | <string notr="true">Add a folder from this computer</string> | 156 | <string notr="true">Add a folder</string> |
186 | 157 | </property> | 157 | </property> |
187 | 158 | <property name="default"> | 158 | <property name="default"> |
188 | 159 | <bool>true</bool> | 159 | <bool>true</bool> |
189 | @@ -161,6 +161,13 @@ | |||
190 | 161 | </widget> | 161 | </widget> |
191 | 162 | </item> | 162 | </item> |
192 | 163 | <item> | 163 | <item> |
193 | 164 | <widget class="QPushButton" name="check_settings_button"> | ||
194 | 165 | <property name="text"> | ||
195 | 166 | <string notr="true">Check settings</string> | ||
196 | 167 | </property> | ||
197 | 168 | </widget> | ||
198 | 169 | </item> | ||
199 | 170 | <item> | ||
200 | 164 | <spacer name="horizontalSpacer_2"> | 171 | <spacer name="horizontalSpacer_2"> |
201 | 165 | <property name="orientation"> | 172 | <property name="orientation"> |
202 | 166 | <enum>Qt::Horizontal</enum> | 173 | <enum>Qt::Horizontal</enum> |
203 | 167 | 174 | ||
204 | === modified file 'ubuntuone/controlpanel/gui/__init__.py' | |||
205 | --- ubuntuone/controlpanel/gui/__init__.py 2012-02-29 21:33:02 +0000 | |||
206 | +++ ubuntuone/controlpanel/gui/__init__.py 2012-03-19 14:00:47 +0000 | |||
207 | @@ -18,6 +18,10 @@ | |||
208 | 18 | 18 | ||
209 | 19 | import gettext | 19 | import gettext |
210 | 20 | 20 | ||
211 | 21 | # pylint: disable=W0611 | ||
212 | 22 | from ubuntuone.clientdefs import APP_NAME | ||
213 | 23 | # pylint: enable=W0611 | ||
214 | 24 | |||
215 | 21 | from ubuntuone.controlpanel import TRANSLATION_DOMAIN | 25 | from ubuntuone.controlpanel import TRANSLATION_DOMAIN |
216 | 22 | from ubuntuone.controlpanel.backend import UBUNTUONE_LINK | 26 | from ubuntuone.controlpanel.backend import UBUNTUONE_LINK |
217 | 23 | 27 | ||
218 | @@ -78,6 +82,17 @@ | |||
219 | 78 | 82 | ||
220 | 79 | ACCOUNT_LABEL = _('Your services') | 83 | ACCOUNT_LABEL = _('Your services') |
221 | 80 | ALWAYS_SUBSCRIBED = _('Always in sync') | 84 | ALWAYS_SUBSCRIBED = _('Always in sync') |
222 | 85 | ARE_YOU_SURE_HELP = _('If you need to know more about Ubuntu One, then ' | ||
223 | 86 | 'please go to {support_url}') | ||
224 | 87 | ARE_YOU_SURE_NO = _('No, continue setting up') | ||
225 | 88 | ARE_YOU_SURE_SUBTITLE = _('You can restart the setup process at any time ' | ||
226 | 89 | 'by clicking on Ubuntu One in your menu.') | ||
227 | 90 | ARE_YOU_SURE_TITLE = _('Are you sure you want to cancel setting up ' | ||
228 | 91 | 'Ubuntu One?') | ||
229 | 92 | ARE_YOU_SURE_YES = _('Yes, I want to cancel') | ||
230 | 93 | CLOUD_TO_COMPUTER_SUBTITLE = _('These are the folders in your cloud. ' | ||
231 | 94 | 'Select the ones you want to sync with this computer.') | ||
232 | 95 | CLOUD_TO_COMPUTER_TITLE = _('Syncing the cloud to your computer') | ||
233 | 81 | CONNECT_BUTTON_LABEL = _('Connect to Ubuntu One') | 96 | CONNECT_BUTTON_LABEL = _('Connect to Ubuntu One') |
234 | 82 | CONTACTS = _('Thunderbird plug-in') | 97 | CONTACTS = _('Thunderbird plug-in') |
235 | 83 | CREDENTIALS_ERROR = _('There was a problem while retrieving the credentials.') | 98 | CREDENTIALS_ERROR = _('There was a problem while retrieving the credentials.') |
236 | 84 | 99 | ||
237 | === modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py' | |||
238 | --- ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-03-14 20:02:25 +0000 | |||
239 | +++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2012-03-19 14:00:47 +0000 | |||
240 | @@ -159,10 +159,12 @@ | |||
241 | 159 | """The facebook button was clicked.""" | 159 | """The facebook button was clicked.""" |
242 | 160 | qt.uri_hook(FACEBOOK_LINK) | 160 | qt.uri_hook(FACEBOOK_LINK) |
243 | 161 | 161 | ||
244 | 162 | @log_call(logger.warning) | ||
245 | 162 | def on_wizard_rejected(self): | 163 | def on_wizard_rejected(self): |
246 | 163 | """Let clients know that we're done.""" | 164 | """Let clients know that we're done.""" |
247 | 164 | self.finished.emit() | 165 | self.finished.emit() |
248 | 165 | 166 | ||
249 | 167 | @log_call(logger.info) | ||
250 | 166 | def on_wizard_finished(self, status): | 168 | def on_wizard_finished(self, status): |
252 | 167 | """Move to controlpanel if wizar ended successfully.""" | 169 | """Move to controlpanel if wizard ended successfully.""" |
253 | 168 | self.on_credentials_found() | 170 | self.on_credentials_found() |
254 | 169 | 171 | ||
255 | === modified file 'ubuntuone/controlpanel/gui/qt/folders.py' | |||
256 | --- ubuntuone/controlpanel/gui/qt/folders.py 2012-03-12 20:31:06 +0000 | |||
257 | +++ ubuntuone/controlpanel/gui/qt/folders.py 2012-03-19 14:00:47 +0000 | |||
258 | @@ -42,7 +42,11 @@ | |||
259 | 42 | NAME_NOT_SET, | 42 | NAME_NOT_SET, |
260 | 43 | SHARE_ICON_NAME, | 43 | SHARE_ICON_NAME, |
261 | 44 | ) | 44 | ) |
263 | 45 | from ubuntuone.controlpanel.gui.qt import uri_hook, icon_from_name | 45 | from ubuntuone.controlpanel.gui.qt import ( |
264 | 46 | handle_errors, | ||
265 | 47 | icon_from_name, | ||
266 | 48 | uri_hook, | ||
267 | 49 | ) | ||
268 | 46 | from ubuntuone.controlpanel.gui.qt.ubuntuonebin import UbuntuOneBin | 50 | from ubuntuone.controlpanel.gui.qt.ubuntuonebin import UbuntuOneBin |
269 | 47 | from ubuntuone.controlpanel.gui.qt.ui import folders_ui | 51 | from ubuntuone.controlpanel.gui.qt.ui import folders_ui |
270 | 48 | 52 | ||
271 | @@ -61,6 +65,15 @@ | |||
272 | 61 | YES = QtGui.QMessageBox.Yes | 65 | YES = QtGui.QMessageBox.Yes |
273 | 62 | 66 | ||
274 | 63 | 67 | ||
275 | 68 | def _process_name(name): | ||
276 | 69 | """Tweak 'name' with a translatable music folder name.""" | ||
277 | 70 | if name == MUSIC_REAL_PATH: | ||
278 | 71 | result = MUSIC_DISPLAY_NAME | ||
279 | 72 | else: | ||
280 | 73 | result = name | ||
281 | 74 | return result | ||
282 | 75 | |||
283 | 76 | |||
284 | 64 | class ExploreFolderButton(QtGui.QPushButton): | 77 | class ExploreFolderButton(QtGui.QPushButton): |
285 | 65 | """A specialized button for the folder listing.""" | 78 | """A specialized button for the folder listing.""" |
286 | 66 | 79 | ||
287 | @@ -77,10 +90,11 @@ | |||
288 | 77 | 90 | ||
289 | 78 | 91 | ||
290 | 79 | class FoldersPanel(UbuntuOneBin): | 92 | class FoldersPanel(UbuntuOneBin): |
292 | 80 | """The Folders Tab Panel widget""" | 93 | """The Folders Tab Panel widget.""" |
293 | 81 | 94 | ||
294 | 95 | logger = logger | ||
295 | 96 | remote_folders = False | ||
296 | 82 | ui_class = folders_ui | 97 | ui_class = folders_ui |
297 | 83 | logger = logger | ||
298 | 84 | widget_items = {} | 98 | widget_items = {} |
299 | 85 | 99 | ||
300 | 86 | def _setup(self): | 100 | def _setup(self): |
301 | @@ -89,14 +103,20 @@ | |||
302 | 89 | self.ui.add_folder_button.folderCreated.connect(self.on_folder_created) | 103 | self.ui.add_folder_button.folderCreated.connect(self.on_folder_created) |
303 | 90 | self.ui.add_folder_button.setText(FOLDERS_BUTTON_ADD_FOLDER) | 104 | self.ui.add_folder_button.setText(FOLDERS_BUTTON_ADD_FOLDER) |
304 | 91 | 105 | ||
308 | 92 | self.ui.folders.headerItem().setText(0, FOLDERS_COLUMN_NAME) | 106 | self.ui.share_publish_button.setVisible(not self.remote_folders) |
309 | 93 | self.ui.folders.headerItem().setText(1, FOLDERS_COLUMN_SYNC_LOCALLY) | 107 | self.ui.add_folder_button.setVisible(not self.remote_folders) |
310 | 94 | self.ui.folders.headerItem().setText(2, FOLDERS_COLUMN_EXPLORE) | 108 | self.ui.check_settings_button.setVisible(self.remote_folders) |
311 | 109 | |||
312 | 110 | self.ui.folders.headerItem().setText(FOLDER_NAME_COL, | ||
313 | 111 | FOLDERS_COLUMN_NAME) | ||
314 | 112 | self.ui.folders.headerItem().setText(SUBSCRIPTION_COL, | ||
315 | 113 | FOLDERS_COLUMN_SYNC_LOCALLY) | ||
316 | 114 | self.ui.folders.headerItem().setText(EXPLORE_COL, | ||
317 | 115 | FOLDERS_COLUMN_EXPLORE) | ||
318 | 95 | headers = self.ui.folders.header() | 116 | headers = self.ui.folders.header() |
319 | 96 | headers.setResizeMode(FOLDER_NAME_COL, headers.Stretch) | 117 | headers.setResizeMode(FOLDER_NAME_COL, headers.Stretch) |
320 | 97 | headers.setResizeMode(SUBSCRIPTION_COL, headers.ResizeToContents) | 118 | headers.setResizeMode(SUBSCRIPTION_COL, headers.ResizeToContents) |
321 | 98 | headers.setResizeMode(EXPLORE_COL, headers.ResizeToContents) | 119 | headers.setResizeMode(EXPLORE_COL, headers.ResizeToContents) |
322 | 99 | headers.setStretchLastSection(False) | ||
323 | 100 | 120 | ||
324 | 101 | self.ui.share_publish_button.setText(FOLDERS_MANAGE_LABEL) | 121 | self.ui.share_publish_button.setText(FOLDERS_MANAGE_LABEL) |
325 | 102 | self.ui.share_publish_button.uri = MANAGE_FILES_LINK | 122 | self.ui.share_publish_button.uri = MANAGE_FILES_LINK |
326 | @@ -125,14 +145,7 @@ | |||
327 | 125 | info = yield self.backend.volumes_info(with_storage_info=False) | 145 | info = yield self.backend.volumes_info(with_storage_info=False) |
328 | 126 | self.process_info(info) | 146 | self.process_info(info) |
329 | 127 | 147 | ||
338 | 128 | def _process_name(self, name): | 148 | @handle_errors(logger=logger) |
331 | 129 | """Tweak 'name' with a translatable music folder name.""" | ||
332 | 130 | if name == MUSIC_REAL_PATH: | ||
333 | 131 | result = MUSIC_DISPLAY_NAME | ||
334 | 132 | else: | ||
335 | 133 | result = name | ||
336 | 134 | return result | ||
337 | 135 | |||
339 | 136 | @log_call(logger.debug) | 149 | @log_call(logger.debug) |
340 | 137 | def process_info(self, info): | 150 | def process_info(self, info): |
341 | 138 | """Load folders info into the tree view.""" | 151 | """Load folders info into the tree view.""" |
342 | @@ -164,6 +177,8 @@ | |||
343 | 164 | self.ui.folders.addTopLevelItem(item) | 177 | self.ui.folders.addTopLevelItem(item) |
344 | 165 | 178 | ||
345 | 166 | for volume in volumes: | 179 | for volume in volumes: |
346 | 180 | subscribed = bool(volume[u'subscribed']) | ||
347 | 181 | |||
348 | 167 | is_root = volume[u'type'] == self.backend.ROOT_TYPE | 182 | is_root = volume[u'type'] == self.backend.ROOT_TYPE |
349 | 168 | is_share = volume[u'type'] == self.backend.SHARE_TYPE | 183 | is_share = volume[u'type'] == self.backend.SHARE_TYPE |
350 | 169 | 184 | ||
351 | @@ -175,7 +190,7 @@ | |||
352 | 175 | child.volume_path = volume['path'] | 190 | child.volume_path = volume['path'] |
353 | 176 | child.volume_id = volume['volume_id'] | 191 | child.volume_id = volume['volume_id'] |
354 | 177 | 192 | ||
356 | 178 | name = self._process_name(volume[u'display_name']) | 193 | name = _process_name(volume[u'display_name']) |
357 | 179 | child.setText(FOLDER_NAME_COL, name) | 194 | child.setText(FOLDER_NAME_COL, name) |
358 | 180 | child.setToolTip(FOLDER_NAME_COL, name) | 195 | child.setToolTip(FOLDER_NAME_COL, name) |
359 | 181 | child.setToolTip(EXPLORE_COL, FOLDERS_COLUMN_EXPLORE) | 196 | child.setToolTip(EXPLORE_COL, FOLDERS_COLUMN_EXPLORE) |
360 | @@ -199,7 +214,7 @@ | |||
361 | 199 | # issues. | 214 | # issues. |
362 | 200 | checkbox = QtGui.QCheckBox(parent=self.ui.folders) | 215 | checkbox = QtGui.QCheckBox(parent=self.ui.folders) |
363 | 201 | self.widget_items[checkbox] = child | 216 | self.widget_items[checkbox] = child |
365 | 202 | if bool(volume[u'subscribed']): | 217 | if subscribed: |
366 | 203 | checkbox.setCheckState(CHECKED) | 218 | checkbox.setCheckState(CHECKED) |
367 | 204 | else: | 219 | else: |
368 | 205 | checkbox.setCheckState(UNCHECKED) | 220 | checkbox.setCheckState(UNCHECKED) |
369 | @@ -217,11 +232,15 @@ | |||
370 | 217 | 232 | ||
371 | 218 | checkbox.stateChanged.connect(cb) | 233 | checkbox.stateChanged.connect(cb) |
372 | 219 | 234 | ||
373 | 235 | if self.remote_folders: | ||
374 | 236 | # no explore button when showing only remote folders | ||
375 | 237 | continue | ||
376 | 238 | |||
377 | 220 | # attach a third item with a button to explore the folder | 239 | # attach a third item with a button to explore the folder |
378 | 221 | button = ExploreFolderButton(folder_path=child.volume_path, | 240 | button = ExploreFolderButton(folder_path=child.volume_path, |
379 | 222 | parent=self.ui.folders) | 241 | parent=self.ui.folders) |
380 | 223 | self.widget_items[button] = child | 242 | self.widget_items[button] = child |
382 | 224 | button.setEnabled(bool(volume[u'subscribed'])) | 243 | button.setEnabled(subscribed) |
383 | 225 | self.ui.folders.setItemWidget(child, EXPLORE_COL, button) | 244 | self.ui.folders.setItemWidget(child, EXPLORE_COL, button) |
384 | 226 | 245 | ||
385 | 227 | self.ui.folders.expandAll() | 246 | self.ui.folders.expandAll() |
386 | @@ -247,6 +266,7 @@ | |||
387 | 247 | # Invalid name "on_folders_itemActivated", "on_folders_itemChanged" | 266 | # Invalid name "on_folders_itemActivated", "on_folders_itemChanged" |
388 | 248 | # pylint: disable=C0103 | 267 | # pylint: disable=C0103 |
389 | 249 | 268 | ||
390 | 269 | @handle_errors(logger=logger) | ||
391 | 250 | def on_folders_itemActivated(self, item, column=None): | 270 | def on_folders_itemActivated(self, item, column=None): |
392 | 251 | """User activated a given row, open the path in a file browser.""" | 271 | """User activated a given row, open the path in a file browser.""" |
393 | 252 | volume_path = getattr(item, 'volume_path', None) | 272 | volume_path = getattr(item, 'volume_path', None) |
394 | @@ -260,6 +280,7 @@ | |||
395 | 260 | uri = unicode(QtCore.QUrl.fromLocalFile(volume_path).toString()) | 280 | uri = unicode(QtCore.QUrl.fromLocalFile(volume_path).toString()) |
396 | 261 | uri_hook(uri) | 281 | uri_hook(uri) |
397 | 262 | 282 | ||
398 | 283 | @handle_errors(logger=logger) | ||
399 | 263 | @defer.inlineCallbacks | 284 | @defer.inlineCallbacks |
400 | 264 | def on_folders_itemChanged(self, item, column=None): | 285 | def on_folders_itemChanged(self, item, column=None): |
401 | 265 | """User changed the subscription for a given folder.""" | 286 | """User changed the subscription for a given folder.""" |
402 | @@ -298,6 +319,12 @@ | |||
403 | 298 | else: | 319 | else: |
404 | 299 | # restore old value | 320 | # restore old value |
405 | 300 | old = UNCHECKED if subscribed else CHECKED | 321 | old = UNCHECKED if subscribed else CHECKED |
407 | 301 | item.setCheckState(SUBSCRIPTION_COL, old) | 322 | checkbox.setCheckState(old) |
408 | 302 | 323 | ||
409 | 303 | self.is_processing = False | 324 | self.is_processing = False |
410 | 325 | |||
411 | 326 | |||
412 | 327 | class RemoteFoldersPanel(FoldersPanel): | ||
413 | 328 | """The Folders Panel that only shows remote cloud folders.""" | ||
414 | 329 | |||
415 | 330 | remote_folders = True | ||
416 | 304 | 331 | ||
417 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py' | |||
418 | --- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2012-03-12 16:53:02 +0000 | |||
419 | +++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2012-03-19 14:00:47 +0000 | |||
420 | @@ -181,6 +181,11 @@ | |||
421 | 181 | 181 | ||
422 | 182 | self.assertNotIn('connect_files', self.ui.backend._called) | 182 | self.assertNotIn('connect_files', self.ui.backend._called) |
423 | 183 | 183 | ||
424 | 184 | def test_folder_panel_shows_all_folders(self): | ||
425 | 185 | """The FolderPanel shows all folders (not remote only).""" | ||
426 | 186 | remote = self.ui.ui.folders_tab.remote_folders | ||
427 | 187 | self.assertFalse(remote) | ||
428 | 188 | |||
429 | 184 | 189 | ||
430 | 185 | class ExternalLinkButtonsTestCase(ControlPanelTestCase): | 190 | class ExternalLinkButtonsTestCase(ControlPanelTestCase): |
431 | 186 | """The link in the go-to-web buttons are correct.""" | 191 | """The link in the go-to-web buttons are correct.""" |
432 | 187 | 192 | ||
433 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_folders.py' | |||
434 | --- ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-03-12 20:31:06 +0000 | |||
435 | +++ ubuntuone/controlpanel/gui/qt/tests/test_folders.py 2012-03-19 14:00:47 +0000 | |||
436 | @@ -16,6 +16,7 @@ | |||
437 | 16 | 16 | ||
438 | 17 | """Tests for the Control Panel.""" | 17 | """Tests for the Control Panel.""" |
439 | 18 | 18 | ||
440 | 19 | import copy | ||
441 | 19 | import logging | 20 | import logging |
442 | 20 | import operator | 21 | import operator |
443 | 21 | import os | 22 | import os |
444 | @@ -44,6 +45,13 @@ | |||
445 | 44 | # pylint: disable=W0212, E1103 | 45 | # pylint: disable=W0212, E1103 |
446 | 45 | 46 | ||
447 | 46 | 47 | ||
448 | 48 | def volumes_with_music_unsubscribed(): | ||
449 | 49 | """Return a copy of FAKE_VOLUMES_MINIMAL_INFO with music unsubscribed.""" | ||
450 | 50 | volumes = copy.deepcopy(FAKE_VOLUMES_MINIMAL_INFO) | ||
451 | 51 | volumes[0][2][1][u'subscribed'] = u'' | ||
452 | 52 | return volumes | ||
453 | 53 | |||
454 | 54 | |||
455 | 47 | def _build_name(name): | 55 | def _build_name(name): |
456 | 48 | """Helper to build the name expected when showing folder info.""" | 56 | """Helper to build the name expected when showing folder info.""" |
457 | 49 | if name: | 57 | if name: |
458 | @@ -91,9 +99,15 @@ | |||
459 | 91 | self.memento.setLevel(logging.DEBUG) | 99 | self.memento.setLevel(logging.DEBUG) |
460 | 92 | gui.logger.addHandler(self.memento) | 100 | gui.logger.addHandler(self.memento) |
461 | 93 | 101 | ||
465 | 94 | old_home = os.environ['HOME'] | 102 | def set_item_checked(self, item, checked=True): |
466 | 95 | os.environ['HOME'] = USER_HOME | 103 | """Make item to be checked.""" |
467 | 96 | self.addCleanup(lambda: os.environ.__setitem__('HOME', old_home)) | 104 | checkbox = self.ui.ui.folders.itemWidget(item, gui.SUBSCRIPTION_COL) |
468 | 105 | checkbox.setCheckState(gui.CHECKED if checked else gui.UNCHECKED) | ||
469 | 106 | |||
470 | 107 | def get_item_checked(self, item): | ||
471 | 108 | """Get if item is checked.""" | ||
472 | 109 | checkbox = self.ui.ui.folders.itemWidget(item, gui.SUBSCRIPTION_COL) | ||
473 | 110 | return (checkbox.checkState() == gui.CHECKED) | ||
474 | 97 | 111 | ||
475 | 98 | 112 | ||
476 | 99 | class FoldersPanelVolumesInfoTestCase(FoldersPanelTestCase): | 113 | class FoldersPanelVolumesInfoTestCase(FoldersPanelTestCase): |
477 | @@ -109,7 +123,45 @@ | |||
478 | 109 | self.assertEqual(unicode(item.text(gui.FOLDER_NAME_COL)), name) | 123 | self.assertEqual(unicode(item.text(gui.FOLDER_NAME_COL)), name) |
479 | 110 | self.assertEqual(unicode(item.text(gui.SUBSCRIPTION_COL)), | 124 | self.assertEqual(unicode(item.text(gui.SUBSCRIPTION_COL)), |
480 | 111 | gui.FOLDERS_COLUMN_SYNC_LOCALLY) | 125 | gui.FOLDERS_COLUMN_SYNC_LOCALLY) |
482 | 112 | self.assertEqual(unicode(item.text(gui.EXPLORE_COL)), '') | 126 | if not self.ui.remote_folders: |
483 | 127 | self.assertEqual(unicode(item.text(gui.EXPLORE_COL)), '') | ||
484 | 128 | |||
485 | 129 | def assert_folder_row_correct(self, item, label, icon_name, volume, | ||
486 | 130 | tweaked_path=None): | ||
487 | 131 | """Check that the folder row 'item' is correct.""" | ||
488 | 132 | folders = self.ui.ui.folders | ||
489 | 133 | |||
490 | 134 | actual_label = unicode(item.text(gui.FOLDER_NAME_COL)) | ||
491 | 135 | self.assertEqual(label, actual_label) | ||
492 | 136 | |||
493 | 137 | if volume['type'] == self.ui.backend.ROOT_TYPE: | ||
494 | 138 | # no check box but the ALWAYS_SUBSCRIBED legend | ||
495 | 139 | self.assertEqual(unicode(item.text(gui.SUBSCRIPTION_COL)), | ||
496 | 140 | gui.ALWAYS_SUBSCRIBED) | ||
497 | 141 | else: | ||
498 | 142 | subscribed = self.get_item_checked(item) | ||
499 | 143 | self.assertEqual(subscribed, bool(volume['subscribed'])) | ||
500 | 144 | |||
501 | 145 | actual_icon_name = item.icon_obj.icon_name | ||
502 | 146 | self.assertEqual(icon_name, actual_icon_name) | ||
503 | 147 | |||
504 | 148 | self.assertEqual(item.volume_id, volume['volume_id']) | ||
505 | 149 | |||
506 | 150 | expected_path = volume['path'] | ||
507 | 151 | if tweaked_path is not None: | ||
508 | 152 | expected_path = tweaked_path | ||
509 | 153 | self.assertEqual(item.volume_path, expected_path) | ||
510 | 154 | |||
511 | 155 | # tooltips are correct | ||
512 | 156 | self.assertEqual(item.toolTip(gui.FOLDER_NAME_COL), label) | ||
513 | 157 | self.assertEqual(item.toolTip(gui.EXPLORE_COL), | ||
514 | 158 | gui.FOLDERS_COLUMN_EXPLORE) | ||
515 | 159 | |||
516 | 160 | if not self.ui.remote_folders: | ||
517 | 161 | # explore button is in place | ||
518 | 162 | model_index = folders.indexFromItem(item, gui.EXPLORE_COL) | ||
519 | 163 | button = folders.indexWidget(model_index) | ||
520 | 164 | self.assertEqual(button.isEnabled(), bool(volume['subscribed'])) | ||
521 | 113 | 165 | ||
522 | 114 | @defer.inlineCallbacks | 166 | @defer.inlineCallbacks |
523 | 115 | def test_is_processing_while_asking_info(self): | 167 | def test_is_processing_while_asking_info(self): |
524 | @@ -151,7 +203,6 @@ | |||
525 | 151 | 203 | ||
526 | 152 | self.assert_folder_group_header_correct(item, name) | 204 | self.assert_folder_group_header_correct(item, name) |
527 | 153 | 205 | ||
528 | 154 | # check children | ||
529 | 155 | self.assertEqual(len(volumes), item.childCount()) | 206 | self.assertEqual(len(volumes), item.childCount()) |
530 | 156 | sorted_vols = sorted(volumes, key=operator.itemgetter('path')) | 207 | sorted_vols = sorted(volumes, key=operator.itemgetter('path')) |
531 | 157 | for volume in sorted_vols: | 208 | for volume in sorted_vols: |
532 | @@ -164,38 +215,14 @@ | |||
533 | 164 | if volume['type'] == self.ui.backend.SHARE_TYPE: | 215 | if volume['type'] == self.ui.backend.SHARE_TYPE: |
534 | 165 | name = volume['name'] | 216 | name = volume['name'] |
535 | 166 | expected_path = volume['realpath'] | 217 | expected_path = volume['realpath'] |
550 | 167 | label = unicode(item.text(gui.FOLDER_NAME_COL)) | 218 | |
537 | 168 | self.assertEqual(label, name) | ||
538 | 169 | |||
539 | 170 | if volume['type'] == self.ui.backend.ROOT_TYPE: | ||
540 | 171 | # no check box but the ALWAYS_SUBSCRIBED legend | ||
541 | 172 | self.assertEqual(unicode(item.text(gui.SUBSCRIPTION_COL)), | ||
542 | 173 | gui.ALWAYS_SUBSCRIBED) | ||
543 | 174 | else: | ||
544 | 175 | checkbox = self.ui.ui.folders.itemWidget( | ||
545 | 176 | item, gui.SUBSCRIPTION_COL) | ||
546 | 177 | subscribed = checkbox.checkState() == gui.CHECKED | ||
547 | 178 | self.assertEqual(subscribed, bool(volume['subscribed'])) | ||
548 | 179 | |||
549 | 180 | icon_name = item.icon_obj.icon_name | ||
551 | 181 | if volume['type'] != self.ui.backend.SHARE_TYPE: | 219 | if volume['type'] != self.ui.backend.SHARE_TYPE: |
553 | 182 | self.assertEqual(icon_name, gui.FOLDER_ICON_NAME) | 220 | icon_name = gui.FOLDER_ICON_NAME |
554 | 183 | else: | 221 | else: |
570 | 184 | self.assertEqual(icon_name, gui.SHARE_ICON_NAME) | 222 | icon_name = gui.SHARE_ICON_NAME |
571 | 185 | 223 | ||
572 | 186 | self.assertEqual(item.volume_id, volume['volume_id']) | 224 | self.assert_folder_row_correct(item, name, icon_name, volume, |
573 | 187 | self.assertEqual(item.volume_path, expected_path) | 225 | tweaked_path=expected_path) |
559 | 188 | |||
560 | 189 | # tooltips are correct | ||
561 | 190 | self.assertEqual(item.toolTip(gui.FOLDER_NAME_COL), name) | ||
562 | 191 | self.assertEqual(item.toolTip(gui.EXPLORE_COL), | ||
563 | 192 | gui.FOLDERS_COLUMN_EXPLORE) | ||
564 | 193 | |||
565 | 194 | # explore button is in place | ||
566 | 195 | model_index = folders.indexFromItem(item, gui.EXPLORE_COL) | ||
567 | 196 | button = folders.indexWidget(model_index) | ||
568 | 197 | self.assertEqual(button.isEnabled(), | ||
569 | 198 | bool(volume['subscribed'])) | ||
574 | 199 | 226 | ||
575 | 200 | treeiter += 1 | 227 | treeiter += 1 |
576 | 201 | item = treeiter.value() | 228 | item = treeiter.value() |
577 | @@ -304,9 +331,12 @@ | |||
578 | 304 | self.assertTrue(self.memento.check_warning(path, 'does not exist')) | 331 | self.assertTrue(self.memento.check_warning(path, 'does not exist')) |
579 | 305 | self.assertEqual(self._called, False) | 332 | self.assertEqual(self._called, False) |
580 | 306 | 333 | ||
582 | 307 | def test_process_info_with_music_folder(self): | 334 | def test_process_info_with_music_folder(self, volumes=None): |
583 | 308 | """The volumes info is processed when ready.""" | 335 | """The volumes info is processed when ready.""" |
585 | 309 | self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) | 336 | if volumes is None: |
586 | 337 | volumes = FAKE_VOLUMES_MINIMAL_INFO | ||
587 | 338 | |||
588 | 339 | self.ui.process_info(volumes) | ||
589 | 310 | folders = self.ui.ui.folders | 340 | folders = self.ui.ui.folders |
590 | 311 | 341 | ||
591 | 312 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) | 342 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) |
592 | @@ -318,46 +348,44 @@ | |||
593 | 318 | treeiter += 1 | 348 | treeiter += 1 |
594 | 319 | item = treeiter.value() | 349 | item = treeiter.value() |
595 | 320 | 350 | ||
615 | 321 | volume = MUSIC_FOLDER | 351 | volume = volumes[0][2][1] |
616 | 322 | 352 | ||
617 | 323 | label = unicode(item.text(gui.FOLDER_NAME_COL)) | 353 | self.assert_folder_row_correct(item, gui.MUSIC_DISPLAY_NAME, |
618 | 324 | self.assertEqual(label, gui.MUSIC_DISPLAY_NAME) | 354 | gui.MUSIC_ICON_NAME, volume) |
600 | 325 | |||
601 | 326 | checkbox = self.ui.ui.folders.itemWidget(item, gui.SUBSCRIPTION_COL) | ||
602 | 327 | subscribed = checkbox.checkState() == gui.CHECKED | ||
603 | 328 | self.assertEqual(subscribed, bool(volume['subscribed'])) | ||
604 | 329 | |||
605 | 330 | icon_name = item.icon_obj.icon_name | ||
606 | 331 | self.assertEqual(icon_name, gui.MUSIC_ICON_NAME) | ||
607 | 332 | |||
608 | 333 | self.assertEqual(item.volume_id, volume['volume_id']) | ||
609 | 334 | self.assertEqual(item.volume_path, volume['path']) | ||
610 | 335 | |||
611 | 336 | def test_share_publish_button(self): | ||
612 | 337 | """When clicking the share/publish button, the proper url is opened.""" | ||
613 | 338 | self.assert_uri_hook_called(self.ui.ui.share_publish_button, | ||
614 | 339 | gui.MANAGE_FILES_LINK) | ||
619 | 340 | 355 | ||
620 | 341 | def test_focus_order(self): | 356 | def test_focus_order(self): |
621 | 342 | """Ensure that the inner widgets are in the correct tab order.""" | 357 | """Ensure that the inner widgets are in the correct tab order.""" |
622 | 343 | self.ui.process_info(FAKE_VOLUMES_INFO) | 358 | self.ui.process_info(FAKE_VOLUMES_INFO) |
625 | 344 | # First, assert we are jumping from ui.folders to an | 359 | folders = self.ui.ui.folders |
626 | 345 | # QPushButton | 360 | |
627 | 346 | widget = self.ui.ui.folders.nextInFocusChain() | 361 | widget = self.ui.ui.folders.nextInFocusChain() |
642 | 347 | self.assertIsInstance(widget, QtGui.QPushButton) | 362 | treeiter = gui.QtGui.QTreeWidgetItemIterator(folders) |
643 | 348 | # Then, assert it's the right one | 363 | for name, _, volumes in FAKE_VOLUMES_INFO: |
644 | 349 | self.assertEqual(unicode( | 364 | item = treeiter.value() |
645 | 350 | self.ui.widget_items[widget].text(0)), u"My Ubuntu") | 365 | sorted_vols = sorted(volumes, key=operator.itemgetter('path')) |
646 | 351 | # Next are a checkbox / pushbutton pair | 366 | for volume in sorted_vols: |
647 | 352 | # in the 'bar' item | 367 | treeiter += 1 |
648 | 353 | widget = widget.nextInFocusChain() | 368 | item = treeiter.value() # get child folder |
649 | 354 | self.assertIsInstance(widget, QtGui.QCheckBox) | 369 | |
650 | 355 | self.assertEqual(unicode( | 370 | name = volume['path'].replace(USER_HOME + os.path.sep, '') |
651 | 356 | self.ui.widget_items[widget].text(0)), u"bar") | 371 | if volume['type'] == self.ui.backend.SHARE_TYPE: |
652 | 357 | widget = widget.nextInFocusChain() | 372 | name = volume['name'] |
653 | 358 | self.assertIsInstance(widget, QtGui.QPushButton) | 373 | self.assertEqual(unicode(item.text(gui.FOLDER_NAME_COL)), name) |
654 | 359 | self.assertEqual(unicode( | 374 | |
655 | 360 | self.ui.widget_items[widget].text(0)), u"bar") | 375 | if volume['type'] != self.ui.backend.ROOT_TYPE: |
656 | 376 | self.assertIsInstance(widget, QtGui.QCheckBox) | ||
657 | 377 | self.assertEqual(unicode( | ||
658 | 378 | self.ui.widget_items[widget].text(0)), name) | ||
659 | 379 | widget = widget.nextInFocusChain() | ||
660 | 380 | |||
661 | 381 | if not self.ui.remote_folders: | ||
662 | 382 | self.assertIsInstance(widget, QtGui.QPushButton) | ||
663 | 383 | self.assertEqual(unicode( | ||
664 | 384 | self.ui.widget_items[widget].text(0)), name) | ||
665 | 385 | widget = widget.nextInFocusChain() | ||
666 | 386 | |||
667 | 387 | treeiter += 1 | ||
668 | 388 | item = treeiter.value() | ||
669 | 361 | 389 | ||
670 | 362 | def test_widget_dict(self): | 390 | def test_widget_dict(self): |
671 | 363 | """Ensure the widget_items dictionary is full.""" | 391 | """Ensure the widget_items dictionary is full.""" |
672 | @@ -377,6 +405,20 @@ | |||
673 | 377 | item) | 405 | item) |
674 | 378 | it += 1 | 406 | it += 1 |
675 | 379 | 407 | ||
676 | 408 | def test_share_publish_button(self): | ||
677 | 409 | """When clicking the share/publish button, the proper url is opened.""" | ||
678 | 410 | self.assertTrue(self.ui.ui.share_publish_button.isVisible()) | ||
679 | 411 | self.assert_uri_hook_called(self.ui.ui.share_publish_button, | ||
680 | 412 | gui.MANAGE_FILES_LINK) | ||
681 | 413 | |||
682 | 414 | def test_add_folder_button(self): | ||
683 | 415 | """The 'add_folder_button' is visible by default.""" | ||
684 | 416 | self.assertTrue(self.ui.ui.add_folder_button.isVisible()) | ||
685 | 417 | |||
686 | 418 | def test_check_settings_button(self): | ||
687 | 419 | """The 'check_settings_button' is not visible by default.""" | ||
688 | 420 | self.assertFalse(self.ui.ui.check_settings_button.isVisible()) | ||
689 | 421 | |||
690 | 380 | 422 | ||
691 | 381 | class FoldersPanelAddFolderTestCase(FoldersPanelTestCase): | 423 | class FoldersPanelAddFolderTestCase(FoldersPanelTestCase): |
692 | 382 | """The test suite for the folder creation from a local dir.""" | 424 | """The test suite for the folder creation from a local dir.""" |
693 | @@ -411,16 +453,25 @@ | |||
694 | 411 | class FoldersPanelSubscriptionTestCase(FoldersPanelTestCase): | 453 | class FoldersPanelSubscriptionTestCase(FoldersPanelTestCase): |
695 | 412 | """The test suite for the folder subscription.""" | 454 | """The test suite for the folder subscription.""" |
696 | 413 | 455 | ||
697 | 456 | faked_volumes = FAKE_VOLUMES_MINIMAL_INFO | ||
698 | 457 | |||
699 | 414 | @defer.inlineCallbacks | 458 | @defer.inlineCallbacks |
700 | 415 | def setUp(self): | 459 | def setUp(self): |
701 | 416 | yield super(FoldersPanelSubscriptionTestCase, self).setUp() | 460 | yield super(FoldersPanelSubscriptionTestCase, self).setUp() |
702 | 417 | self.patch(gui.os.path, 'exists', lambda path: True) | 461 | self.patch(gui.os.path, 'exists', lambda path: True) |
703 | 418 | FakedDialog.response = gui.YES | 462 | FakedDialog.response = gui.YES |
704 | 419 | 463 | ||
706 | 420 | self.ui.process_info(FAKE_VOLUMES_MINIMAL_INFO) | 464 | self.ui.process_info(self.faked_volumes) |
707 | 421 | # the music folder | 465 | # the music folder |
708 | 422 | self.item = self.ui.ui.folders.topLevelItem(0).child(1) | 466 | self.item = self.ui.ui.folders.topLevelItem(0).child(1) |
709 | 423 | 467 | ||
710 | 468 | def set_item_checked(self, item=None, checked=True): | ||
711 | 469 | """Make item to be checked.""" | ||
712 | 470 | if item is None: | ||
713 | 471 | item = self.item | ||
714 | 472 | test = super(FoldersPanelSubscriptionTestCase, self).set_item_checked | ||
715 | 473 | test(item=item, checked=checked) | ||
716 | 474 | |||
717 | 424 | @defer.inlineCallbacks | 475 | @defer.inlineCallbacks |
718 | 425 | def test_on_folders_item_changed(self): | 476 | def test_on_folders_item_changed(self): |
719 | 426 | """Clicking on 'subscribed' updates the folder subscription.""" | 477 | """Clicking on 'subscribed' updates the folder subscription.""" |
720 | @@ -428,12 +479,9 @@ | |||
721 | 428 | volume = MUSIC_FOLDER | 479 | volume = MUSIC_FOLDER |
722 | 429 | fid = volume['volume_id'] | 480 | fid = volume['volume_id'] |
723 | 430 | subscribed = not bool(volume['subscribed']) | 481 | subscribed = not bool(volume['subscribed']) |
724 | 431 | check_state = gui.CHECKED if subscribed else gui.UNCHECKED | ||
725 | 432 | 482 | ||
726 | 433 | self.ui.is_processing = True | 483 | self.ui.is_processing = True |
730 | 434 | checkbox = self.ui.ui.folders.itemWidget(self.item, | 484 | self.set_item_checked(self.item, subscribed) |
728 | 435 | gui.SUBSCRIPTION_COL) | ||
729 | 436 | checkbox.setCheckState(check_state) | ||
731 | 437 | self.ui.is_processing = False | 485 | self.ui.is_processing = False |
732 | 438 | 486 | ||
733 | 439 | yield self.ui.on_folders_itemChanged(self.item) | 487 | yield self.ui.on_folders_itemChanged(self.item) |
734 | @@ -442,9 +490,7 @@ | |||
735 | 442 | self.assert_backend_called('change_volume_settings', | 490 | self.assert_backend_called('change_volume_settings', |
736 | 443 | fid, {'subscribed': subscribed}) | 491 | fid, {'subscribed': subscribed}) |
737 | 444 | 492 | ||
741 | 445 | checkbox = self.ui.ui.folders.itemWidget(self.item, | 493 | value = self.get_item_checked(self.item) |
739 | 446 | gui.SUBSCRIPTION_COL) | ||
740 | 447 | value = checkbox.checkState() == gui.CHECKED | ||
742 | 448 | self.assertEqual(value, bool(subscribed)) | 494 | self.assertEqual(value, bool(subscribed)) |
743 | 449 | 495 | ||
744 | 450 | # folder list was reloaded | 496 | # folder list was reloaded |
745 | @@ -494,7 +540,7 @@ | |||
746 | 494 | 540 | ||
747 | 495 | # make sure the item is subscribed | 541 | # make sure the item is subscribed |
748 | 496 | self.ui.is_processing = True | 542 | self.ui.is_processing = True |
750 | 497 | self.item.setCheckState(gui.SUBSCRIPTION_COL, gui.CHECKED) | 543 | self.set_item_checked() |
751 | 498 | self.ui.is_processing = False | 544 | self.ui.is_processing = False |
752 | 499 | 545 | ||
753 | 500 | yield self.ui.on_folders_itemChanged(self.item) | 546 | yield self.ui.on_folders_itemChanged(self.item) |
754 | @@ -513,7 +559,7 @@ | |||
755 | 513 | 559 | ||
756 | 514 | # make sure the item is unsubscribed | 560 | # make sure the item is unsubscribed |
757 | 515 | self.ui.is_processing = True | 561 | self.ui.is_processing = True |
759 | 516 | self.item.setCheckState(gui.SUBSCRIPTION_COL, gui.UNCHECKED) | 562 | self.set_item_checked() |
760 | 517 | self.ui.is_processing = False | 563 | self.ui.is_processing = False |
761 | 518 | 564 | ||
762 | 519 | yield self.ui.on_folders_itemChanged(self.item) | 565 | yield self.ui.on_folders_itemChanged(self.item) |
763 | @@ -528,7 +574,7 @@ | |||
764 | 528 | 574 | ||
765 | 529 | # make sure the item is subscribed | 575 | # make sure the item is subscribed |
766 | 530 | self.ui.is_processing = True | 576 | self.ui.is_processing = True |
768 | 531 | self.item.setCheckState(gui.SUBSCRIPTION_COL, gui.CHECKED) | 577 | self.set_item_checked() |
769 | 532 | self.ui.is_processing = False | 578 | self.ui.is_processing = False |
770 | 533 | 579 | ||
771 | 534 | yield self.ui.on_folders_itemChanged(self.item) | 580 | yield self.ui.on_folders_itemChanged(self.item) |
772 | @@ -537,8 +583,7 @@ | |||
773 | 537 | self.assertNotIn('change_volume_settings', self.ui.backend._called) | 583 | self.assertNotIn('change_volume_settings', self.ui.backend._called) |
774 | 538 | self.assertFalse(self.ui.is_processing) | 584 | self.assertFalse(self.ui.is_processing) |
775 | 539 | 585 | ||
778 | 540 | subscribed = self.item.checkState(gui.SUBSCRIPTION_COL) == gui.CHECKED | 586 | self.assertFalse(self.get_item_checked(self.item)) |
777 | 541 | self.assertEqual(subscribed, False) | ||
779 | 542 | 587 | ||
780 | 543 | @defer.inlineCallbacks | 588 | @defer.inlineCallbacks |
781 | 544 | def test_subscribe_does_not_call_backend_if_answer_is_no(self): | 589 | def test_subscribe_does_not_call_backend_if_answer_is_no(self): |
782 | @@ -547,7 +592,7 @@ | |||
783 | 547 | 592 | ||
784 | 548 | # make sure the item is subscribed | 593 | # make sure the item is subscribed |
785 | 549 | self.ui.is_processing = True | 594 | self.ui.is_processing = True |
787 | 550 | self.item.setCheckState(gui.SUBSCRIPTION_COL, gui.CHECKED) | 595 | self.set_item_checked() |
788 | 551 | self.ui.is_processing = False | 596 | self.ui.is_processing = False |
789 | 552 | 597 | ||
790 | 553 | yield self.ui.on_folders_itemChanged(self.item) | 598 | yield self.ui.on_folders_itemChanged(self.item) |
791 | @@ -556,17 +601,14 @@ | |||
792 | 556 | self.assertNotIn('change_volume_settings', self.ui.backend._called) | 601 | self.assertNotIn('change_volume_settings', self.ui.backend._called) |
793 | 557 | self.assertFalse(self.ui.is_processing) | 602 | self.assertFalse(self.ui.is_processing) |
794 | 558 | 603 | ||
797 | 559 | subscribed = self.item.checkState(gui.SUBSCRIPTION_COL) == gui.CHECKED | 604 | self.assertFalse(self.get_item_checked(self.item)) |
796 | 560 | self.assertEqual(subscribed, False) | ||
798 | 561 | 605 | ||
799 | 562 | @defer.inlineCallbacks | 606 | @defer.inlineCallbacks |
800 | 563 | def test_no_confirmation_if_unsubscribing(self): | 607 | def test_no_confirmation_if_unsubscribing(self): |
801 | 564 | """The confirmation dialog is not shown if unsubscribing.""" | 608 | """The confirmation dialog is not shown if unsubscribing.""" |
802 | 565 | # make sure the item is unsubscribed | 609 | # make sure the item is unsubscribed |
803 | 566 | self.ui.is_processing = True | 610 | self.ui.is_processing = True |
807 | 567 | checkbox = self.ui.ui.folders.itemWidget( | 611 | self.set_item_checked(checked=False) |
805 | 568 | self.item, gui.SUBSCRIPTION_COL) | ||
806 | 569 | checkbox.setCheckState(gui.UNCHECKED) | ||
808 | 570 | self.ui.is_processing = False | 612 | self.ui.is_processing = False |
809 | 571 | 613 | ||
810 | 572 | # the confirm dialog was not called so far | 614 | # the confirm dialog was not called so far |
811 | @@ -577,3 +619,34 @@ | |||
812 | 577 | 619 | ||
813 | 578 | self.assertTrue(FakedDialog.args is None, 'dialog was not run') | 620 | self.assertTrue(FakedDialog.args is None, 'dialog was not run') |
814 | 579 | self.assertTrue(FakedDialog.kwargs is None, 'dialog was hid') | 621 | self.assertTrue(FakedDialog.kwargs is None, 'dialog was hid') |
815 | 622 | |||
816 | 623 | |||
817 | 624 | class RemoteFoldersPanelTestCase(FoldersPanelVolumesInfoTestCase): | ||
818 | 625 | """The test case for the RemoteFoldersPanel widget.""" | ||
819 | 626 | |||
820 | 627 | class_ui = gui.RemoteFoldersPanel | ||
821 | 628 | |||
822 | 629 | def test_process_info_with_music_folder(self, volumes=None): | ||
823 | 630 | """The volumes info is processed when ready.""" | ||
824 | 631 | volumes = volumes_with_music_unsubscribed() | ||
825 | 632 | parent = super(RemoteFoldersPanelTestCase, self) | ||
826 | 633 | parent.test_process_info_with_music_folder(volumes=volumes) | ||
827 | 634 | |||
828 | 635 | def test_share_publish_button(self): | ||
829 | 636 | """When clicking the share/publish button, the proper url is opened.""" | ||
830 | 637 | self.assertFalse(self.ui.ui.share_publish_button.isVisible()) | ||
831 | 638 | |||
832 | 639 | def test_add_folder_button(self): | ||
833 | 640 | """The 'add_folder_button' is not visible by default.""" | ||
834 | 641 | self.assertFalse(self.ui.ui.add_folder_button.isVisible()) | ||
835 | 642 | |||
836 | 643 | def test_check_settings_button(self): | ||
837 | 644 | """The 'check_settings_button' is visible by default.""" | ||
838 | 645 | self.assertTrue(self.ui.ui.check_settings_button.isVisible()) | ||
839 | 646 | |||
840 | 647 | |||
841 | 648 | class RemoteFoldersPanelSubscriptionTestCase(FoldersPanelSubscriptionTestCase): | ||
842 | 649 | """The test suite for the remote folder subscription.""" | ||
843 | 650 | |||
844 | 651 | class_ui = gui.RemoteFoldersPanel | ||
845 | 652 | faked_volumes = volumes_with_music_unsubscribed() | ||
846 | 580 | 653 | ||
847 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_wizard.py' | |||
848 | --- ubuntuone/controlpanel/gui/qt/tests/test_wizard.py 2012-03-12 16:53:02 +0000 | |||
849 | +++ ubuntuone/controlpanel/gui/qt/tests/test_wizard.py 2012-03-19 14:00:47 +0000 | |||
850 | @@ -22,10 +22,121 @@ | |||
851 | 22 | from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase, TOKEN | 22 | from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase, TOKEN |
852 | 23 | 23 | ||
853 | 24 | 24 | ||
854 | 25 | BUTTONS = [ | ||
855 | 26 | 'BackButton', 'CancelButton', 'CommitButton', | ||
856 | 27 | 'CustomButton1', 'CustomButton2', 'CustomButton3', | ||
857 | 28 | 'FinishButton', 'HelpButton', 'NextButton', | ||
858 | 29 | ] | ||
859 | 30 | |||
860 | 31 | |||
861 | 32 | class AreYouSureTestCase(BaseTestCase): | ||
862 | 33 | """Test suite for the "Are you sure?" dialog.""" | ||
863 | 34 | |||
864 | 35 | class_ui = gui.AreYouSure | ||
865 | 36 | |||
866 | 37 | def test_title(self): | ||
867 | 38 | """Check the window title.""" | ||
868 | 39 | self.assertEqual(self.ui.windowTitle(), gui.APP_NAME) | ||
869 | 40 | self.assertEqual(self.ui.ui.title_label.text(), gui.ARE_YOU_SURE_TITLE) | ||
870 | 41 | |||
871 | 42 | def test_message_label(self): | ||
872 | 43 | """Check the message label text.""" | ||
873 | 44 | link = gui.LINK_STYLE.format(link_url=gui.UBUNTUONE_LINK, | ||
874 | 45 | link_text=gui.UBUNTUONE_LINK) | ||
875 | 46 | msg = u'%s<p>%s' % (gui.ARE_YOU_SURE_SUBTITLE, | ||
876 | 47 | gui.ARE_YOU_SURE_HELP.format(support_url=link)) | ||
877 | 48 | self.assertEqual(unicode(self.ui.ui.message_label.text()), msg) | ||
878 | 49 | |||
879 | 50 | def test_buttons(self): | ||
880 | 51 | """The buttons have the correct text.""" | ||
881 | 52 | self.assertEqual(self.ui.ui.yes_button.text(), gui.ARE_YOU_SURE_YES) | ||
882 | 53 | self.assertEqual(self.ui.ui.no_button.text(), gui.ARE_YOU_SURE_NO) | ||
883 | 54 | |||
884 | 55 | |||
885 | 56 | class UbuntuOnePageTestCase(BaseTestCase): | ||
886 | 57 | """Test the UbuntuOnePage widget.""" | ||
887 | 58 | |||
888 | 59 | class_ui = gui.UbuntuOnePage | ||
889 | 60 | main_title = '' | ||
890 | 61 | panel_class = gui.QtGui.QFrame | ||
891 | 62 | sub_title = '' | ||
892 | 63 | |||
893 | 64 | def test_panel_class(self): | ||
894 | 65 | """The panel_class is correct.""" | ||
895 | 66 | self.assertIsInstance(self.ui.panel, self.panel_class) | ||
896 | 67 | |||
897 | 68 | def test_panel_is_created(self): | ||
898 | 69 | """The panel is properly added to the layout.""" | ||
899 | 70 | self.assertEqual(self.ui.layout().itemAt(2).widget(), self.ui.panel) | ||
900 | 71 | |||
901 | 72 | def test_title(self): | ||
902 | 73 | """The title is correct.""" | ||
903 | 74 | self.assertIn(self.main_title, self.ui.title()) # avoid markup | ||
904 | 75 | |||
905 | 76 | def test_subtitle(self): | ||
906 | 77 | """The subtitle is correct.""" | ||
907 | 78 | self.assertEqual(self.ui.subTitle(), self.sub_title) | ||
908 | 79 | |||
909 | 80 | def test_error_label(self): | ||
910 | 81 | """The error label is hidden.""" | ||
911 | 82 | self.assertFalse(self.ui.form_errors_label.isVisible()) | ||
912 | 83 | |||
913 | 84 | def test_is_final(self): | ||
914 | 85 | """The page is not final.""" | ||
915 | 86 | # from the doc: | ||
916 | 87 | |||
917 | 88 | # After calling setFinalPage(true), isFinalPage() returns true and the | ||
918 | 89 | # Finish button is visible (and enabled if isComplete() returns true). | ||
919 | 90 | |||
920 | 91 | # After calling setFinalPage(false), isFinalPage() returns true if | ||
921 | 92 | #nextId() returns -1; otherwise, it returns false. | ||
922 | 93 | |||
923 | 94 | self.patch(self.ui, 'nextId', lambda *a: 0) | ||
924 | 95 | self.assertFalse(self.ui.isFinalPage()) | ||
925 | 96 | |||
926 | 97 | |||
927 | 98 | class SignInPageTestCase(UbuntuOnePageTestCase): | ||
928 | 99 | """Test the SignInPage wizard page.""" | ||
929 | 100 | |||
930 | 101 | class_ui = gui.SignInPage | ||
931 | 102 | panel_class = gui.SignInPanel | ||
932 | 103 | |||
933 | 104 | |||
934 | 105 | class CloudToComputerPageTestCase(UbuntuOnePageTestCase): | ||
935 | 106 | """Test the CloudToComputerPage wizard page.""" | ||
936 | 107 | |||
937 | 108 | class_ui = gui.CloudToComputerPage | ||
938 | 109 | main_title = gui.CLOUD_TO_COMPUTER_TITLE | ||
939 | 110 | panel_class = gui.RemoteFoldersPanel | ||
940 | 111 | sub_title = gui.CLOUD_TO_COMPUTER_SUBTITLE | ||
941 | 112 | |||
942 | 113 | def test_is_final(self): | ||
943 | 114 | """The page is not final.""" | ||
944 | 115 | self.assertTrue(self.ui.isFinalPage()) | ||
945 | 116 | |||
946 | 117 | def test_folder_panel_shows_remote_folders_only(self): | ||
947 | 118 | """The FolderPanel shows only remote folders.""" | ||
948 | 119 | self.assertTrue(self.ui.panel.remote_folders) | ||
949 | 120 | |||
950 | 121 | |||
951 | 122 | class SettingsPageTestCase(UbuntuOnePageTestCase): | ||
952 | 123 | """Test the SettingsPage wizard page.""" | ||
953 | 124 | |||
954 | 125 | class_ui = gui.SettingsPage | ||
955 | 126 | panel_class = gui.PreferencesPanel | ||
956 | 127 | |||
957 | 128 | |||
958 | 25 | class UbuntuOneWizardTestCase(BaseTestCase): | 129 | class UbuntuOneWizardTestCase(BaseTestCase): |
960 | 26 | """Test the UbuntuOneWizard.""" | 130 | """Test the UbuntuOneWizard widget.""" |
961 | 27 | 131 | ||
962 | 28 | class_ui = gui.UbuntuOneWizard | 132 | class_ui = gui.UbuntuOneWizard |
963 | 133 | confirm_response = gui.QtGui.QDialog.Accepted | ||
964 | 134 | |||
965 | 135 | @defer.inlineCallbacks | ||
966 | 136 | def setUp(self): | ||
967 | 137 | yield super(UbuntuOneWizardTestCase, self).setUp() | ||
968 | 138 | self.patch(self.ui.confirm_dialog, 'exec_', | ||
969 | 139 | lambda: self.confirm_response) | ||
970 | 29 | 140 | ||
971 | 30 | def test_options(self): | 141 | def test_options(self): |
972 | 31 | """Tne wizard options are correct.""" | 142 | """Tne wizard options are correct.""" |
973 | @@ -40,59 +151,48 @@ | |||
974 | 40 | """Tne wizard style is Modern.""" | 151 | """Tne wizard style is Modern.""" |
975 | 41 | self.assertEqual(self.ui.wizardStyle(), self.ui.ModernStyle) | 152 | self.assertEqual(self.ui.wizardStyle(), self.ui.ModernStyle) |
976 | 42 | 153 | ||
1016 | 43 | def test_cancel_button(self): | 154 | def test_side_widget(self): |
978 | 44 | """Send the rejected signal when the cancel button is clicked.""" | ||
979 | 45 | button = self.ui.button(self.ui.CancelButton) | ||
980 | 46 | self.assertEqual(unicode(button.text()), gui.CLOSE_AND_SETUP_LATER) | ||
981 | 47 | |||
982 | 48 | self.ui.rejected.connect(self._set_called) | ||
983 | 49 | button.click() | ||
984 | 50 | |||
985 | 51 | self.assertEqual(self._called, ((), {})) | ||
986 | 52 | |||
987 | 53 | def test_button_layout(self): | ||
988 | 54 | """The button layout is correct.""" | ||
989 | 55 | buttons = [ | ||
990 | 56 | 'BackButton', 'CommitButton', 'CustomButton1', 'CustomButton2', | ||
991 | 57 | 'CustomButton3', 'FinishButton', 'HelpButton', 'NextButton', | ||
992 | 58 | ] | ||
993 | 59 | for button_name in buttons: | ||
994 | 60 | button = self.ui.button(getattr(self.ui, button_name)) | ||
995 | 61 | self.assertFalse(button.isVisible(), | ||
996 | 62 | 'Button %s should not be visible.' % button_name) | ||
997 | 63 | |||
998 | 64 | button = self.ui.button(self.ui.CancelButton) | ||
999 | 65 | self.assertTrue(button.isVisible(), | ||
1000 | 66 | 'Cancel button should not be visible.') | ||
1001 | 67 | |||
1002 | 68 | def test_first_page(self): | ||
1003 | 69 | """The first page is the correct one.""" | ||
1004 | 70 | self.assertEqual(self.ui.startId(), | ||
1005 | 71 | self.ui.pages[self.ui.signin_page]) | ||
1006 | 72 | |||
1007 | 73 | def test_tab_order(self): | ||
1008 | 74 | """The button tab order is correct.""" | ||
1009 | 75 | # can not be tested due to Qt API limitations | ||
1010 | 76 | |||
1011 | 77 | |||
1012 | 78 | class SideWidgetTestCase(UbuntuOneWizardTestCase): | ||
1013 | 79 | """Test the side widget in the wizard.""" | ||
1014 | 80 | |||
1015 | 81 | def test_is_there(self): | ||
1017 | 82 | """The side widget is correct.""" | 155 | """The side widget is correct.""" |
1018 | 83 | self.assertIsInstance(self.ui.side_widget, gui.SideWidget) | 156 | self.assertIsInstance(self.ui.side_widget, gui.SideWidget) |
1019 | 84 | self.assertIs(self.ui.sideWidget(), self.ui.side_widget) | 157 | self.assertIs(self.ui.sideWidget(), self.ui.side_widget) |
1020 | 85 | 158 | ||
1023 | 86 | 159 | def test_confirm_dialog(self): | |
1024 | 87 | class SignInPageTestCase(UbuntuOneWizardTestCase): | 160 | """The confirm dialog is correct.""" |
1025 | 161 | self.assertIsInstance(self.ui.confirm_dialog, gui.AreYouSure) | ||
1026 | 162 | |||
1027 | 163 | def test_first_page(self): | ||
1028 | 164 | """The first page is the correct one.""" | ||
1029 | 165 | expected = self.ui.pages[self.ui.signin_page] | ||
1030 | 166 | self.assertEqual(self.ui.startId(), expected) | ||
1031 | 167 | |||
1032 | 168 | def test_done_accepted(self): | ||
1033 | 169 | """When the wizard reached the end, emit finished.""" | ||
1034 | 170 | self.ui.finished.connect(self._set_called) | ||
1035 | 171 | |||
1036 | 172 | self.ui.done(gui.QtGui.QDialog.Accepted) | ||
1037 | 173 | |||
1038 | 174 | self.assertEqual(self._called, ((gui.QtGui.QDialog.Accepted,), {})) | ||
1039 | 175 | |||
1040 | 176 | |||
1041 | 177 | class UbuntuOneWizardSignInTestCase(UbuntuOneWizardTestCase): | ||
1042 | 88 | """Test the SignInPage wizard page.""" | 178 | """Test the SignInPage wizard page.""" |
1043 | 89 | 179 | ||
1044 | 180 | buttons = {'CancelButton': (gui.CLOSE_AND_SETUP_LATER, 'rejected', ())} | ||
1045 | 90 | page_name = 'signin' | 181 | page_name = 'signin' |
1046 | 182 | stage_name = page_name | ||
1047 | 91 | 183 | ||
1048 | 92 | @defer.inlineCallbacks | 184 | @defer.inlineCallbacks |
1049 | 93 | def setUp(self): | 185 | def setUp(self): |
1051 | 94 | yield super(SignInPageTestCase, self).setUp() | 186 | yield super(UbuntuOneWizardSignInTestCase, self).setUp() |
1052 | 95 | self.page = getattr(self.ui, '%s_page' % self.page_name) | 187 | self.page = getattr(self.ui, '%s_page' % self.page_name) |
1053 | 188 | self._move_to_this_page() | ||
1054 | 189 | |||
1055 | 190 | def _move_to_this_page(self): | ||
1056 | 191 | """Fake the wizard is moved to this page.""" | ||
1057 | 192 | page_id = self.ui.pages[self.page] | ||
1058 | 193 | if self.ui.currentId() != page_id: | ||
1059 | 194 | self.ui._next_id = page_id | ||
1060 | 195 | self.ui.next() | ||
1061 | 96 | 196 | ||
1062 | 97 | def test_was_added(self): | 197 | def test_was_added(self): |
1063 | 98 | """The SignInPage is added correctly.""" | 198 | """The SignInPage is added correctly.""" |
1064 | @@ -103,8 +203,98 @@ | |||
1065 | 103 | """The page is enabled at startup.""" | 203 | """The page is enabled at startup.""" |
1066 | 104 | self.assertTrue(self.page.isEnabled()) | 204 | self.assertTrue(self.page.isEnabled()) |
1067 | 105 | 205 | ||
1070 | 106 | 206 | def test_focus_order(self): | |
1071 | 107 | class LoginTestCase(UbuntuOneWizardTestCase): | 207 | """The focus order is correct.""" |
1072 | 208 | # can not be tested due to Qt API limitations | ||
1073 | 209 | |||
1074 | 210 | def test_button_layout(self): | ||
1075 | 211 | """The button layout is correct.""" | ||
1076 | 212 | msg = '%s should not be visible.' | ||
1077 | 213 | for button_name in BUTTONS: | ||
1078 | 214 | button = self.ui.button(getattr(self.ui, button_name)) | ||
1079 | 215 | if button_name in self.buttons: | ||
1080 | 216 | self.assertTrue(button.isVisible(), | ||
1081 | 217 | '%s should be visible.' % button_name) | ||
1082 | 218 | else: | ||
1083 | 219 | self.assertFalse(button.isVisible(), msg % button_name) | ||
1084 | 220 | |||
1085 | 221 | def test_side_widget_stage(self): | ||
1086 | 222 | """When in this page, the side_widget' stage is correct.""" | ||
1087 | 223 | self.assertEqual(self.ui.side_widget.stage, | ||
1088 | 224 | getattr(self.ui.side_widget, '%s_stage' % self.stage_name)) | ||
1089 | 225 | |||
1090 | 226 | def test_buttons_behavior(self): | ||
1091 | 227 | """Send the rejected signal when the cancel button is clicked.""" | ||
1092 | 228 | msg = '%r should emit %r with args %r when clicked.' | ||
1093 | 229 | |||
1094 | 230 | for name, (text, signal, signal_args) in self.buttons.iteritems(): | ||
1095 | 231 | button = self.ui.button(getattr(self.ui, name)) | ||
1096 | 232 | |||
1097 | 233 | if text is not None: | ||
1098 | 234 | self.assertEqual(unicode(button.text()), text) | ||
1099 | 235 | |||
1100 | 236 | getattr(self.ui, signal).connect(self._set_called) | ||
1101 | 237 | button.click() | ||
1102 | 238 | |||
1103 | 239 | self.assertEqual(self._called, (signal_args, {}), | ||
1104 | 240 | msg % (name, signal, signal_args)) | ||
1105 | 241 | self._called = False | ||
1106 | 242 | |||
1107 | 243 | def test_done_rejected(self): | ||
1108 | 244 | """When the wizard was cancelled and user confirmed, finish.""" | ||
1109 | 245 | self.patch(self, 'confirm_response', gui.QtGui.QDialog.Accepted) | ||
1110 | 246 | self.ui.rejected.connect(self._set_called) | ||
1111 | 247 | |||
1112 | 248 | assert not self.ui.page(self.ui.currentId()).isFinalPage() | ||
1113 | 249 | self.ui.done(gui.QtGui.QDialog.Rejected) | ||
1114 | 250 | |||
1115 | 251 | self.assertEqual(self._called, ((), {})) | ||
1116 | 252 | |||
1117 | 253 | def test_done_rejected_confirmation_rejected(self): | ||
1118 | 254 | """When the wizard was cancelled but user unconfimed, do not finish.""" | ||
1119 | 255 | self.patch(self, 'confirm_response', gui.QtGui.QDialog.Rejected) | ||
1120 | 256 | self.ui.accepted.connect(self._set_called) | ||
1121 | 257 | self.ui.rejected.connect(self._set_called) | ||
1122 | 258 | self.ui.finished.connect(self._set_called) | ||
1123 | 259 | |||
1124 | 260 | assert not self.ui.page(self.ui.currentId()).isFinalPage() | ||
1125 | 261 | self.ui.done(gui.QtGui.QDialog.Rejected) | ||
1126 | 262 | |||
1127 | 263 | self.assertEqual(self._called, False) | ||
1128 | 264 | |||
1129 | 265 | |||
1130 | 266 | class UbuntuOneWizardCloudToComputerTestCase(UbuntuOneWizardSignInTestCase): | ||
1131 | 267 | """Test the CloudToComputerPage wizard page.""" | ||
1132 | 268 | |||
1133 | 269 | buttons = {'FinishButton': | ||
1134 | 270 | (None, 'finished', (gui.QtGui.QDialog.Accepted,))} | ||
1135 | 271 | page_name = 'cloud_folders' | ||
1136 | 272 | stage_name = 'folders' | ||
1137 | 273 | |||
1138 | 274 | def test_done_rejected(self): | ||
1139 | 275 | """When the wizard is closed on the final page, emit rejected.""" | ||
1140 | 276 | self.ui.finished.connect(self._set_called) | ||
1141 | 277 | |||
1142 | 278 | self.ui._next_id = self.ui.pages[self.ui.cloud_folders_page] | ||
1143 | 279 | assert self.ui.page(self.ui.currentId()).isFinalPage() | ||
1144 | 280 | self.ui.done(gui.QtGui.QDialog.Rejected) | ||
1145 | 281 | |||
1146 | 282 | self.assertEqual(self._called, ((gui.QtGui.QDialog.Rejected,), {})) | ||
1147 | 283 | |||
1148 | 284 | def test_done_rejected_confirmation_rejected(self): | ||
1149 | 285 | """When the wizard was cancelled but user unconfimed, do not finish.""" | ||
1150 | 286 | # does not apply to this page | ||
1151 | 287 | |||
1152 | 288 | |||
1153 | 289 | class UbuntuOneWizardSettingsTestCase(UbuntuOneWizardSignInTestCase): | ||
1154 | 290 | """Test the CloudToComputerPage wizard page.""" | ||
1155 | 291 | |||
1156 | 292 | buttons = {'BackButton': (None, 'currentIdChanged', (0,))} | ||
1157 | 293 | page_name = 'settings' | ||
1158 | 294 | stage_name = 'folders' | ||
1159 | 295 | |||
1160 | 296 | |||
1161 | 297 | class UbuntuOneWizardLoginTestCase(UbuntuOneWizardTestCase): | ||
1162 | 108 | """Test the login through the wizard.""" | 298 | """Test the login through the wizard.""" |
1163 | 109 | 299 | ||
1164 | 110 | method = 'login' | 300 | method = 'login' |
1165 | @@ -112,7 +302,7 @@ | |||
1166 | 112 | @defer.inlineCallbacks | 302 | @defer.inlineCallbacks |
1167 | 113 | def test_with_credentials(self): | 303 | def test_with_credentials(self): |
1168 | 114 | """Wizard is done when credentials were retrieved.""" | 304 | """Wizard is done when credentials were retrieved.""" |
1170 | 115 | self.ui.finished.connect(self._set_called) | 305 | self.ui.currentIdChanged.connect(self._set_called) |
1171 | 116 | d = defer.succeed(TOKEN) | 306 | d = defer.succeed(TOKEN) |
1172 | 117 | 307 | ||
1173 | 118 | def check(): | 308 | def check(): |
1174 | @@ -128,12 +318,13 @@ | |||
1175 | 128 | yield d | 318 | yield d |
1176 | 129 | 319 | ||
1177 | 130 | self.assertTrue(self.ui.signin_page.isEnabled()) | 320 | self.assertTrue(self.ui.signin_page.isEnabled()) |
1179 | 131 | self.assertEqual(self._called, ((1,), {})) | 321 | expected_next_id = self.ui.pages[self.ui.cloud_folders_page] |
1180 | 322 | self.assertEqual(self._called, ((expected_next_id,), {})) | ||
1181 | 132 | 323 | ||
1182 | 133 | @defer.inlineCallbacks | 324 | @defer.inlineCallbacks |
1183 | 134 | def test_without_credentials(self): | 325 | def test_without_credentials(self): |
1184 | 135 | """Wizard is done when credentials were retrieved.""" | 326 | """Wizard is done when credentials were retrieved.""" |
1186 | 136 | self.ui.finished.connect(self._set_called) | 327 | self.ui.currentIdChanged.connect(self._set_called) |
1187 | 137 | d = defer.succeed(None) | 328 | d = defer.succeed(None) |
1188 | 138 | 329 | ||
1189 | 139 | def check(): | 330 | def check(): |
1190 | @@ -152,7 +343,7 @@ | |||
1191 | 152 | self.assertFalse(self._called) | 343 | self.assertFalse(self._called) |
1192 | 153 | 344 | ||
1193 | 154 | 345 | ||
1195 | 155 | class RegisterTestCase(LoginTestCase): | 346 | class UbuntuOneWizardRegisterTestCase(UbuntuOneWizardLoginTestCase): |
1196 | 156 | """Test the register through the wizard.""" | 347 | """Test the register through the wizard.""" |
1197 | 157 | 348 | ||
1198 | 158 | method = 'register' | 349 | method = 'register' |
1199 | 159 | 350 | ||
1200 | === modified file 'ubuntuone/controlpanel/gui/qt/wizard.py' | |||
1201 | --- ubuntuone/controlpanel/gui/qt/wizard.py 2012-03-02 17:13:04 +0000 | |||
1202 | +++ ubuntuone/controlpanel/gui/qt/wizard.py 2012-03-19 14:00:47 +0000 | |||
1203 | @@ -19,26 +19,82 @@ | |||
1204 | 19 | from PyQt4 import QtGui, QtCore | 19 | from PyQt4 import QtGui, QtCore |
1205 | 20 | 20 | ||
1206 | 21 | from twisted.internet import defer | 21 | from twisted.internet import defer |
1207 | 22 | from ubuntu_sso.qt import LINK_STYLE | ||
1208 | 23 | from ubuntu_sso.qt.sso_wizard_page import BaseWizardPage | ||
1209 | 22 | from ubuntu_sso.utils.ui import CLOSE_AND_SETUP_LATER | 24 | from ubuntu_sso.utils.ui import CLOSE_AND_SETUP_LATER |
1210 | 23 | 25 | ||
1211 | 24 | from ubuntuone.controlpanel import cache | 26 | from ubuntuone.controlpanel import cache |
1212 | 27 | from ubuntuone.controlpanel.logger import log_call, setup_logging | ||
1213 | 28 | from ubuntuone.controlpanel.gui import ( | ||
1214 | 29 | APP_NAME, | ||
1215 | 30 | ARE_YOU_SURE_HELP, | ||
1216 | 31 | ARE_YOU_SURE_NO, | ||
1217 | 32 | ARE_YOU_SURE_SUBTITLE, | ||
1218 | 33 | ARE_YOU_SURE_TITLE, | ||
1219 | 34 | ARE_YOU_SURE_YES, | ||
1220 | 35 | CLOUD_TO_COMPUTER_SUBTITLE, | ||
1221 | 36 | CLOUD_TO_COMPUTER_TITLE, | ||
1222 | 37 | UBUNTUONE_LINK, | ||
1223 | 38 | ) | ||
1224 | 39 | from ubuntuone.controlpanel.gui.qt.folders import ( | ||
1225 | 40 | RemoteFoldersPanel, | ||
1226 | 41 | ) | ||
1227 | 42 | from ubuntuone.controlpanel.gui.qt.preferences import PreferencesPanel | ||
1228 | 25 | from ubuntuone.controlpanel.gui.qt.signin import SignInPanel | 43 | from ubuntuone.controlpanel.gui.qt.signin import SignInPanel |
1229 | 26 | from ubuntuone.controlpanel.gui.qt.side_widget import SideWidget | 44 | from ubuntuone.controlpanel.gui.qt.side_widget import SideWidget |
1233 | 27 | 45 | from ubuntuone.controlpanel.gui.qt.ui import are_you_sure_ui | |
1234 | 28 | 46 | ||
1235 | 29 | class UbuntuOnePage(QtGui.QWizardPage): | 47 | |
1236 | 48 | logger = setup_logging('qt.wizard') | ||
1237 | 49 | |||
1238 | 50 | |||
1239 | 51 | class AreYouSure(QtGui.QDialog): | ||
1240 | 52 | |||
1241 | 53 | """A 'Are you sure?' dialog.""" | ||
1242 | 54 | |||
1243 | 55 | def __init__(self, *args, **kwargs): | ||
1244 | 56 | super(AreYouSure, self).__init__(*args, **kwargs) | ||
1245 | 57 | self.ui = are_you_sure_ui.Ui_Dialog() | ||
1246 | 58 | self.ui.setupUi(self) | ||
1247 | 59 | self.setWindowTitle(APP_NAME) | ||
1248 | 60 | |||
1249 | 61 | self.ui.title_label.setText(ARE_YOU_SURE_TITLE) | ||
1250 | 62 | |||
1251 | 63 | link = LINK_STYLE.format(link_url=UBUNTUONE_LINK, | ||
1252 | 64 | link_text=UBUNTUONE_LINK) | ||
1253 | 65 | msg = u'%s<p>%s' % (ARE_YOU_SURE_SUBTITLE, | ||
1254 | 66 | ARE_YOU_SURE_HELP.format(support_url=link)) | ||
1255 | 67 | self.ui.message_label.setText(msg) | ||
1256 | 68 | |||
1257 | 69 | self.ui.yes_button.setText(ARE_YOU_SURE_YES) | ||
1258 | 70 | self.ui.no_button.setText(ARE_YOU_SURE_NO) | ||
1259 | 71 | |||
1260 | 72 | |||
1261 | 73 | class UbuntuOnePage(BaseWizardPage): | ||
1262 | 30 | """A generic page for the UbuntuOneWizard.""" | 74 | """A generic page for the UbuntuOneWizard.""" |
1263 | 31 | 75 | ||
1265 | 32 | panel_class = None | 76 | is_final = False |
1266 | 77 | main_title = None | ||
1267 | 78 | max_width = 5000 | ||
1268 | 79 | panel_class = QtGui.QFrame | ||
1269 | 80 | sub_title = None | ||
1270 | 33 | 81 | ||
1271 | 34 | def __init__(self, *args, **kwargs): | 82 | def __init__(self, *args, **kwargs): |
1272 | 35 | super(UbuntuOnePage, self).__init__(*args, **kwargs) | 83 | super(UbuntuOnePage, self).__init__(*args, **kwargs) |
1273 | 36 | 84 | ||
1274 | 37 | self.layout = QtGui.QVBoxLayout(self) | ||
1275 | 38 | self.panel = None | 85 | self.panel = None |
1276 | 39 | if self.panel_class is not None: | 86 | if self.panel_class is not None: |
1279 | 40 | self.panel = SignInPanel() | 87 | self.panel = self.panel_class() |
1280 | 41 | self.layout.addWidget(self.panel) | 88 | self.layout().addWidget(self.panel) |
1281 | 89 | |||
1282 | 90 | if self.main_title is not None: | ||
1283 | 91 | self.setTitle(self.main_title) | ||
1284 | 92 | |||
1285 | 93 | if self.sub_title is not None: | ||
1286 | 94 | self.setSubTitle(self.sub_title) | ||
1287 | 95 | |||
1288 | 96 | self.form_errors_label.hide() | ||
1289 | 97 | self.setFinalPage(self.is_final) | ||
1290 | 42 | 98 | ||
1291 | 43 | 99 | ||
1292 | 44 | class SignInPage(UbuntuOnePage): | 100 | class SignInPage(UbuntuOnePage): |
1293 | @@ -47,9 +103,30 @@ | |||
1294 | 47 | panel_class = SignInPanel | 103 | panel_class = SignInPanel |
1295 | 48 | 104 | ||
1296 | 49 | 105 | ||
1297 | 106 | class CloudToComputerPage(UbuntuOnePage): | ||
1298 | 107 | """The page to choose cloud folders to sync locally.""" | ||
1299 | 108 | |||
1300 | 109 | main_title = CLOUD_TO_COMPUTER_TITLE | ||
1301 | 110 | panel_class = RemoteFoldersPanel | ||
1302 | 111 | sub_title = CLOUD_TO_COMPUTER_SUBTITLE | ||
1303 | 112 | is_final = True | ||
1304 | 113 | |||
1305 | 114 | def __init__(self, *args, **kwargs): | ||
1306 | 115 | super(CloudToComputerPage, self).__init__(*args, **kwargs) | ||
1307 | 116 | self.panel.ui.add_folder_button.hide() | ||
1308 | 117 | |||
1309 | 118 | |||
1310 | 119 | class SettingsPage(UbuntuOnePage): | ||
1311 | 120 | """The page to adjust the service settings.""" | ||
1312 | 121 | |||
1313 | 122 | panel_class = PreferencesPanel | ||
1314 | 123 | |||
1315 | 124 | |||
1316 | 50 | class UbuntuOneWizard(cache.Cache, QtGui.QWizard): | 125 | class UbuntuOneWizard(cache.Cache, QtGui.QWizard): |
1317 | 51 | """The Ubuntu One wizard.""" | 126 | """The Ubuntu One wizard.""" |
1318 | 52 | 127 | ||
1319 | 128 | show_license = False # do not change unless you know what you're doing | ||
1320 | 129 | |||
1321 | 53 | def __init__(self, *args, **kwargs): | 130 | def __init__(self, *args, **kwargs): |
1322 | 54 | super(UbuntuOneWizard, self).__init__(*args, **kwargs) | 131 | super(UbuntuOneWizard, self).__init__(*args, **kwargs) |
1323 | 55 | self.pages = {} | 132 | self.pages = {} |
1324 | @@ -58,13 +135,13 @@ | |||
1325 | 58 | self.setOption(self.HaveFinishButtonOnEarlyPages, False) | 135 | self.setOption(self.HaveFinishButtonOnEarlyPages, False) |
1326 | 59 | self.setWizardStyle(self.ModernStyle) | 136 | self.setWizardStyle(self.ModernStyle) |
1327 | 60 | 137 | ||
1330 | 61 | self.setButtonText(self.CancelButton, CLOSE_AND_SETUP_LATER) | 138 | self.confirm_dialog = AreYouSure(self) |
1329 | 62 | self.setButtonLayout([self.Stretch, self.CancelButton]) | ||
1331 | 63 | 139 | ||
1332 | 64 | self.side_widget = SideWidget() | 140 | self.side_widget = SideWidget() |
1333 | 65 | self.side_widget.stage = self.side_widget.signin_stage | 141 | self.side_widget.stage = self.side_widget.signin_stage |
1334 | 66 | self.setSideWidget(self.side_widget) | 142 | self.setSideWidget(self.side_widget) |
1335 | 67 | 143 | ||
1336 | 144 | # sign in | ||
1337 | 68 | self.signin_page = SignInPage() | 145 | self.signin_page = SignInPage() |
1338 | 69 | self.addPage(self.signin_page) | 146 | self.addPage(self.signin_page) |
1339 | 70 | 147 | ||
1340 | @@ -72,10 +149,19 @@ | |||
1341 | 72 | self.signin_page.panel.ui.register_button.clicked.connect( | 149 | self.signin_page.panel.ui.register_button.clicked.connect( |
1342 | 73 | self.register) | 150 | self.register) |
1343 | 74 | 151 | ||
1348 | 75 | self.setTabOrder(self.signin_page.panel.ui.login_button, | 152 | # cloud to compuer |
1349 | 76 | self.signin_page.panel.ui.register_button) | 153 | self.cloud_folders_page = CloudToComputerPage() |
1350 | 77 | self.setTabOrder(self.signin_page.panel.ui.register_button, | 154 | self.addPage(self.cloud_folders_page) |
1351 | 78 | self.button(self.CancelButton)) | 155 | |
1352 | 156 | self.cloud_folders_page.panel.ui.check_settings_button.clicked.connect( | ||
1353 | 157 | self.check_settings) | ||
1354 | 158 | |||
1355 | 159 | # settings | ||
1356 | 160 | self.settings_page = SettingsPage() | ||
1357 | 161 | self.addPage(self.settings_page) | ||
1358 | 162 | |||
1359 | 163 | self._next_id = self.pages[self.signin_page] | ||
1360 | 164 | self.next() | ||
1361 | 79 | 165 | ||
1362 | 80 | # pylint: disable=C0103 | 166 | # pylint: disable=C0103 |
1363 | 81 | 167 | ||
1364 | @@ -84,8 +170,67 @@ | |||
1365 | 84 | page_id = super(UbuntuOneWizard, self).addPage(page) | 170 | page_id = super(UbuntuOneWizard, self).addPage(page) |
1366 | 85 | self.pages[page] = page_id | 171 | self.pages[page] = page_id |
1367 | 86 | 172 | ||
1368 | 173 | @log_call(logger.info) | ||
1369 | 174 | def initializePage(self, page_id): | ||
1370 | 175 | """The wizard will show the page 'page_id'.""" | ||
1371 | 176 | page = self.page(page_id) | ||
1372 | 177 | logger.debug('UbuntuOneWizard.initializePage: page is %r.', page) | ||
1373 | 178 | |||
1374 | 179 | button_layout = button_to = button = stage = None | ||
1375 | 180 | |||
1376 | 181 | if page is self.signin_page: | ||
1377 | 182 | self.setButtonText(self.CancelButton, CLOSE_AND_SETUP_LATER) | ||
1378 | 183 | |||
1379 | 184 | button_layout = [self.Stretch, self.CancelButton] | ||
1380 | 185 | button = self.signin_page.panel.ui.register_button | ||
1381 | 186 | button_to = self.button(self.CancelButton) | ||
1382 | 187 | stage = self.side_widget.signin_stage | ||
1383 | 188 | self._next_id = self.pages[self.cloud_folders_page] | ||
1384 | 189 | elif page is self.cloud_folders_page: | ||
1385 | 190 | button_layout = [self.Stretch, self.FinishButton] | ||
1386 | 191 | button = self.cloud_folders_page.panel.ui.check_settings_button | ||
1387 | 192 | button_to = self.button(self.FinishButton) | ||
1388 | 193 | stage = self.side_widget.folders_stage | ||
1389 | 194 | elif page is self.settings_page: | ||
1390 | 195 | button_layout = [self.BackButton, self.Stretch] | ||
1391 | 196 | button = self.settings_page.panel.ui.apply_changes_button | ||
1392 | 197 | button_to = self.button(self.BackButton) | ||
1393 | 198 | stage = self.side_widget.folders_stage | ||
1394 | 199 | self._next_id = self.pages[self.cloud_folders_page] | ||
1395 | 200 | else: | ||
1396 | 201 | logger.error('UbuntuOneWizard.initializePage was called with an' | ||
1397 | 202 | 'unknown page: %r (page_id was %r).', page, page_id) | ||
1398 | 203 | |||
1399 | 204 | logger.info('UbuntuOneWizard.initializePage: new page is %r, ' | ||
1400 | 205 | 'new button layout is %r, ' | ||
1401 | 206 | 'new side widget stage is %r.', page, button_layout, stage) | ||
1402 | 207 | |||
1403 | 208 | if button is not None and button_to is not None: | ||
1404 | 209 | self.setTabOrder(button, button_to) | ||
1405 | 210 | if button_layout is not None: | ||
1406 | 211 | self.setButtonLayout(button_layout) | ||
1407 | 212 | if stage is not None: | ||
1408 | 213 | self.side_widget.stage = stage | ||
1409 | 214 | |||
1410 | 215 | @log_call(logger.info) | ||
1411 | 216 | def cleanupPage(self, page_id): | ||
1412 | 217 | """Called clean up 'page_id' just before the user leaves it.""" | ||
1413 | 218 | page = self.page(page_id) | ||
1414 | 219 | logger.debug('UbuntuOneWizard.cleanupPage: page is %r.', page) | ||
1415 | 220 | if page is self.settings_page: | ||
1416 | 221 | self.initializePage(self.pages[self.cloud_folders_page]) | ||
1417 | 222 | |||
1418 | 223 | def nextId(self): | ||
1419 | 224 | """Return the nextId to show.""" | ||
1420 | 225 | return self._next_id | ||
1421 | 226 | |||
1422 | 87 | # pylint: enable=C0103 | 227 | # pylint: enable=C0103 |
1423 | 88 | 228 | ||
1424 | 229 | def _process_credentials(self, credentials=None): | ||
1425 | 230 | """Confirm which is the next step after analyzing 'credentials'.""" | ||
1426 | 231 | if credentials: | ||
1427 | 232 | self.next() | ||
1428 | 233 | |||
1429 | 89 | @QtCore.pyqtSlot() | 234 | @QtCore.pyqtSlot() |
1430 | 90 | @defer.inlineCallbacks | 235 | @defer.inlineCallbacks |
1431 | 91 | def login(self): | 236 | def login(self): |
1432 | @@ -104,7 +249,19 @@ | |||
1433 | 104 | self._process_credentials(credentials) | 249 | self._process_credentials(credentials) |
1434 | 105 | self.setEnabled(True) | 250 | self.setEnabled(True) |
1435 | 106 | 251 | ||
1440 | 107 | def _process_credentials(self, credentials=None): | 252 | @QtCore.pyqtSlot() |
1441 | 108 | """Confirm which is the next step after analyzing 'credentials'.""" | 253 | def check_settings(self): |
1442 | 109 | if credentials: | 254 | """Show the check settings page.""" |
1443 | 110 | self.accept() | 255 | self._next_id = self.pages[self.settings_page] |
1444 | 256 | self.next() | ||
1445 | 257 | |||
1446 | 258 | def done(self, result): | ||
1447 | 259 | """The main window is being closed, call any custom callback.""" | ||
1448 | 260 | if (result == QtGui.QDialog.Rejected and | ||
1449 | 261 | not self.page(self.currentId()).isFinalPage()): | ||
1450 | 262 | response = self.confirm_dialog.exec_() | ||
1451 | 263 | if response == QtGui.QDialog.Accepted: | ||
1452 | 264 | logger.warning('UbuntuOneWizard: user canceled setup.') | ||
1453 | 265 | self.rejected.emit() | ||
1454 | 266 | else: | ||
1455 | 267 | super(UbuntuOneWizard, self).done(result) |
Approved, provided that bug #957458 is fixed on the next branch.