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)
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
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)
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
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)
def test_shortcuts(self, shortcut, action, headerbar, menu, session, shortcut_engine): active_shortcut(shortcut_engine, shortcut) getattr(session, action).assert_called_once_with()
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()