mirror of
https://github.com/koreader/koreader
synced 2024-11-04 12:00:25 +00:00
62059f8d68
* This removes support for the following deprecated constants: `DTAP_ZONE_FLIPPING`, `DTAP_ZONE_BOOKMARK`, `DCREREADER_CONFIG_DEFAULT_FONT_GAMMA` * The "Advanced settings" panel now highlights modified values in bold (think about:config in Firefox ;)). * LuaData: Isolate global table lookup shenanigans, and fix a few issues in unused-in-prod codepaths. * CodeStyle: Require module locals for Lua/C modules, too. * ScreenSaver: Actually garbage collect our widget on close (ScreenSaver itself is not an instantiated object). * DateTimeWidget: Code cleanups to ensure child widgets can be GC'ed.
50 lines
1.9 KiB
Lua
50 lines
1.9 KiB
Lua
describe("defaults module", function()
|
|
local Defaults, DataStorage, lfs, persistent_filename
|
|
setup(function()
|
|
require("commonrequire")
|
|
DataStorage = require("datastorage")
|
|
persistent_filename = DataStorage:getDataDir() .. "/defaults.defaults_spec.lua"
|
|
Defaults = require("luadefaults"):open(persistent_filename)
|
|
lfs = require("libs/libkoreader-lfs")
|
|
end)
|
|
|
|
it("should load all defaults from defaults.lua", function()
|
|
assert.is_true(Defaults:has("DHINTCOUNT"))
|
|
Defaults:close()
|
|
end)
|
|
|
|
it("should save changes to defaults.custom.lua", function()
|
|
os.remove(persistent_filename)
|
|
os.remove(persistent_filename .. ".old")
|
|
|
|
-- This defaults to false
|
|
Defaults:makeTrue("DSHOWOVERLAP")
|
|
assert.is_true(Defaults:hasBeenCustomized("DSHOWOVERLAP"))
|
|
assert.is_true(Defaults:isTrue("DSHOWOVERLAP"))
|
|
|
|
Defaults:close()
|
|
assert.is_true(lfs.attributes(persistent_filename, "mode") == "file")
|
|
|
|
Defaults = nil
|
|
Defaults = require("luadefaults"):open(persistent_filename)
|
|
assert.is_true(Defaults:hasBeenCustomized("DSHOWOVERLAP"))
|
|
assert.is_true(Defaults:isTrue("DSHOWOVERLAP"))
|
|
Defaults:makeFalse("DSHOWOVERLAP")
|
|
Defaults:close()
|
|
|
|
os.remove(persistent_filename)
|
|
os.remove(persistent_filename .. ".old")
|
|
end)
|
|
|
|
it("should delete entry from defaults.custom.lua if value is reverted back to default", function()
|
|
-- This defaults to false
|
|
Defaults:makeTrue("DSHOWOVERLAP")
|
|
assert.is_true(Defaults:hasBeenCustomized("DSHOWOVERLAP"))
|
|
assert.is_true(Defaults:isTrue("DSHOWOVERLAP"))
|
|
Defaults:makeFalse("DSHOWOVERLAP")
|
|
assert.is_true(Defaults:hasNotBeenCustomized("DSHOWOVERLAP"))
|
|
assert.is_true(Defaults:isFalse("DSHOWOVERLAP"))
|
|
Defaults:close()
|
|
end)
|
|
end)
|