mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
automatically adjust ev time for kobo touch
This commit is contained in:
@@ -15,7 +15,9 @@ describe("device module", function()
|
||||
end)
|
||||
|
||||
describe("kobo", function()
|
||||
local TimeVal
|
||||
setup(function()
|
||||
TimeVal = require("ui/timeval")
|
||||
mock_fb = {
|
||||
new = function()
|
||||
return {
|
||||
@@ -63,6 +65,7 @@ describe("device module", function()
|
||||
kobo_dev:init()
|
||||
local Screen = kobo_dev.screen
|
||||
|
||||
kobo_dev.touch_probe_ev_epoch_time = false
|
||||
assert.is.same("Kobo_trilogy", kobo_dev.model)
|
||||
assert.truthy(kobo_dev:needsTouchScreenProbe())
|
||||
G_reader_settings:saveSetting("kobo_touch_switch_xy", true)
|
||||
@@ -93,6 +96,63 @@ describe("device module", function()
|
||||
package.loaded['ffi/framebuffer_mxcfb'] = nil
|
||||
os.getenv:revert()
|
||||
mock_input.open:revert()
|
||||
-- reset eventAdjustHook
|
||||
kobo_dev.input.eventAdjustHook = function() end
|
||||
kobo_dev.touch_probe_ev_epoch_time = true
|
||||
end)
|
||||
|
||||
it("should setup eventAdjustHooks properly for trilogy with non-epoch ev time", function()
|
||||
local saved_getenv = os.getenv
|
||||
stub(os, "getenv")
|
||||
os.getenv.invokes(function(key)
|
||||
if key == "PRODUCT" then
|
||||
return "trilogy"
|
||||
else
|
||||
return saved_getenv(key)
|
||||
end
|
||||
end)
|
||||
package.loaded['device/kobo/device'] = nil
|
||||
package.loaded['ffi/framebuffer_mxcfb'] = mock_fb
|
||||
mock_input = require('device/input')
|
||||
stub(mock_input, "open")
|
||||
|
||||
local kobo_dev = require("device/kobo/device")
|
||||
kobo_dev:init()
|
||||
local Screen = kobo_dev.screen
|
||||
|
||||
assert.is.same("Kobo_trilogy", kobo_dev.model)
|
||||
local x, y = Screen:getWidth()-5, 10
|
||||
local EV_ABS = 3
|
||||
local ABS_X = 00
|
||||
local ABS_Y = 01
|
||||
-- mirror x, then switch_xy
|
||||
local ev_x = {
|
||||
type = EV_ABS,
|
||||
code = ABS_X,
|
||||
value = x,
|
||||
time = {sec = 1000}
|
||||
}
|
||||
local ev_y = {
|
||||
type = EV_ABS,
|
||||
code = ABS_Y,
|
||||
value = y,
|
||||
time = {sec = 1000}
|
||||
}
|
||||
|
||||
assert.truthy(kobo_dev.touch_probe_ev_epoch_time)
|
||||
G_reader_settings:saveSetting("kobo_touch_switch_xy", true)
|
||||
kobo_dev:touchScreenProbe()
|
||||
|
||||
kobo_dev.input:eventAdjustHook(ev_x)
|
||||
kobo_dev.input:eventAdjustHook(ev_y)
|
||||
local cur_sec = TimeVal:now().sec
|
||||
assert.truthy(cur_sec - ev_x.time.sec < 10)
|
||||
assert.truthy(cur_sec - ev_y.time.sec < 10)
|
||||
|
||||
package.loaded['ffi/framebuffer_mxcfb'] = nil
|
||||
os.getenv:revert()
|
||||
mock_input.open:revert()
|
||||
kobo_dev.input.eventAdjustHook = function() end
|
||||
end)
|
||||
|
||||
it("should flush book settings before suspend", function()
|
||||
|
||||
Reference in New Issue
Block a user