mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
test: extended test coverage for axis settings, plot base and qt toolbar action
This commit is contained in:
@ -3,7 +3,7 @@ from typing import Literal
|
||||
import pytest
|
||||
from qtpy.QtCore import QPoint, Qt
|
||||
from qtpy.QtGui import QContextMenuEvent
|
||||
from qtpy.QtWidgets import QComboBox, QLabel, QMenu, QToolButton, QWidget
|
||||
from qtpy.QtWidgets import QComboBox, QLabel, QMenu, QStyle, QToolButton, QWidget
|
||||
|
||||
from bec_widgets.qt_utils.toolbar import (
|
||||
DeviceSelectionAction,
|
||||
@ -12,6 +12,7 @@ from bec_widgets.qt_utils.toolbar import (
|
||||
LongPressToolButton,
|
||||
MaterialIconAction,
|
||||
ModularToolBar,
|
||||
QtIconAction,
|
||||
SeparatorAction,
|
||||
SwitchableToolBarAction,
|
||||
ToolbarBundle,
|
||||
@ -63,6 +64,12 @@ def material_icon_action():
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def qt_icon_action():
|
||||
"""Fixture to create a QtIconAction."""
|
||||
return QtIconAction(standard_icon=QStyle.SP_FileIcon, tooltip="Qt File", checkable=True)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def device_selection_action():
|
||||
"""Fixture to create a DeviceSelectionAction."""
|
||||
@ -146,7 +153,12 @@ def test_set_orientation(toolbar_fixture, qtbot, dummy_widget):
|
||||
|
||||
|
||||
def test_add_action(
|
||||
toolbar_fixture, icon_action, separator_action, material_icon_action, dummy_widget
|
||||
toolbar_fixture,
|
||||
icon_action,
|
||||
separator_action,
|
||||
material_icon_action,
|
||||
qt_icon_action,
|
||||
dummy_widget,
|
||||
):
|
||||
"""Test adding different types of actions to the toolbar."""
|
||||
toolbar = toolbar_fixture
|
||||
@ -168,6 +180,12 @@ def test_add_action(
|
||||
assert toolbar.widgets["material_icon_action"] == material_icon_action
|
||||
assert material_icon_action.action in toolbar.actions()
|
||||
|
||||
# Add QtIconAction
|
||||
toolbar.add_action("qt_icon_action", qt_icon_action, dummy_widget)
|
||||
assert "qt_icon_action" in toolbar.widgets
|
||||
assert toolbar.widgets["qt_icon_action"] == qt_icon_action
|
||||
assert qt_icon_action.action in toolbar.actions()
|
||||
|
||||
|
||||
def test_hide_show_action(toolbar_fixture, icon_action, qtbot, dummy_widget):
|
||||
"""Test hiding and showing actions on the toolbar."""
|
||||
|
Reference in New Issue
Block a user