Bug 964270 - Part 2: Update tests. r=gene
authorAlbert Crespell <acperez@tid.es>
Thu, 30 Jan 2014 21:24:40 +0100
changeset 178055 c2852f280c71cf2ec017031eaf8efcfda8707db6
parent 178054 3dd8d8379d2a5a74c5f1c1cc62ddded51d88168a
child 178056 f4784457271eadee12bf650f6a716efa1d8d7996
push id5439
push userffxbld
push dateMon, 17 Mar 2014 23:08:15 +0000
treeherdermozilla-aurora@c0befb3c8038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgene
bugs964270
milestone30.0a1
Bug 964270 - Part 2: Update tests. r=gene
dom/network/tests/unit_stats/test_networkstats_service.js
--- a/dom/network/tests/unit_stats/test_networkstats_service.js
+++ b/dom/network/tests/unit_stats/test_networkstats_service.js
@@ -1,13 +1,17 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
 
+const NETWORK_STATUS_READY   = 0;
+const NETWORK_STATUS_STANDBY = 1;
+const NETWORK_STATUS_AWAY    = 2;
+
 function getNetworks(callback) {
   NetworkStatsService._db.getAvailableNetworks(function onGetNetworks(aError, aResult) {
     callback(aError, aResult);
   });
 }
 
 add_test(function test_clearDB() {
   getNetworks(function onGetNetworks(error, result) {
@@ -80,19 +84,28 @@ add_test(function test_updateQueueIndex(
   index = NetworkStatsService.updateQueueIndex(10);
   do_check_eq(index, -1);
 
   NetworkStatsService.updateQueue = [];
   run_next_test();
 });
 
 add_test(function test_updateAllStats() {
+  NetworkStatsService._networks[wifiId].status = NETWORK_STATUS_READY;
   NetworkStatsService.updateAllStats(function(success, msg) {
     do_check_eq(success, true);
-    run_next_test();
+    NetworkStatsService._networks[wifiId].status = NETWORK_STATUS_STANDBY;
+    NetworkStatsService.updateAllStats(function(success, msg) {
+      do_check_eq(success, true);
+      NetworkStatsService._networks[wifiId].status = NETWORK_STATUS_AWAY;
+      NetworkStatsService.updateAllStats(function(success, msg) {
+        do_check_eq(success, true);
+        run_next_test();
+      });
+    });
   });
 });
 
 add_test(function test_updateStats_ok() {
   getNetworkId(function onGetId(error, result) {
     do_check_eq(error, null);
     var netId = result;
     NetworkStatsService.updateStats(netId, function(success, msg){
@@ -184,16 +197,18 @@ add_test(function test_setAlarm_invalid_
                 threshold: -10000,
                 absoluteThreshold: null,
                 alarmStart: null,
                 alarmEnd: null,
                 data: null,
                 pageURL: testPageURL,
                 manifestURL: testManifestURL };
 
+  NetworkStatsService._networks[wifiId].status = NETWORK_STATUS_READY;
+
   NetworkStatsService._setAlarm(alarm, function onSet(error, result) {
     do_check_eq(error, "InvalidStateError");
     run_next_test();
   });
 });
 
 add_test(function test_fireAlarm() {
   // Add a fake alarm into database.