Skip to content

Commit 206fb31

Browse files
committed
add new test cases
1 parent 5e92dc2 commit 206fb31

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

core/tests/widgets/test_container_debug_mode.py

+35-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
import toga
55

66

7+
# test that a container-like widget in normal mode has a default background
8+
def test_box_no_background_in_normal_mode():
9+
"""A Box has no default background."""
10+
# Disable layout debug mode
11+
with MonkeyPatch.context() as mp:
12+
mp.setenv("TOGA_DEBUG_LAYOUT", "0")
13+
box = toga.Box()
14+
# assert that the bg is default
15+
assert hasattr(box.style, "background_color")
16+
assert not box.style.background_color
17+
18+
719
# test that a non-container-like widget in layout debug mode has a default background
820
def test_button_debug_background():
921
"""A Button in layout debug mode has a default background."""
@@ -16,8 +28,21 @@ def test_button_debug_background():
1628
assert not button.style.background_color
1729

1830

31+
# test that a label in layout debug mode has a default background
32+
def test_label_no_debug_background():
33+
"""A Label in layout debug mode has a default background."""
34+
# Enable layout debug mode
35+
with MonkeyPatch.context() as mp:
36+
mp.setenv("TOGA_DEBUG_LAYOUT", "1")
37+
label = toga.Label("label")
38+
# assert that the bg is default
39+
assert hasattr(label.style, "background_color")
40+
assert not label.style.background_color
41+
42+
1943
# test that a container-like widget in layout debug mode has a non-default background
20-
def test_box_debug_background():
44+
# that matches the expected debug_background_palette
45+
def test_box_debug_backgrounds():
2146
"""A Box in layout debug mode has a non-default background."""
2247
# Enable layout debug mode
2348
with MonkeyPatch.context() as mp:
@@ -38,13 +63,14 @@ def test_box_debug_background():
3863
)
3964

4065

41-
# test that a container-like widget in normal mode has a default background
42-
def test_box_normal_background():
43-
"""A Box has no default background."""
66+
# test that a scroll container widget in layout debug mode doesn't have
67+
# a default background
68+
def test_scroll_container_debug_background():
69+
"""A container widget has a default background."""
4470
# Disable layout debug mode
4571
with MonkeyPatch.context() as mp:
46-
mp.setenv("TOGA_DEBUG_LAYOUT", "0")
47-
box = toga.Box()
48-
# assert that the bg is default
49-
assert hasattr(box.style, "background_color")
50-
assert not box.style.background_color
72+
mp.setenv("TOGA_DEBUG_LAYOUT", "1")
73+
sc = toga.ScrollContainer()
74+
# assert that the bg is not default
75+
assert hasattr(sc.style, "background_color")
76+
assert sc.style.background_color != color("white")

0 commit comments

Comments
 (0)