1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. 5 Use of this source code is governed by a BSD-style license that can be 6 found in the LICENSE file. 7 --> 8 <head i18n-values="dir:textdirection;"> 9 <title>AsyncSliceGroupTrack tests</title> 10 <style> 11 .container { 12 border: 1px solid red; 13 } 14 </style> 15 <script src="/src/base.js"></script> 16 <script> 17 base.require('unittest'); 18 base.require('test_utils'); 19 base.require('timeline_track_view'); 20 base.require('model'); 21 </script> 22 </head> 23 <body> 24 <script> 25 'use strict'; 26 27 var AsyncSliceGroup = tracing.model.AsyncSliceGroup; 28 var AsyncSliceGroupTrack = 29 tracing.tracks.AsyncSliceGroupTrack; 30 var Process = tracing.model.Process; 31 var Thread = tracing.model.Thread; 32 var newAsyncSlice = test_utils.newAsyncSlice; 33 34 function testAsyncSliceGroup_filterSubRows() { 35 var p1 = new Process(1); 36 var t1 = new Thread(p1, 1); 37 var g = new AsyncSliceGroup(); 38 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 39 var track = new AsyncSliceGroupTrack(); 40 track.group = g; 41 42 assertEquals(1, track.subRows_.length); 43 assertTrue(track.visible); 44 45 track.categoryFilter = new tracing.TitleFilter('x'); 46 assertFalse(track.visible); 47 48 track.categoryFilter = new tracing.TitleFilter('a'); 49 assertTrue(track.visible); 50 assertEquals(1, track.subRows_.length); 51 } 52 53 function testAsyncSliceGroup_rebuildSubRows_twoNonOverlappingSlices() { 54 var p1 = new Process(1); 55 var t1 = new Thread(p1, 1); 56 var g = new AsyncSliceGroup(); 57 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 58 g.slices.push(newAsyncSlice(1, 1, t1, t1)); 59 var track = new AsyncSliceGroupTrack(); 60 track.group = g; 61 var subRows = track.subRows_; 62 63 assertEquals(1, subRows.length); 64 assertEquals(2, subRows[0].length); 65 assertEquals(g.slices[0].subSlices[0], subRows[0][0]); 66 assertEquals(g.slices[1].subSlices[0], subRows[0][1]); 67 } 68 69 function testAsyncSliceGroup_rebuildSubRows_twoOverlappingSlices() { 70 var p1 = new Process(1); 71 var t1 = new Thread(p1, 1); 72 var g = new AsyncSliceGroup(); 73 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 74 g.slices.push(newAsyncSlice(0, 1.5, t1, t1)); 75 g.updateBounds(); 76 var track = new AsyncSliceGroupTrack(); 77 track.group = g; 78 var subRows = track.subRows_; 79 80 assertEquals(2, subRows.length); 81 assertEquals(1, subRows[0].length); 82 assertEquals(g.slices[0], subRows[0][0]); 83 assertEquals(1, subRows[1].length); 84 assertEquals(g.slices[1], subRows[1][0]); 85 } 86 87 function testAsyncSliceGroup_rebuildSubRows_threePartlyOverlappingSlices() { 88 var p1 = new Process(1); 89 var t1 = new Thread(p1, 1); 90 var g = new AsyncSliceGroup(); 91 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 92 g.slices.push(newAsyncSlice(0, 1.5, t1, t1)); 93 g.slices.push(newAsyncSlice(1, 1.5, t1, t1)); 94 g.updateBounds(); 95 var track = new AsyncSliceGroupTrack(); 96 track.group = g; 97 var subRows = track.subRows_; 98 99 assertEquals(2, subRows.length); 100 assertEquals(2, subRows[0].length); 101 assertEquals(g.slices[0].subSlices[0], subRows[0][0]); 102 assertEquals(g.slices[2].subSlices[0], subRows[0][1]); 103 assertEquals(1, subRows[1].length); 104 assertEquals(g.slices[1].subSlices[0], subRows[1][0]); 105 } 106 107 function testAsyncSliceGroup_rebuildSubRows_twoOverlappingSlices() { 108 var p1 = new Process(1); 109 var t1 = new Thread(p1, 1); 110 var g = new AsyncSliceGroup(); 111 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 112 g.slices.push(newAsyncSlice(0, 1.5, t1, t1)); 113 g.slices.push(newAsyncSlice(2, 1, t1, t1)); 114 g.updateBounds(); 115 var track = new AsyncSliceGroupTrack(); 116 track.group = g; 117 var subRows = track.subRows_; 118 119 assertEquals(2, subRows.length); 120 assertEquals(2, subRows[0].length); 121 assertEquals(g.slices[0].subSlices[0], subRows[0][0]); 122 assertEquals(g.slices[2].subSlices[0], subRows[0][1]); 123 assertEquals(1, subRows[1].length); 124 assertEquals(g.slices[1].subSlices[0], subRows[1][0]); 125 } 126 127 function testAsyncSliceGroup_computeSubGroups_twoThreadSpecificSlices() { 128 var p1 = new Process(1); 129 var t1 = new Thread(p1, 1); 130 var t2 = new Thread(p1, 2); 131 var g = new AsyncSliceGroup(); 132 g.slices.push(newAsyncSlice(0, 1, t1, t1)); 133 g.slices.push(newAsyncSlice(0, 1, t2, t2)); 134 var track = new AsyncSliceGroupTrack(); 135 track.group = g; 136 var subRows = track.subRows_; 137 138 var subGroups = g.computeSubGroups(); 139 assertEquals(2, subGroups.length); 140 141 assertEquals(g.name, subGroups[0].name); 142 assertEquals(1, subGroups[0].slices.length); 143 assertEquals(g.slices[0], subGroups[0].slices[0]); 144 145 assertEquals(g.name, subGroups[1].name); 146 assertEquals(1, subGroups[1].slices.length); 147 assertEquals(g.slices[1], subGroups[1].slices[0]); 148 } 149 </script> 150 </body> 151 </html> 152