Html程序  |  61行  |  1.31 KB

<!DOCTYPE HTML>
<html>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>Process tests</title>
<style>
  .view {
    border: 1px solid black;
    margin: 10px;
  }
  .find-dialog {
    border: 1px solid black;
    margin: 10px;
  }
</style>
<script src="/src/base.js"></script>
<script>
  base.require('unittest');
  base.require('test_utils');
  base.require('model.process');
</script>
</head>
<body>
<script>
  'use strict';

  var Process = tracing.model.Process;

  function testGetOrCreateCounter() {
    var process = new Process(7);
    var ctrBar = process.getOrCreateCounter('foo', 'bar');
    var ctrBar2 = process.getOrCreateCounter('foo', 'bar');
    assertEquals(ctrBar2, ctrBar);
  }

  function testShiftTimestampsForward() {
    var process = new Process(7);
    var ctr = process.getOrCreateCounter('foo', 'bar');
    var thread = process.getOrCreateThread(1);

    var shiftCount = 0;
    thread.shiftTimestampsForward = function(ts) {
      if (ts == 0.32)
        shiftCount++;
    };
    ctr.shiftTimestampsForward = function(ts) {
      if (ts == 0.32)
        shiftCount++;
    };
    process.shiftTimestampsForward(0.32);
    assertEquals(2, shiftCount);
  }

</script>
</body>
</html>