Skip to content

Commit

Permalink
Added input test
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl committed Jul 9, 2018
1 parent a11f3f8 commit 6120769
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions test/test_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ return function()
local node = gui.new_text_node(vmath.vector3(10, 10, 0), "")
gui.set_id(node, "text")

local config = nil
-- select and enter some text
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.pressed(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.released(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TEXT, actions.text("f"))
Expand All @@ -45,12 +45,13 @@ return function()
local node = gui.new_text_node(vmath.vector3(10, 10, 0), "")
gui.set_id(node, "text")

local config = nil
-- select and enter some text
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.pressed(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.released(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TEXT, actions.text("foobar"))
assert(gooey.input("text").text == "foobar")

-- erase
local input = gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.BACKSPACE, actions.text(""))
assert(input.text == "fooba")
end)
Expand All @@ -59,14 +60,28 @@ return function()
local node = gui.new_text_node(vmath.vector3(10, 10, 0), "")
gui.set_id(node, "text")

local config = nil
-- select and enter some text
gooey.input("text", gui.KEYBOARD_TYPE_PASSWORD, gooey.TOUCH, actions.pressed(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_PASSWORD, gooey.TOUCH, actions.released(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_PASSWORD, gooey.TEXT, actions.text("foobar"))
print(gooey.input("text").text)

-- check that the text is masked
assert(gooey.input("text").masked_text == "******")
assert(gui.get_text(node) == "******")
end)


test("it should be possible to set the text directly", function()
local node = gui.new_text_node(vmath.vector3(10, 10, 0), "")
gui.set_id(node, "text")

-- select and enter some text
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.pressed(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TOUCH, actions.released(10, 10))
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT, gooey.TEXT, actions.text("foo"))

-- set text directly
gooey.input("text", gui.KEYBOARD_TYPE_DEFAULT).set_text("foobar")
assert(gooey.input("text").text == "foobar")
end)
end)
end

0 comments on commit 6120769

Please sign in to comment.