Merge lp:~ralsina/ubuntuone-control-panel/minus-one-is-the-loneliest-number into lp:ubuntuone-control-panel
- minus-one-is-the-loneliest-number
- Merge into trunk
Proposed by
Roberto Alsina
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Brian Curtin | ||||
Approved revision: | 326 | ||||
Merged at revision: | 325 | ||||
Proposed branch: | lp:~ralsina/ubuntuone-control-panel/minus-one-is-the-loneliest-number | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
380 lines (+88/-144) 5 files modified
data/qt/preferences.ui (+43/-17) data/qt/ubuntuone.qss (+7/-0) ubuntuone/controlpanel/gui/__init__.py (+0/-2) ubuntuone/controlpanel/gui/qt/preferences.py (+14/-50) ubuntuone/controlpanel/gui/qt/tests/test_preferences.py (+24/-75) |
||||
To merge this branch: | bzr merge lp:~ralsina/ubuntuone-control-panel/minus-one-is-the-loneliest-number | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brian Curtin (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
Review via email: mp+105869@code.launchpad.net |
Commit message
- Improved the UX for the bandwidth settings (Fixes lp:847227).
Description of the change
* Removed the warning 'Please note that your files will not sync if you set your bandwidth to 0' which was not even true
* Enable/disable the spinboxes when you check/uncheck the matching checkbox
* Made the minimum bandwidth value 1, removing the bogus -1 and 0 (it still saves -1 to mean disabled)
- Improved the UX for the bandwidth settings (Fixes lp:847227).
To post a comment you must log in.
Revision history for this message
Brian Curtin (brian.curtin) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'data/qt/preferences.ui' | |||
2 | --- data/qt/preferences.ui 2012-05-15 13:53:50 +0000 | |||
3 | +++ data/qt/preferences.ui 2012-05-15 18:48:18 +0000 | |||
4 | @@ -38,18 +38,21 @@ | |||
5 | 38 | </item> | 38 | </item> |
6 | 39 | <item row="0" column="1"> | 39 | <item row="0" column="1"> |
7 | 40 | <widget class="QSpinBox" name="upload_speed_spinbox"> | 40 | <widget class="QSpinBox" name="upload_speed_spinbox"> |
8 | 41 | <property name="enabled"> | ||
9 | 42 | <bool>false</bool> | ||
10 | 43 | </property> | ||
11 | 41 | <property name="alignment"> | 44 | <property name="alignment"> |
12 | 42 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | 45 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
13 | 43 | </property> | 46 | </property> |
14 | 44 | <property name="minimum"> | 47 | <property name="minimum"> |
16 | 45 | <number>-1</number> | 48 | <number>1</number> |
17 | 46 | </property> | 49 | </property> |
18 | 47 | <property name="maximum"> | 50 | <property name="maximum"> |
19 | 48 | <number>999999999</number> | 51 | <number>999999999</number> |
20 | 49 | </property> | 52 | </property> |
21 | 50 | </widget> | 53 | </widget> |
22 | 51 | </item> | 54 | </item> |
24 | 52 | <item row="0" column="3"> | 55 | <item row="0" column="2"> |
25 | 53 | <spacer name="horizontalSpacer_2"> | 56 | <spacer name="horizontalSpacer_2"> |
26 | 54 | <property name="orientation"> | 57 | <property name="orientation"> |
27 | 55 | <enum>Qt::Horizontal</enum> | 58 | <enum>Qt::Horizontal</enum> |
28 | @@ -71,11 +74,14 @@ | |||
29 | 71 | </item> | 74 | </item> |
30 | 72 | <item row="1" column="1"> | 75 | <item row="1" column="1"> |
31 | 73 | <widget class="QSpinBox" name="download_speed_spinbox"> | 76 | <widget class="QSpinBox" name="download_speed_spinbox"> |
32 | 77 | <property name="enabled"> | ||
33 | 78 | <bool>false</bool> | ||
34 | 79 | </property> | ||
35 | 74 | <property name="alignment"> | 80 | <property name="alignment"> |
36 | 75 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | 81 | <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> |
37 | 76 | </property> | 82 | </property> |
38 | 77 | <property name="minimum"> | 83 | <property name="minimum"> |
40 | 78 | <number>-1</number> | 84 | <number>1</number> |
41 | 79 | </property> | 85 | </property> |
42 | 80 | <property name="maximum"> | 86 | <property name="maximum"> |
43 | 81 | <number>999999999</number> | 87 | <number>999999999</number> |
44 | @@ -98,19 +104,6 @@ | |||
45 | 98 | </property> | 104 | </property> |
46 | 99 | </spacer> | 105 | </spacer> |
47 | 100 | </item> | 106 | </item> |
48 | 101 | <item row="3" column="0" colspan="3"> | ||
49 | 102 | <widget class="QLabel" name="label_2"> | ||
50 | 103 | <property name="text"> | ||
51 | 104 | <string notr="true">Please note that your files will not sync if you set bandwidth to 0</string> | ||
52 | 105 | </property> | ||
53 | 106 | <property name="scaledContents"> | ||
54 | 107 | <bool>false</bool> | ||
55 | 108 | </property> | ||
56 | 109 | <property name="wordWrap"> | ||
57 | 110 | <bool>false</bool> | ||
58 | 111 | </property> | ||
59 | 112 | </widget> | ||
60 | 113 | </item> | ||
61 | 114 | </layout> | 107 | </layout> |
62 | 115 | </widget> | 108 | </widget> |
63 | 116 | </item> | 109 | </item> |
64 | @@ -223,5 +216,38 @@ | |||
65 | 223 | </layout> | 216 | </layout> |
66 | 224 | </widget> | 217 | </widget> |
67 | 225 | <resources/> | 218 | <resources/> |
69 | 226 | <connections/> | 219 | <connections> |
70 | 220 | <connection> | ||
71 | 221 | <sender>limit_uploads_checkbox</sender> | ||
72 | 222 | <signal>toggled(bool)</signal> | ||
73 | 223 | <receiver>upload_speed_spinbox</receiver> | ||
74 | 224 | <slot>setEnabled(bool)</slot> | ||
75 | 225 | <hints> | ||
76 | 226 | <hint type="sourcelabel"> | ||
77 | 227 | <x>94</x> | ||
78 | 228 | <y>24</y> | ||
79 | 229 | </hint> | ||
80 | 230 | <hint type="destinationlabel"> | ||
81 | 231 | <x>256</x> | ||
82 | 232 | <y>28</y> | ||
83 | 233 | </hint> | ||
84 | 234 | </hints> | ||
85 | 235 | </connection> | ||
86 | 236 | <connection> | ||
87 | 237 | <sender>limit_downloads_checkbox</sender> | ||
88 | 238 | <signal>toggled(bool)</signal> | ||
89 | 239 | <receiver>download_speed_spinbox</receiver> | ||
90 | 240 | <slot>setEnabled(bool)</slot> | ||
91 | 241 | <hints> | ||
92 | 242 | <hint type="sourcelabel"> | ||
93 | 243 | <x>212</x> | ||
94 | 244 | <y>70</y> | ||
95 | 245 | </hint> | ||
96 | 246 | <hint type="destinationlabel"> | ||
97 | 247 | <x>242</x> | ||
98 | 248 | <y>66</y> | ||
99 | 249 | </hint> | ||
100 | 250 | </hints> | ||
101 | 251 | </connection> | ||
102 | 252 | </connections> | ||
103 | 227 | </ui> | 253 | </ui> |
104 | 228 | 254 | ||
105 | === modified file 'data/qt/ubuntuone.qss' | |||
106 | --- data/qt/ubuntuone.qss 2012-05-15 02:05:41 +0000 | |||
107 | +++ data/qt/ubuntuone.qss 2012-05-15 18:48:18 +0000 | |||
108 | @@ -338,6 +338,13 @@ | |||
109 | 338 | background-color: white; | 338 | background-color: white; |
110 | 339 | } | 339 | } |
111 | 340 | 340 | ||
112 | 341 | QSpinBox:disabled { | ||
113 | 342 | padding: 3px; | ||
114 | 343 | background-color: transparent; | ||
115 | 344 | color: darkgrey; | ||
116 | 345 | } | ||
117 | 346 | |||
118 | 347 | |||
119 | 341 | QTreeWidget::item:selected { | 348 | QTreeWidget::item:selected { |
120 | 342 | background: #fcece7; | 349 | background: #fcece7; |
121 | 343 | color: black; | 350 | color: black; |
122 | 344 | 351 | ||
123 | === modified file 'ubuntuone/controlpanel/gui/__init__.py' | |||
124 | --- ubuntuone/controlpanel/gui/__init__.py 2012-05-15 13:53:50 +0000 | |||
125 | +++ ubuntuone/controlpanel/gui/__init__.py 2012-05-15 18:48:18 +0000 | |||
126 | @@ -224,8 +224,6 @@ | |||
127 | 224 | SETTINGS_ALLOW_NOTIFICATIONS = _('Allow all notifications to this device') | 224 | SETTINGS_ALLOW_NOTIFICATIONS = _('Allow all notifications to this device') |
128 | 225 | SETTINGS_AUTO_CONNECT = _('Connect automatically when computer starts') | 225 | SETTINGS_AUTO_CONNECT = _('Connect automatically when computer starts') |
129 | 226 | SETTINGS_BANDWIDTH = _('Bandwidth Settings') | 226 | SETTINGS_BANDWIDTH = _('Bandwidth Settings') |
130 | 227 | SETTINGS_BANDWIDTH_ZERO_WARNING = _('Please note that your files will not ' | ||
131 | 228 | 'sync if you set bandwidth to 0') | ||
132 | 229 | SETTINGS_BUTTON_APPLY = _('Apply these settings') | 227 | SETTINGS_BUTTON_APPLY = _('Apply these settings') |
133 | 230 | SETTINGS_BUTTON_DEFAULT = _('Default settings') | 228 | SETTINGS_BUTTON_DEFAULT = _('Default settings') |
134 | 231 | SETTINGS_CHANGE_ERROR = _('The settings could not be changed,\n' | 229 | SETTINGS_CHANGE_ERROR = _('The settings could not be changed,\n' |
135 | 232 | 230 | ||
136 | === modified file 'ubuntuone/controlpanel/gui/qt/preferences.py' | |||
137 | --- ubuntuone/controlpanel/gui/qt/preferences.py 2012-05-15 13:53:50 +0000 | |||
138 | +++ ubuntuone/controlpanel/gui/qt/preferences.py 2012-05-15 18:48:18 +0000 | |||
139 | @@ -29,7 +29,6 @@ | |||
140 | 29 | SETTINGS_ALLOW_NOTIFICATIONS, | 29 | SETTINGS_ALLOW_NOTIFICATIONS, |
141 | 30 | SETTINGS_AUTO_CONNECT, | 30 | SETTINGS_AUTO_CONNECT, |
142 | 31 | SETTINGS_BANDWIDTH, | 31 | SETTINGS_BANDWIDTH, |
143 | 32 | SETTINGS_BANDWIDTH_ZERO_WARNING, | ||
144 | 33 | SETTINGS_BUTTON_APPLY, | 32 | SETTINGS_BUTTON_APPLY, |
145 | 34 | SETTINGS_BUTTON_DEFAULT, | 33 | SETTINGS_BUTTON_DEFAULT, |
146 | 35 | SETTINGS_FILE_SYNC, | 34 | SETTINGS_FILE_SYNC, |
147 | @@ -55,22 +54,6 @@ | |||
148 | 55 | return CHECKED if checked else UNCHECKED | 54 | return CHECKED if checked else UNCHECKED |
149 | 56 | 55 | ||
150 | 57 | 56 | ||
151 | 58 | def tweak_speed(speed): | ||
152 | 59 | """Return the proper speed in kilobytes. | ||
153 | 60 | |||
154 | 61 | If speed < 0, return -1. | ||
155 | 62 | If speed == 0, return 1 (almost nothing, the backed won't accept 0. | ||
156 | 63 | If speed > 0, return the kilobytes presentation of that. | ||
157 | 64 | |||
158 | 65 | """ | ||
159 | 66 | result = -1 | ||
160 | 67 | if speed > 0: | ||
161 | 68 | result = speed * KILOBYTES | ||
162 | 69 | elif speed == 0: | ||
163 | 70 | result = 1 | ||
164 | 71 | return result | ||
165 | 72 | |||
166 | 73 | |||
167 | 74 | class PreferencesPanel(UbuntuOneBin): | 57 | class PreferencesPanel(UbuntuOneBin): |
168 | 75 | """The Preferences Tab Panel widget""" | 58 | """The Preferences Tab Panel widget""" |
169 | 76 | 59 | ||
170 | @@ -87,7 +70,6 @@ | |||
171 | 87 | SETTINGS_KILOBITS_PER_SECOND) | 70 | SETTINGS_KILOBITS_PER_SECOND) |
172 | 88 | self.ui.download_speed_spinbox.setSuffix(" " + | 71 | self.ui.download_speed_spinbox.setSuffix(" " + |
173 | 89 | SETTINGS_KILOBITS_PER_SECOND) | 72 | SETTINGS_KILOBITS_PER_SECOND) |
174 | 90 | self.ui.label_2.setText(SETTINGS_BANDWIDTH_ZERO_WARNING) | ||
175 | 91 | self.ui.restore_defaults_button.setText(SETTINGS_BUTTON_DEFAULT) | 73 | self.ui.restore_defaults_button.setText(SETTINGS_BUTTON_DEFAULT) |
176 | 92 | 74 | ||
177 | 93 | # pylint: disable=E0202 | 75 | # pylint: disable=E0202 |
178 | @@ -119,40 +101,18 @@ | |||
179 | 119 | # signal handlers | 101 | # signal handlers |
180 | 120 | self.ui.download_speed_spinbox.setValue(download_speed) | 102 | self.ui.download_speed_spinbox.setValue(download_speed) |
181 | 121 | self.ui.upload_speed_spinbox.setValue(upload_speed) | 103 | self.ui.upload_speed_spinbox.setValue(upload_speed) |
182 | 104 | if upload_speed > 0: | ||
183 | 105 | self.ui.limit_uploads_checkbox.setCheckState(CHECKED) | ||
184 | 106 | else: | ||
185 | 107 | self.ui.limit_uploads_checkbox.setCheckState(UNCHECKED) | ||
186 | 108 | if download_speed > 0: | ||
187 | 109 | self.ui.limit_downloads_checkbox.setCheckState(CHECKED) | ||
188 | 110 | else: | ||
189 | 111 | self.ui.limit_downloads_checkbox.setCheckState(UNCHECKED) | ||
190 | 122 | self.is_processing = False | 112 | self.is_processing = False |
191 | 123 | 113 | ||
192 | 124 | def process_speed_settings(self, new_value, checkbox): | ||
193 | 125 | """A new speed limit was set.""" | ||
194 | 126 | if new_value < 0: | ||
195 | 127 | checkbox.setCheckState(UNCHECKED) | ||
196 | 128 | else: | ||
197 | 129 | checkbox.setCheckState(CHECKED) | ||
198 | 130 | |||
199 | 131 | # Invalid name "on_{down, up}load_speed_spinbox_valueChanged" | ||
200 | 132 | # pylint: disable=C0103 | 114 | # pylint: disable=C0103 |
201 | 133 | 115 | ||
202 | 134 | @QtCore.pyqtSlot(int) | ||
203 | 135 | def on_download_speed_spinbox_valueChanged(self, new_value): | ||
204 | 136 | """A new download speed was set.""" | ||
205 | 137 | self.process_speed_settings(new_value, | ||
206 | 138 | self.ui.limit_downloads_checkbox) | ||
207 | 139 | |||
208 | 140 | @QtCore.pyqtSlot(int) | ||
209 | 141 | def on_upload_speed_spinbox_valueChanged(self, new_value): | ||
210 | 142 | """A new upload speed was set.""" | ||
211 | 143 | self.process_speed_settings(new_value, | ||
212 | 144 | self.ui.limit_uploads_checkbox) | ||
213 | 145 | |||
214 | 146 | def on_limit_downloads_checkbox_stateChanged(self, new_state): | ||
215 | 147 | """Limit download speed checkbox changed.""" | ||
216 | 148 | if new_state == UNCHECKED: | ||
217 | 149 | self.ui.download_speed_spinbox.setValue(-1) | ||
218 | 150 | |||
219 | 151 | def on_limit_uploads_checkbox_stateChanged(self, new_state): | ||
220 | 152 | """Limit upload speed checkbox changed.""" | ||
221 | 153 | if new_state == UNCHECKED: | ||
222 | 154 | self.ui.upload_speed_spinbox.setValue(-1) | ||
223 | 155 | |||
224 | 156 | @QtCore.pyqtSlot() | 116 | @QtCore.pyqtSlot() |
225 | 157 | @defer.inlineCallbacks | 117 | @defer.inlineCallbacks |
226 | 158 | def on_apply_changes_button_clicked(self): | 118 | def on_apply_changes_button_clicked(self): |
227 | @@ -161,8 +121,12 @@ | |||
228 | 161 | notifications = self.ui.show_all_notifications_checkbox.checkState() | 121 | notifications = self.ui.show_all_notifications_checkbox.checkState() |
229 | 162 | share_autosubscribe = self.ui.share_autosubscribe_checkbox.checkState() | 122 | share_autosubscribe = self.ui.share_autosubscribe_checkbox.checkState() |
230 | 163 | udf_autosubscribe = self.ui.udf_autosubscribe_checkbox.checkState() | 123 | udf_autosubscribe = self.ui.udf_autosubscribe_checkbox.checkState() |
233 | 164 | download_speed = tweak_speed(self.ui.download_speed_spinbox.value()) | 124 | download_speed = self.ui.download_speed_spinbox.value() * KILOBYTES |
234 | 165 | upload_speed = tweak_speed(self.ui.upload_speed_spinbox.value()) | 125 | if self.ui.limit_uploads_checkbox.checkState() == UNCHECKED: |
235 | 126 | upload_speed = -1 | ||
236 | 127 | upload_speed = self.ui.upload_speed_spinbox.value() * KILOBYTES | ||
237 | 128 | if self.ui.limit_downloads_checkbox.checkState() == UNCHECKED: | ||
238 | 129 | download_speed = -1 | ||
239 | 166 | 130 | ||
240 | 167 | settings = { | 131 | settings = { |
241 | 168 | backend.AUTOCONNECT_KEY: autoconnect == CHECKED, | 132 | backend.AUTOCONNECT_KEY: autoconnect == CHECKED, |
242 | 169 | 133 | ||
243 | === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_preferences.py' | |||
244 | --- ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 2012-05-15 13:53:50 +0000 | |||
245 | +++ ubuntuone/controlpanel/gui/qt/tests/test_preferences.py 2012-05-15 18:48:18 +0000 | |||
246 | @@ -55,8 +55,8 @@ | |||
247 | 55 | gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: notifs == gui.CHECKED, | 55 | gui.backend.SHOW_ALL_NOTIFICATIONS_KEY: notifs == gui.CHECKED, |
248 | 56 | gui.backend.SHARE_AUTOSUBSCRIBE_KEY: share_auto == gui.CHECKED, | 56 | gui.backend.SHARE_AUTOSUBSCRIBE_KEY: share_auto == gui.CHECKED, |
249 | 57 | gui.backend.UDF_AUTOSUBSCRIBE_KEY: udf_auto == gui.CHECKED, | 57 | gui.backend.UDF_AUTOSUBSCRIBE_KEY: udf_auto == gui.CHECKED, |
252 | 58 | gui.backend.DOWNLOAD_KEY: gui.tweak_speed(download_speed), | 58 | gui.backend.DOWNLOAD_KEY: download_speed * gui.KILOBYTES, |
253 | 59 | gui.backend.UPLOAD_KEY: gui.tweak_speed(upload_speed), | 59 | gui.backend.UPLOAD_KEY: upload_speed * gui.KILOBYTES, |
254 | 60 | } | 60 | } |
255 | 61 | return result | 61 | return result |
256 | 62 | 62 | ||
257 | @@ -120,18 +120,20 @@ | |||
258 | 120 | speed = settings[gui.backend.DOWNLOAD_KEY] | 120 | speed = settings[gui.backend.DOWNLOAD_KEY] |
259 | 121 | if speed > 0: | 121 | if speed > 0: |
260 | 122 | speed = settings[gui.backend.DOWNLOAD_KEY] // gui.KILOBYTES | 122 | speed = settings[gui.backend.DOWNLOAD_KEY] // gui.KILOBYTES |
263 | 123 | download_speed = self.ui.ui.download_speed_spinbox.value() | 123 | download_speed = self.ui.ui.download_speed_spinbox.value() |
264 | 124 | self.assertEqual(speed, download_speed) | 124 | self.assertEqual(speed, download_speed) |
265 | 125 | limit_downloads = self.ui.ui.limit_downloads_checkbox.checkState() | 125 | limit_downloads = self.ui.ui.limit_downloads_checkbox.checkState() |
267 | 126 | self.assertEqual(speed > 0, limit_downloads == gui.CHECKED) | 126 | self.assertEqual(self.ui.ui.download_speed_spinbox.isEnabled(), |
268 | 127 | limit_downloads == gui.CHECKED) | ||
269 | 127 | 128 | ||
270 | 128 | speed = settings[gui.backend.UPLOAD_KEY] | 129 | speed = settings[gui.backend.UPLOAD_KEY] |
271 | 129 | if speed > 0: | 130 | if speed > 0: |
272 | 130 | speed = settings[gui.backend.UPLOAD_KEY] // gui.KILOBYTES | 131 | speed = settings[gui.backend.UPLOAD_KEY] // gui.KILOBYTES |
275 | 131 | upload_speed = self.ui.ui.upload_speed_spinbox.value() | 132 | upload_speed = self.ui.ui.upload_speed_spinbox.value() |
276 | 132 | self.assertEqual(speed, upload_speed) | 133 | self.assertEqual(speed, upload_speed) |
277 | 133 | limit_uploads = self.ui.ui.limit_uploads_checkbox.checkState() | 134 | limit_uploads = self.ui.ui.limit_uploads_checkbox.checkState() |
279 | 134 | self.assertEqual(speed > 0, limit_uploads == gui.CHECKED) | 135 | self.assertEqual(self.ui.ui.upload_speed_spinbox.isEnabled(), |
280 | 136 | limit_uploads == gui.CHECKED) | ||
281 | 135 | 137 | ||
282 | 136 | def test_update_ui_from_backed_info(self): | 138 | def test_update_ui_from_backed_info(self): |
283 | 137 | """The ui is correctly updated when the backend info is received.""" | 139 | """The ui is correctly updated when the backend info is received.""" |
284 | @@ -153,63 +155,22 @@ | |||
285 | 153 | self.ui.process_info(settings) | 155 | self.ui.process_info(settings) |
286 | 154 | self._test_update_ui_from_settings_info(settings) | 156 | self._test_update_ui_from_settings_info(settings) |
287 | 155 | 157 | ||
306 | 156 | def _test_speed_checkbox_value_changed_to_positive(self, speed_spinbox, | 158 | def _test_speed_checkbox_toggled(self, speed_spinbox, limit_checkbox): |
307 | 157 | limit_checkbox): | 159 | """The checkbox is checked if and only if the spinbox is enabled.""" |
290 | 158 | """When the speed is set to a positive value, enable the checkbox.""" | ||
291 | 159 | limit_checkbox.setCheckState(gui.UNCHECKED) | ||
292 | 160 | speed_spinbox.setValue(33) | ||
293 | 161 | |||
294 | 162 | self.assertEqual(gui.CHECKED, limit_checkbox.checkState()) | ||
295 | 163 | |||
296 | 164 | def _test_speed_checkbox_value_changed_to_negative(self, speed_spinbox, | ||
297 | 165 | limit_checkbox): | ||
298 | 166 | """When the speed is set to a negative value, disable the checkbox.""" | ||
299 | 167 | limit_checkbox.setCheckState(gui.UNCHECKED) | ||
300 | 168 | speed_spinbox.setValue(-1) | ||
301 | 169 | |||
302 | 170 | self.assertEqual(gui.UNCHECKED, limit_checkbox.checkState()) | ||
303 | 171 | |||
304 | 172 | def _test_speed_checkbox_unchecked(self, speed_spinbox, limit_checkbox): | ||
305 | 173 | """When the speed checkbox is unchecked, reset speed to -1.""" | ||
308 | 174 | limit_checkbox.setCheckState(gui.CHECKED) | 160 | limit_checkbox.setCheckState(gui.CHECKED) |
310 | 175 | speed_spinbox.setValue(33) | 161 | self.assertTrue(speed_spinbox.isEnabled()) |
311 | 176 | limit_checkbox.setCheckState(gui.UNCHECKED) | 162 | limit_checkbox.setCheckState(gui.UNCHECKED) |
348 | 177 | 163 | self.assertFalse(speed_spinbox.isEnabled()) | |
349 | 178 | self.assertEqual(-1, speed_spinbox.value()) | 164 | |
350 | 179 | 165 | def test_download_speed_checkbox_connections(self): | |
351 | 180 | def test_download_speed_checkbox_value_changed_to_positive(self): | 166 | """Check connections for download_speed_checkbox.""" |
352 | 181 | """When the download speed is set, enable the checkbox.""" | 167 | self._test_speed_checkbox_toggled( |
353 | 182 | self._test_speed_checkbox_value_changed_to_positive( | 168 | self.ui.ui.download_speed_spinbox, |
354 | 183 | self.ui.ui.download_speed_spinbox, | 169 | self.ui.ui.limit_downloads_checkbox) |
355 | 184 | self.ui.ui.limit_downloads_checkbox) | 170 | |
356 | 185 | 171 | def test_upload_speed_checkbox_connections(self): | |
357 | 186 | def test_download_speed_checkbox_value_changed_to_negative(self): | 172 | """Check connections for upload_speed_checkbox.""" |
358 | 187 | """When the download speed is set, enable the checkbox.""" | 173 | self._test_speed_checkbox_toggled( |
323 | 188 | self._test_speed_checkbox_value_changed_to_negative( | ||
324 | 189 | self.ui.ui.download_speed_spinbox, | ||
325 | 190 | self.ui.ui.limit_downloads_checkbox) | ||
326 | 191 | |||
327 | 192 | def test_download_speed_checkbox_unchecked(self): | ||
328 | 193 | """Reset the speed to -1 when the checkbox is disabled.""" | ||
329 | 194 | self._test_speed_checkbox_unchecked( | ||
330 | 195 | self.ui.ui.download_speed_spinbox, | ||
331 | 196 | self.ui.ui.limit_downloads_checkbox) | ||
332 | 197 | |||
333 | 198 | def test_upload_speed_checkbox_value_changed_to_positive(self): | ||
334 | 199 | """When the upload speed is set, enable the checkbox.""" | ||
335 | 200 | self._test_speed_checkbox_value_changed_to_positive( | ||
336 | 201 | self.ui.ui.upload_speed_spinbox, | ||
337 | 202 | self.ui.ui.limit_uploads_checkbox) | ||
338 | 203 | |||
339 | 204 | def test_upload_speed_checkbox_value_changed_to_negative(self): | ||
340 | 205 | """When the upload speed is set, enable the checkbox.""" | ||
341 | 206 | self._test_speed_checkbox_value_changed_to_negative( | ||
342 | 207 | self.ui.ui.upload_speed_spinbox, | ||
343 | 208 | self.ui.ui.limit_uploads_checkbox) | ||
344 | 209 | |||
345 | 210 | def test_upload_speed_checkbox_unchecked(self): | ||
346 | 211 | """Reset the speed to -1 when the checkbox is disabled.""" | ||
347 | 212 | self._test_speed_checkbox_unchecked( | ||
359 | 213 | self.ui.ui.upload_speed_spinbox, | 174 | self.ui.ui.upload_speed_spinbox, |
360 | 214 | self.ui.ui.limit_uploads_checkbox) | 175 | self.ui.ui.limit_uploads_checkbox) |
361 | 215 | 176 | ||
362 | @@ -288,18 +249,6 @@ | |||
363 | 288 | 249 | ||
364 | 289 | yield self.ui.ui.restore_defaults_button.click() | 250 | yield self.ui.ui.restore_defaults_button.click() |
365 | 290 | 251 | ||
366 | 291 | def test_tweak_speed_negative(self): | ||
367 | 292 | """Tweak speed properly: if param is negative, return -1.""" | ||
368 | 293 | self.assertEqual(-1, gui.tweak_speed(-5)) | ||
369 | 294 | |||
370 | 295 | def test_tweak_speed_zero(self): | ||
371 | 296 | """Tweak speed properly: if param is zero, return 1.""" | ||
372 | 297 | self.assertEqual(1, gui.tweak_speed(0)) | ||
373 | 298 | |||
374 | 299 | def test_tweak_speed_positive(self): | ||
375 | 300 | """Tweak speed properly: if param is positive, return kilobytes.""" | ||
376 | 301 | self.assertEqual(123456 * gui.KILOBYTES, gui.tweak_speed(123456)) | ||
377 | 302 | |||
378 | 303 | def test_resize_event(self): | 252 | def test_resize_event(self): |
379 | 304 | """Check that the QCheckBox widgets receive the proper texts.""" | 253 | """Check that the QCheckBox widgets receive the proper texts.""" |
380 | 305 | wrap_calls = {} | 254 | wrap_calls = {} |
+1