Bug 720636 - Permanent orange: TEST-UNEXPECTED-FAIL | test_TelemetryPing.js | false == true. Update the test to not rely on the graphics hardware installed as it is really just testing that the hardware information gets reported. r=jdaggett,a=akeybl
authorMark Banner <bugzilla@standard8.plus.com>
Mon, 13 Feb 2012 10:05:53 +0000
changeset 87215 dfb7c3567c492805465fe1ebf01a52e5e0f5fa1e
parent 87214 57a4882d9b7885a0113e54d4e2fbf1dd8d2a1d26
child 87216 77b10632390c2be7a75c6da29fe99c3f9b42dc06
push id875
push userbugzilla@standard8.plus.com
push dateMon, 20 Feb 2012 09:58:26 +0000
treeherdermozilla-aurora@dfb7c3567c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdaggett, akeybl
bugs720636
milestone12.0a2
Bug 720636 - Permanent orange: TEST-UNEXPECTED-FAIL | test_TelemetryPing.js | false == true. Update the test to not rely on the graphics hardware installed as it is really just testing that the hardware information gets reported. r=jdaggett,a=akeybl
toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
--- a/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
+++ b/toolkit/components/telemetry/tests/unit/test_TelemetryPing.js
@@ -10,18 +10,18 @@
 
 do_load_httpd_js();
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/LightweightThemeManager.jsm");
 
 const PATH = "/submit/telemetry/test-ping";
 const SERVER = "http://localhost:4444";
 const IGNORE_HISTOGRAM = "test::ignore_me";
-const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED"
-const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also"
+const IGNORE_HISTOGRAM_TO_CLONE = "MEMORY_HEAP_ALLOCATED";
+const IGNORE_CLONED_HISTOGRAM = "test::ignore_me_also";
 
 const BinaryInputStream = Components.Constructor(
   "@mozilla.org/binaryinputstream;1",
   "nsIBinaryInputStream",
   "setInputStream");
 const Telemetry = Cc["@mozilla.org/base/telemetry;1"].getService(Ci.nsITelemetry);
 
 var httpserver = new nsHttpServer();
@@ -56,39 +56,46 @@ function telemetryObserver(aSubject, aTo
 function checkHistograms(request, response) {
   // do not need the http server anymore
   httpserver.stop(do_test_finished);
   let s = request.bodyInputStream;
   let payload = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON)
                                              .decodeFromStream(s, s.available());
 
   do_check_eq(request.getHeader("content-type"), "application/json; charset=UTF-8");
-  do_check_true(payload.simpleMeasurements.uptime >= 0)
+  do_check_true(payload.simpleMeasurements.uptime >= 0);
   do_check_true(payload.simpleMeasurements.startupInterrupted === 1);
   // get rid of the non-deterministic field
   const expected_info = {
     reason: "test-ping",
     OS: "XPCShell", 
     appID: "xpcshell@tests.mozilla.org", 
     appVersion: "1", 
     appName: "XPCShell", 
     appBuildID: "2007010101",
     platformBuildID: "2007010101"
   };
 
   for (let f in expected_info) {
     do_check_eq(payload.info[f], expected_info[f]);
   }
 
-  var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
-  var isOSX = ("nsILocalFileMac" in Components.interfaces);
+  try {
+    // If we've not got nsIGfxInfoDebug, then this will throw and stop us doing
+    // this test.
+    var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
+    var isWindows = ("@mozilla.org/windows-registry-key;1" in Components.classes);
+    var isOSX = ("nsILocalFileMac" in Components.interfaces);
 
-  if (isWindows || isOSX) {
-    do_check_true("adapterVendorID" in payload.info);
-    do_check_true("adapterDeviceID" in payload.info);
+    if (isWindows || isOSX) {
+      do_check_true("adapterVendorID" in payload.info);
+      do_check_true("adapterDeviceID" in payload.info);
+    }
+  }
+  catch (x) {
   }
 
   const TELEMETRY_PING = "TELEMETRY_PING";
   const TELEMETRY_SUCCESS = "TELEMETRY_SUCCESS";
   do_check_true(TELEMETRY_PING in payload.histograms);
   let rh = Telemetry.registeredHistograms;
   for (let name in rh) {
     if (/SQLITE/.test(name) && name in payload.histograms) {
@@ -100,18 +107,18 @@ function checkHistograms(request, respon
 
   // There should be one successful report from the previous telemetry ping.
   const expected_tc = {
     range: [1, 2],
     bucket_count: 3,
     histogram_type: 2,
     values: {0:1, 1:1, 2:0},
     sum: 1
-  }
-  let tc = payload.histograms[TELEMETRY_SUCCESS]
+  };
+  let tc = payload.histograms[TELEMETRY_SUCCESS];
   do_check_eq(uneval(tc), 
               uneval(expected_tc));
 
   do_check_true(("mainThread" in payload.slowSQL) &&
                 ("otherThreads" in payload.slowSQL));
   gFinished = true;
 }
 
@@ -171,26 +178,34 @@ function dummyTheme(id) {
     headerURL: "http://lwttest.invalid/a.png",
     footerURL: "http://lwttest.invalid/b.png",
     textcolor: Math.random().toString(),
     accentcolor: Math.random().toString()
   };
 }
 
 function run_test() {
+  try {
+    var gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfoDebug);
+    gfxInfo.spoofVendorID("0xabcd");
+    gfxInfo.spoofDeviceID("0x1234");
+  } catch (x) {
+    // If we can't test gfxInfo, that's fine, we'll note it later.
+  }
+
   // Addon manager needs a profile directory
   do_get_profile();
   createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
   // try to make LightweightThemeManager do stuff
   let gInternalManager = Cc["@mozilla.org/addons/integration;1"]
                          .getService(Ci.nsIObserver)
                          .QueryInterface(Ci.nsITimerCallback);
 
   gInternalManager.observe(null, "addons-startup", null);
   LightweightThemeManager.currentTheme = dummyTheme("1234");
 
   Services.obs.addObserver(nonexistentServerObserver, "telemetry-test-xhr-complete", false);
   telemetry_ping();
   // spin the event loop
   do_test_pending();
   // ensure that test runs to completion
-  do_register_cleanup(function () do_check_true(gFinished))
+  do_register_cleanup(function () do_check_true(gFinished));
  }