2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/spec/unit/readerui_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

52 lines
2.0 KiB
Lua

describe("Readerui module", function()
local DocumentRegistry, ReaderUI, DocSettings, UIManager, 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")
DocSettings = require("docsettings")
UIManager = require("ui/uimanager")
Screen = require("device").screen
readerui = ReaderUI:new{
dimen = Screen:getSize(),
document = DocumentRegistry:openDocument(sample_epub),
}
end)
it("should save settings", function()
-- remove history settings and sidecar settings
DocSettings:open(sample_epub):purge()
local doc_settings = DocSettings:open(sample_epub)
assert.are.same(doc_settings.data, {})
readerui:saveSettings()
assert.are_not.same(readerui.doc_settings.data, {})
doc_settings = DocSettings:open(sample_epub)
assert.truthy(doc_settings.data.last_xpointer)
assert.are.same(doc_settings.data.last_xpointer,
readerui.doc_settings.data.last_xpointer)
end)
it("should show reader", function()
UIManager:quit()
UIManager:show(readerui)
UIManager:scheduleIn(1, function() UIManager:close(readerui) end)
UIManager:run()
end)
it("should close document", function()
readerui:closeDocument()
assert(readerui.document == nil)
end)
it("should not reset running_instance by mistake", function()
ReaderUI:doShowReader(sample_epub)
local new_readerui = ReaderUI:_getRunningInstance()
assert.is.truthy(new_readerui.document)
ReaderUI:new{
dimen = Screen:getSize(),
document = DocumentRegistry:openDocument(sample_epub)
}:onClose()
assert.is.truthy(new_readerui.document)
new_readerui:onClose()
end)
end)