forked from DFHack/dfhack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgets.Label.lua
More file actions
94 lines (82 loc) · 2.37 KB
/
Copy pathwidgets.Label.lua
File metadata and controls
94 lines (82 loc) · 2.37 KB
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
-- test -dhack/scripts/devel/tests -twidgets.Label
local gui = require('gui')
local widgets = require('gui.widgets')
local xtest = {} -- use to temporarily disable tests (change `function xtest.somename` to `function xxtest.somename`)
local wait = function(n)
delay(n or 30) -- enable for debugging the tests
end
local fs = defclass(fs, gui.FramedScreen)
fs.ATTRS = {
frame_style = gui.GREY_LINE_FRAME,
frame_title = 'TestFramedScreen',
frame_width = 10,
frame_height = 10,
frame_inset = 0,
focus_path = 'test-framed-screen',
}
function test.Label_correct_frame_body_with_scroll_icons()
local t = {}
for i = 1, 12 do
t[#t+1] = tostring(i)
t[#t+1] = NEWLINE
end
function fs:init(args)
self:addviews{
widgets.Label{
view_id = 'text',
frame_inset = 0,
text = t,
--show_scroll_icons = 'right',
},
}
end
local o = fs{}
--o:show()
--wait()
expect.eq(o.subviews.text.frame_body.width, 9, "Label's frame_body.x2 and .width should be one smaller because of show_scroll_icons.")
--o:dismiss()
end
function test.Label_correct_frame_body_with_few_text_lines()
local t = {}
for i = 1, 10 do
t[#t+1] = tostring(i)
t[#t+1] = NEWLINE
end
function fs:init(args)
self:addviews{
widgets.Label{
view_id = 'text',
frame_inset = 0,
text = t,
--show_scroll_icons = 'right',
},
}
end
local o = fs{}
--o:show()
--wait()
expect.eq(o.subviews.text.frame_body.width, 10, "Label's frame_body.x2 and .width should not change with show_scroll_icons = false.")
--o:dismiss()
end
function test.Label_correct_frame_body_without_show_scroll_icons()
local t = {}
for i = 1, 12 do
t[#t+1] = tostring(i)
t[#t+1] = NEWLINE
end
function fs:init(args)
self:addviews{
widgets.Label{
view_id = 'text',
frame_inset = 0,
text = t,
show_scroll_icons = false,
},
}
end
local o = fs{}
--o:show()
--wait()
expect.eq(o.subviews.text.frame_body.width, 10, "Label's frame_body.x2 and .width should not change with show_scroll_icons = false.")
--o:dismiss()
end