176
176
self.assertIs(None, progress_bar.current)
178
178
def test_tick(self):
179
# tick() shows the widget, does one pulse, then clears the pending
179
# tick() shows the widget, does one pulse, then handles the pending
180
180
# events in the main loop.
181
181
MockMethod.bind(self, ui.GtkProgressBar, 'show')
182
182
MockMethod.bind(self, ui.GtkProgressBar, 'pulse')
183
183
progress_bar = ui.GtkProgressBar()
184
184
progress_bar.tick()
185
185
self.assertIs(True, progress_bar.show.called)
186
self.assetEqual('with_main_iteration', progress_bar.tick.__name__)
186
self.assertEqual('with_main_iteration', progress_bar.tick.__name__)
188
188
def test_update_with_data(self):
189
# update() shows the widget, sets the fraction, then clears the pending
190
# events in the main loop.
189
# update() shows the widget, sets the fraction, then handles the
190
# pending events in the main loop.
191
191
MockMethod.bind(self, ui.GtkProgressBar, 'show')
192
192
progress_bar = ui.GtkProgressBar()
193
193
progress_bar.update(msg='test', current_cnt=5, total_cnt=10)
195
195
self.assertEqual(0.5, progress_bar.props.fraction)
196
196
self.assertEqual(10, progress_bar.total)
197
197
self.assertEqual(5, progress_bar.current)
198
self.assetEqual('with_main_iteration', progress_bar.update.__name__)
198
self.assertEqual('with_main_iteration', progress_bar.update.__name__)
200
200
def test_update_without_data(self):
201
201
progress_bar = ui.GtkProgressBar()
209
209
progress_bar = ui.GtkProgressBar()
210
210
self.assertRaises(
211
211
ValueError, progress_bar.update, None, 20, 2)
213
def test_finished(self):
214
# finished() hides the widget, resets the state, then handles the
215
# pending events in the main loop.
216
MockMethod.bind(self, ui.GtkProgressBar, 'hide')
217
progress_bar = ui.GtkProgressBar()
218
progress_bar.finished()
219
self.assertIs(True, progress_bar.hide.called)
220
self.assertEqual(0.0, progress_bar.props.fraction)
221
self.assertIs(None, progress_bar.total)
222
self.assertIs(None, progress_bar.current)
223
self.assertEqual('with_main_iteration', progress_bar.finished.__name__)
225
def test_clear(self):
226
# clear() is synonymous with finished.
227
MockMethod.bind(self, ui.GtkProgressBar, 'finished')
228
progress_bar = ui.GtkProgressBar()
229
progress_bar.finished()
230
self.assertIs(True, progress_bar.finished.called)