mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fake battery status in readerfooter_spec to succeed on devices with batteries (#6417)
Cf. <https://github.com/koreader/koreader/pull/6370#issuecomment-662382487>.
This commit is contained in:
@@ -5,7 +5,7 @@ local SDLPowerD = BasePowerD:new{}
|
||||
|
||||
function SDLPowerD:getCapacityHW()
|
||||
local _, _, _, percent = SDL.getPowerInfo()
|
||||
-- never return negative values, since tests rely on battery being 0%
|
||||
-- -1 looks a bit odd compared to 0
|
||||
if percent == -1 then return 0 end
|
||||
return percent
|
||||
end
|
||||
|
||||
@@ -6,7 +6,11 @@ describe("Readerfooter module", function()
|
||||
setup(function()
|
||||
require("commonrequire")
|
||||
package.unloadAll()
|
||||
require("document/canvascontext"):init(require("device"))
|
||||
local Device = require("device")
|
||||
-- Override powerd for running tests on devices with batteries.
|
||||
Device.powerd.isChargingHW = function() return false end
|
||||
Device.powerd.getCapacityHW = function() return 0 end
|
||||
require("document/canvascontext"):init(Device)
|
||||
DocumentRegistry = require("document/documentregistry")
|
||||
DocSettings = require("docsettings")
|
||||
ReaderUI = require("apps/reader/readerui")
|
||||
|
||||
Reference in New Issue
Block a user