예제 #1
0
    def test_gtk_schedule_action_periodic(self):
        scheduler = GtkScheduler()
        period = 50
        counter = [3]

        def action(state):
            if state:
                counter[0] -= 1
                return state - 1

        scheduler.schedule_periodic(period, action, counter[0])

        def done(data):
            Gtk.main_quit()
            assert counter[0] == 0
            return False

        GLib.timeout_add(300, done, None)
        Gtk.main()
예제 #2
0
    def test_gtk_schedule_action_periodic(self):
        scheduler = GtkScheduler()
        gate = threading.Semaphore(0)
        period = 0.05
        counter = 3

        def action(state):
            nonlocal counter
            if state:
                counter -= 1
                return state - 1

        scheduler.schedule_periodic(period, action, counter)

        def done(data):
            Gtk.main_quit()
            gate.release()

        GLib.timeout_add(300, done, None)
        Gtk.main()

        gate.acquire()
        assert counter == 0
예제 #3
0
    def test_gtk_schedule_action_periodic(self):
        scheduler = GtkScheduler()
        gate = threading.Semaphore(0)
        period = 0.05
        counter = 3

        def action(state):
            nonlocal counter
            if state:
                counter -= 1
                return state - 1

        scheduler.schedule_periodic(period, action, counter)

        def done(data):
            Gtk.main_quit()
            gate.release()
            return False

        GLib.timeout_add(300, done, None)
        Gtk.main()

        gate.acquire()
        assert counter == 0