mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
tests: improve frontend testsuite isolation
This commit is contained in:
committed by
Frans de Jonge
parent
8005275388
commit
8c839d9ead
@@ -1,21 +1,23 @@
|
||||
describe("FileManager module", function()
|
||||
local FileManager, lfs, docsettings, UIManager, Screen, util
|
||||
local DataStorage, FileManager, lfs, docsettings, UIManager, Screen, makePath, util
|
||||
setup(function()
|
||||
require("commonrequire")
|
||||
package.unloadAll()
|
||||
require("document/canvascontext"):init(require("device"))
|
||||
DataStorage = require("datastorage")
|
||||
FileManager = require("apps/filemanager/filemanager")
|
||||
Screen = require("device").screen
|
||||
UIManager = require("ui/uimanager")
|
||||
docsettings = require("docsettings")
|
||||
lfs = require("libs/libkoreader-lfs")
|
||||
makePath = require("util").makePath
|
||||
util = require("ffi/util")
|
||||
end)
|
||||
it("should show file manager", function()
|
||||
UIManager:quit()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
root_path = "spec/front/unit/data",
|
||||
}
|
||||
UIManager:show(filemanager)
|
||||
UIManager:scheduleIn(1, function() filemanager:onClose() end)
|
||||
@@ -24,7 +26,7 @@ describe("FileManager module", function()
|
||||
it("should show error on non-existent file", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
root_path = "spec/front/unit/data",
|
||||
}
|
||||
local old_show = UIManager.show
|
||||
local tmp_fn = "/abc/123/test/foo.bar.baz.tmp.epub.pdf"
|
||||
@@ -39,15 +41,15 @@ describe("FileManager module", function()
|
||||
it("should not delete not empty sidecar folder", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
root_path = "spec/front/unit/data",
|
||||
}
|
||||
|
||||
local tmp_fn = "../../test/2col.test.tmp.foo"
|
||||
util.copyFile("../../test/2col.pdf", tmp_fn)
|
||||
local tmp_fn = DataStorage:getDataDir() .. "/2col.test.tmp.foo"
|
||||
util.copyFile("spec/front/unit/data/2col.pdf", tmp_fn)
|
||||
|
||||
local tmp_sidecar = docsettings:getSidecarDir(util.realpath(tmp_fn))
|
||||
lfs.mkdir(tmp_sidecar)
|
||||
local tmp_sidecar_file = docsettings:getSidecarDir(util.realpath(tmp_fn)).."/"..docsettings.getSidecarFilename(util.realpath(tmp_fn))
|
||||
local tmp_sidecar = docsettings:getSidecarDir(tmp_fn)
|
||||
makePath(tmp_sidecar)
|
||||
local tmp_sidecar_file = docsettings.getSidecarFilename(tmp_fn)
|
||||
local tmp_sidecar_file_foo = tmp_sidecar_file .. ".foo" -- non-docsettings file
|
||||
local tmpsf = io.open(tmp_sidecar_file, "w")
|
||||
tmpsf:write("{}")
|
||||
@@ -77,15 +79,15 @@ describe("FileManager module", function()
|
||||
it("should delete document with its settings", function()
|
||||
local filemanager = FileManager:new{
|
||||
dimen = Screen:getSize(),
|
||||
root_path = "../../test",
|
||||
root_path = "spec/front/unit/data",
|
||||
}
|
||||
|
||||
local tmp_fn = "../../test/2col.test.tmp.pdf"
|
||||
util.copyFile("../../test/2col.pdf", tmp_fn)
|
||||
local tmp_fn = DataStorage:getDataDir() .. "/2col.test.tmp.pdf"
|
||||
util.copyFile("spec/front/unit/data/2col.pdf", tmp_fn)
|
||||
|
||||
local tmp_sidecar = docsettings:getSidecarDir(util.realpath(tmp_fn))
|
||||
lfs.mkdir(tmp_sidecar)
|
||||
local tmp_sidecar_file = docsettings:getSidecarDir(util.realpath(tmp_fn)).."/"..docsettings.getSidecarFilename(util.realpath(tmp_fn))
|
||||
local tmp_sidecar = docsettings:getSidecarDir(tmp_fn)
|
||||
makePath(tmp_sidecar)
|
||||
local tmp_sidecar_file = docsettings.getSidecarFilename(tmp_fn)
|
||||
local tmpsf = io.open(tmp_sidecar_file, "w")
|
||||
tmpsf:write("{}")
|
||||
tmpsf:close()
|
||||
|
||||
Reference in New Issue
Block a user