2016-04-03 04:52:30 +00:00
|
|
|
describe("touch probe module", function()
|
2017-08-08 20:35:40 +00:00
|
|
|
local x, y
|
2016-04-03 04:52:30 +00:00
|
|
|
setup(function()
|
|
|
|
require("commonrequire")
|
|
|
|
end)
|
|
|
|
|
|
|
|
it("should probe properly for kobo touch", function()
|
|
|
|
local Device = require("device")
|
2016-08-11 11:29:09 +00:00
|
|
|
local TouchProbe = require("tools/kobo_touch_probe"):new{}
|
2016-04-03 04:52:30 +00:00
|
|
|
local need_to_switch_xy
|
|
|
|
TouchProbe.saveSwitchXYSetting = function(_, new_need_to_switch_xy)
|
|
|
|
need_to_switch_xy = new_need_to_switch_xy
|
|
|
|
end
|
|
|
|
-- for kobo touch, we have mirror_x, then switch_xy
|
|
|
|
-- tap lower right corner
|
2017-08-08 20:35:40 +00:00
|
|
|
x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40
|
2016-04-03 04:52:30 +00:00
|
|
|
need_to_switch_xy = nil
|
|
|
|
TouchProbe:onTapProbe(nil, {
|
|
|
|
pos = {
|
|
|
|
x = y,
|
|
|
|
y = Device.screen:getWidth()-x,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
assert.is.same(TouchProbe.curr_probe_step, 1)
|
|
|
|
assert.truthy(need_to_switch_xy)
|
|
|
|
|
|
|
|
-- now only test mirror_x
|
|
|
|
-- tap lower right corner
|
2017-08-08 20:35:40 +00:00
|
|
|
x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40
|
2016-04-03 04:52:30 +00:00
|
|
|
need_to_switch_xy = nil
|
|
|
|
TouchProbe:onTapProbe(nil, {
|
|
|
|
pos = {
|
|
|
|
x = Device.screen:getWidth()-x,
|
|
|
|
y = y,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
assert.is.same(TouchProbe.curr_probe_step, 1)
|
|
|
|
assert.falsy(need_to_switch_xy)
|
|
|
|
|
|
|
|
-- now only test switch_xy
|
|
|
|
-- tap lower right corner
|
2017-08-08 20:35:40 +00:00
|
|
|
x, y = Device.screen:getWidth()-40, Device.screen:getHeight()-40
|
2016-04-03 04:52:30 +00:00
|
|
|
need_to_switch_xy = nil
|
|
|
|
TouchProbe:onTapProbe(nil, {
|
|
|
|
pos = {
|
|
|
|
x = y,
|
|
|
|
y = x,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
assert.is.same(TouchProbe.curr_probe_step, 2)
|
|
|
|
assert.falsy(need_to_switch_xy)
|
|
|
|
-- tap upper right corner
|
2017-08-08 20:35:40 +00:00
|
|
|
x, y = Device.screen:getWidth()-40, 40
|
2016-04-03 04:52:30 +00:00
|
|
|
TouchProbe:onTapProbe(nil, {
|
|
|
|
pos = {
|
|
|
|
x = y,
|
|
|
|
y = x,
|
|
|
|
}
|
|
|
|
})
|
|
|
|
assert.is.same(TouchProbe.curr_probe_step, 2)
|
|
|
|
assert.truthy(need_to_switch_xy)
|
|
|
|
end)
|
|
|
|
end)
|