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. 4 5 'use strict'; 6 7 base.require('tracing.test_utils'); 8 base.require('tracing.trace_model'); 9 base.require('tracing.trace_model.process'); 10 11 base.unittest.testSuite('tracing.trace_model.process', function() { 12 test('getOrCreateCounter', function() { 13 var model = new tracing.TraceModel(); 14 var process = new tracing.trace_model.Process(model, 7); 15 var ctrBar = process.getOrCreateCounter('foo', 'bar'); 16 var ctrBar2 = process.getOrCreateCounter('foo', 'bar'); 17 assertEquals(ctrBar2, ctrBar); 18 }); 19 20 test('shiftTimestampsForward', function() { 21 var model = new tracing.TraceModel(); 22 var process = new tracing.trace_model.Process(model, 7); 23 var ctr = process.getOrCreateCounter('foo', 'bar'); 24 var thread = process.getOrCreateThread(1); 25 26 var shiftCount = 0; 27 thread.shiftTimestampsForward = function(ts) { 28 if (ts == 0.32) 29 shiftCount++; 30 }; 31 ctr.shiftTimestampsForward = function(ts) { 32 if (ts == 0.32) 33 shiftCount++; 34 }; 35 process.shiftTimestampsForward(0.32); 36 assertEquals(2, shiftCount); 37 }); 38 39 test('compareOnPID', function() { 40 var model = new tracing.TraceModel(); 41 var p1 = new tracing.trace_model.Process(model, 1); 42 p1.name = 'Renderer'; 43 44 var model = new tracing.TraceModel(); 45 var p2 = new tracing.trace_model.Process(model, 2); 46 p2.name = 'Renderer'; 47 48 assertTrue(p1.compareTo(p2) < 0); 49 }); 50 51 test('compareOnSortIndex', function() { 52 var model = new tracing.TraceModel(); 53 var p1 = new tracing.trace_model.Process(model, 1); 54 p1.name = 'Renderer'; 55 p1.sortIndex = 1; 56 57 var p2 = new tracing.trace_model.Process(model, 2); 58 p2.name = 'Renderer'; 59 60 assertTrue(p1.compareTo(p2) > 0); 61 }); 62 63 test('compareOnName', function() { 64 var model = new tracing.TraceModel(); 65 var p1 = new tracing.trace_model.Process(model, 1); 66 p1.name = 'Browser'; 67 68 var p2 = new tracing.trace_model.Process(model, 2); 69 p2.name = 'Renderer'; 70 71 assertTrue(p1.compareTo(p2) < 0); 72 }); 73 74 test('compareOnLabels', function() { 75 var model = new tracing.TraceModel(); 76 var p1 = new tracing.trace_model.Process(model, 1); 77 p1.name = 'Renderer'; 78 p1.labels = ['a']; 79 80 var p2 = new tracing.trace_model.Process(model, 2); 81 p2.name = 'Renderer'; 82 p2.labels = ['b']; 83 84 assertTrue(p1.compareTo(p2) < 0); 85 }); 86 87 }); 88