/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_ui.py

  • Committer: Curtis Hovey
  • Date: 2012-02-27 15:56:01 UTC
  • mto: (776.2.1 ui-factory)
  • mto: This revision was merged to the branch mainline in revision 779.
  • Revision ID: sinzui.is@verizon.net-20120227155601-23fqryhuepg8twzz
Added tests for finshed() and clear.

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
        self.assertIs(None, progress_bar.current)
177
177
 
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__)
187
187
 
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__)
199
199
 
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)
 
212
 
 
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__)
 
224
 
 
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)