示例#1
0
def test_change(shortcut_engine, mocker):
    callback = mocker.Mock(return_value=True)
    old_shortcut = Shortcut("start", "<control>a")
    new_shortcut = Shortcut("start", "<control>b")

    shortcut_engine.connect(old_shortcut, callback)
    shortcut_engine.change(new_shortcut)

    assert active_shortcut(shortcut_engine, old_shortcut) is False
    assert active_shortcut(shortcut_engine, new_shortcut) is True

    key, mod = Gtk.accelerator_parse(new_shortcut.value)
    callback.assert_called_once_with(shortcut_engine.accel_group, mocker.ANY,
                                     key, mod)
示例#2
0
def test_disconnect(shortcut_engine, mocker):
    shortcut = Shortcut("start", "<control>s")
    shortcut_engine.connect(shortcut, mocker.Mock())

    shortcut_engine.disconnect(shortcut)

    assert active_shortcut(shortcut_engine, shortcut) is False
示例#3
0
def test_connect(shortcut_engine, mocker):
    callback = mocker.Mock(return_value=True)
    shortcut = Shortcut("start", "<control>s")

    shortcut_engine.connect(shortcut, callback)
    assert active_shortcut(shortcut_engine, shortcut) is True

    key, mod = Gtk.accelerator_parse(shortcut.value)
    callback.assert_called_once_with(shortcut_engine.accel_group, mocker.ANY,
                                     key, mod)
示例#4
0
def test_shortcuts(shortcut_engine, window):
    from focusyn.ui.widgets import HeaderBar

    assert active_shortcut(shortcut_engine,
                           HeaderBar.START_SHORTCUT,
                           window=window.widget) is True
示例#5
0
def test_shortcuts(shortcut, session_type, session_button, shortcut_engine,
                   session):
    assert active_shortcut(shortcut_engine, shortcut) is True
    session.change.assert_called_once_with(session=session_type)
示例#6
0
 def test_shortcuts(self, shortcut, action, headerbar, menu, session,
                    shortcut_engine):
     active_shortcut(shortcut_engine, shortcut)
     getattr(session, action).assert_called_once_with()
示例#7
0
    def test_shortcut(self, menu, shortcut_engine, preference):
        assert active_shortcut(shortcut_engine,
                               HeaderBarMenu.PREFERENCE_SHORTCUT) is True

        preference.widget.run.assert_called_once_with()