2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/spec/unit/screenshoter_spec.lua
yparitcher f7d538b108
Landscape FM / Refactor rotation (#6309)
* landscape FM / Refactor rotation

refactor and simplify the orientation handling code. the user generally cares about the rotation (what direction the device is facing) and not about if koreader is displaying in portrait or landscape mode

* bump base

update luasocket, libjpeg-turbo, curl
add logging to evernote-sdk-lua
update framebuffer for proper rotation
2020-07-01 16:17:41 -04:00

48 lines
1.8 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.ORIENTATION_PORTRAIT))
end)
it("should get screenshot in portrait", function()
local name = "screenshots/reader_screenshot_portrait.png"
readerui:handleEvent(Event:new("SetRotationMode", Screen.ORIENTATION_PORTRAIT))
UIManager:quit()
UIManager:show(readerui)
UIManager:scheduleIn(1, function() UIManager:close(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.ORIENTATION_LANDSCAPE))
UIManager:quit()
UIManager:show(readerui)
UIManager:scheduleIn(2, function() UIManager:close(readerui) end)
UIManager:run()
readerui.screenshot:onScreenshot(name)
assert.truthy(lfs.attributes(name, "mode"))
UIManager:quit()
end)
end)