2014-10-07 05:06:06 +00:00
|
|
|
require("commonrequire")
|
|
|
|
local DocumentRegistry = require("document/documentregistry")
|
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
|
|
|
local DocSettings = require("docsettings")
|
2014-11-05 08:58:09 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2014-10-07 05:06:06 +00:00
|
|
|
|
|
|
|
describe("Readerui module", function()
|
|
|
|
local sample_epub = "spec/front/unit/data/leaves.epub"
|
2014-11-05 10:06:05 +00:00
|
|
|
local readerui
|
|
|
|
setup(function()
|
|
|
|
readerui = ReaderUI:new{
|
|
|
|
document = DocumentRegistry:openDocument(sample_epub),
|
|
|
|
}
|
|
|
|
end)
|
2014-10-07 05:06:06 +00:00
|
|
|
it("should save settings", function()
|
|
|
|
-- remove history settings and sidecar settings
|
|
|
|
DocSettings:open(sample_epub):clear()
|
|
|
|
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)
|
2014-11-05 08:58:09 +00:00
|
|
|
it("should show reader", function()
|
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()
|
|
|
|
end)
|
2014-10-07 05:06:06 +00:00
|
|
|
it("should close document", function()
|
|
|
|
readerui:closeDocument()
|
|
|
|
assert(readerui.document == nil)
|
|
|
|
end)
|
|
|
|
end)
|