• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE HTML>
2<html>
3<!--
4Copyright (c) 2012 The Chromium Authors. All rights reserved.
5Use of this source code is governed by a BSD-style license that can be
6found in the LICENSE file.
7-->
8<head>
9<title>TimelineAsyncSliceGroup tests</title>
10<script src="base.js"></script>
11</head>
12<body>
13  <script>
14    base.require('unittest');
15    base.require('test_utils');
16    base.require('timeline_model');
17  </script>
18  <script>
19    'use strict';
20
21  var TimelineProcess = tracing.TimelineProcess;
22  var TimelineThread = tracing.TimelineThread;
23  var TimelineModel = tracing.TimelineModel;
24  var TimelineAsyncSlice = tracing.TimelineAsyncSlice;
25  var TimelineAsyncSliceGroup = tracing.TimelineAsyncSliceGroup;
26  var newAsyncSlice = test_utils.newAsyncSlice;
27
28  function testAsyncSliceGroupBounds_Empty() {
29    var g = new TimelineAsyncSliceGroup(name);
30    g.updateBounds();
31    assertEquals(undefined, g.minTimestamp);
32    assertEquals(undefined, g.maxTimestamp);
33  }
34
35  function testAsyncSliceGroupBounds_Basic() {
36    var p1 = new TimelineProcess(1);
37    var t1 = new TimelineThread(p1, 1);
38    var g = new TimelineAsyncSliceGroup('a');
39    g.push(newAsyncSlice(0, 1, t1, t1));
40    g.push(newAsyncSlice(1, 1.5, t1, t1));
41    assertEquals(2, g.length);
42    g.updateBounds();
43    assertEquals(0, g.minTimestamp);
44    assertEquals(2.5, g.maxTimestamp);
45  }
46
47  function testAsyncSlice_toJSON() {
48    var js = [
49      '{',
50      '  "category" : "",',
51      '  "title" : "a",',
52      '  "start" : 0,',
53      '  "colorId" : 0,',
54      '  "didNotFinish" : false,',
55      '  "duration" : 1,',
56      '  "startThread" : "1:1",',
57      '  "endThread" : "1:1",',
58      '  "subSlices" : [ {',
59      '        "category" : "",',
60      '        "title" : "a",',
61      '        "start" : 0,',
62      '        "colorId" : 0,',
63      '        "didNotFinish" : false,',
64      '        "duration" : 1,',
65      '        "startThread" : "1:1",',
66      '        "endThread" : "1:1"',
67      '      } ]',
68      '}'].join('\n');
69    // Modify whitespace of "js" so that string compare with another
70    // JSON.stringified version can succeed.
71    js = JSON.stringify(JSON.parse(js));
72
73    var p1 = new TimelineProcess(1);
74    var t1 = new TimelineThread(p1, 1);
75    var s = newAsyncSlice(0, 1, t1, t1);
76
77    assertEquals(js, JSON.stringify(s));
78  }
79
80</script>
81</body>
82</html>
83