1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 tvcm.require('tracing.test_utils');
8 tvcm.require('tracing.trace_model');
10 tvcm.unittest.testSuite('tracing.trace_model.thread_test', function() {
11 var ThreadSlice = tracing.trace_model.ThreadSlice;
12 var Process = tracing.trace_model.Process;
13 var Thread = tracing.trace_model.Thread;
14 var newSliceNamed = tracing.test_utils.newSliceNamed;
15 var newAsyncSlice = tracing.test_utils.newAsyncSlice;
17 test('threadBounds_Empty', function() {
18 var model = new tracing.TraceModel();
19 var t = new Thread(new Process(model, 7), 1);
21 assertEquals(undefined, t.bounds.min);
22 assertEquals(undefined, t.bounds.max);
25 test('threadBounds_SubRow', function() {
26 var model = new tracing.TraceModel();
27 var t = new Thread(new Process(model, 7), 1);
28 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3));
30 assertEquals(1, t.bounds.min);
31 assertEquals(4, t.bounds.max);
34 test('threadBounds_AsyncSliceGroup', function() {
35 var model = new tracing.TraceModel();
36 var t = new Thread(new Process(model, 7), 1);
37 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 1, {}, 3));
38 t.asyncSliceGroup.push(newAsyncSlice(0.1, 5, t, t));
40 assertEquals(0.1, t.bounds.min);
41 assertEquals(5.1, t.bounds.max);
44 test('threadBounds_Cpu', function() {
45 var model = new tracing.TraceModel();
46 var t = new Thread(new Process(model, 7), 1);
47 t.timeSlices = [newSliceNamed('x', 0, 1)];
49 assertEquals(0, t.bounds.min);
50 assertEquals(1, t.bounds.max);
53 test('shiftTimestampsForwardWithCpu', function() {
54 var model = new tracing.TraceModel();
55 var t = new Thread(new Process(model, 7), 1);
56 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3));
57 t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t));
58 t.timeSlices = [newSliceNamed('x', 0, 1)];
61 t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
66 t.shiftTimestampsForward(0.32);
68 assertEquals(1, shiftCount);
69 assertEquals(0.32, t.sliceGroup.slices[0].start);
70 assertEquals(0.32, t.timeSlices[0].start);
73 test('shiftTimestampsForwardWithoutCpu', function() {
74 var model = new tracing.TraceModel();
75 var t = new Thread(new Process(model, 7), 1);
76 t.sliceGroup.pushSlice(new ThreadSlice('', 'a', 0, 0, {}, 3));
77 t.asyncSliceGroup.push(newAsyncSlice(0, 5, t, t));
80 t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
85 t.shiftTimestampsForward(0.32);
87 assertEquals(1, shiftCount);
88 assertEquals(0.32, t.sliceGroup.slices[0].start);