2016-04-02 21:52:30 -07:00
|
|
|
describe("device module", function()
|
2017-08-08 22:35:40 +02:00
|
|
|
-- luacheck: push ignore
|
2016-04-02 21:52:30 -07:00
|
|
|
local mock_fb, mock_input
|
2016-08-13 18:47:38 +08:00
|
|
|
local iopen = io.open
|
2022-09-10 13:45:31 +02:00
|
|
|
local ipopen = io.popen
|
2016-08-13 18:47:38 +08:00
|
|
|
local osgetenv = os.getenv
|
2021-04-13 17:53:15 +02:00
|
|
|
local ffi, C
|
2016-08-13 18:47:38 +08:00
|
|
|
|
2016-04-02 21:52:30 -07:00
|
|
|
setup(function()
|
2023-05-18 23:13:43 +02:00
|
|
|
local fb = require("ffi/framebuffer")
|
2016-04-02 21:52:30 -07:00
|
|
|
mock_fb = {
|
|
|
|
|
new = function()
|
|
|
|
|
return {
|
2023-05-18 23:13:43 +02:00
|
|
|
device = package.loaded.device,
|
|
|
|
|
bb = require("ffi/blitbuffer").new(600, 800, 1),
|
2021-05-13 13:05:05 +02:00
|
|
|
getRawSize = function() return {w = 600, h = 800} end,
|
2016-04-02 21:52:30 -07:00
|
|
|
getWidth = function() return 600 end,
|
2023-05-18 23:13:43 +02:00
|
|
|
getHeight = function() return 800 end,
|
2016-04-02 21:52:30 -07:00
|
|
|
getDPI = function() return 72 end,
|
2016-08-13 18:47:38 +08:00
|
|
|
setViewport = function() end,
|
|
|
|
|
getRotationMode = function() return 0 end,
|
|
|
|
|
getScreenMode = function() return "portrait" end,
|
|
|
|
|
setRotationMode = function() end,
|
2023-05-18 23:13:43 +02:00
|
|
|
scaleByDPI = fb.scaleByDPI,
|
|
|
|
|
scaleBySize = fb.scaleBySize,
|
|
|
|
|
setWindowTitle = function() end,
|
|
|
|
|
refreshFull = function() end,
|
2023-08-12 03:15:11 +02:00
|
|
|
getHWNightmode = function() return false end,
|
|
|
|
|
setupDithering = function() end,
|
2016-04-02 21:52:30 -07:00
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
require("commonrequire")
|
2024-12-25 15:46:02 +01:00
|
|
|
disable_plugins()
|
2021-04-13 17:53:15 +02:00
|
|
|
ffi = require("ffi")
|
|
|
|
|
C = ffi.C
|
|
|
|
|
require("ffi/linux_input_h")
|
2019-02-18 08:01:00 -08:00
|
|
|
require("document/canvascontext"):init(require("device"))
|
2016-04-02 21:52:30 -07:00
|
|
|
end)
|
|
|
|
|
|
2016-08-13 18:47:38 +08:00
|
|
|
before_each(function()
|
2023-05-03 03:59:33 +02:00
|
|
|
package.loaded["ffi/framebuffer_mxcfb"] = mock_fb
|
|
|
|
|
mock_input = require("device/input")
|
2024-09-22 20:23:28 +02:00
|
|
|
mock_input.input = {}
|
|
|
|
|
mock_input.gameControllerRumble = function() return false end
|
2016-08-13 18:47:38 +08:00
|
|
|
stub(mock_input, "open")
|
|
|
|
|
stub(os, "getenv")
|
|
|
|
|
stub(os, "execute")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
after_each(function()
|
2023-05-18 23:13:43 +02:00
|
|
|
-- Don't let UIManager hang on to a stale Device reference, and vice-versa...
|
|
|
|
|
package.unload("device")
|
|
|
|
|
package.unload("device/generic/device")
|
|
|
|
|
package.unload("device/generic/powerd")
|
|
|
|
|
package.unload("ui/uimanager")
|
|
|
|
|
package.unload("apps/reader/readerui")
|
2016-08-13 18:47:38 +08:00
|
|
|
mock_input.open:revert()
|
|
|
|
|
os.getenv:revert()
|
2023-05-18 23:13:43 +02:00
|
|
|
os.execute:revert()
|
2016-08-13 18:47:38 +08:00
|
|
|
|
|
|
|
|
os.getenv = osgetenv
|
|
|
|
|
io.open = iopen
|
2022-09-10 13:45:31 +02:00
|
|
|
io.popen = ipopen
|
2016-08-13 18:47:38 +08:00
|
|
|
end)
|
|
|
|
|
|
2016-04-02 21:52:30 -07:00
|
|
|
describe("kobo", function()
|
2022-11-01 00:03:22 +01:00
|
|
|
local time
|
2016-09-11 21:41:56 -07:00
|
|
|
local NickelConf
|
2016-04-02 21:52:30 -07:00
|
|
|
setup(function()
|
2022-11-01 00:03:22 +01:00
|
|
|
time = require("ui/time")
|
2016-09-11 21:41:56 -07:00
|
|
|
NickelConf = require("device/kobo/nickel_conf")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
|
stub(NickelConf.frontLightLevel, "get")
|
|
|
|
|
NickelConf.frontLightLevel.get.returns(0)
|
|
|
|
|
stub(NickelConf.frontLightState, "get")
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
after_each(function()
|
|
|
|
|
NickelConf.frontLightLevel.get:revert()
|
|
|
|
|
NickelConf.frontLightState.get:revert()
|
2016-04-02 21:52:30 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should initialize properly on Kobo dahlia", function()
|
|
|
|
|
os.getenv.returns("dahlia")
|
|
|
|
|
local kobo_dev = require("device/kobo/device")
|
|
|
|
|
|
|
|
|
|
kobo_dev:init()
|
|
|
|
|
assert.is.same("Kobo_dahlia", kobo_dev.model)
|
|
|
|
|
end)
|
|
|
|
|
|
2022-09-04 23:38:13 +02:00
|
|
|
it("should setup eventAdjustHooks properly for input on trilogy C", function()
|
2016-04-02 21:52:30 -07:00
|
|
|
os.getenv.invokes(function(key)
|
|
|
|
|
if key == "PRODUCT" then
|
|
|
|
|
return "trilogy"
|
2022-09-04 23:38:13 +02:00
|
|
|
elseif key == "MODEL_NUMBER" then
|
|
|
|
|
return "320"
|
2016-04-02 21:52:30 -07:00
|
|
|
else
|
2018-05-10 06:26:07 -04:00
|
|
|
return osgetenv(key)
|
2016-04-02 21:52:30 -07:00
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
2023-05-03 03:59:33 +02:00
|
|
|
package.loaded["device/kobo/device"] = nil
|
2016-04-02 21:52:30 -07:00
|
|
|
local kobo_dev = require("device/kobo/device")
|
|
|
|
|
kobo_dev:init()
|
|
|
|
|
local Screen = kobo_dev.screen
|
|
|
|
|
|
2022-09-04 23:38:13 +02:00
|
|
|
assert.is.same("Kobo_trilogy_C", kobo_dev.model)
|
2016-04-02 21:52:30 -07:00
|
|
|
local x, y = Screen:getWidth()-5, 10
|
|
|
|
|
-- mirror x, then switch_xy
|
|
|
|
|
local ev_x = {
|
2021-04-13 17:53:15 +02:00
|
|
|
type = C.EV_ABS,
|
|
|
|
|
code = C.ABS_X,
|
2016-04-02 21:52:30 -07:00
|
|
|
value = y,
|
2022-11-01 00:03:22 +01:00
|
|
|
time = time:realtime(),
|
2016-04-02 21:52:30 -07:00
|
|
|
}
|
|
|
|
|
local ev_y = {
|
2021-04-13 17:53:15 +02:00
|
|
|
type = C.EV_ABS,
|
|
|
|
|
code = C.ABS_Y,
|
2022-09-04 23:38:13 +02:00
|
|
|
value = Screen:getWidth() - 1 - x,
|
2022-11-01 00:03:22 +01:00
|
|
|
time = time:realtime(),
|
2016-04-02 21:52:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kobo_dev.input:eventAdjustHook(ev_x)
|
|
|
|
|
kobo_dev.input:eventAdjustHook(ev_y)
|
|
|
|
|
assert.is.same(x, ev_y.value)
|
2021-04-13 17:53:15 +02:00
|
|
|
assert.is.same(C.ABS_X, ev_y.code)
|
2016-04-02 21:52:30 -07:00
|
|
|
assert.is.same(y, ev_x.value)
|
2021-04-13 17:53:15 +02:00
|
|
|
assert.is.same(C.ABS_Y, ev_x.code)
|
2016-04-02 21:52:30 -07:00
|
|
|
|
2016-05-23 22:38:08 -07:00
|
|
|
-- reset eventAdjustHook
|
|
|
|
|
kobo_dev.input.eventAdjustHook = function() end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should setup eventAdjustHooks properly for trilogy with non-epoch ev time", function()
|
2020-10-18 15:57:42 +02:00
|
|
|
-- This has no more value since #6798 as ev time can now stay
|
|
|
|
|
-- non-epoch. Adjustments are made on first event handled, and
|
|
|
|
|
-- have only effects when handling long-press (so, the long-press
|
|
|
|
|
-- for dict lookup tests with test this).
|
|
|
|
|
-- We just check here it still works with non-epoch ev time, as previous test
|
2016-05-23 22:38:08 -07:00
|
|
|
os.getenv.invokes(function(key)
|
|
|
|
|
if key == "PRODUCT" then
|
|
|
|
|
return "trilogy"
|
2022-09-04 23:38:13 +02:00
|
|
|
elseif key == "MODEL_NUMBER" then
|
|
|
|
|
return "320"
|
2016-05-23 22:38:08 -07:00
|
|
|
else
|
2018-05-10 06:26:07 -04:00
|
|
|
return osgetenv(key)
|
2016-05-23 22:38:08 -07:00
|
|
|
end
|
|
|
|
|
end)
|
2019-01-08 02:59:47 +01:00
|
|
|
|
2023-05-03 03:59:33 +02:00
|
|
|
package.loaded["device/kobo/device"] = nil
|
2016-05-23 22:38:08 -07:00
|
|
|
local kobo_dev = require("device/kobo/device")
|
|
|
|
|
kobo_dev:init()
|
|
|
|
|
local Screen = kobo_dev.screen
|
|
|
|
|
|
2022-09-04 23:38:13 +02:00
|
|
|
assert.is.same("Kobo_trilogy_C", kobo_dev.model)
|
2016-05-23 22:38:08 -07:00
|
|
|
local x, y = Screen:getWidth()-5, 10
|
|
|
|
|
local ev_x = {
|
2021-04-13 17:53:15 +02:00
|
|
|
type = C.EV_ABS,
|
|
|
|
|
code = C.ABS_X,
|
2020-10-18 15:57:42 +02:00
|
|
|
value = y,
|
2016-05-23 22:38:08 -07:00
|
|
|
time = {sec = 1000}
|
|
|
|
|
}
|
|
|
|
|
local ev_y = {
|
2021-04-13 17:53:15 +02:00
|
|
|
type = C.EV_ABS,
|
|
|
|
|
code = C.ABS_Y,
|
2022-09-04 23:38:13 +02:00
|
|
|
value = Screen:getWidth() - 1 - x,
|
2016-05-23 22:38:08 -07:00
|
|
|
time = {sec = 1000}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kobo_dev.input:eventAdjustHook(ev_x)
|
|
|
|
|
kobo_dev.input:eventAdjustHook(ev_y)
|
2020-10-18 15:57:42 +02:00
|
|
|
assert.is.same(x, ev_y.value)
|
2021-04-13 17:53:15 +02:00
|
|
|
assert.is.same(C.ABS_X, ev_y.code)
|
2020-10-18 15:57:42 +02:00
|
|
|
assert.is.same(y, ev_x.value)
|
2021-04-13 17:53:15 +02:00
|
|
|
assert.is.same(C.ABS_Y, ev_x.code)
|
2016-05-23 22:38:08 -07:00
|
|
|
|
2019-01-08 02:59:47 +01:00
|
|
|
-- reset eventAdjustHook
|
2016-05-23 22:38:08 -07:00
|
|
|
kobo_dev.input.eventAdjustHook = function() end
|
2016-04-02 21:52:30 -07:00
|
|
|
end)
|
|
|
|
|
end)
|
2016-04-26 00:16:27 -07:00
|
|
|
|
2016-08-13 18:47:38 +08:00
|
|
|
describe("kindle", function()
|
2023-05-03 03:59:33 +02:00
|
|
|
local function make_io_open_kindle_model_override(model_no)
|
|
|
|
|
return function(filename, mode)
|
2016-08-13 18:47:38 +08:00
|
|
|
if filename == "/proc/usid" then
|
|
|
|
|
return {
|
2023-05-03 03:59:33 +02:00
|
|
|
read = function() return model_no end,
|
2016-08-13 18:47:38 +08:00
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return iopen(filename, mode)
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-05-03 03:59:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
insulate("without framework", function()
|
|
|
|
|
local mock_lipc = {
|
|
|
|
|
init = function()
|
|
|
|
|
return {
|
|
|
|
|
set_int_property = mock(function() end),
|
|
|
|
|
get_int_property = function() return 0 end,
|
|
|
|
|
get_string_property = function() return "string prop" end,
|
|
|
|
|
set_string_property = function() end,
|
|
|
|
|
register_int_property = function() return {} end,
|
|
|
|
|
close = function () end,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
package.loaded["liblipclua"] = mock_lipc
|
|
|
|
|
|
|
|
|
|
before_each(function()
|
|
|
|
|
os.getenv.invokes(function(e)
|
|
|
|
|
if e == "STOP_FRAMEWORK" then
|
|
|
|
|
return "yes"
|
|
|
|
|
else
|
|
|
|
|
return osgetenv(e)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("sets framework_lipc_handle", function ()
|
|
|
|
|
io.open = make_io_open_kindle_model_override("B013XX")
|
|
|
|
|
|
|
|
|
|
local kindle_dev = require("device/kindle/device")
|
|
|
|
|
assert.is.truthy(kindle_dev.framework_lipc_handle)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("reactivates voyage whispertouch keys", function ()
|
|
|
|
|
io.open = make_io_open_kindle_model_override("B013XX")
|
|
|
|
|
|
|
|
|
|
local kindle_dev = require("device/kindle/device")
|
|
|
|
|
local fw_lipc_handle = kindle_dev.framework_lipc_handle
|
|
|
|
|
|
|
|
|
|
kindle_dev:init()
|
|
|
|
|
|
|
|
|
|
for _, fsr_prop in pairs{
|
|
|
|
|
"fsrkeypadEnable",
|
|
|
|
|
"fsrkeypadPrevEnable",
|
|
|
|
|
"fsrkeypadNextEnable"
|
|
|
|
|
} do
|
|
|
|
|
assert.stub(fw_lipc_handle.set_int_property).was.called_with(
|
|
|
|
|
fw_lipc_handle, "com.lab126.deviced", fsr_prop, 1
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
insulate("with framework", function()
|
|
|
|
|
it("does not set framework_lipc_handle", function ()
|
|
|
|
|
io.open = make_io_open_kindle_model_override("B013XX")
|
|
|
|
|
|
|
|
|
|
local kindle_dev = require("device/kindle/device")
|
|
|
|
|
assert.is.falsy(kindle_dev.framework_lipc_handle)
|
|
|
|
|
end)
|
|
|
|
|
end)
|
2016-04-26 00:16:27 -07:00
|
|
|
|
2023-05-03 03:59:33 +02:00
|
|
|
it("should initialize voyage without error", function()
|
|
|
|
|
io.open = make_io_open_kindle_model_override("B013XX")
|
|
|
|
|
|
|
|
|
|
local kindle_dev = require("device/kindle/device")
|
2016-04-26 00:16:27 -07:00
|
|
|
assert.is.same(kindle_dev.model, "KindleVoyage")
|
|
|
|
|
kindle_dev:init()
|
|
|
|
|
assert.is.same(kindle_dev.input.event_map[104], "LPgBack")
|
|
|
|
|
assert.is.same(kindle_dev.input.event_map[109], "LPgFwd")
|
|
|
|
|
assert.is.same(kindle_dev.powerd.fl_min, 0)
|
2020-03-26 04:56:34 +01:00
|
|
|
-- NOTE: fl_max + 1 since #5989
|
|
|
|
|
assert.is.same(kindle_dev.powerd.fl_max, 25)
|
2016-04-26 00:16:27 -07:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("should toggle frontlight", function()
|
2016-08-13 18:47:38 +08:00
|
|
|
io.open = function(filename, mode)
|
|
|
|
|
if filename == "/proc/usid" then
|
|
|
|
|
return {
|
2019-07-19 23:16:25 +02:00
|
|
|
read = function() return "B013XX" end,
|
2016-08-13 18:47:38 +08:00
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
elseif filename == "/sys/class/backlight/max77696-bl/brightness" then
|
|
|
|
|
return {
|
2021-01-16 04:41:46 +01:00
|
|
|
read = function() return 12 end,
|
2016-08-13 18:47:38 +08:00
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return iopen(filename, mode)
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-04-26 00:16:27 -07:00
|
|
|
|
|
|
|
|
local kindle_dev = require("device/kindle/device")
|
|
|
|
|
kindle_dev:init()
|
|
|
|
|
|
|
|
|
|
assert.is.same(kindle_dev.powerd.fl_intensity, 12)
|
|
|
|
|
kindle_dev.powerd:setIntensity(5)
|
|
|
|
|
assert.is.same(kindle_dev.powerd.fl_intensity, 5)
|
|
|
|
|
|
|
|
|
|
kindle_dev.powerd:toggleFrontlight()
|
2018-12-10 22:10:35 +01:00
|
|
|
-- Here be shenanigans: we don't override powerd's fl_intensity when we turn the light off,
|
|
|
|
|
-- so that we can properly turn it back on at the previous intensity ;)
|
2016-04-26 00:16:27 -07:00
|
|
|
assert.is.same(kindle_dev.powerd.fl_intensity, 5)
|
2018-12-10 22:10:35 +01:00
|
|
|
-- But if we were to cat /sys/class/backlight/max77696-bl/brightness, it should now be 0.
|
2016-04-26 00:16:27 -07:00
|
|
|
|
|
|
|
|
kindle_dev.powerd:toggleFrontlight()
|
2018-12-10 22:10:35 +01:00
|
|
|
assert.is.same(kindle_dev.powerd.fl_intensity, 5)
|
|
|
|
|
-- And /sys/class/backlight/max77696-bl/brightness is now !0
|
|
|
|
|
-- (exact value is HW-dependent, each model has a different curve, we let lipc do the work for us).
|
2016-08-13 18:47:38 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("oasis should interpret orientation event", function()
|
2023-05-03 03:59:33 +02:00
|
|
|
package.unload("device/kindle/device")
|
|
|
|
|
io.open = make_io_open_kindle_model_override("G0B0GCXXX")
|
2016-08-13 18:47:38 +08:00
|
|
|
|
2024-09-22 20:23:28 +02:00
|
|
|
stub(mock_input.input, "waitForEvent")
|
|
|
|
|
mock_input.input.waitForEvent.returns(true, {
|
2021-04-03 01:48:35 +02:00
|
|
|
{
|
2021-04-13 17:53:15 +02:00
|
|
|
type = C.EV_ABS,
|
2021-04-03 01:48:35 +02:00
|
|
|
time = {
|
|
|
|
|
usec = 450565,
|
|
|
|
|
sec = 1471081881
|
|
|
|
|
},
|
2022-12-21 15:50:39 +01:00
|
|
|
code = 24, -- C.ABS_PRESSURE
|
2021-04-03 01:48:35 +02:00
|
|
|
value = 16
|
|
|
|
|
}
|
2016-08-13 18:47:38 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
stub(UIManager, "onRotation")
|
|
|
|
|
|
2023-05-03 03:59:33 +02:00
|
|
|
local kindle_dev = require("device/kindle/device")
|
2016-08-13 18:47:38 +08:00
|
|
|
assert.is.same("KindleOasis", kindle_dev.model)
|
|
|
|
|
kindle_dev:init()
|
2020-07-09 19:11:44 +02:00
|
|
|
kindle_dev:lockGSensor(true)
|
2016-08-13 18:47:38 +08:00
|
|
|
|
|
|
|
|
kindle_dev.input:waitEvent()
|
|
|
|
|
assert.stub(UIManager.onRotation).was_called()
|
2016-04-26 00:16:27 -07:00
|
|
|
|
2024-09-22 20:23:28 +02:00
|
|
|
mock_input.input.waitForEvent:revert()
|
2016-08-13 18:47:38 +08:00
|
|
|
UIManager.onRotation:revert()
|
2016-04-26 00:16:27 -07:00
|
|
|
end)
|
|
|
|
|
end)
|
2022-09-10 13:45:31 +02:00
|
|
|
|
|
|
|
|
describe("Flush book Settings for", function()
|
|
|
|
|
it("Kobo", function()
|
|
|
|
|
os.getenv.invokes(function(key)
|
|
|
|
|
if key == "PRODUCT" then
|
|
|
|
|
return "trilogy"
|
2023-05-18 23:13:43 +02:00
|
|
|
elseif key == "MODEL_NUMBER" then
|
|
|
|
|
return "320"
|
2022-09-10 13:45:31 +02:00
|
|
|
else
|
|
|
|
|
return osgetenv(key)
|
|
|
|
|
end
|
|
|
|
|
end)
|
2023-05-18 23:13:43 +02:00
|
|
|
-- Bypass frontend/device probeDevice, while making sure that it points to the right implementation
|
|
|
|
|
local Device = require("device/kobo/device")
|
|
|
|
|
-- Apparently common isn't setup properly in the testsuite, so we can't have nice things
|
|
|
|
|
stub(Device, "initNetworkManager")
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(Device, "suspend")
|
2023-05-18 23:13:43 +02:00
|
|
|
Device:init()
|
|
|
|
|
-- Don't poke the RTC
|
|
|
|
|
Device.wakeup_mgr = require("device/wakeupmgr"):new{rtc = require("device/kindle/mockrtc")}
|
|
|
|
|
-- Don't poke the fl
|
|
|
|
|
Device.powerd.fl = nil
|
|
|
|
|
package.loaded.device = Device
|
2022-09-10 13:45:31 +02:00
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
-- Generic's onPowerEvent may request a repaint, but we can't do that
|
|
|
|
|
stub(UIManager, "forceRePaint")
|
2022-09-10 13:45:31 +02:00
|
|
|
UIManager:init()
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
2022-09-10 13:45:31 +02:00
|
|
|
ReaderUI:doShowReader(sample_pdf)
|
2023-07-03 17:43:13 +03:00
|
|
|
local readerui = ReaderUI.instance
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(readerui, "onFlushSettings")
|
Assorted bag'o tweaks & fixes (#9569)
* UIManager: Support more specialized update modes for corner-cases:
* A2, which we'll use for the VirtualKeyboards keys (they'd... inadvertently switched to UI with the highlight refactor).
* NO_MERGE variants of ui & partial (for sunxi). Use `[ui]` in ReaderHighlight's popup, because of a Sage kernel bug that could otherwise make it translucent, sometimes completely so (*sigh*).
* UIManager: Assorted code cleanups & simplifications.
* Logger & dbg: Unify logging style, and code cleanups.
* SDL: Unbreak suspend/resume outside of the emulator (fix #9567).
* NetworkMgr: Cache the network status, and allow it to be queried. (Used by AutoSuspend to avoid repeatedly poking the system when computing the standby schedule delay).
* OneTimeMigration: Don't forget about `NETWORK_PROXY` & `STARDICT_DATA_DIR` when migrating `defaults.persistent.lua` (fix #9573)
* WakeupMgr: Workaround an apparent limitation of the RTC found on i.MX5 Kobo devices, where setting a wakealarm further than UINT16_MAX seconds in the future would apparently overflow and wraparound... (fix #8039, many thanks to @yfede for the extensive deep-dive and for actually accurately pinpointing the issue!).
* Kobo: Handle standby transitions at full CPU clock speeds, in order to limit the latency hit.
* UIManager: Properly quit on reboot & exit. This ensures our exit code is preserved, as we exit on our own terms (instead of being killed by the init system). This is important on platforms where exit codes are semantically meaningful (e.g., Kobo).
* UIManager: Speaking of reboot & exit, make sure the Screensaver shows in all circumstances (e.g., autoshutdown, re: #9542)), and that there aren't any extraneous refreshes triggered. (Additionally, fix a minor regression since #9448 about tracking this very transient state on Kobo & Cervantes).
* Kindle: ID the upcoming Scribe.
* Bump base (https://github.com/koreader/koreader-base/pull/1524)
2022-10-02 03:01:49 +02:00
|
|
|
UIManager.event_handlers.PowerPress()
|
|
|
|
|
UIManager.event_handlers.PowerRelease()
|
2022-09-10 13:45:31 +02:00
|
|
|
assert.stub(readerui.onFlushSettings).was_called()
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
UIManager.forceRePaint:revert()
|
|
|
|
|
Device.initNetworkManager:revert()
|
2022-09-10 13:45:31 +02:00
|
|
|
Device.suspend:revert()
|
|
|
|
|
readerui.onFlushSettings:revert()
|
|
|
|
|
Device.screen_saver_mode = false
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("Cervantes", function()
|
|
|
|
|
io.popen = function(filename, mode)
|
|
|
|
|
if filename:find("/usr/bin/ntxinfo") then
|
|
|
|
|
return {
|
|
|
|
|
read = function()
|
|
|
|
|
return 68 -- Cervantes4
|
|
|
|
|
end,
|
|
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ipopen(filename, mode)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local Device = require("device/cervantes/device")
|
|
|
|
|
stub(Device, "initNetworkManager")
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(Device, "suspend")
|
2023-05-18 23:13:43 +02:00
|
|
|
Device:init()
|
|
|
|
|
Device.powerd.fl = nil
|
|
|
|
|
package.loaded.device = Device
|
2022-09-10 13:45:31 +02:00
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
stub(UIManager, "forceRePaint")
|
2022-09-10 13:45:31 +02:00
|
|
|
UIManager:init()
|
|
|
|
|
|
|
|
|
|
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
|
|
|
|
ReaderUI:doShowReader(sample_pdf)
|
2023-07-03 17:43:13 +03:00
|
|
|
local readerui = ReaderUI.instance
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(readerui, "onFlushSettings")
|
Assorted bag'o tweaks & fixes (#9569)
* UIManager: Support more specialized update modes for corner-cases:
* A2, which we'll use for the VirtualKeyboards keys (they'd... inadvertently switched to UI with the highlight refactor).
* NO_MERGE variants of ui & partial (for sunxi). Use `[ui]` in ReaderHighlight's popup, because of a Sage kernel bug that could otherwise make it translucent, sometimes completely so (*sigh*).
* UIManager: Assorted code cleanups & simplifications.
* Logger & dbg: Unify logging style, and code cleanups.
* SDL: Unbreak suspend/resume outside of the emulator (fix #9567).
* NetworkMgr: Cache the network status, and allow it to be queried. (Used by AutoSuspend to avoid repeatedly poking the system when computing the standby schedule delay).
* OneTimeMigration: Don't forget about `NETWORK_PROXY` & `STARDICT_DATA_DIR` when migrating `defaults.persistent.lua` (fix #9573)
* WakeupMgr: Workaround an apparent limitation of the RTC found on i.MX5 Kobo devices, where setting a wakealarm further than UINT16_MAX seconds in the future would apparently overflow and wraparound... (fix #8039, many thanks to @yfede for the extensive deep-dive and for actually accurately pinpointing the issue!).
* Kobo: Handle standby transitions at full CPU clock speeds, in order to limit the latency hit.
* UIManager: Properly quit on reboot & exit. This ensures our exit code is preserved, as we exit on our own terms (instead of being killed by the init system). This is important on platforms where exit codes are semantically meaningful (e.g., Kobo).
* UIManager: Speaking of reboot & exit, make sure the Screensaver shows in all circumstances (e.g., autoshutdown, re: #9542)), and that there aren't any extraneous refreshes triggered. (Additionally, fix a minor regression since #9448 about tracking this very transient state on Kobo & Cervantes).
* Kindle: ID the upcoming Scribe.
* Bump base (https://github.com/koreader/koreader-base/pull/1524)
2022-10-02 03:01:49 +02:00
|
|
|
UIManager.event_handlers.PowerPress()
|
|
|
|
|
UIManager.event_handlers.PowerRelease()
|
2022-09-10 13:45:31 +02:00
|
|
|
assert.stub(readerui.onFlushSettings).was_called()
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
UIManager.forceRePaint:revert()
|
|
|
|
|
Device.initNetworkManager:revert()
|
2022-09-10 13:45:31 +02:00
|
|
|
Device.suspend:revert()
|
|
|
|
|
readerui.onFlushSettings:revert()
|
2022-11-07 17:40:45 +01:00
|
|
|
Device.screen_saver_mode = false
|
2022-09-10 13:45:31 +02:00
|
|
|
readerui:onClose()
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
it("Remarkable", function()
|
|
|
|
|
io.open = function(filename, mode)
|
|
|
|
|
if filename == "/usr/bin/xochitl" then
|
|
|
|
|
return {
|
|
|
|
|
read = function()
|
|
|
|
|
return true
|
|
|
|
|
end,
|
|
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
elseif filename == "/sys/devices/soc0/machine" then
|
|
|
|
|
return {
|
|
|
|
|
read = function()
|
|
|
|
|
return "reMarkable", "generic"
|
|
|
|
|
end,
|
|
|
|
|
close = function() end
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return iopen(filename, mode)
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-05-18 23:13:43 +02:00
|
|
|
local Device = require("device/remarkable/device")
|
|
|
|
|
stub(Device, "initNetworkManager")
|
|
|
|
|
stub(Device, "suspend")
|
|
|
|
|
Device:init()
|
|
|
|
|
Device.powerd.fl = nil
|
|
|
|
|
package.loaded.device = Device
|
|
|
|
|
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
|
stub(UIManager, "forceRePaint")
|
|
|
|
|
UIManager:init()
|
|
|
|
|
|
2022-09-10 13:45:31 +02:00
|
|
|
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
2023-05-18 23:13:43 +02:00
|
|
|
ReaderUI:doShowReader(sample_pdf)
|
2023-07-03 17:43:13 +03:00
|
|
|
local readerui = ReaderUI.instance
|
2023-05-18 23:13:43 +02:00
|
|
|
stub(readerui, "onFlushSettings")
|
|
|
|
|
UIManager.event_handlers.PowerPress()
|
|
|
|
|
UIManager.event_handlers.PowerRelease()
|
|
|
|
|
assert.stub(readerui.onFlushSettings).was_called()
|
2022-09-10 13:45:31 +02:00
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
UIManager.forceRePaint:revert()
|
|
|
|
|
Device.initNetworkManager:revert()
|
|
|
|
|
Device.suspend:revert()
|
|
|
|
|
readerui.onFlushSettings:revert()
|
|
|
|
|
Device.screen_saver_mode = false
|
|
|
|
|
readerui:onClose()
|
|
|
|
|
end)
|
2022-09-10 13:45:31 +02:00
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
it("SDL", function()
|
|
|
|
|
local Device = require("device/sdl/device")
|
|
|
|
|
stub(Device, "initNetworkManager")
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(Device, "suspend")
|
2023-05-18 23:13:43 +02:00
|
|
|
Device:init()
|
|
|
|
|
package.loaded.device = Device
|
2022-09-10 13:45:31 +02:00
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local UIManager = require("ui/uimanager")
|
2022-09-10 13:45:31 +02:00
|
|
|
UIManager:init()
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
local sample_pdf = "spec/front/unit/data/tall.pdf"
|
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
2022-09-10 13:45:31 +02:00
|
|
|
ReaderUI:doShowReader(sample_pdf)
|
2023-07-03 17:43:13 +03:00
|
|
|
local readerui = ReaderUI.instance
|
2022-09-10 13:45:31 +02:00
|
|
|
stub(readerui, "onFlushSettings")
|
2023-05-18 23:13:43 +02:00
|
|
|
-- UIManager.event_handlers.PowerPress() -- We only fake a Release event on the Emu
|
Assorted bag'o tweaks & fixes (#9569)
* UIManager: Support more specialized update modes for corner-cases:
* A2, which we'll use for the VirtualKeyboards keys (they'd... inadvertently switched to UI with the highlight refactor).
* NO_MERGE variants of ui & partial (for sunxi). Use `[ui]` in ReaderHighlight's popup, because of a Sage kernel bug that could otherwise make it translucent, sometimes completely so (*sigh*).
* UIManager: Assorted code cleanups & simplifications.
* Logger & dbg: Unify logging style, and code cleanups.
* SDL: Unbreak suspend/resume outside of the emulator (fix #9567).
* NetworkMgr: Cache the network status, and allow it to be queried. (Used by AutoSuspend to avoid repeatedly poking the system when computing the standby schedule delay).
* OneTimeMigration: Don't forget about `NETWORK_PROXY` & `STARDICT_DATA_DIR` when migrating `defaults.persistent.lua` (fix #9573)
* WakeupMgr: Workaround an apparent limitation of the RTC found on i.MX5 Kobo devices, where setting a wakealarm further than UINT16_MAX seconds in the future would apparently overflow and wraparound... (fix #8039, many thanks to @yfede for the extensive deep-dive and for actually accurately pinpointing the issue!).
* Kobo: Handle standby transitions at full CPU clock speeds, in order to limit the latency hit.
* UIManager: Properly quit on reboot & exit. This ensures our exit code is preserved, as we exit on our own terms (instead of being killed by the init system). This is important on platforms where exit codes are semantically meaningful (e.g., Kobo).
* UIManager: Speaking of reboot & exit, make sure the Screensaver shows in all circumstances (e.g., autoshutdown, re: #9542)), and that there aren't any extraneous refreshes triggered. (Additionally, fix a minor regression since #9448 about tracking this very transient state on Kobo & Cervantes).
* Kindle: ID the upcoming Scribe.
* Bump base (https://github.com/koreader/koreader-base/pull/1524)
2022-10-02 03:01:49 +02:00
|
|
|
UIManager.event_handlers.PowerRelease()
|
2022-09-10 13:45:31 +02:00
|
|
|
assert.stub(readerui.onFlushSettings).was_called()
|
|
|
|
|
|
2023-05-18 23:13:43 +02:00
|
|
|
Device.initNetworkManager:revert()
|
2022-09-10 13:45:31 +02:00
|
|
|
Device.suspend:revert()
|
|
|
|
|
readerui.onFlushSettings:revert()
|
2022-11-07 17:40:45 +01:00
|
|
|
Device.screen_saver_mode = false
|
2022-09-10 13:45:31 +02:00
|
|
|
readerui:onClose()
|
|
|
|
|
end)
|
|
|
|
|
end)
|
2017-08-08 22:35:40 +02:00
|
|
|
-- luacheck: pop
|
2016-04-02 21:52:30 -07:00
|
|
|
end)
|