chrome_auditor_test.html revision 4a4f2fe02baf385f6c24fc98c6e17bf6ac5e0724
1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/core/test_utils.html"> 9<link rel="import" href="/tracing/extras/chrome/chrome_auditor.html"> 10<link rel="import" href="/tracing/model/model.html"> 11<link rel="import" href="/tracing/ui/base/color_scheme.html"> 12 13<script> 14'use strict'; 15 16tr.b.unittest.testSuite(function() { 17 function createModelWithChromeAuditor(customizeModelCallback) { 18 return tr.c.test_utils.newModelWithAuditor(function(m) { 19 m.browserProcess = m.getOrCreateProcess(1); 20 m.browserMain = m.browserProcess.getOrCreateThread(2); 21 m.browserMain.name = 'CrBrowserMain'; 22 23 m.renderer1 = m.getOrCreateProcess(3); 24 m.renderer1Main = m.renderer1.getOrCreateThread(4); 25 m.renderer1Main.name = 'CrRendererMain'; 26 27 m.renderer1Compositor = m.renderer1.getOrCreateThread(4); 28 m.renderer1Compositor.name = 'Compositor'; 29 30 customizeModelCallback(m); 31 }, tr.e.audits.ChromeAuditor); 32 } 33 34 function newInputLatencyEvent(tsStart, tsEnd, opt_args) { 35 var e = new tr.model.AsyncSlice( 36 'benchmark', 'InputLatency', 37 tr.ui.b.getColorIdForGeneralPurposeString('InputLatency'), 38 tsStart, opt_args); 39 e.duration = tsEnd - tsStart; 40 return e; 41 } 42 43 function newImplRenderingStatsEvent(ts, opt_args) { 44 var e = new tr.model.ThreadSlice( 45 'benchmark', 'BenchmarkInstrumentation::ImplThreadRenderingStats', 46 tr.ui.b.getColorIdForGeneralPurposeString('x'), 47 ts, opt_args, 0); 48 return e; 49 } 50 51 test('simple', function() { 52 var m = createModelWithChromeAuditor(function(m) { 53 var bAsyncSlices = m.browserMain.asyncSliceGroup; 54 bAsyncSlices.push(newInputLatencyEvent(100, 130)); 55 bAsyncSlices.push(newInputLatencyEvent(116, 150)); 56 bAsyncSlices.push(newInputLatencyEvent(133, 166)); 57 bAsyncSlices.push(newInputLatencyEvent(150, 183)); 58 bAsyncSlices.push(newInputLatencyEvent(166, 200)); 59 bAsyncSlices.push(newInputLatencyEvent(183, 216)); 60 61 var rm1Slices = m.renderer1Compositor.sliceGroup; 62 rm1Slices.pushSlice(newImplRenderingStatsEvent(113)); 63 rm1Slices.pushSlice(newImplRenderingStatsEvent(130)); 64 rm1Slices.pushSlice(newImplRenderingStatsEvent(147)); 65 rm1Slices.pushSlice(newImplRenderingStatsEvent(163)); 66 rm1Slices.pushSlice(newImplRenderingStatsEvent(180)); 67 rm1Slices.pushSlice(newImplRenderingStatsEvent(197)); 68 rm1Slices.pushSlice(newImplRenderingStatsEvent(213)); 69 rm1Slices.pushSlice(newImplRenderingStatsEvent(230)); 70 rm1Slices.pushSlice(newImplRenderingStatsEvent(247)); 71 }); 72 }); 73}); 74</script> 75