Bug 1217282 - Add test coverage. r=gfritzsche

This commit is contained in:
Alessio Placitelli 2015-12-15 05:44:00 +01:00
Родитель 168e97983d
Коммит 9f6f7449c9
4 изменённых файлов: 30 добавлений и 0 удалений

Просмотреть файл

@ -233,3 +233,7 @@ function replaceExperiments(experiment, list) {
},
});
}
// Experiments require Telemetry to be enabled, and that's not true for debug
// builds. Let's just enable it here instead of going through each test.
Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, true);

Просмотреть файл

@ -0,0 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
Cu.import("resource:///modules/experiments/Experiments.jsm");
add_test(function test_experiments_activation() {
do_get_profile();
loadAddonManager();
Services.prefs.setBoolPref(PREF_EXPERIMENTS_ENABLED, true);
Services.prefs.setBoolPref(PREF_TELEMETRY_ENABLED, false);
let experiments = Experiments.instance();
Assert.ok(!experiments.enabled, "Experiments must be disabled if Telemetry is disabled.");
// TODO: Test that Experiments are turned back on when bug 1232648 lands.
run_next_test();
});

Просмотреть файл

@ -24,6 +24,7 @@ generated-files =
[test_disableExperiments.js]
[test_fetch.js]
[test_telemetry.js]
[test_telemetry_disabled.js]
[test_healthreport.js]
[test_previous_provider.js]
[test_upgrade.js]

Просмотреть файл

@ -98,6 +98,7 @@ add_task(function* initializeState() {
registerCleanupFunction(() => {
Services.prefs.clearUserPref("experiments.enabled");
Services.prefs.clearUserPref("toolkit.telemetry.enabled");
if (gHttpServer) {
gHttpServer.stop(() => {});
if (gSavedManifestURI !== undefined) {
@ -294,6 +295,7 @@ add_task(function* testActivateExperiment() {
// We need to remove the cache file to help ensure consistent state.
yield OS.File.remove(gExperiments._cacheFilePath);
Services.prefs.setBoolPref("toolkit.telemetry.enabled", true);
Services.prefs.setBoolPref("experiments.enabled", true);
info("Initializing experiments service.");
@ -635,6 +637,8 @@ add_task(function* testCleanup() {
yield OS.File.remove(gExperiments._cacheFilePath);
yield gExperiments.uninit();
yield gExperiments.init();
Services.prefs.clearUserPref("toolkit.telemetry.enabled");
}
// Check post-conditions.