зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1448945 - Add test coverage for dynamic builtin events. r=chutten
MozReview-Commit-ID: AFZPTBM7QqQ --HG-- extra : rebase_source : a0052a271d66414fabd652ffb95a1be40ac472cd
This commit is contained in:
Родитель
11b35b780f
Коммит
32b432e9fb
|
@ -0,0 +1,48 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
add_task(async function test_dynamicBuiltinEvents() {
|
||||
Telemetry.clearEvents();
|
||||
Telemetry.canRecordExtended = true;
|
||||
|
||||
const TEST_EVENT_NAME = "telemetry.test.dynamicbuiltin";
|
||||
|
||||
// Register some dynbamic builtin test events.
|
||||
Telemetry.registerBuiltinEvents(TEST_EVENT_NAME, {
|
||||
// Event with only required fields.
|
||||
"test1": {
|
||||
methods: ["test1"],
|
||||
objects: ["object1"],
|
||||
},
|
||||
// Event with extra_keys.
|
||||
"test2": {
|
||||
methods: ["test2", "test2b"],
|
||||
objects: ["object1", "object2"],
|
||||
extra_keys: ["key1", "key2"],
|
||||
},
|
||||
});
|
||||
|
||||
// Record some events.
|
||||
Telemetry.recordEvent(TEST_EVENT_NAME, "test1", "object1");
|
||||
Telemetry.recordEvent(TEST_EVENT_NAME, "test2", "object1", null,
|
||||
{"key1": "foo", "key2": "bar"});
|
||||
Telemetry.recordEvent(TEST_EVENT_NAME, "test2b", "object2", null,
|
||||
{"key2": "bar"});
|
||||
// Now check that the snapshot contains the expected data.
|
||||
let snapshot =
|
||||
Telemetry.snapshotEvents(Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTIN, false);
|
||||
Assert.ok(("parent" in snapshot), "Should have parent events in the snapshot.");
|
||||
|
||||
let expected = [
|
||||
[TEST_EVENT_NAME, "test1", "object1"],
|
||||
[TEST_EVENT_NAME, "test2", "object1", null, {key1: "foo", key2: "bar"}],
|
||||
[TEST_EVENT_NAME, "test2b", "object2", null, {key2: "bar"}],
|
||||
];
|
||||
let events = snapshot.parent;
|
||||
Assert.equal(events.length, expected.length, "Should have recorded the right amount of events.");
|
||||
for (let i = 0; i < expected.length; ++i) {
|
||||
Assert.deepEqual(events[i].slice(1), expected[i],
|
||||
"Should have recorded the expected event data.");
|
||||
}
|
||||
});
|
|
@ -68,6 +68,7 @@ tags = addons
|
|||
skip-if = toolkit == 'android'
|
||||
[test_TelemetryCaptureStack.js]
|
||||
[test_TelemetryEvents.js]
|
||||
[test_TelemetryEvents_buildFaster.js]
|
||||
[test_ChildEvents.js]
|
||||
skip-if = os == "android" # Disabled due to crashes (see bug 1331366)
|
||||
[test_TelemetryModules.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче