mirror of
https://github.com/koreader/koreader
synced 2024-11-13 19:11:25 +00:00
130 lines
5.0 KiB
Lua
130 lines
5.0 KiB
Lua
|
describe("input module", function()
|
||
|
local Input
|
||
|
setup(function()
|
||
|
require("commonrequire")
|
||
|
Input = require("device/input")
|
||
|
end)
|
||
|
|
||
|
describe("handleTouchEvPhoenix", function()
|
||
|
--[[
|
||
|
-- a touch looks something like this (from H2Ov1)
|
||
|
Event: time 1510346968.993890, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1
|
||
|
Event: time 1510346968.994362, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 1
|
||
|
Event: time 1510346968.994384, type 3 (EV_ABS), code 50 (ABS_MT_WIDTH_MAJOR), value 1
|
||
|
Event: time 1510346968.994399, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1012
|
||
|
Event: time 1510346968.994409, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 914
|
||
|
Event: time 1510346968.994420, ++++++++++++++ SYN_MT_REPORT ++++++++++++
|
||
|
Event: time 1510346968.994429, -------------- SYN_REPORT ------------
|
||
|
Event: time 1510346969.057898, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1
|
||
|
Event: time 1510346969.058251, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 1
|
||
|
Event: time 1510346969.058417, type 3 (EV_ABS), code 50 (ABS_MT_WIDTH_MAJOR), value 1
|
||
|
Event: time 1510346969.058436, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1012
|
||
|
Event: time 1510346969.058446, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 915
|
||
|
Event: time 1510346969.058456, ++++++++++++++ SYN_MT_REPORT ++++++++++++
|
||
|
Event: time 1510346969.058464, -------------- SYN_REPORT ------------
|
||
|
Event: time 1510346969.066903, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1
|
||
|
Event: time 1510346969.067102, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 1
|
||
|
Event: time 1510346969.067260, type 3 (EV_ABS), code 50 (ABS_MT_WIDTH_MAJOR), value 1
|
||
|
Event: time 1510346969.067415, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1010
|
||
|
Event: time 1510346969.067433, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 918
|
||
|
Event: time 1510346969.067443, ++++++++++++++ SYN_MT_REPORT ++++++++++++
|
||
|
Event: time 1510346969.067451, -------------- SYN_REPORT ------------
|
||
|
Event: time 1510346969.076230, type 3 (EV_ABS), code 57 (ABS_MT_TRACKING_ID), value 1
|
||
|
Event: time 1510346969.076549, type 3 (EV_ABS), code 48 (ABS_MT_TOUCH_MAJOR), value 0
|
||
|
Event: time 1510346969.076714, type 3 (EV_ABS), code 50 (ABS_MT_WIDTH_MAJOR), value 0
|
||
|
Event: time 1510346969.076869, type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 1010
|
||
|
Event: time 1510346969.076887, type 3 (EV_ABS), code 54 (ABS_MT_POSITION_Y), value 918
|
||
|
Event: time 1510346969.076898, ++++++++++++++ SYN_MT_REPORT ++++++++++++
|
||
|
Event: time 1510346969.076908, -------------- SYN_REPORT ------------
|
||
|
]]
|
||
|
it("should set cur_slot correctly", function()
|
||
|
local ev
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 57,
|
||
|
value = 1,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 48,
|
||
|
value = 1,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 50,
|
||
|
value = 1,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 53,
|
||
|
value = 1012,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 54,
|
||
|
value = 914,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
|
||
|
-- EV_SYN
|
||
|
-- depends on gesture_detector
|
||
|
--[[
|
||
|
ev = {
|
||
|
type = 0,
|
||
|
code = 0,
|
||
|
value = 0,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(1, Input.cur_slot)
|
||
|
]]
|
||
|
|
||
|
-- this value=2 stuff doesn't happen IRL, just testing logic
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 57,
|
||
|
value = 2,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(2, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 48,
|
||
|
value = 2,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(2, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 50,
|
||
|
value = 2,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(2, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 53,
|
||
|
value = 1012,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(2, Input.cur_slot)
|
||
|
ev = {
|
||
|
type = 3,
|
||
|
code = 54,
|
||
|
value = 914,
|
||
|
}
|
||
|
Input:handleTouchEvPhoenix(ev)
|
||
|
assert.is_equal(2, Input.cur_slot)
|
||
|
end)
|
||
|
end)
|
||
|
|
||
|
end)
|