File: test_titlebox.py

package info (click to toggle)
python-guizero 1.6.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,872 kB
  • sloc: python: 7,160; makefile: 34; sh: 17
file content (145 lines) | stat: -rw-r--r-- 2,964 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
from threading import Event
from guizero import App, Text, TitleBox
from common_test import (
    schedule_after_test,
    schedule_repeat_test,
    destroy_test,
    display_test,
    color_test,
    size_pixel_test,
    size_fill_test,
    events_test,
    cascading_enable_test,
    cascading_properties_test,
    inheriting_properties_test,
    add_tk_widget_test,
    grid_layout_test,
    auto_layout_test
    )

def test_default_values():
    a = App()
    b = TitleBox(a, "title")
    assert b.text == "title"
    assert b.master == a
    assert b.layout == "auto"
    assert b.grid == None
    assert b.align == None
    assert b.border == 2
    a.destroy()

def test_alt_values():
    a = App(layout = "grid")
    b = TitleBox(a, "title", layout="grid", grid=[0,1], align="top", width=10, height=11, border=0)
    assert b.layout == "grid"
    assert b.grid[0] == 0
    assert b.grid[1] == 1
    assert b.align == "top"
    assert b.width == 10
    assert b.height == 11
    assert b.border == 0
    a.destroy()

def test_border():
    a = App()
    b = TitleBox(a, "title")
    assert b.border == 2

    b.border = True
    assert b.border == 1

    b.border = False
    assert b.border == 0

    b.border = 10
    assert b.border == 10

    a.destroy()

def test_after_schedule():
    a = App()
    b = TitleBox(a, "title")
    schedule_after_test(a, b)
    a.destroy()

def test_repeat_schedule():
    a = App()
    b = TitleBox(a, "title")
    schedule_repeat_test(a, b)
    a.destroy()

def test_destroy():
    a = App()
    b = TitleBox(a, "title")
    destroy_test(b)
    a.destroy()

def test_display():
    a = App()
    b = TitleBox(a, "title")
    display_test(b)
    a.destroy()

def test_color():
    a = App()
    b = TitleBox(a, "title")
    color_test(b)
    a.destroy()

def test_size():
    a = App()
    b = TitleBox(a, "title")
    size_pixel_test(b)
    size_fill_test(b)
    a.destroy()

def test_enable():
    a = App()
    b = TitleBox(a, "title")
    t = Text(b)
    cascading_enable_test(a)
    cascading_enable_test(b)
    a.destroy()

def test_events():
    a = App()
    b = TitleBox(a, "title")
    events_test(b)
    a.destroy()

def test_cascading_properties():
    a = App()
    b = TitleBox(a, "title")
    cascading_properties_test(b)
    a.destroy()

def test_inheriting_properties():
    a = App()
    b = TitleBox(a, "title")
    inheriting_properties_test(b)
    a.destroy()

def test_add_tk_widget():
    a = App()
    add_tk_widget_test(a)
    a.destroy()

def test_auto_layout():
    a = App()
    w = TitleBox(a, "title")
    auto_layout_test(w, None)
    a.destroy()

def test_grid_layout():
    a = App(layout="grid")

    w = TitleBox(a, "title", grid=[1,2])
    grid_layout_test(w, 1, 2, 1, 1, None)

    ws = TitleBox(a, "title", grid=[1,2,3,4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = TitleBox(a, "title", grid=[1,2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")

    a.destroy()