3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/test_utils.html">
9 <link rel="import" href="/tracing/trace_model.html">
14 tvcm.unittest.testSuite(function() {
15 var ThreadSlice = tracing.trace_model.ThreadSlice;
16 var Process = tracing.trace_model.Process;
17 var Thread = tracing.trace_model.Thread;
18 var newSliceNamed = tracing.test_utils.newSliceNamed;
19 var newAsyncSlice = tracing.test_utils.newAsyncSlice;
21 test('threadBounds_Empty', function() {
22 var model = new tracing.TraceModel();
23 var t = new Thread(new Process(model, 7), 1);
25 assertEquals(undefined, t.bounds.min);
26 assertEquals(undefined, t.bounds.max);
29 test('threadBounds_SubRow', function() {
30 var model = new tracing.TraceModel();
31 var t = new Thread(new Process(model, 7), 1);
32 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3));
34 assertEquals(1, t.bounds.min);
35 assertEquals(4, t.bounds.max);
38 test('threadBounds_AsyncSliceGroup', function() {
39 var model = new tracing.TraceModel();
40 var t = new Thread(new Process(model, 7), 1);
41 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3));
42 t.asyncSliceGroup.push(newAsyncSlice(0.1, 5, t, t));
44 assertEquals(0.1, t.bounds.min);
45 assertEquals(5.1, t.bounds.max);
48 test('threadBounds_Cpu', function() {
49 var model = new tracing.TraceModel();
50 var t = new Thread(new Process(model, 7), 1);
51 t.timeSlices = [newSliceNamed('x', 0, 1)];
53 assertEquals(0, t.bounds.min);
54 assertEquals(1, t.bounds.max);
57 test('shiftTimestampsForwardWithCpu', function() {
58 var model = new tracing.TraceModel();
59 var t = new Thread(new Process(model, 7), 1);
60 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3));
61 t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t));
62 t.timeSlices = [newSliceNamed('x', 0, 1)];
65 t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
70 t.shiftTimestampsForward(0.32);
72 assertEquals(1, shiftCount);
73 assertEquals(0.32, t.sliceGroup.slices[0].start);
74 assertEquals(0.32, t.timeSlices[0].start);
77 test('shiftTimestampsForwardWithoutCpu', function() {
78 var model = new tracing.TraceModel();
79 var t = new Thread(new Process(model, 7), 1);
80 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3));
81 t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t));
84 t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
89 t.shiftTimestampsForward(0.32);
91 assertEquals(1, shiftCount);
92 assertEquals(0.32, t.sliceGroup.slices[0].start);