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> 9 <title>V8LogImporter tests</title> 10 <script src="../base.js"></script> 11 <script> 12 base.require('unittest'); 13 base.require('test_utils'); 14 base.require('importer.v8_log_importer'); 15 </script> 16 </head> 17 <body> 18 <script> 19 'use strict'; 20 21 var findSliceNamed = test_utils.findSliceNamed; 22 var V8LogImporter = tracing.importer.V8LogImporter; 23 24 function testTickEventInSharedLibrary() { 25 var lines = ['shared-library,"/usr/lib/libc++.1.dylib",0x99d8aae0,0x99dce729', 26 'tick,0x99d8aae4,0xbff02f08,12158,0,0x0,5',]; 27 var m = new tracing.Model(lines.join('\n')); 28 var p = m.processes[-32]; 29 var threads = p.findAllThreadsNamed('V8 PC'); 30 var t = threads[0]; 31 assertEquals(1, t.samples.length); 32 assertEquals("/usr/lib/libc++.1.dylib", t.samples[0].title); 33 } 34 35 function testTickEventInGeneratedCode() { 36 var lines = ['shared-library,"/usr/lib/libc++.1.dylib",0x99d8aae0,0x99dce729', 37 'code-creation,Stub,2,0x5b60ce80,1259,"StringAddStub"', 38 'tick,0x5b60ce84,0xbff02f08,12158,0,0x0,5',]; 39 var m = new tracing.Model(lines.join('\n')); 40 var p = m.processes[-32]; 41 var threads = p.findAllThreadsNamed('V8 PC'); 42 var t = threads[0]; 43 assertEquals(1, t.samples.length); 44 assertEquals("StringAddStub", t.samples[0].title); 45 } 46 47 function testTickEventInUknownCode() { 48 var lines = ['shared-library,"/usr/lib/libc++.1.dylib",0x99d8aae0,0x99dce729', 49 'code-creation,Stub,2,0x5b60ce80,1259,"StringAddStub"', 50 'tick,0x4,0xbff02f08,12158,0,0x0,5',]; 51 var m = new tracing.Model(lines.join('\n')); 52 var p = m.processes[-32]; 53 var threads = p.findAllThreadsNamed('V8 PC'); 54 var t = threads[0]; 55 assertEquals(1, t.samples.length); 56 assertEquals('UnknownCode', t.samples[0].title); 57 } 58 59 function testTimerEventSliceCreation() { 60 var lines = ['timer-event,"V8.External",38189483,3']; 61 var m = new tracing.Model(lines.join('\n')); 62 var p = m.processes[-32]; 63 var threads = p.findAllThreadsNamed('V8 Timers'); 64 assertNotUndefined(threads); 65 assertEquals(threads.length, 1); 66 var t = threads[0]; 67 assertEquals(t.slices.length, 1); 68 } 69 70 function testProcessThreadCreation() { 71 var lines = ['timer-event,"V8.External",38189483,3']; 72 var m = new tracing.Model(lines.join('\n')); 73 assertNotUndefined(m); 74 var p = m.processes[-32]; 75 assertNotUndefined(p); 76 var threads = p.findAllThreadsNamed('V8 Timers'); 77 assertNotUndefined(threads); 78 assertEquals(threads.length, 1); 79 var t = threads[0]; 80 assertEquals(t.name, 'V8 Timers'); 81 } 82 83 84 function testCanImport() { 85 assertTrue(V8LogImporter.canImport('timer-event,"V8.External",38189483,3')); 86 assertFalse(V8LogImporter.canImport('')); 87 assertFalse(V8LogImporter.canImport([])); 88 } 89 90 </script> 91 </body> 92 </html> 93