4
4
import toga
5
5
6
6
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
+
7
19
# test that a non-container-like widget in layout debug mode has a default background
8
20
def test_button_debug_background ():
9
21
"""A Button in layout debug mode has a default background."""
@@ -16,8 +28,21 @@ def test_button_debug_background():
16
28
assert not button .style .background_color
17
29
18
30
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
+
19
43
# 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 ():
21
46
"""A Box in layout debug mode has a non-default background."""
22
47
# Enable layout debug mode
23
48
with MonkeyPatch .context () as mp :
@@ -38,13 +63,14 @@ def test_box_debug_background():
38
63
)
39
64
40
65
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."""
44
70
# Disable layout debug mode
45
71
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