~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ui.py

  • Committer: Martin Pool
  • Date: 2009-03-12 07:09:28 UTC
  • mto: This revision was merged to the branch mainline in revision 4144.
  • Revision ID: mbp@sourcefrog.net-20090312070928-f110be8twil0w4ye
If one ProgressTask has no count, it passes through that of its child

Show diffs side-by-side

added added

removed removed

Lines of Context:
278
278
'\r[####/               ] reticulating splines 5/20                               \r'
279
279
            , out.getvalue())
280
280
 
281
 
    def test_render_progress_easy(self):
282
 
        """Just one task and one quarter done"""
 
281
    def test_render_progress_nested(self):
 
282
        """Tasks proportionally contribute to overall progress"""
283
283
        out, uif = self._make_factory()
284
284
        task = uif.nested_progress_bar()
285
285
        task.update('reticulating splines', 0, 2)
290
290
        self.assertEqual(
291
291
'[####-               ] reticulating splines:stage2 1/2'
292
292
            , uif._progress_view._render_line())
 
293
        # if the nested task is complete, then we're all the way through the
 
294
        # first half of the overall work
 
295
        task2.update('stage2', 2, 2)
 
296
        self.assertEqual(
 
297
r'[#########\          ] reticulating splines:stage2 2/2'
 
298
            , uif._progress_view._render_line())
 
299
 
 
300
    def test_render_progress_sub_nested(self):
 
301
        """Intermediate tasks don't mess up calculation."""
 
302
        out, uif = self._make_factory()
 
303
        task_a = uif.nested_progress_bar()
 
304
        task_a.update('a', 0, 2)
 
305
        task_b = uif.nested_progress_bar()
 
306
        task_b.update('b')
 
307
        task_c = uif.nested_progress_bar()
 
308
        task_c.update('c', 1, 2)
 
309
        # the top-level task is in its first half; the middle one has no
 
310
        # progress indication, just a label; and the bottom one is half done,
 
311
        # so the overall fraction is 1/4
 
312
        self.assertEqual(
 
313
            r'[####-               ] a:b:c 1/2'
 
314
            , uif._progress_view._render_line())
 
315