Bug 1197612 - In test_TelemetrySendOldPings.js, set the FHR pref to the value the tests assume it has. r=gfritzsche, a=sledru
authoraleth <aleth@instantbird.org>
Mon, 24 Aug 2015 12:38:49 +0200
changeset 288900 4386fc15cc9d1ab1a06f924ddfcb756759668a34
parent 288899 affe675fc3c62b88073aeaaf7ccb195a422b0411
child 288901 05f2f11077f58a0d417733cd55f6d95ae884c7dd
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche, sledru
bugs1197612
milestone42.0a2
Bug 1197612 - In test_TelemetrySendOldPings.js, set the FHR pref to the value the tests assume it has. r=gfritzsche, a=sledru
toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
--- a/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetrySendOldPings.js
@@ -33,16 +33,18 @@ const OVERDUE_PING_FILE_AGE = TelemetryS
 const PING_SAVE_FOLDER = "saved-telemetry-pings";
 const PING_TIMEOUT_LENGTH = 5000;
 const OVERDUE_PINGS = 6;
 const OLD_FORMAT_PINGS = 4;
 const RECENT_PINGS = 4;
 
 const TOTAL_EXPECTED_PINGS = OVERDUE_PINGS + RECENT_PINGS + OLD_FORMAT_PINGS;
 
+const PREF_FHR_UPLOAD = "datareporting.healthreport.uploadEnabled";
+
 let gCreatedPings = 0;
 let gSeenPings = 0;
 
 /**
  * Creates some Telemetry pings for the and saves them to disk. Each ping gets a
  * unique ID based on an incrementor.
  *
  * @param {Array} aPingInfos An array of ping type objects. Each entry must be an
@@ -54,17 +56,17 @@ let gSeenPings = 0;
  * @resolve an Array with the created pings ids.
  */
 let createSavedPings = Task.async(function* (aPingInfos) {
   let pingIds = [];
   let now = Date.now();
 
   for (let type in aPingInfos) {
     let num = aPingInfos[type].num;
-    let age = now - aPingInfos[type].age;
+    let age = now - (aPingInfos[type].age || 0);
     for (let i = 0; i < num; ++i) {
       let pingId = yield TelemetryController.addPendingPing("test-ping", {}, { overwrite: true });
       if (aPingInfos[type].age) {
         // savePing writes to the file synchronously, so we're good to
         // modify the lastModifedTime now.
         let filePath = getSavePathForPingId(pingId);
         yield File.setDates(filePath, null, age);
       }
@@ -174,16 +176,19 @@ function run_test() {
   run_next_test();
 }
 
 /**
  * Setup the tests by making sure the ping storage directory is available, otherwise
  * |TelemetryController.testSaveDirectoryToFile| could fail.
  */
 add_task(function* setupEnvironment() {
+  // The following tests assume this pref to be true by default.
+  Services.prefs.setBoolPref(PREF_FHR_UPLOAD, true);
+
   yield TelemetryController.setup();
 
   let directory = TelemetryStorage.pingDirectoryPath;
   yield File.makeDir(directory, { ignoreExisting: true, unixMode: OS.Constants.S_IRWXU });
 
   yield clearPendingPings();
 });
 
@@ -392,17 +397,16 @@ add_task(function* test_overdue_old_form
   Assert.equal(receivedPings, 1, "We must receive a ping in the old format.");
 
   yield clearPendingPings();
   PingServer.resetPingHandler();
 });
 
 add_task(function* test_pendingPingsQuota() {
   const PING_TYPE = "foo";
-  const PREF_FHR_UPLOAD = "datareporting.healthreport.uploadEnabled";
 
   // Disable upload so pings don't get sent and removed from the pending pings directory.
   Services.prefs.setBoolPref(PREF_FHR_UPLOAD, false);
 
   // Remove all the pending pings then startup and wait for the cleanup task to complete.
   // There should be nothing to remove.
   yield clearPendingPings();
   yield TelemetryController.reset();