Skip to content

Commit 27e7fa5

Browse files
committed
Add UI block tests for skeleton color combo
Adds a new `tests/gui/ui_blocks/test_ui_blocks.py` suite to validate skeleton color dropdown behavior. The tests cover presence of the gradient option, round-tripping both gradient and solid styles, fallback to the default solid color when an unknown color is provided, and icon creation when enabled.
1 parent 2b5f3c8 commit 27e7fa5

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
from __future__ import annotations
2+
3+
from dlclivegui.display import BBoxColors
4+
from dlclivegui.gui.misc.color_dropdowns import (
5+
get_skeleton_style_from_combo,
6+
make_skeleton_color_combo,
7+
set_skeleton_combo_from_style,
8+
)
9+
10+
11+
def test_skeleton_combo_contains_gradient_and_all_colors(
12+
qtbot,
13+
) -> None:
14+
combo = make_skeleton_color_combo(
15+
BBoxColors,
16+
include_icons=False,
17+
)
18+
qtbot.addWidget(combo)
19+
20+
assert combo.count() == 1 + len(BBoxColors)
21+
22+
gradient = combo.itemData(0)
23+
assert gradient == {
24+
"mode": "gradient_keypoints",
25+
"color": None,
26+
}
27+
28+
29+
def test_skeleton_combo_round_trips_gradient_style(
30+
qtbot,
31+
) -> None:
32+
combo = make_skeleton_color_combo(
33+
BBoxColors,
34+
include_icons=False,
35+
)
36+
qtbot.addWidget(combo)
37+
38+
set_skeleton_combo_from_style(
39+
combo,
40+
mode="gradient_keypoints",
41+
color=None,
42+
)
43+
44+
assert get_skeleton_style_from_combo(combo) == (
45+
"gradient_keypoints",
46+
None,
47+
)
48+
49+
50+
def test_skeleton_combo_round_trips_solid_color(
51+
qtbot,
52+
) -> None:
53+
combo = make_skeleton_color_combo(
54+
BBoxColors,
55+
include_icons=False,
56+
)
57+
qtbot.addWidget(combo)
58+
59+
set_skeleton_combo_from_style(
60+
combo,
61+
mode="solid",
62+
color=(0, 255, 0),
63+
)
64+
65+
assert get_skeleton_style_from_combo(combo) == (
66+
"solid",
67+
(0, 255, 0),
68+
)
69+
70+
71+
def test_skeleton_combo_falls_back_to_first_solid_color(
72+
qtbot,
73+
) -> None:
74+
combo = make_skeleton_color_combo(
75+
BBoxColors,
76+
include_icons=False,
77+
)
78+
qtbot.addWidget(combo)
79+
80+
set_skeleton_combo_from_style(
81+
combo,
82+
mode="solid",
83+
color=(1, 2, 3),
84+
)
85+
86+
mode, color = get_skeleton_style_from_combo(combo)
87+
88+
assert mode == "solid"
89+
assert color == BBoxColors.RED.value
90+
91+
92+
def test_skeleton_combo_can_create_icons(qtbot) -> None:
93+
combo = make_skeleton_color_combo(
94+
BBoxColors,
95+
include_icons=True,
96+
)
97+
qtbot.addWidget(combo)
98+
99+
assert not combo.itemIcon(0).isNull()

0 commit comments

Comments
 (0)