Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: tracing/tracing/ui/tracks/model_track_test.html

Issue 2771723003: [tracing] Move math utilities from base into their own subdirectory (attempt 2) (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright (c) 2014 The Chromium Authors. All rights reserved. 3 Copyright (c) 2014 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/model/thread.html"> 8 <link rel="import" href="/tracing/model/thread.html">
9 <link rel="import" href="/tracing/ui/tracks/model_track.html"> 9 <link rel="import" href="/tracing/ui/tracks/model_track.html">
10 10
11 <script> 11 <script>
12 'use strict'; 12 'use strict';
13 13
14 tr.b.unittest.testSuite(function() { 14 tr.b.unittest.testSuite(function() {
15 var VIEW_L_WORLD = 100; 15 const Range = tr.b.math.Range;
16 var VIEW_R_WORLD = 1000; 16 const VIEW_L_WORLD = 100;
17 const VIEW_R_WORLD = 1000;
17 18
18 function testGenerateStripes(times, expectedRanges) { 19 function testGenerateStripes(times, expectedRanges) {
19 var ranges = tr.ui.tracks.ModelTrack.generateStripes_( 20 var ranges = tr.ui.tracks.ModelTrack.generateStripes_(
20 times, VIEW_L_WORLD, VIEW_R_WORLD); 21 times, VIEW_L_WORLD, VIEW_R_WORLD);
21 22
22 assert.sameDeepMembers(ranges, expectedRanges); 23 assert.sameDeepMembers(ranges, expectedRanges);
23 } 24 }
24 25
25 test('generateStripesInside', function() { 26 test('generateStripesInside', function() {
26 var range200To500 = tr.b.Range.fromExplicitRange(200, 500); 27 var range200To500 = Range.fromExplicitRange(200, 500);
27 var range800To900 = tr.b.Range.fromExplicitRange(800, 900); 28 var range800To900 = Range.fromExplicitRange(800, 900);
28 var range998To999 = tr.b.Range.fromExplicitRange(998, 999); 29 var range998To999 = Range.fromExplicitRange(998, 999);
29 testGenerateStripes([], []); 30 testGenerateStripes([], []);
30 testGenerateStripes([200, 500], [range200To500]); 31 testGenerateStripes([200, 500], [range200To500]);
31 testGenerateStripes([200, 500, 800, 900], [range200To500, range800To900]); 32 testGenerateStripes([200, 500, 800, 900], [range200To500, range800To900]);
32 testGenerateStripes( 33 testGenerateStripes(
33 [200, 500, 800, 900, 998, 999], 34 [200, 500, 800, 900, 998, 999],
34 [range200To500, range800To900, range998To999]); 35 [range200To500, range800To900, range998To999]);
35 }); 36 });
36 37
37 test('generateStripesOutside', function() { 38 test('generateStripesOutside', function() {
38 var range101To999 = tr.b.Range.fromExplicitRange(101, 999); 39 var range101To999 = Range.fromExplicitRange(101, 999);
39 // Far left. 40 // Far left.
40 testGenerateStripes([0, 99], []); 41 testGenerateStripes([0, 99], []);
41 testGenerateStripes([0, 10, 50, 99], []); 42 testGenerateStripes([0, 10, 50, 99], []);
42 testGenerateStripes([0, 99, 101, 999], [range101To999]); 43 testGenerateStripes([0, 99, 101, 999], [range101To999]);
43 testGenerateStripes([0, 10, 50, 99, 101, 999], [range101To999]); 44 testGenerateStripes([0, 10, 50, 99, 101, 999], [range101To999]);
44 45
45 // Far right. 46 // Far right.
46 testGenerateStripes([1001, 2000], []); 47 testGenerateStripes([1001, 2000], []);
47 testGenerateStripes([1001, 2000, 3000, 4000], []); 48 testGenerateStripes([1001, 2000, 3000, 4000], []);
48 testGenerateStripes([101, 999, 1001, 2000], [range101To999]); 49 testGenerateStripes([101, 999, 1001, 2000], [range101To999]);
49 testGenerateStripes([101, 999, 1001, 2000, 3000, 4000], [range101To999]); 50 testGenerateStripes([101, 999, 1001, 2000, 3000, 4000], [range101To999]);
50 51
51 // Far both. 52 // Far both.
52 testGenerateStripes([0, 99, 1001, 2000], []); 53 testGenerateStripes([0, 99, 1001, 2000], []);
53 testGenerateStripes([0, 10, 50, 99, 1001, 2000], []); 54 testGenerateStripes([0, 10, 50, 99, 1001, 2000], []);
54 testGenerateStripes([0, 10, 50, 99, 1001, 2000, 3000, 4000], []); 55 testGenerateStripes([0, 10, 50, 99, 1001, 2000, 3000, 4000], []);
55 testGenerateStripes([0, 99, 101, 999, 1001, 2000], [range101To999]); 56 testGenerateStripes([0, 99, 101, 999, 1001, 2000], [range101To999]);
56 }); 57 });
57 58
58 test('generateStripesOverlap', function() { 59 test('generateStripesOverlap', function() {
59 var rangeLeftWorldTo101 = tr.b.Range.fromExplicitRange(VIEW_L_WORLD, 101); 60 var rangeLeftWorldTo101 = Range.fromExplicitRange(VIEW_L_WORLD, 101);
60 var range102To103 = tr.b.Range.fromExplicitRange(102, 103); 61 var range102To103 = Range.fromExplicitRange(102, 103);
61 var range200To900 = tr.b.Range.fromExplicitRange(200, 900); 62 var range200To900 = Range.fromExplicitRange(200, 900);
62 var range997To998 = tr.b.Range.fromExplicitRange(997, 998); 63 var range997To998 = Range.fromExplicitRange(997, 998);
63 var range999ToRightWorld = tr.b.Range.fromExplicitRange(999, VIEW_R_WORLD); 64 var range999ToRightWorld = Range.fromExplicitRange(999, VIEW_R_WORLD);
64 var rangeLeftWorldToRightWorld = 65 var rangeLeftWorldToRightWorld =
65 tr.b.Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD); 66 Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD);
66 67
67 68
68 // Left overlap. 69 // Left overlap.
69 testGenerateStripes([0, 101], [rangeLeftWorldTo101]); 70 testGenerateStripes([0, 101], [rangeLeftWorldTo101]);
70 testGenerateStripes([0, 1, 2, 101], [rangeLeftWorldTo101]); 71 testGenerateStripes([0, 1, 2, 101], [rangeLeftWorldTo101]);
71 testGenerateStripes( 72 testGenerateStripes(
72 [2, 101, 102, 103], 73 [2, 101, 102, 103],
73 [rangeLeftWorldTo101, range102To103]); 74 [rangeLeftWorldTo101, range102To103]);
74 testGenerateStripes( 75 testGenerateStripes(
75 [0, 1, 2, 101, 102, 103], 76 [0, 1, 2, 101, 102, 103],
(...skipping 25 matching lines...) Expand all
101 [rangeLeftWorldTo101, range200To900, range999ToRightWorld]); 102 [rangeLeftWorldTo101, range200To900, range999ToRightWorld]);
102 testGenerateStripes( 103 testGenerateStripes(
103 [0, 10, 90, 101, 999, 2000, 3000, 4000], 104 [0, 10, 90, 101, 999, 2000, 3000, 4000],
104 [rangeLeftWorldTo101, range999ToRightWorld]); 105 [rangeLeftWorldTo101, range999ToRightWorld]);
105 testGenerateStripes( 106 testGenerateStripes(
106 [0, 10, 90, 101, 200, 900, 999, 2000, 3000, 4000], 107 [0, 10, 90, 101, 200, 900, 999, 2000, 3000, 4000],
107 [rangeLeftWorldTo101, range200To900, range999ToRightWorld]); 108 [rangeLeftWorldTo101, range200To900, range999ToRightWorld]);
108 }); 109 });
109 110
110 test('generateStripesOdd', function() { 111 test('generateStripesOdd', function() {
111 var range500To900 = tr.b.Range.fromExplicitRange(500, 900); 112 var range500To900 = Range.fromExplicitRange(500, 900);
112 var rangeLeftWorldTo200 = tr.b.Range.fromExplicitRange(VIEW_L_WORLD, 200); 113 var rangeLeftWorldTo200 = Range.fromExplicitRange(VIEW_L_WORLD, 200);
113 var rangeLeftWorldTo500 = tr.b.Range.fromExplicitRange(VIEW_L_WORLD, 500); 114 var rangeLeftWorldTo500 = Range.fromExplicitRange(VIEW_L_WORLD, 500);
114 var range500ToRightWorld = tr.b.Range.fromExplicitRange(500, VIEW_R_WORLD); 115 var range500ToRightWorld = Range.fromExplicitRange(500, VIEW_R_WORLD);
115 var rangeLeftWorldToRightWorld = 116 var rangeLeftWorldToRightWorld =
116 tr.b.Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD); 117 Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD);
117 118
118 // One VSync. 119 // One VSync.
119 testGenerateStripes([0], [rangeLeftWorldToRightWorld]); 120 testGenerateStripes([0], [rangeLeftWorldToRightWorld]);
120 testGenerateStripes([500], [range500ToRightWorld]); 121 testGenerateStripes([500], [range500ToRightWorld]);
121 testGenerateStripes([1500], []); 122 testGenerateStripes([1500], []);
122 123
123 // Multiple VSyncs. 124 // Multiple VSyncs.
124 testGenerateStripes([0, 10, 20], [rangeLeftWorldToRightWorld]); 125 testGenerateStripes([0, 10, 20], [rangeLeftWorldToRightWorld]);
125 testGenerateStripes([0, 500, 2000], [rangeLeftWorldTo500]); 126 testGenerateStripes([0, 500, 2000], [rangeLeftWorldTo500]);
126 testGenerateStripes([0, 10, 500], [range500ToRightWorld]); 127 testGenerateStripes([0, 10, 500], [range500ToRightWorld]);
127 testGenerateStripes([0, 10, 2000], []); 128 testGenerateStripes([0, 10, 2000], []);
128 testGenerateStripes( 129 testGenerateStripes(
129 [0, 200, 500], 130 [0, 200, 500],
130 [rangeLeftWorldTo200, range500ToRightWorld]); 131 [rangeLeftWorldTo200, range500ToRightWorld]);
131 testGenerateStripes( 132 testGenerateStripes(
132 [0, 200, 500, 900], 133 [0, 200, 500, 900],
133 [rangeLeftWorldTo200, range500To900]); 134 [rangeLeftWorldTo200, range500To900]);
134 }); 135 });
135 136
136 test('generateStripesBorder', function() { 137 test('generateStripesBorder', function() {
137 var rangeLeftWorldToLeftWorld = 138 var rangeLeftWorldToLeftWorld =
138 tr.b.Range.fromExplicitRange(VIEW_L_WORLD, VIEW_L_WORLD); 139 Range.fromExplicitRange(VIEW_L_WORLD, VIEW_L_WORLD);
139 var rangeRightWorldToRightWorld = 140 var rangeRightWorldToRightWorld =
140 tr.b.Range.fromExplicitRange(VIEW_R_WORLD, VIEW_R_WORLD); 141 Range.fromExplicitRange(VIEW_R_WORLD, VIEW_R_WORLD);
141 var rangeLeftWorldToRightWorld = 142 var rangeLeftWorldToRightWorld =
142 tr.b.Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD); 143 Range.fromExplicitRange(VIEW_L_WORLD, VIEW_R_WORLD);
143 var rangeLeftWorldTo200 = tr.b.Range.fromExplicitRange(VIEW_L_WORLD, 200); 144 var rangeLeftWorldTo200 = Range.fromExplicitRange(VIEW_L_WORLD, 200);
144 var range200To500 = tr.b.Range.fromExplicitRange(200, 500); 145 var range200To500 = Range.fromExplicitRange(200, 500);
145 var range500ToRightWorld = tr.b.Range.fromExplicitRange(500, VIEW_R_WORLD); 146 var range500ToRightWorld = Range.fromExplicitRange(500, VIEW_R_WORLD);
146 testGenerateStripes([0, VIEW_L_WORLD], [rangeLeftWorldToLeftWorld]); 147 testGenerateStripes([0, VIEW_L_WORLD], [rangeLeftWorldToLeftWorld]);
147 testGenerateStripes( 148 testGenerateStripes(
148 [VIEW_L_WORLD, VIEW_L_WORLD], 149 [VIEW_L_WORLD, VIEW_L_WORLD],
149 [rangeLeftWorldToLeftWorld]); 150 [rangeLeftWorldToLeftWorld]);
150 testGenerateStripes( 151 testGenerateStripes(
151 [VIEW_R_WORLD, 2000], 152 [VIEW_R_WORLD, 2000],
152 [rangeRightWorldToRightWorld]); 153 [rangeRightWorldToRightWorld]);
153 testGenerateStripes( 154 testGenerateStripes(
154 [VIEW_R_WORLD, VIEW_R_WORLD], 155 [VIEW_R_WORLD, VIEW_R_WORLD],
155 [rangeRightWorldToRightWorld]); 156 [rangeRightWorldToRightWorld]);
(...skipping 12 matching lines...) Expand all
168 testGenerateStripes( 169 testGenerateStripes(
169 [0, VIEW_L_WORLD, 200, 500, VIEW_R_WORLD, 2000], 170 [0, VIEW_L_WORLD, 200, 500, VIEW_R_WORLD, 2000],
170 [rangeLeftWorldToLeftWorld, range200To500, 171 [rangeLeftWorldToLeftWorld, range200To500,
171 rangeRightWorldToRightWorld]); 172 rangeRightWorldToRightWorld]);
172 testGenerateStripes( 173 testGenerateStripes(
173 [0, 10, VIEW_L_WORLD, VIEW_R_WORLD, 2000, 3000], 174 [0, 10, VIEW_L_WORLD, VIEW_R_WORLD, 2000, 3000],
174 [rangeLeftWorldToRightWorld]); 175 [rangeLeftWorldToRightWorld]);
175 }); 176 });
176 }); 177 });
177 </script> 178 </script>
OLDNEW
« no previous file with comments | « tracing/tracing/ui/tracks/model_track.html ('k') | tracing/tracing/ui/tracks/multi_row_track.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698