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
Example #3
0
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_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
Example #5
0
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
Example #7
0
    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
Example #8
0
    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
Example #9
0
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
Example #10
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))
Example #11
0
 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