2014-11-05 08:58:09 +00:00
|
|
|
describe("ReaderScreenshot module", function()
|
2017-08-08 20:35:40 +00:00
|
|
|
local DocumentRegistry, ReaderUI, lfs, UIManager, Event
|
2014-11-05 08:58:09 +00:00
|
|
|
local sample_epub = "spec/front/unit/data/leaves.epub"
|
|
|
|
local readerui
|
|
|
|
setup(function()
|
2016-06-02 04:32:35 +00:00
|
|
|
require("commonrequire")
|
|
|
|
DocumentRegistry = require("document/documentregistry")
|
|
|
|
ReaderUI = require("apps/reader/readerui")
|
|
|
|
lfs = require("libs/libkoreader-lfs")
|
|
|
|
UIManager = require("ui/uimanager")
|
|
|
|
Event = require("ui/event")
|
|
|
|
|
2014-11-05 08:58:09 +00:00
|
|
|
readerui = ReaderUI:new{
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
}
|
|
|
|
end)
|
2016-06-02 04:32:35 +00:00
|
|
|
|
2016-08-11 09:12:55 +00:00
|
|
|
teardown(function()
|
|
|
|
readerui:handleEvent(Event:new("ChangeScreenMode", "portrait"))
|
|
|
|
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("ChangeScreenMode", "portrait"))
|
2014-11-05 10:06:05 +00:00
|
|
|
UIManager:quit()
|
2014-11-05 08:58:09 +00:00
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:scheduleIn(1, function() UIManager:close(readerui) end)
|
|
|
|
UIManager:run()
|
|
|
|
readerui.screenshot:onScreenshot(name)
|
|
|
|
assert.truthy(lfs.attributes(name, "mode"))
|
2016-06-02 04:32:35 +00:00
|
|
|
UIManager:quit()
|
2014-11-05 08:58:09 +00:00
|
|
|
end)
|
2016-06-02 04:32:35 +00:00
|
|
|
|
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("ChangeScreenMode", "landscape"))
|
2014-11-05 10:06:05 +00:00
|
|
|
UIManager:quit()
|
2014-11-05 08:58:09 +00:00
|
|
|
UIManager:show(readerui)
|
|
|
|
UIManager:scheduleIn(2, function() UIManager:close(readerui) end)
|
|
|
|
UIManager:run()
|
|
|
|
readerui.screenshot:onScreenshot(name)
|
|
|
|
assert.truthy(lfs.attributes(name, "mode"))
|
2016-06-02 04:32:35 +00:00
|
|
|
UIManager:quit()
|
2014-11-05 08:58:09 +00:00
|
|
|
end)
|
|
|
|
end)
|