Skip to content

Commit 8d2b8c2

Browse files
committed
Update tests
1 parent b7fd33b commit 8d2b8c2

File tree

9 files changed

+538
-17
lines changed

9 files changed

+538
-17
lines changed

.luacov

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ return {
5555
-- Nothing will be excluded if nothing is listed.
5656
-- Do not include the '.lua' extension. Path separator is always '/'.
5757
-- Overrules `include`.
58-
exclude = { "^test%/.+$" },
58+
exclude = {
59+
"^test%/.+$",
60+
"^druid/system/utf8.lua$",
61+
},
5962

6063
--- Table mapping names of modules to be included to their filenames.
6164
-- Has no effect if empty.

test/test.gui

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ textures {
99
}
1010
material: "/builtins/materials/gui.material"
1111
adjust_reference: ADJUST_REFERENCE_DISABLED
12+
max_nodes: 2048

test/test.gui_script

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
local deftest = require("deftest.deftest")
22

33
function init(self)
4+
deftest.add(require("test.tests.test_druid_instance"))
5+
deftest.add(require("test.tests.test_back_handler"))
46
deftest.add(require("test.tests.test_blocker"))
57
deftest.add(require("test.tests.test_button"))
6-
deftest.add(require("test.tests.test_hover"))
8+
deftest.add(require("test.tests.test_container"))
79
deftest.add(require("test.tests.test_drag"))
8-
deftest.add(require("test.tests.test_back_handler"))
10+
deftest.add(require("test.tests.test_grid"))
911
deftest.add(require("test.tests.test_helper"))
10-
deftest.add(require("test.tests.test_text"))
12+
deftest.add(require("test.tests.test_hover"))
1113
deftest.add(require("test.tests.test_input"))
1214
deftest.add(require("test.tests.test_layout"))
13-
deftest.add(require("test.tests.test_container"))
1415
deftest.add(require("test.tests.test_rich_text"))
15-
deftest.add(require("test.tests.test_druid_instance"))
16+
deftest.add(require("test.tests.test_scroll"))
17+
deftest.add(require("test.tests.test_text"))
1618

1719
local is_report = (sys.get_config_int("test.report", 0) == 1)
1820
deftest.run({ coverage = { enabled = is_report } })

test/tests/test_blocker.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ return function()
2626
end)
2727

2828
it("Should consume input", function()
29-
local button_node = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(100, 100, 0))
29+
local button_node = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(150, 150, 0))
3030
local blocker_node = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(20, 20, 0))
3131
local on_click_calls = 0
3232

@@ -35,8 +35,8 @@ return function()
3535
end)
3636
druid:new_blocker(blocker_node)
3737

38-
druid:on_input(mock_input.click_pressed(40, 40))
39-
druid:on_input(mock_input.click_released(40, 40))
38+
druid:on_input(mock_input.click_pressed(20, 20))
39+
druid:on_input(mock_input.click_released(20, 20))
4040
assert(on_click_calls == 1)
4141

4242
-- Click should been consumed by blocker component

test/tests/test_button.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,8 @@ return function()
330330
end)
331331

332332
it("Should work with click zone", function()
333-
local button = gui.new_box_node(vmath.vector3(50, 25, 0), vmath.vector3(100, 50, 0))
334-
local zone = gui.new_box_node(vmath.vector3(50, 50, 0), vmath.vector3(50, 50, 0))
333+
local button = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(200, 200, 0))
334+
local zone = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(50, 50, 0))
335335
local button_params = {}
336336

337337
local on_click_calls = 0
@@ -341,12 +341,13 @@ return function()
341341

342342
local instance = druid:new_button(button, on_click, button_params)
343343
instance:set_click_zone(zone)
344-
druid:on_input(mock_input.click_pressed(10, 10))
345-
druid:on_input(mock_input.click_released(10, 10))
344+
345+
druid:on_input(mock_input.click_pressed(70, 70))
346+
druid:on_input(mock_input.click_released(70, 70))
346347
assert(on_click_calls == 0)
347348

348-
druid:on_input(mock_input.click_pressed(50, 50))
349-
druid:on_input(mock_input.click_released(50, 50))
349+
druid:on_input(mock_input.click_pressed(10, 10))
350+
druid:on_input(mock_input.click_released(10, 10))
350351
assert(on_click_calls == 1)
351352
end)
352353

test/tests/test_drag.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ return function()
131131
local on_drag_calls = 0
132132
local function on_drag() on_drag_calls = on_drag_calls + 1 end
133133
local instance = create_drag_instance(on_drag)
134-
local zone = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(10, 10, 0))
134+
local zone = gui.new_box_node(vmath.vector3(0, 0, 0), vmath.vector3(20, 20, 0))
135135
instance:set_click_zone(zone)
136136

137137
druid:on_input(mock_input.click_pressed(20, 20))
@@ -149,6 +149,7 @@ return function()
149149
assert(instance.is_touch == true)
150150

151151
druid:on_input(mock_input.input_empty(5, 5))
152+
druid:on_input(mock_input.click_released(5, 5))
152153
assert(on_drag_calls == 1)
153154
end)
154155

test/tests/test_druid_instance.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ return function()
178178

179179
local drag = druid_instance:new_drag(button_node, on_drag)
180180
drag.style.DRAG_DEADZONE = 0
181+
drag.style.NO_USE_SCREEN_KOEF = true
181182

182183
assert(drag ~= nil)
183184
assert(drag.node == button_node)
@@ -187,7 +188,6 @@ return function()
187188
druid_instance:on_input(mock_input.input_empty(60, 35))
188189
druid_instance:on_input(mock_input.click_released(60, 35))
189190

190-
print(drag_dx, drag_dy)
191191
assert(on_drag_calls == 1)
192192
assert(math.floor(drag_dx) == 10)
193193
assert(math.floor(drag_dy) == 10)

0 commit comments

Comments
 (0)