mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
788ccac561
* Get rid of the `canToggleGSensor` Device cap, it's now mandatory for `hasGSensor` devices. (This means Kindles can now toggle the gyro, fix #9136).
* This also means that `Device:toggleGSensor` is now implemented by `Generic`.
* Update the Screen & Gyro rotation constants to be clearer (c.f., https://github.com/koreader/koreader-base/pull/1568) (/!\ This might conceivably break some `rotation_map` user-patches).
* Input: Move the platform-specific gyro handling to Device implementations, and let Input only handle a single, custom protocol (`EV_MSC:MSC_GYRO`).
* Input: Refine the `rotation_map` disable method implemented in 43b021d37c
. Instead of directly poking at the internal field, use a new method, `disableRotationMap` (/!\ Again, this might break some `rotation_map` user-patches).
* Input: Minor tweaks to event adjust hooks to make them more modular, allowing the Kobo implementation to build and use a single composite hook. API compatibility maintained with wrappers.
58 lines
2.0 KiB
Lua
58 lines
2.0 KiB
Lua
describe("ReaderScreenshot module", function()
|
|
local DocumentRegistry, ReaderUI, lfs, UIManager, Event, Screen
|
|
local sample_epub = "spec/front/unit/data/leaves.epub"
|
|
local readerui
|
|
setup(function()
|
|
require("commonrequire")
|
|
DocumentRegistry = require("document/documentregistry")
|
|
ReaderUI = require("apps/reader/readerui")
|
|
lfs = require("libs/libkoreader-lfs")
|
|
UIManager = require("ui/uimanager")
|
|
Event = require("ui/event")
|
|
Screen = require("device").screen
|
|
|
|
readerui = ReaderUI:new{
|
|
dimen = Screen:getSize(),
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
}
|
|
end)
|
|
|
|
teardown(function()
|
|
readerui:handleEvent(Event:new("SetRotationMode", Screen.DEVICE_ROTATED_UPRIGHT))
|
|
readerui:closeDocument()
|
|
readerui:onClose()
|
|
end)
|
|
|
|
it("should get screenshot in portrait", function()
|
|
local name = "screenshots/reader_screenshot_portrait.png"
|
|
readerui:handleEvent(Event:new("SetRotationMode", Screen.DEVICE_ROTATED_UPRIGHT))
|
|
UIManager:quit()
|
|
UIManager:show(readerui)
|
|
UIManager:scheduleIn(1, function()
|
|
UIManager:close(readerui)
|
|
-- We haven't torn it down yet
|
|
ReaderUI.instance = readerui
|
|
end)
|
|
UIManager:run()
|
|
readerui.screenshot:onScreenshot(name)
|
|
assert.truthy(lfs.attributes(name, "mode"))
|
|
UIManager:quit()
|
|
end)
|
|
|
|
it("should get screenshot in landscape", function()
|
|
local name = "screenshots/reader_screenshot_landscape.png"
|
|
readerui:handleEvent(Event:new("SetRotationMode", Screen.DEVICE_ROTATED_CLOCKWISE))
|
|
UIManager:quit()
|
|
UIManager:show(readerui)
|
|
UIManager:scheduleIn(2, function()
|
|
UIManager:close(readerui)
|
|
-- We haven't torn it down yet
|
|
ReaderUI.instance = readerui
|
|
end)
|
|
UIManager:run()
|
|
readerui.screenshot:onScreenshot(name)
|
|
assert.truthy(lfs.attributes(name, "mode"))
|
|
UIManager:quit()
|
|
end)
|
|
end)
|