def test_multiple_handler_calls(self, monkeypatch):
        """Test that the various Handler gets calles"""
        monkeypatch.setattr(Connection, 'connect_dbus', Mock())
        controller = Controller(address='unix:abstract=abcd')

        signals = ('preview_port_added', 'preview_port_removed',
                   'new_mode_online', 'show_face_marker',
                   'show_track_marker', 'select_face')
        test_cbs = {}
        for signal in signals:
            test_cbs[signal] = Mock()
            getattr(controller, 'on_'+signal)(test_cbs[signal])
            getattr(controller, 'on_'+signal)(test_cbs[signal])
            getattr(controller, 'on_'+signal)(test_cbs[signal])

        for signal in signals:
            controller.cb_signal_handler(
                None,
                ':0',
                '/us/timvideos/gstswitch/SwitchControllerInterface',
                'us.timvideos.gstswitch.SwitchControllerInterface',
                signal,
                GLib.Variant('(i)', (123,)),
                None)

        for signal in signals:
            test_cbs[signal].assert_called_with(123)
            assert test_cbs[signal].call_count == 3
示例#2
0
    def test_multiple_handler_calls(self, monkeypatch):
        """Test that the various Handler gets calles"""
        monkeypatch.setattr(Connection, 'connect_dbus', Mock())
        controller = Controller(address='unix:abstract=abcd')

        signals = ('preview_port_added', 'preview_port_removed',
                   'new_mode_online', 'show_face_marker', 'show_track_marker',
                   'select_face')
        test_cbs = {}
        for signal in signals:
            test_cbs[signal] = Mock()
            getattr(controller, 'on_' + signal)(test_cbs[signal])
            getattr(controller, 'on_' + signal)(test_cbs[signal])
            getattr(controller, 'on_' + signal)(test_cbs[signal])

        for signal in signals:
            controller.cb_signal_handler(
                None, ':0',
                '/us/timvideos/gstswitch/SwitchControllerInterface',
                'us.timvideos.gstswitch.SwitchControllerInterface', signal,
                GLib.Variant('(i)', (123, )), None)

        for signal in signals:
            test_cbs[signal].assert_called_with(123)
            assert test_cbs[signal].call_count == 3
示例#3
0
 def test_signal_name_collision(self, monkeypatch):
     """Test that nothing happens when a signal is on the bus which name
     collides with an attribute also starting with 'callbacks_'
     """
     monkeypatch.setattr(Connection, 'connect_dbus', Mock())
     controller = Controller(address='unix:abstract=abcd')
     controller.callbacks_foobar = 123
     controller.cb_signal_handler(None, ':0', '/foo/bar', 'foo.bar',
                                  'foobar', None, None)
 def test_signal_name_collision(self, monkeypatch):
     """Test that nothing happens when a signal is on the bus which name
     collides with an attribute also starting with 'callbacks_'
     """
     monkeypatch.setattr(Connection, 'connect_dbus', Mock())
     controller = Controller(address='unix:abstract=abcd')
     controller.callbacks_foobar = 123
     controller.cb_signal_handler(None, ':0', '/foo/bar',
                                  'foo.bar', 'foobar', None, None)
    def test_single_handler_calls(self, monkeypatch):
        """Test that the various Handler gets calles"""
        monkeypatch.setattr(Connection, 'connect_dbus', Mock())

        for signal in ('preview_port_added', 'preview_port_removed',
                       'new_mode_online', 'show_face_marker',
                       'show_track_marker', 'select_face'):
            test_cb = Mock()
            controller = Controller(address='unix:abstract=abcd')
            getattr(controller, 'on_'+signal)(test_cb)

            controller.cb_signal_handler(
                None,
                ':0',
                '/us/timvideos/gstswitch/SwitchControllerInterface',
                'us.timvideos.gstswitch.SwitchControllerInterface',
                signal,
                GLib.Variant('(iii)', (5, 10, 20,)),
                None)
            test_cb.assert_called_once_with(5, 10, 20)
示例#6
0
    def test_single_handler_calls(self, monkeypatch):
        """Test that the various Handler gets calles"""
        monkeypatch.setattr(Connection, 'connect_dbus', Mock())

        for signal in ('preview_port_added', 'preview_port_removed',
                       'new_mode_online', 'show_face_marker',
                       'show_track_marker', 'select_face'):
            test_cb = Mock()
            controller = Controller(address='unix:abstract=abcd')
            getattr(controller, 'on_' + signal)(test_cb)

            controller.cb_signal_handler(
                None, ':0',
                '/us/timvideos/gstswitch/SwitchControllerInterface',
                'us.timvideos.gstswitch.SwitchControllerInterface', signal,
                GLib.Variant('(iii)', (
                    5,
                    10,
                    20,
                )), None)
            test_cb.assert_called_once_with(5, 10, 20)
 def test_unknown_signal_name(self, monkeypatch):
     """Test that nothing happens when a unknown signal is on the bus"""
     monkeypatch.setattr(Connection, 'connect_dbus', Mock())
     controller = Controller(address='unix:abstract=abcd')
     controller.cb_signal_handler(None, ':0', '/foo/bar',
                                  'foo.bar', 'foobar', None, None)
示例#8
0
 def test_unknown_signal_name(self, monkeypatch):
     """Test that nothing happens when a unknown signal is on the bus"""
     monkeypatch.setattr(Connection, 'connect_dbus', Mock())
     controller = Controller(address='unix:abstract=abcd')
     controller.cb_signal_handler(None, ':0', '/foo/bar', 'foo.bar',
                                  'foobar', None, None)