Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / trace_model / thread_test.html
1 <!DOCTYPE html>
2 <!--
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.
6 -->
7
8 <link rel="import" href="/tracing/test_utils.html">
9 <link rel="import" href="/tracing/trace_model.html">
10
11 <script>
12 'use strict';
13
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;
20
21   test('threadBounds_Empty', function() {
22     var model = new tracing.TraceModel();
23     var t = new Thread(new Process(model, 7), 1);
24     t.updateBounds();
25     assertEquals(undefined, t.bounds.min);
26     assertEquals(undefined, t.bounds.max);
27   });
28
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));
33     t.updateBounds();
34     assertEquals(1, t.bounds.min);
35     assertEquals(4, t.bounds.max);
36   });
37
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));
43     t.updateBounds();
44     assertEquals(0.1, t.bounds.min);
45     assertEquals(5.1, t.bounds.max);
46   });
47
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)];
52     t.updateBounds();
53     assertEquals(0, t.bounds.min);
54     assertEquals(1, t.bounds.max);
55   });
56
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)];
63
64     var shiftCount = 0;
65     t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
66       if (ts == 0.32)
67         shiftCount++;
68     };
69
70     t.shiftTimestampsForward(0.32);
71
72     assertEquals(1, shiftCount);
73     assertEquals(0.32, t.sliceGroup.slices[0].start);
74     assertEquals(0.32, t.timeSlices[0].start);
75   });
76
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));
82
83     var shiftCount = 0;
84     t.asyncSliceGroup.shiftTimestampsForward = function(ts) {
85       if (ts == 0.32)
86         shiftCount++;
87     };
88
89     t.shiftTimestampsForward(0.32);
90
91     assertEquals(1, shiftCount);
92     assertEquals(0.32, t.sliceGroup.slices[0].start);
93   });
94 });
95 </script>
96