mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 16:25:38 +00:00
Bug 1143796 - Add test for TelemetryScheduler tick interval changing when user is idle. r=gfritzsche
This commit is contained in:
parent
a29a01a271
commit
8df60ded78
@ -137,6 +137,11 @@ function fakeGenerateUUID(sessionFunc, subsessionFunc) {
|
||||
session.Policy.generateSubsessionUUID = subsessionFunc;
|
||||
}
|
||||
|
||||
function fakeIdleNotification(topic) {
|
||||
let session = Cu.import("resource://gre/modules/TelemetrySession.jsm");
|
||||
session.TelemetryScheduler.observe(null, topic, null);
|
||||
}
|
||||
|
||||
function registerPingHandler(handler) {
|
||||
gHttpServer.registerPrefixHandler("/submit/telemetry/",
|
||||
wrapWithExceptionHandler(handler));
|
||||
@ -1615,6 +1620,39 @@ add_task(function* test_pingExtendedStats() {
|
||||
"UITelemetry must be sent if the extended set is on.");
|
||||
});
|
||||
|
||||
add_task(function* test_schedulerUserIdle() {
|
||||
if (gIsAndroid || gIsGonk) {
|
||||
// We don't have the aborted session or the daily ping here.
|
||||
return;
|
||||
}
|
||||
|
||||
const SCHEDULER_TICK_INTERVAL_MS = 5 * 60 * 1000;
|
||||
const SCHEDULER_TICK_IDLE_INTERVAL_MS = 60 * 60 * 1000;
|
||||
|
||||
let schedulerTimeout = 0;
|
||||
fakeSchedulerTimer((callback, timeout) => {
|
||||
schedulerTimeout = timeout;
|
||||
}, () => {});
|
||||
yield TelemetrySession.reset();
|
||||
|
||||
// When not idle, the scheduler should have a 5 minutes tick interval.
|
||||
Assert.equal(schedulerTimeout, SCHEDULER_TICK_INTERVAL_MS);
|
||||
|
||||
// Send an "idle" notification to the scheduler.
|
||||
fakeIdleNotification("idle");
|
||||
|
||||
// When idle, the scheduler should have a 1hr tick interval.
|
||||
Assert.equal(schedulerTimeout, SCHEDULER_TICK_IDLE_INTERVAL_MS);
|
||||
|
||||
// Send an "active" notification to the scheduler.
|
||||
fakeIdleNotification("active");
|
||||
|
||||
// When user is back active, the scheduler tick should be 5 minutes again.
|
||||
Assert.equal(schedulerTimeout, SCHEDULER_TICK_INTERVAL_MS);
|
||||
|
||||
yield TelemetrySession.shutdown();
|
||||
});
|
||||
|
||||
add_task(function* stopServer(){
|
||||
gHttpServer.stop(do_test_finished);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user