test_timingservice.js
Go to the documentation of this file.
1 
27 function newAppRelativeFile( path ) {
28 
29  var file = Cc["@mozilla.org/file/directory_service;1"]
30  .getService(Ci.nsIProperties)
31  .get("resource:app", Ci.nsIFile);
32  file = file.clone();
33 
34  var nodes = path.split("/");
35  for ( var i = 0, end = nodes.length; i < end; i++ )
36  {
37  file.append( nodes[ i ] );
38  }
39 
40  return file;
41 }
42 
43 function runTest () {
44  var timingService = Cc["@songbirdnest.com/Songbird/TimingService;1"]
45  .getService(Ci.sbITimingService);
46 
47  var logFile = newAppRelativeFile("timingServiceLog.txt");
48  timingService.logFile = logFile;
49 
50  timingService.startPerfTimer("testTimer");
51  timingService.startPerfTimer("anotherTimer");
52 
53  sleep(1000);
54 
55  var actualTotalTime = timingService.stopPerfTimer("testTimer");
56  var anotherTotalTime = timingService.stopPerfTimer("anotherTimer");
57 
58  log("Actual total time of performance timer is: " + actualTotalTime + "us");
59 
60  assertTrue(actualTotalTime >= 1000,
61  "welcome to the impossible! time travel!");
62 
63  return Components.results.NS_OK;
64 }
65 
function sleep(ms, suppressOutput)
const Cc
function log(s)
function runTest()
Advanced DataRemote unit tests.
function assertTrue(aTest, aMessage)
function newAppRelativeFile(path)
const Ci
_getSelectedPageStyle s i
var file