/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 18:21:25 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-20120227182125-bdjt57afukf3ljtj
Verify that pending events are processed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
class MainIterationTestCase(tests.TestCase):
34
34
 
35
35
    def test_main_iteration(self):
 
36
        # The main_iteration decorator iterates over the pending Gtk events
 
37
        # after calling its function so that the UI is updated too.
 
38
        button = Gtk.ToggleButton(label='before')
 
39
 
 
40
        def event_listener(button):
 
41
            button.props.label = 'after'
 
42
 
 
43
        button.connect('clicked', event_listener)
 
44
 
36
45
        def test_func(self):
 
46
            button.emit('clicked')
37
47
            return True
 
48
 
38
49
        decorated_func = ui.main_iteration(test_func)
39
50
        result = decorated_func(object())
40
51
        self.assertIs(True, result)
 
52
        self.assertIs(False, Gtk.events_pending())
 
53
        self.assertEqual('after', button.props.label)
41
54
 
42
55
 
43
56
class GtkUIFactoryTestCase(tests.TestCase):