def toggle_plugin(row: int): TV.map( Q.select(preference.widget, Q.props("name", "plugin.list")), TV.column(Q.props("title", "Active")), TV.cell_renderer(0), Q.emit("toggled", row), )
def test_without_custom_alarm(self, config, plugin): config.remove(SECTION_NAME, OPTION_NAME) window = plugin.settings_window(Gtk.Window()) window.run() entry = Q.select(window.widget, Q.props("name", "alarm_entry")) assert entry.props.text == "" assert entry.props.sensitive is False switch = Q.select(window.widget, Q.props("name", "alarm_switch")) assert switch.props.active is False
def test_with_custom_alarm(self, plugin, config): config.set(SECTION_NAME, OPTION_NAME, CUSTOM_ALARM) window = plugin.settings_window(Gtk.Window()) window.run() entry = Q.select(window.widget, Q.props("name", "alarm_entry")) assert entry.props.text == CUSTOM_ALARM assert entry.props.sensitive is True switch = Q.select(window.widget, Q.props("name", "alarm_switch")) assert switch.props.active is True
def test_enable_custom_alarm(self, config, plugin): dialog = plugin.settings_window(Gtk.Window()) dialog.run() switch = Q.select(dialog.widget, Q.props("name", "alarm_switch")) switch.props.active = True switch.notify("activate") entry = Q.select(dialog.widget, Q.props("name", "alarm_entry")) assert entry.props.sensitive is True entry.set_text(CUSTOM_ALARM) dialog.widget.emit("response", 0) assert config.get(SECTION_NAME, OPTION_NAME) == CUSTOM_ALARM
def test_enable_only_the_stop_button_when_session_starts( self, bus, headerbar): bus.send(Events.SESSION_START) assert Q.select( headerbar.widget, Q.props( "name", HeaderBar.START_SHORTCUT.name)).props.visible is False assert Q.select( headerbar.widget, Q.props( "name", HeaderBar.STOP_SHORTCUT.name)).props.visible is True assert Q.select( headerbar.widget, Q.props( "name", HeaderBar.RESET_SHORTCUT.name)).props.sensitive is False
def test_buttons_visibility_and_title_in_the_first_session( self, event, title, reset, headerbar, payload, bus): bus.send(event, payload=payload) assert Q.select( headerbar.widget, Q.props( "name", headerbar.START_SHORTCUT.name)).props.visible is True assert Q.select( headerbar.widget, Q.props( "name", headerbar.STOP_SHORTCUT.name)).props.visible is False assert Q.select( headerbar.widget, Q.props( "name", headerbar.RESET_SHORTCUT.name)).props.sensitive is reset assert headerbar.widget.props.title == title
def test_initial_plugin_list(plugin, row, columns, preference, plugin_engine): plugin_engine.collect() preference.run() def get_columns(tree_store: Gtk.TreeStore): return [ tree_store[row][column] for column in (PluginGrid.NAME, PluginGrid.ACTIVE, PluginGrid.DETAIL) ] assert TV.map(Q.select(preference.widget, Q.props("name", "plugin.list")), TV.model, get_columns) == columns assert Q.select(preference.widget, Q.props( "name", "plugin.settings")).props.sensitive is False
def test_disable_custom_alarm(self, config, plugin): config.set(SECTION_NAME, OPTION_NAME, CUSTOM_ALARM) dialog = plugin.settings_window(Gtk.Window()) dialog.run() switch = Q.select(dialog.widget, Q.props("name", "alarm_switch")) switch.props.active = False switch.notify("activate") entry = Q.select(dialog.widget, Q.props("name", "alarm_entry")) assert entry.props.text == "" assert entry.props.sensitive is False dialog.widget.emit("response", 0) assert config.has_option(SECTION_NAME, OPTION_NAME) is False
def test_change_session(self, button_name, action, session, headerbar): button = Q.select(headerbar.widget, Q.props("name", button_name)) button.emit("clicked") refresh_gui() getattr(session, action).assert_called_once_with()
def test_open_plugin_settings(preference, plugin_engine): plugin_engine.collect() preference.run() TV.map( Q.select(preference.widget, Q.props("name", "plugin.list")), TV.column(Q.props("title", "Active")), TV.cell_renderer(0), Q.emit("toggled", 0), ) settings_button = Q.select(preference.widget, Q.props("name", "plugin.settings")) assert settings_button.props.sensitive is True settings_button.emit("clicked") plugin_a = plugin_engine.lookup("PluginA") assert plugin_a.plugin_object.parent == preference.widget
def test_save_config_when_task_duration_change(duration_name, option, value, config, preference): spin_button = Q.select(preference.widget, Q.props("name", duration_name)) assert spin_button is not None spin_button.props.value = value spin_button.emit("value-changed") assert config.get_int(Config.DURATION_SECTION, option) == value
def test_disables_reset_button_when_session_is_reset( self, headerbar, bus, session): reset_button = Q.select(headerbar.widget, Q.props("name", headerbar.RESET_SHORTCUT.name)) reset_button.props.sensitive = True bus.send(Events.SESSION_RESET) assert reset_button.props.sensitive is False assert headerbar.widget.props.title == "No session yet"
def test_menu_items(self, widget, label, mock_name, menu, about, preference): menu_item = Q.select(menu.widget, Q.props("name", widget)) assert menu_item.props.label == label menu_item.emit("activate") refresh_gui() dialog = locals()[mock_name].widget dialog.run.assert_called_once_with()
def test_refresh_reload_plugins(preference, plugin_engine): plugin_engine.collect() preference.run() plugin_list = Q.select(preference.widget, Q.props("name", "plugin.list")) assert TV.map(plugin_list, TV.model, len) == 2 for plugin in plugin_engine.all(): plugin_engine.remove(plugin) preference.run() assert TV.map(plugin_list, TV.model, len) == 0
def test_buttons(button_name, label, tooltip_text, session_button): button = Q.select(session_button.widget, Q.props("name", button_name)) assert button.props.tooltip_text == tooltip_text assert Q.select(button, Q.props("label", label))
def test_buttons_tooltip(self, button_name, tooltip, headerbar): button = Q.select(headerbar.widget, Q.props("name", button_name)) assert tooltip == button.props.tooltip_text