def test_statusnotifier_icon_size(manager_nospawn, sni_config): """Check that widget displays and removes icon.""" manager_nospawn.start(sni_config) widget = manager_nospawn.c.widget["statusnotifier"] assert widget.info()["width"] == 0 win = manager_nospawn.test_window("TestSNI", export_sni=True) wait_for_icon(widget, hidden=False) # Width should be icon_size (35) + 2 * padding (3) = 41 assert widget.info()["width"] == 41 manager_nospawn.kill_window(win)
def test_statusnotifier_left_click_vertical_bar(manager_nospawn, sni_config): """Check `activate` method when left-clicking widget in vertical bar.""" screen = sni_config.screens[0] screen.left = screen.top screen.top = None manager_nospawn.start(sni_config) widget = manager_nospawn.c.widget["statusnotifier"] windows = manager_nospawn.c.windows assert widget.info()["height"] == 0 win = manager_nospawn.test_window("TestSNILeftClick", export_sni=True) wait_for_icon(widget, hidden=False, prop="height") # Check we have window and that it's not fullscreen assert len(windows()) == 1 check_fullscreen(windows, False) # Left click will toggle fullscreen manager_nospawn.c.bar["left"].fake_button_press(0, "left", 0, 10, 1) check_fullscreen(windows, True) # Left click again will restore window manager_nospawn.c.bar["left"].fake_button_press(0, "left", 0, 10, 1) check_fullscreen(windows, False) manager_nospawn.kill_window(win) assert not windows()
def test_statusnotifier_left_click(manager_nospawn, sni_config): """Check `activate` method when left-clicking widget.""" manager_nospawn.start(sni_config) widget = manager_nospawn.c.widget["statusnotifier"] windows = manager_nospawn.c.windows assert widget.info()["width"] == 0 win = manager_nospawn.test_window("TestSNILeftClick", export_sni=True) wait_for_icon(widget, hidden=False) # Check we have window and that it's not fullscreen assert len(windows()) == 1 check_fullscreen(windows, False) # Left click will toggle fullscreen manager_nospawn.c.bar["top"].fake_button_press(0, "top", 10, 0, 1) check_fullscreen(windows, True) # Left click again will restore window manager_nospawn.c.bar["top"].fake_button_press(0, "top", 10, 0, 1) check_fullscreen(windows, False) manager_nospawn.kill_window(win) assert not windows()
def test_mpd2_widget_idle_message(mpd2_manager): """Quick test to check idle message.""" widget = mpd2_manager.c.widget["mpd2"] # Inject everything to make test quicker widget.eval("self.client.force_idle()") # Update widget and check text widget.eval("self.update(self.poll())") assert widget.info()["text"] == "■ MPD IDLE[-----]"
def test_mpd2_widget_extra_info(mpd2_manager): """Quick test to check extra info is displayed ok.""" widget = mpd2_manager.c.widget["mpd2"] # Inject everything to make test quicker widget.eval("self.client.add_states()") # Update widget and check text widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Rick Astley/Never gonna give you up [rz1cU]"
def test_statusnotifier_defaults(manager_nospawn, sni_config): """Check that widget displays and removes icon.""" manager_nospawn.start(sni_config) widget = manager_nospawn.c.widget["statusnotifier"] assert widget.info()["width"] == 0 win = manager_nospawn.test_window("TestSNI", export_sni=True) wait_for_icon(widget, hidden=False) # Kill it and icon disappears manager_nospawn.kill_window(win) wait_for_icon(widget, hidden=True)
def test_statusnotifier_defaults_vertical_bar(manager_nospawn, sni_config): """Check that widget displays and removes icon.""" screen = sni_config.screens[0] screen.left = screen.top screen.top = None manager_nospawn.start(sni_config) widget = manager_nospawn.c.widget["statusnotifier"] assert widget.info()["height"] == 0 win = manager_nospawn.test_window("TestSNI", export_sni=True) wait_for_icon(widget, hidden=False, prop="height") # Kill it and icon disappears manager_nospawn.kill_window(win) wait_for_icon(widget, hidden=True, prop="height")
def test_mpd2_widget_display_and_actions(mpd2_manager): widget = mpd2_manager.c.widget["mpd2"] assert widget.info()["text"] == "⏸ Rick Astley/Never gonna give you up [-----]" # Button 1 toggles state mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 1) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "▶ Rick Astley/Never gonna give you up [-----]" # Button 3 stops mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 3) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "■ Rick Astley/Never gonna give you up [-----]" # Button 1 toggles state mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 1) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "▶ Rick Astley/Never gonna give you up [-----]" mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 1) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Rick Astley/Never gonna give you up [-----]" # Button 5 is "next" mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 5) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Neil Diamond/Sweet Caroline [-----]" mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 5) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Fred Again../Marea [-----]" # Button 4 is previous mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 4) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Neil Diamond/Sweet Caroline [-----]" mpd2_manager.c.bar["top"].fake_button_press(0, "top", 0, 0, 4) widget.eval("self.update(self.poll())") assert widget.info()["text"] == "⏸ Rick Astley/Never gonna give you up [-----]"
def wait_for_icon(widget, hidden=True, prop="width"): width = widget.info()[prop] if hidden: assert width == 0 else: assert width > 0