Merge lp:~nataliabidart/ubuntuone-windows-installer/setup-button into lp:ubuntuone-windows-installer
- setup-button
- Merge into trunk
Proposed by
Natalia Bidart
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 67 |
Merged at revision: | 69 |
Proposed branch: | lp:~nataliabidart/ubuntuone-windows-installer/setup-button |
Merge into: | lp:ubuntuone-windows-installer |
Diff against target: |
600 lines (+214/-152) 7 files modified
run-tests (+2/-1) ubuntuone_installer/gui/qt/gui.py (+4/-4) ubuntuone_installer/gui/qt/setup_account.py (+3/-1) ubuntuone_installer/gui/qt/tests/__init__.py (+106/-1) ubuntuone_installer/gui/qt/tests/test_gui.py (+31/-77) ubuntuone_installer/gui/qt/tests/test_local_folders.py (+1/-0) ubuntuone_installer/gui/qt/tests/test_setup_account.py (+67/-68) |
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-windows-installer/setup-button |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Manuel de la Peña (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
Review via email:
|
Commit message
- Improved the test suite for set_up_button handling.
Description of the change
To post a comment you must log in.
- 66. By Natalia Bidart
-
Merged trunk in.
- 67. By Natalia Bidart
-
All test green.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Manuel de la Peña (mandel) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'run-tests' | |||
2 | --- run-tests 2011-08-24 15:24:03 +0000 | |||
3 | +++ run-tests 2011-09-16 13:04:24 +0000 | |||
4 | @@ -27,7 +27,8 @@ | |||
5 | 27 | fi | 27 | fi |
6 | 28 | 28 | ||
7 | 29 | style_check() { | 29 | style_check() { |
9 | 30 | u1lint --ignore ubuntuone_installer/gui/qt/ui | 30 | ./setup.py clean |
10 | 31 | u1lint | ||
11 | 31 | if [ -x `which pep8` ]; then | 32 | if [ -x `which pep8` ]; then |
12 | 32 | pep8 --exclude '.svn,CVS,.bzr,.hg,.git,*_ui.py,*_rc.py' --repeat . | 33 | pep8 --exclude '.svn,CVS,.bzr,.hg,.git,*_ui.py,*_rc.py' --repeat . |
13 | 33 | else | 34 | else |
14 | 34 | 35 | ||
15 | === modified file 'ubuntuone_installer/gui/qt/gui.py' | |||
16 | --- ubuntuone_installer/gui/qt/gui.py 2011-09-15 19:10:23 +0000 | |||
17 | +++ ubuntuone_installer/gui/qt/gui.py 2011-09-16 13:04:24 +0000 | |||
18 | @@ -305,8 +305,8 @@ | |||
19 | 305 | # Add the pages in the right order | 305 | # Add the pages in the right order |
20 | 306 | # pylint: disable=C0103 | 306 | # pylint: disable=C0103 |
21 | 307 | 307 | ||
24 | 308 | self.LICENSE_PAGE = LicensePage() | 308 | self.license_page = LicensePage() |
25 | 309 | self.LICENSE_PAGE_ID = self.addPage(self.LICENSE_PAGE) | 309 | self.LICENSE_PAGE = self.addPage(self.license_page) |
26 | 310 | 310 | ||
27 | 311 | #SSO Pages | 311 | #SSO Pages |
28 | 312 | title_page = TITLE_STYLE % SIGN_IN | 312 | title_page = TITLE_STYLE % SIGN_IN |
29 | @@ -389,7 +389,7 @@ | |||
30 | 389 | self.button(QtGui.QWizard.NextButton).setDefault(True) | 389 | self.button(QtGui.QWizard.NextButton).setDefault(True) |
31 | 390 | 390 | ||
32 | 391 | if installing: | 391 | if installing: |
34 | 392 | self.setStartId(self.LICENSE_PAGE_ID) | 392 | self.setStartId(self.LICENSE_PAGE) |
35 | 393 | else: | 393 | else: |
36 | 394 | self.setStartId(self.SIGNIN_PAGE) | 394 | self.setStartId(self.SIGNIN_PAGE) |
37 | 395 | self.restart() | 395 | self.restart() |
38 | @@ -440,7 +440,7 @@ | |||
39 | 440 | # Finished, not cancelled | 440 | # Finished, not cancelled |
40 | 441 | if result == 1: # Cancelled | 441 | if result == 1: # Cancelled |
41 | 442 | qt.utils.start_control_panel() | 442 | qt.utils.start_control_panel() |
43 | 443 | elif self.currentId() == self.LICENSE_PAGE_ID: | 443 | elif self.currentId() == self.LICENSE_PAGE: |
44 | 444 | if not AreYouSure(self).exec_(): | 444 | if not AreYouSure(self).exec_(): |
45 | 445 | qt.utils.uninstall_application() | 445 | qt.utils.uninstall_application() |
46 | 446 | else: | 446 | else: |
47 | 447 | 447 | ||
48 | === modified file 'ubuntuone_installer/gui/qt/setup_account.py' | |||
49 | --- ubuntuone_installer/gui/qt/setup_account.py 2011-09-15 18:00:49 +0000 | |||
50 | +++ ubuntuone_installer/gui/qt/setup_account.py 2011-09-16 13:04:24 +0000 | |||
51 | @@ -25,6 +25,7 @@ | |||
52 | 25 | 25 | ||
53 | 26 | from ubuntu_sso.qt import common | 26 | from ubuntu_sso.qt import common |
54 | 27 | from ubuntu_sso.qt import gui as sso_gui | 27 | from ubuntu_sso.qt import gui as sso_gui |
55 | 28 | from ubuntu_sso.utils.ui import SET_UP_ACCOUNT_BUTTON | ||
56 | 28 | 29 | ||
57 | 29 | from ubuntuone_installer.gui.qt import enhanced_check_box | 30 | from ubuntuone_installer.gui.qt import enhanced_check_box |
58 | 30 | 31 | ||
59 | @@ -98,9 +99,10 @@ | |||
60 | 98 | self.wizard().customButtonClicked.disconnect() | 99 | self.wizard().customButtonClicked.disconnect() |
61 | 99 | except TypeError: | 100 | except TypeError: |
62 | 100 | pass | 101 | pass |
64 | 101 | self.setButtonText(QtGui.QWizard.CustomButton3, _('Set Up Account')) | 102 | self.setButtonText(QtGui.QWizard.CustomButton3, SET_UP_ACCOUNT_BUTTON) |
65 | 102 | self.set_up_button = self.wizard().button(QtGui.QWizard.CustomButton3) | 103 | self.set_up_button = self.wizard().button(QtGui.QWizard.CustomButton3) |
66 | 103 | self.set_up_button.clicked.connect(self.wizard().overlay.show) | 104 | self.set_up_button.clicked.connect(self.wizard().overlay.show) |
67 | 105 | self.set_up_button.clicked.connect(self.controller.set_next_validation) | ||
68 | 104 | self.set_up_button.setEnabled(False) | 106 | self.set_up_button.setEnabled(False) |
69 | 105 | 107 | ||
70 | 106 | self.ui.name_label.setText(NAME) | 108 | self.ui.name_label.setText(NAME) |
71 | 107 | 109 | ||
72 | === modified file 'ubuntuone_installer/gui/qt/tests/__init__.py' | |||
73 | --- ubuntuone_installer/gui/qt/tests/__init__.py 2011-09-01 18:12:12 +0000 | |||
74 | +++ ubuntuone_installer/gui/qt/tests/__init__.py 2011-09-16 13:04:24 +0000 | |||
75 | @@ -18,8 +18,11 @@ | |||
76 | 18 | 18 | ||
77 | 19 | """The test suite for the Qt UI of the Ubuntu One Installer.""" | 19 | """The test suite for the Qt UI of the Ubuntu One Installer.""" |
78 | 20 | 20 | ||
79 | 21 | from PyQt4 import QtGui, QtCore | ||
80 | 22 | from ubuntuone.controlpanel.gui.qt import loadingoverlay | ||
81 | 23 | |||
82 | 24 | from ubuntuone_installer.gui.tests import FakedObject | ||
83 | 21 | from ubuntuone_installer.tests import TestCase | 25 | from ubuntuone_installer.tests import TestCase |
84 | 22 | from ubuntuone_installer.gui.tests import FakedObject | ||
85 | 23 | 26 | ||
86 | 24 | # Attribute 'yyy' defined outside __init__, access to a protected member | 27 | # Attribute 'yyy' defined outside __init__, access to a protected member |
87 | 25 | # pylint: disable=W0201, W0212 | 28 | # pylint: disable=W0201, W0212 |
88 | @@ -34,6 +37,106 @@ | |||
89 | 34 | exposed_methods = ['setupUi'] | 37 | exposed_methods = ['setupUi'] |
90 | 35 | 38 | ||
91 | 36 | 39 | ||
92 | 40 | class FakeSignal(object): | ||
93 | 41 | |||
94 | 42 | """A fake PyQt signal.""" | ||
95 | 43 | |||
96 | 44 | def __init__(self, *args, **kwargs): | ||
97 | 45 | """Initialize.""" | ||
98 | 46 | self.target = None | ||
99 | 47 | |||
100 | 48 | def connect(self, target): | ||
101 | 49 | """Fake connect.""" | ||
102 | 50 | self.target = target | ||
103 | 51 | |||
104 | 52 | def disconnect(self, *args): | ||
105 | 53 | """Fake disconnect.""" | ||
106 | 54 | self.target = None | ||
107 | 55 | |||
108 | 56 | def emit(self, *args): | ||
109 | 57 | """Fake emit.""" | ||
110 | 58 | if self.target: | ||
111 | 59 | self.target(*args) | ||
112 | 60 | |||
113 | 61 | |||
114 | 62 | class FakeController(object): | ||
115 | 63 | |||
116 | 64 | """A fake controller for the tests.""" | ||
117 | 65 | |||
118 | 66 | is_fake = True | ||
119 | 67 | set_next_validation = lambda *a, **kw: None | ||
120 | 68 | |||
121 | 69 | def __init__(self, *args, **kwargs): | ||
122 | 70 | self.args = (args, kwargs) | ||
123 | 71 | |||
124 | 72 | # pylint: disable=C0103 | ||
125 | 73 | def setupUi(self, view): | ||
126 | 74 | """Fake the setup.""" | ||
127 | 75 | # pylint: enable=C0103 | ||
128 | 76 | |||
129 | 77 | |||
130 | 78 | class FakeOverlay(object): | ||
131 | 79 | |||
132 | 80 | """A fake delay overlay.""" | ||
133 | 81 | |||
134 | 82 | def __init__(self, *args, **kwargs): | ||
135 | 83 | """Initialize.""" | ||
136 | 84 | self.show_counter = 0 | ||
137 | 85 | self.hide_counter = 0 | ||
138 | 86 | self.args = (args, kwargs) | ||
139 | 87 | |||
140 | 88 | def show(self): | ||
141 | 89 | """Fake show.""" | ||
142 | 90 | self.show_counter += 1 | ||
143 | 91 | |||
144 | 92 | def hide(self): | ||
145 | 93 | """Fake hide.""" | ||
146 | 94 | self.hide_counter += 1 | ||
147 | 95 | |||
148 | 96 | def resize(self, *args): | ||
149 | 97 | """Fake resize.""" | ||
150 | 98 | |||
151 | 99 | |||
152 | 100 | class FakeWizard(object): | ||
153 | 101 | """Replace wizard() function on wizard pages.""" | ||
154 | 102 | |||
155 | 103 | customButtonClicked = QtCore.QObject() | ||
156 | 104 | |||
157 | 105 | def __init__(self): | ||
158 | 106 | self.overlay = FakeOverlay() | ||
159 | 107 | self.called = [] | ||
160 | 108 | self.buttons = {} | ||
161 | 109 | |||
162 | 110 | # Invalid name "setButtonLayout", "setOption" | ||
163 | 111 | # pylint: disable=C0103 | ||
164 | 112 | |||
165 | 113 | def setButtonLayout(self, *args, **kwargs): | ||
166 | 114 | """Fake the functionality of setButtonLayout on QWizard class.""" | ||
167 | 115 | self.called.append(('setButtonLayout', (args, kwargs))) | ||
168 | 116 | |||
169 | 117 | def setOption(self, *args, **kwargs): | ||
170 | 118 | """Fake the functionality of setOption on QWizard class.""" | ||
171 | 119 | self.called.append(('setOption', (args, kwargs))) | ||
172 | 120 | |||
173 | 121 | # pylint: enable=C0103 | ||
174 | 122 | |||
175 | 123 | def button(self, button_id): | ||
176 | 124 | """Fake the functionality of button on QWizard class.""" | ||
177 | 125 | return self.buttons.setdefault(button_id, QtGui.QPushButton()) | ||
178 | 126 | |||
179 | 127 | |||
180 | 128 | class FakeWizardPage(object): | ||
181 | 129 | |||
182 | 130 | """A fake wizard page.""" | ||
183 | 131 | |||
184 | 132 | def __init__(self, *args, **kwargs): | ||
185 | 133 | self.has_back_button = True | ||
186 | 134 | |||
187 | 135 | # pylint: disable=C0103 | ||
188 | 136 | def initializePage(self): | ||
189 | 137 | """Fake initializePage.""" | ||
190 | 138 | |||
191 | 139 | |||
192 | 37 | class BaseTestCase(TestCase): | 140 | class BaseTestCase(TestCase): |
193 | 38 | """Base Test Case.""" | 141 | """Base Test Case.""" |
194 | 39 | 142 | ||
195 | @@ -52,3 +155,5 @@ | |||
196 | 52 | if hasattr(self.ui, 'backend'): | 155 | if hasattr(self.ui, 'backend'): |
197 | 53 | # clean backend calls | 156 | # clean backend calls |
198 | 54 | self.ui.backend._called.clear() | 157 | self.ui.backend._called.clear() |
199 | 158 | |||
200 | 159 | self.patch(loadingoverlay, 'LoadingOverlay', FakeOverlay) | ||
201 | 55 | 160 | ||
202 | === modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py' | |||
203 | --- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-15 22:02:03 +0000 | |||
204 | +++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-16 13:04:24 +0000 | |||
205 | @@ -25,21 +25,14 @@ | |||
206 | 25 | 25 | ||
207 | 26 | from ubuntuone_installer.gui import NEXT | 26 | from ubuntuone_installer.gui import NEXT |
208 | 27 | from ubuntuone_installer.gui.qt import gui, forgotten, utils | 27 | from ubuntuone_installer.gui.qt import gui, forgotten, utils |
224 | 28 | from ubuntuone_installer.gui.qt.tests import BaseTestCase, NO_OP | 28 | from ubuntuone_installer.gui.qt.tests import ( |
225 | 29 | 29 | BaseTestCase, | |
226 | 30 | 30 | FakeController, | |
227 | 31 | class FakeController(object): | 31 | FakeOverlay, |
228 | 32 | 32 | FakeSignal, | |
229 | 33 | """A fake controller for the tests.""" | 33 | FakeWizardPage, |
230 | 34 | 34 | NO_OP, | |
231 | 35 | def __init__(self, *args, **kwargs): | 35 | ) |
217 | 36 | self.args = (args, kwargs) | ||
218 | 37 | |||
219 | 38 | # pylint: disable=C0103 | ||
220 | 39 | def setupUi(self, view): | ||
221 | 40 | """Fake the setup.""" | ||
222 | 41 | # pylint: enable=C0103 | ||
223 | 42 | is_fake = True | ||
232 | 43 | 36 | ||
233 | 44 | 37 | ||
234 | 45 | class FakeAreYouSure(object): | 38 | class FakeAreYouSure(object): |
235 | @@ -58,28 +51,6 @@ | |||
236 | 58 | return self.result # Means reject | 51 | return self.result # Means reject |
237 | 59 | 52 | ||
238 | 60 | 53 | ||
239 | 61 | class FakeOverlay(object): | ||
240 | 62 | |||
241 | 63 | """A fake delay overlay.""" | ||
242 | 64 | |||
243 | 65 | def __init__(self, *args, **kwargs): | ||
244 | 66 | """Initialize.""" | ||
245 | 67 | self.show_counter = 0 | ||
246 | 68 | self.hide_counter = 0 | ||
247 | 69 | self.args = (args, kwargs) | ||
248 | 70 | |||
249 | 71 | def show(self): | ||
250 | 72 | """Fake show.""" | ||
251 | 73 | self.show_counter += 1 | ||
252 | 74 | |||
253 | 75 | def hide(self): | ||
254 | 76 | """Fake hide.""" | ||
255 | 77 | self.hide_counter += 1 | ||
256 | 78 | |||
257 | 79 | def resize(self, *args): | ||
258 | 80 | """Fake resize.""" | ||
259 | 81 | |||
260 | 82 | |||
261 | 83 | class FakeLocalFoldersPage(QtGui.QWizardPage): | 54 | class FakeLocalFoldersPage(QtGui.QWizardPage): |
262 | 84 | """Fake Local Folders Page.""" | 55 | """Fake Local Folders Page.""" |
263 | 85 | 56 | ||
264 | @@ -195,7 +166,7 @@ | |||
265 | 195 | def test_with_flag(self): | 166 | def test_with_flag(self): |
266 | 196 | """test with flag activated.""" | 167 | """test with flag activated.""" |
267 | 197 | win = gui.MainWindow(installing=True) | 168 | win = gui.MainWindow(installing=True) |
269 | 198 | self.assertEqual(win.startId(), win.LICENSE_PAGE_ID) | 169 | self.assertEqual(win.startId(), win.LICENSE_PAGE) |
270 | 199 | self.assertEqual( | 170 | self.assertEqual( |
271 | 200 | unicode(self.ui.sign_in_page.ui.message_label.text()), | 171 | unicode(self.ui.sign_in_page.ui.message_label.text()), |
272 | 201 | u"") | 172 | u"") |
273 | @@ -244,7 +215,7 @@ | |||
274 | 244 | 215 | ||
275 | 245 | def test_execute_uninstall_on_licence_cancel(self): | 216 | def test_execute_uninstall_on_licence_cancel(self): |
276 | 246 | """Pressing Disagree button from license page the uninstall is exec.""" | 217 | """Pressing Disagree button from license page the uninstall is exec.""" |
278 | 247 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) | 218 | self.ui.setStartId(self.ui.LICENSE_PAGE) |
279 | 248 | self.ui.restart() | 219 | self.ui.restart() |
280 | 249 | self.ui.show() | 220 | self.ui.show() |
281 | 250 | self.addCleanup(self.ui.hide) | 221 | self.addCleanup(self.ui.hide) |
282 | @@ -255,7 +226,7 @@ | |||
283 | 255 | 226 | ||
284 | 256 | def test_execute_uninstall_on_licence_cancel_frozen(self): | 227 | def test_execute_uninstall_on_licence_cancel_frozen(self): |
285 | 257 | """Pressing Disagree button from license page the uninstall is exec.""" | 228 | """Pressing Disagree button from license page the uninstall is exec.""" |
287 | 258 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) | 229 | self.ui.setStartId(self.ui.LICENSE_PAGE) |
288 | 259 | self.ui.restart() | 230 | self.ui.restart() |
289 | 260 | self.ui.show() | 231 | self.ui.show() |
290 | 261 | self.addCleanup(self.ui.hide) | 232 | self.addCleanup(self.ui.hide) |
291 | @@ -436,7 +407,7 @@ | |||
292 | 436 | 407 | ||
293 | 437 | def test_next_hides_overlay(self): | 408 | def test_next_hides_overlay(self): |
294 | 438 | """Make sure next() hides the overlay.""" | 409 | """Make sure next() hides the overlay.""" |
296 | 439 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) | 410 | self.ui.setStartId(self.ui.LICENSE_PAGE) |
297 | 440 | self.ui.restart() | 411 | self.ui.restart() |
298 | 441 | self.ui.show() | 412 | self.ui.show() |
299 | 442 | self.addCleanup(self.ui.hide) | 413 | self.addCleanup(self.ui.hide) |
300 | @@ -447,11 +418,11 @@ | |||
301 | 447 | 418 | ||
302 | 448 | def test_insert_remove_critical_message(self): | 419 | def test_insert_remove_critical_message(self): |
303 | 449 | """Make sure critical message is added and next() removes it.""" | 420 | """Make sure critical message is added and next() removes it.""" |
305 | 450 | self.ui.setStartId(self.ui.LICENSE_PAGE_ID) | 421 | self.ui.setStartId(self.ui.LICENSE_PAGE) |
306 | 451 | self.ui.restart() | 422 | self.ui.restart() |
307 | 452 | self.ui.show() | 423 | self.ui.show() |
308 | 453 | self.addCleanup(self.ui.hide) | 424 | self.addCleanup(self.ui.hide) |
310 | 454 | license_page = self.ui.page(self.ui.LICENSE_PAGE_ID) | 425 | license_page = self.ui.page(self.ui.LICENSE_PAGE) |
311 | 455 | self.assertEqual(self.ui.form_errors_label.parentWidget(), None) | 426 | self.assertEqual(self.ui.form_errors_label.parentWidget(), None) |
312 | 456 | self.ui.critical("test critical message") | 427 | self.ui.critical("test critical message") |
313 | 457 | self.assertEqual(self.ui.form_errors_label.parentWidget(), | 428 | self.assertEqual(self.ui.form_errors_label.parentWidget(), |
314 | @@ -534,7 +505,7 @@ | |||
315 | 534 | 505 | ||
316 | 535 | def test_stage_progression_1(self): | 506 | def test_stage_progression_1(self): |
317 | 536 | """Check that each page in the wizard sets the correct stage.""" | 507 | """Check that each page in the wizard sets the correct stage.""" |
319 | 537 | self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE_ID) | 508 | self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE) |
320 | 538 | self.assertEqual(self.ui.sideWidget().stage, 0) | 509 | self.assertEqual(self.ui.sideWidget().stage, 0) |
321 | 539 | 510 | ||
322 | 540 | def test_stage_progression_2(self): | 511 | def test_stage_progression_2(self): |
323 | @@ -608,39 +579,22 @@ | |||
324 | 608 | # Check if syncdaemon was added to autostart | 579 | # Check if syncdaemon was added to autostart |
325 | 609 | self.assertEqual(self._called, ((), {})) | 580 | self.assertEqual(self._called, ((), {})) |
326 | 610 | 581 | ||
360 | 611 | 582 | def test_side_widget_state(self): | |
361 | 612 | class FakeSignal(object): | 583 | """Test if the side widget of the wizard has state frame visible.""" |
362 | 613 | 584 | self.ui.show() | |
363 | 614 | """A fake PyQt signal.""" | 585 | self.addCleanup(self.ui.hide) |
364 | 615 | 586 | ||
365 | 616 | def __init__(self, *args, **kwargs): | 587 | self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE) |
366 | 617 | """Initialize.""" | 588 | self.assertFalse(self.ui.sideWidget().ui.states_frame.isVisible()) |
367 | 618 | self.target = None | 589 | |
368 | 619 | 590 | self.ui.on_currentIdChanged(self.ui.SIGNIN_PAGE) | |
369 | 620 | def connect(self, target): | 591 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) |
370 | 621 | """Fake connect.""" | 592 | |
371 | 622 | self.target = target | 593 | self.ui.on_currentIdChanged(self.ui.local_folders_page_id) |
372 | 623 | 594 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) | |
373 | 624 | def disconnect(self, *args): | 595 | |
374 | 625 | """Fake disconnect.""" | 596 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) |
375 | 626 | self.target = None | 597 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) |
343 | 627 | |||
344 | 628 | def emit(self, *args): | ||
345 | 629 | """Fake emit.""" | ||
346 | 630 | if self.target: | ||
347 | 631 | self.target(*args) | ||
348 | 632 | |||
349 | 633 | |||
350 | 634 | class FakeWizardPage(object): | ||
351 | 635 | |||
352 | 636 | """A fake wizard page.""" | ||
353 | 637 | |||
354 | 638 | def __init__(self, *args, **kwargs): | ||
355 | 639 | self.has_back_button = True | ||
356 | 640 | |||
357 | 641 | # pylint: disable=C0103 | ||
358 | 642 | def initializePage(self): | ||
359 | 643 | """Fake initializePage.""" | ||
376 | 644 | 598 | ||
377 | 645 | 599 | ||
378 | 646 | class FakeMainWindow(object): | 600 | class FakeMainWindow(object): |
379 | 647 | 601 | ||
380 | === modified file 'ubuntuone_installer/gui/qt/tests/test_local_folders.py' | |||
381 | --- ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-13 02:07:43 +0000 | |||
382 | +++ ubuntuone_installer/gui/qt/tests/test_local_folders.py 2011-09-16 13:04:24 +0000 | |||
383 | @@ -452,6 +452,7 @@ | |||
384 | 452 | @defer.inlineCallbacks | 452 | @defer.inlineCallbacks |
385 | 453 | def test_add_folder_valid_starts_selected(self): | 453 | def test_add_folder_valid_starts_selected(self): |
386 | 454 | """When adding a valid folder, it starts as selected.""" | 454 | """When adding a valid folder, it starts as selected.""" |
387 | 455 | self.patch(self.ui, 'update_sizes', lambda: None) | ||
388 | 455 | self.patch(QtGui, "QFileDialog", FakeFileDialog()) | 456 | self.patch(QtGui, "QFileDialog", FakeFileDialog()) |
389 | 456 | yield self.ui.on_add_folder_button_clicked() | 457 | yield self.ui.on_add_folder_button_clicked() |
390 | 457 | self.assertEqual( | 458 | self.assertEqual( |
391 | 458 | 459 | ||
392 | === modified file 'ubuntuone_installer/gui/qt/tests/test_setup_account.py' | |||
393 | --- ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-09-15 18:00:49 +0000 | |||
394 | +++ ubuntuone_installer/gui/qt/tests/test_setup_account.py 2011-09-16 13:04:24 +0000 | |||
395 | @@ -24,54 +24,13 @@ | |||
396 | 24 | 24 | ||
397 | 25 | from ubuntu_sso.qt import common | 25 | from ubuntu_sso.qt import common |
398 | 26 | 26 | ||
403 | 27 | from ubuntuone_installer.gui.qt import gui, setup_account | 27 | from ubuntuone_installer.gui.qt import setup_account as gui |
404 | 28 | from ubuntuone_installer.gui.qt.tests import BaseTestCase | 28 | from ubuntuone_installer.gui.qt.tests import ( |
405 | 29 | from ubuntuone_installer.gui.qt.ui import ( | 29 | BaseTestCase, |
406 | 30 | setup_account_ui, | 30 | FakeController, |
407 | 31 | FakeWizard, | ||
408 | 31 | ) | 32 | ) |
452 | 32 | 33 | from ubuntuone_installer.gui.qt.ui import setup_account_ui | |
410 | 33 | |||
411 | 34 | class FakeController(object): | ||
412 | 35 | |||
413 | 36 | """A fake controller for the tests.""" | ||
414 | 37 | |||
415 | 38 | def __init__(self, *args, **kwargs): | ||
416 | 39 | self.args = (args, kwargs) | ||
417 | 40 | |||
418 | 41 | # pylint: disable=C0103 | ||
419 | 42 | def setupUi(self, view): | ||
420 | 43 | """Fake the setup.""" | ||
421 | 44 | # pylint: enable=C0103 | ||
422 | 45 | |||
423 | 46 | |||
424 | 47 | class FakeWizard(object): | ||
425 | 48 | """Replace wizard() function on wizard pages.""" | ||
426 | 49 | |||
427 | 50 | customButtonClicked = QtCore.QObject() | ||
428 | 51 | overlay = None | ||
429 | 52 | params = None | ||
430 | 53 | |||
431 | 54 | # Invalid name "setButtonLayout" | ||
432 | 55 | # pylint: disable=C0103 | ||
433 | 56 | |||
434 | 57 | def setButtonLayout(self, *args, **kwargs): | ||
435 | 58 | """Fake the functionality of setButtonLayout on QWizard class.""" | ||
436 | 59 | FakeWizard.params = (args, kwargs) | ||
437 | 60 | |||
438 | 61 | # pylint: enable=C0103 | ||
439 | 62 | |||
440 | 63 | # Invalid name "setOption" | ||
441 | 64 | # pylint: disable=C0103 | ||
442 | 65 | |||
443 | 66 | def setOption(self, *args, **kwargs): | ||
444 | 67 | """Fake the functionality of setOption on QWizard class.""" | ||
445 | 68 | FakeWizard.params = (args, kwargs) | ||
446 | 69 | |||
447 | 70 | # pylint: enable=C0103 | ||
448 | 71 | |||
449 | 72 | def button(self, *args, **kwargs): | ||
450 | 73 | """Fake the functionality of button on QWizard class.""" | ||
451 | 74 | return QtGui.QPushButton() | ||
453 | 75 | 34 | ||
454 | 76 | 35 | ||
455 | 77 | class FakeValidationDict(object): | 36 | class FakeValidationDict(object): |
456 | @@ -108,7 +67,7 @@ | |||
457 | 108 | class SetupAccountTestCase(BaseTestCase): | 67 | class SetupAccountTestCase(BaseTestCase): |
458 | 109 | """Test the SetupAccountPage code.""" | 68 | """Test the SetupAccountPage code.""" |
459 | 110 | 69 | ||
461 | 111 | class_ui = setup_account.SetupAccountPage | 70 | class_ui = gui.SetupAccountPage |
462 | 112 | kwargs = dict( | 71 | kwargs = dict( |
463 | 113 | ui=setup_account_ui.Ui_SetUpAccountPage(), | 72 | ui=setup_account_ui.Ui_SetUpAccountPage(), |
464 | 114 | controller=FakeController(), | 73 | controller=FakeController(), |
465 | @@ -138,7 +97,7 @@ | |||
466 | 138 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) | 97 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) |
467 | 139 | self.assertEqual( | 98 | self.assertEqual( |
468 | 140 | unicode(self.ui.ui.name_assistance.text()), | 99 | unicode(self.ui.ui.name_assistance.text()), |
470 | 141 | setup_account.ERROR % setup_account.EMPTY_NAME) | 100 | gui.ERROR % gui.EMPTY_NAME) |
471 | 142 | self.ui.hide() | 101 | self.ui.hide() |
472 | 143 | 102 | ||
473 | 144 | def test_password_default_assistance(self): | 103 | def test_password_default_assistance(self): |
474 | @@ -163,19 +122,6 @@ | |||
475 | 163 | unicode(self.ui.ui.password_assistance.text()), | 122 | unicode(self.ui.ui.password_assistance.text()), |
476 | 164 | ) | 123 | ) |
477 | 165 | 124 | ||
478 | 166 | def test_side_widget_state(self): | ||
479 | 167 | """Test if the side widget of the wizard has state frame visible.""" | ||
480 | 168 | if type(self.ui) != gui.MainWindow: | ||
481 | 169 | return | ||
482 | 170 | self.ui.on_currentIdChanged(self.ui.LICENSE_PAGE) | ||
483 | 171 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) | ||
484 | 172 | self.ui.on_currentIdChanged(self.ui.SIGNIN_PAGE) | ||
485 | 173 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) | ||
486 | 174 | self.ui.on_currentIdChanged(self.ui.local_folders_page_id) | ||
487 | 175 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) | ||
488 | 176 | self.ui.on_currentIdChanged(self.ui.CONGRATULATIONS_PAGE) | ||
489 | 177 | self.assertTrue(self.ui.sideWidget().ui.states_frame.isVisible()) | ||
490 | 178 | |||
491 | 179 | def test_focus_changed_1(self): | 125 | def test_focus_changed_1(self): |
492 | 180 | """Check functions execution when focus_changed() is executed.""" | 126 | """Check functions execution when focus_changed() is executed.""" |
493 | 181 | self.patch(self.ui, 'validation_functions', FakeValidationDict()) | 127 | self.patch(self.ui, 'validation_functions', FakeValidationDict()) |
494 | @@ -216,7 +162,7 @@ | |||
495 | 216 | class SetupAccountFakeWizardTestCase(BaseTestCase): | 162 | class SetupAccountFakeWizardTestCase(BaseTestCase): |
496 | 217 | """Test the SetupAccountPage code.""" | 163 | """Test the SetupAccountPage code.""" |
497 | 218 | 164 | ||
499 | 219 | class_ui = setup_account.SetupAccountPage | 165 | class_ui = gui.SetupAccountPage |
500 | 220 | kwargs = dict( | 166 | kwargs = dict( |
501 | 221 | ui=setup_account_ui.Ui_SetUpAccountPage(), | 167 | ui=setup_account_ui.Ui_SetUpAccountPage(), |
502 | 222 | controller=FakeController(), | 168 | controller=FakeController(), |
503 | @@ -228,7 +174,60 @@ | |||
504 | 228 | # Faking each SSO object instead of doing it lower | 174 | # Faking each SSO object instead of doing it lower |
505 | 229 | # so we don't rely on any SSO behaviour | 175 | # so we don't rely on any SSO behaviour |
506 | 230 | super(SetupAccountFakeWizardTestCase, self).setUp() | 176 | super(SetupAccountFakeWizardTestCase, self).setUp() |
508 | 231 | self.patch(self.ui, 'wizard', FakeWizard) | 177 | self.wizard = FakeWizard() |
509 | 178 | self.patch(self.ui, 'wizard', lambda: self.wizard) | ||
510 | 179 | |||
511 | 180 | def test_initialize_page(self): | ||
512 | 181 | """Widgets are properly initialized.""" | ||
513 | 182 | self.ui.initializePage() | ||
514 | 183 | self.ui.show() | ||
515 | 184 | self.addCleanup(self.ui.hide) | ||
516 | 185 | |||
517 | 186 | # titles | ||
518 | 187 | self.assertEqual(self.ui.header.title_label.text(), | ||
519 | 188 | gui.TITLE_STYLE % gui.TITLE) | ||
520 | 189 | self.assertEqual(self.ui.header.subtitle_label.text(), gui.SUBTITLE) | ||
521 | 190 | |||
522 | 191 | # set up account button | ||
523 | 192 | expected = [QtGui.QWizard.BackButton, QtGui.QWizard.Stretch, | ||
524 | 193 | QtGui.QWizard.CustomButton3] | ||
525 | 194 | self.assertIn(('setButtonLayout', ((expected,), {})), | ||
526 | 195 | self.ui.wizard().called) | ||
527 | 196 | self.assertEqual(gui.SET_UP_ACCOUNT_BUTTON, | ||
528 | 197 | self.ui.buttonText(QtGui.QWizard.CustomButton3)) | ||
529 | 198 | self.assertTrue(self.ui.wizard().button(QtGui.QWizard.CustomButton3) is | ||
530 | 199 | self.ui.set_up_button) | ||
531 | 200 | self.assertFalse(self.ui.set_up_button.isEnabled()) | ||
532 | 201 | |||
533 | 202 | # labels | ||
534 | 203 | self.assertEqual(self.ui.ui.name_label.text(), gui.NAME) | ||
535 | 204 | self.assertEqual(self.ui.ui.email_label.text(), gui.EMAIL) | ||
536 | 205 | self.assertEqual(self.ui.ui.confirm_email_label.text(), | ||
537 | 206 | gui.RETYPE_EMAIL) | ||
538 | 207 | self.assertEqual(self.ui.ui.password_label.text(), | ||
539 | 208 | gui.PASSWORD) | ||
540 | 209 | self.assertEqual(self.ui.ui.confirm_password_label.text(), | ||
541 | 210 | gui.RETYPE_PASSWORD) | ||
542 | 211 | self.assertFalse(self.ui.ui.password_info_label.isVisible()) | ||
543 | 212 | |||
544 | 213 | # assistants | ||
545 | 214 | self.assertFalse(self.ui.ui.name_assistance.isVisible()) | ||
546 | 215 | self.assertFalse(self.ui.ui.email_assistance.isVisible()) | ||
547 | 216 | self.assertFalse(self.ui.ui.confirm_email_assistance.isVisible()) | ||
548 | 217 | self.assertFalse(self.ui.ui.password_assistance.isVisible()) | ||
549 | 218 | self.assertTrue(self.ui.ui.refresh_label.isVisible()) | ||
550 | 219 | |||
551 | 220 | def test_set_up_button_clicked(self): | ||
552 | 221 | """Validation and overlay is shown when the setupbutton is clicked.""" | ||
553 | 222 | self.patch(self.ui.controller, 'set_next_validation', self._set_called) | ||
554 | 223 | self.ui.initializePage() | ||
555 | 224 | self.ui.show() | ||
556 | 225 | self.addCleanup(self.ui.hide) | ||
557 | 226 | |||
558 | 227 | self.ui.set_up_button.clicked.emit(False) | ||
559 | 228 | |||
560 | 229 | self.assertEqual(self.ui.wizard().overlay.show_counter, 1) | ||
561 | 230 | self.assertEqual(self._called, ((False,), {})) | ||
562 | 232 | 231 | ||
563 | 233 | def test_set_error_message(self): | 232 | def test_set_error_message(self): |
564 | 234 | """Check the state of the label after calling: set_error_message.""" | 233 | """Check the state of the label after calling: set_error_message.""" |
565 | @@ -239,7 +238,7 @@ | |||
566 | 239 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) | 238 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) |
567 | 240 | self.assertEqual( | 239 | self.assertEqual( |
568 | 241 | unicode(self.ui.ui.email_assistance.text()), | 240 | unicode(self.ui.ui.email_assistance.text()), |
570 | 242 | setup_account.ERROR % "message") | 241 | gui.ERROR % "message") |
571 | 243 | 242 | ||
572 | 244 | def test_blank_name(self): | 243 | def test_blank_name(self): |
573 | 245 | """Status when the name field is blank (spaces). | 244 | """Status when the name field is blank (spaces). |
574 | @@ -254,7 +253,7 @@ | |||
575 | 254 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) | 253 | self.assertTrue(self.ui.ui.name_assistance.isVisible()) |
576 | 255 | self.assertEqual( | 254 | self.assertEqual( |
577 | 256 | unicode(self.ui.ui.name_assistance.text()), | 255 | unicode(self.ui.ui.name_assistance.text()), |
579 | 257 | setup_account.ERROR % setup_account.EMPTY_NAME) | 256 | gui.ERROR % gui.EMPTY_NAME) |
580 | 258 | self.ui.hide() | 257 | self.ui.hide() |
581 | 259 | 258 | ||
582 | 260 | def test_valid_name(self): | 259 | def test_valid_name(self): |
583 | @@ -282,7 +281,7 @@ | |||
584 | 282 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) | 281 | self.assertTrue(self.ui.ui.email_assistance.isVisible()) |
585 | 283 | self.assertEqual( | 282 | self.assertEqual( |
586 | 284 | unicode(self.ui.ui.email_assistance.text()), | 283 | unicode(self.ui.ui.email_assistance.text()), |
588 | 285 | setup_account.ERROR % setup_account.INVALID_EMAIL) | 284 | gui.ERROR % gui.INVALID_EMAIL) |
589 | 286 | 285 | ||
590 | 287 | def test_valid_email(self): | 286 | def test_valid_email(self): |
591 | 288 | """Status when the email field has a @. | 287 | """Status when the email field has a @. |
592 | @@ -323,7 +322,7 @@ | |||
593 | 323 | self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible()) | 322 | self.assertTrue(self.ui.ui.confirm_email_assistance.isVisible()) |
594 | 324 | self.assertEqual( | 323 | self.assertEqual( |
595 | 325 | unicode(self.ui.ui.confirm_email_assistance.text()), | 324 | unicode(self.ui.ui.confirm_email_assistance.text()), |
597 | 326 | setup_account.ERROR % setup_account.EMAIL_MATCH) | 325 | gui.ERROR % gui.EMAIL_MATCH) |
598 | 327 | self.ui.hide() | 326 | self.ui.hide() |
599 | 328 | 327 | ||
600 | 329 | def test_focus_changed_password_visibility(self): | 328 | def test_focus_changed_password_visibility(self): |
+1