You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/statusstats_spec.lua
+93-4Lines changed: 93 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,20 @@ local function assertTrue(value, message)
12
12
end
13
13
end
14
14
15
+
localui_manager_state= {
16
+
shown= {},
17
+
unscheduled= {},
18
+
scheduled= {},
19
+
broadcasted= {},
20
+
}
21
+
22
+
localfunctionresetUIManagerState()
23
+
ui_manager_state.shown= {}
24
+
ui_manager_state.unscheduled= {}
25
+
ui_manager_state.scheduled= {}
26
+
ui_manager_state.broadcasted= {}
27
+
end
28
+
15
29
package.preload["ui/event"] =function()
16
30
return {
17
31
new=function(_, name)
@@ -30,10 +44,25 @@ end
30
44
31
45
package.preload["ui/uimanager"] =function()
32
46
return {
33
-
show=function() end,
34
-
unschedule=function() end,
35
-
scheduleIn=function() end,
36
-
broadcastEvent=function() end,
47
+
show=function(_, widget)
48
+
table.insert(ui_manager_state.shown, widget)
49
+
end,
50
+
unschedule=function(_, callback, context)
51
+
table.insert(ui_manager_state.unscheduled, {
52
+
callback=callback,
53
+
context=context,
54
+
})
55
+
end,
56
+
scheduleIn=function(_, delay, callback, context)
57
+
table.insert(ui_manager_state.scheduled, {
58
+
delay=delay,
59
+
callback=callback,
60
+
context=context,
61
+
})
62
+
end,
63
+
broadcastEvent=function(_, event)
64
+
table.insert(ui_manager_state.broadcasted, event)
65
+
end,
37
66
}
38
67
end
39
68
@@ -85,6 +114,7 @@ local StatusStats = dofile("main.lua")
85
114
86
115
localfunctionnewPlugin(settings, stats)
87
116
saved_settings=settings
117
+
resetUIManagerState()
88
118
89
119
localfooter= {
90
120
settings= {
@@ -267,6 +297,65 @@ assertTrue(menu_text:find("Today", 1, true) ~= nil, "today menu should exist")
267
297
assertTrue(menu_text:find("Label style", 1, true) ==nil, "label style menu should be removed")
268
298
assertTrue(menu_text:find("Book stats", 1, true) ==nil, "book stats menu should be removed")
269
299
300
+
localtime_refresh_plugin=newPlugin({
301
+
show_value_in_footer=true,
302
+
session= {
303
+
time=true,
304
+
pages=false,
305
+
},
306
+
}, {
307
+
session= {
308
+
time=125,
309
+
pages=0,
310
+
},
311
+
today= {
312
+
time=0,
313
+
pages=0,
314
+
},
315
+
})
316
+
317
+
time_refresh_plugin:onReaderReady()
318
+
319
+
assertEquals(ui_manager_state.scheduled[#ui_manager_state.scheduled].delay, 55, "time-based footer refresh should align to the next minute boundary")
320
+
321
+
localpages_only_plugin=newPlugin({
322
+
show_value_in_footer=true,
323
+
session= {
324
+
time=false,
325
+
pages=true,
326
+
},
327
+
}, {
328
+
session= {
329
+
time=125,
330
+
pages=3,
331
+
},
332
+
today= {
333
+
time=0,
334
+
pages=0,
335
+
},
336
+
})
337
+
338
+
pages_only_plugin:onReaderReady()
339
+
340
+
assertEquals(#ui_manager_state.scheduled, 0, "page-only status display should not start a periodic ticker")
341
+
342
+
localscreensaver_plugin=newPlugin({
343
+
show_value_in_footer=true,
344
+
}, {
345
+
session= {
346
+
time=0,
347
+
pages=0,
348
+
},
349
+
today= {
350
+
time=0,
351
+
pages=0,
352
+
},
353
+
})
354
+
355
+
screensaver_plugin:onOutOfScreenSaver()
356
+
357
+
assertEquals(ui_manager_state.broadcasted[#ui_manager_state.broadcasted].name, "RefreshAdditionalContent", "leaving the screensaver should refresh the footer content")
0 commit comments