2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/spec/unit/screenshoter_spec.lua

58 lines
2.0 KiB
Lua
Raw Normal View History

2014-11-05 08:58:09 +00:00
describe("ReaderScreenshot module", function()
local DocumentRegistry, ReaderUI, lfs, UIManager, Event, Screen
2014-11-05 08:58:09 +00:00
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
2014-11-05 08:58:09 +00:00
readerui = ReaderUI:new{
dimen = Screen:getSize(),
2014-11-05 08:58:09 +00:00
document = DocumentRegistry:openDocument(sample_epub),
}
end)
teardown(function()
readerui:handleEvent(Event:new("SetRotationMode", Screen.DEVICE_ROTATED_UPRIGHT))
readerui:closeDocument()
readerui:onClose()
end)
2014-11-05 08:58:09 +00:00
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()
2014-11-05 08:58:09 +00:00
UIManager:show(readerui)
UIManager:scheduleIn(1, function()
UIManager:close(readerui)
-- We haven't torn it down yet
ReaderUI.instance = readerui
end)
2014-11-05 08:58:09 +00:00
UIManager:run()
readerui.screenshot:onScreenshot(name)
assert.truthy(lfs.attributes(name, "mode"))
UIManager:quit()
2014-11-05 08:58:09 +00:00
end)
2014-11-05 08:58:09 +00:00
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()
2014-11-05 08:58:09 +00:00
UIManager:show(readerui)
UIManager:scheduleIn(2, function()
UIManager:close(readerui)
-- We haven't torn it down yet
ReaderUI.instance = readerui
end)
2014-11-05 08:58:09 +00:00
UIManager:run()
readerui.screenshot:onScreenshot(name)
assert.truthy(lfs.attributes(name, "mode"))
UIManager:quit()
2014-11-05 08:58:09 +00:00
end)
end)