| OLD | NEW |
| (Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Copyright 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. |
| 6 --> |
| 7 |
| 8 <link rel="import" href="/tracing/extras/chrome/blame_context/blame_context.html
"> |
| 9 <link rel="import" href="/tracing/model/model.html"> |
| 10 <link rel="import" href="/tracing/model/scoped_id.html"> |
| 11 |
| 12 <script> |
| 13 'use strict'; |
| 14 |
| 15 tr.b.unittest.testSuite(function() { |
| 16 var BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot; |
| 17 var BlameContextInstance = tr.e.chrome.BlameContextInstance; |
| 18 |
| 19 function TestBlameContextSnapshot() { |
| 20 BlameContextSnapshot.apply(this, arguments); |
| 21 } |
| 22 |
| 23 TestBlameContextSnapshot.prototype = { |
| 24 __proto__: BlameContextSnapshot.prototype, |
| 25 |
| 26 get userFriendlyName() { |
| 27 return 'Test'; |
| 28 } |
| 29 }; |
| 30 |
| 31 tr.model.ObjectSnapshot.register( |
| 32 TestBlameContextSnapshot, |
| 33 {typeName: 'Test'}); |
| 34 |
| 35 function TestBlameContextInstance() { |
| 36 BlameContextInstance.apply(this, arguments); |
| 37 } |
| 38 |
| 39 TestBlameContextInstance.prototype = { |
| 40 __proto__: BlameContextInstance.prototype, |
| 41 |
| 42 get isTracedByRenderer() { |
| 43 return false; |
| 44 }, |
| 45 |
| 46 get blameContextType() { |
| 47 return 'Test'; |
| 48 } |
| 49 }; |
| 50 |
| 51 tr.model.ObjectInstance.register( |
| 52 TestBlameContextInstance, |
| 53 {typeName: 'Test'}); |
| 54 |
| 55 test('parentContext', function() { |
| 56 var model = new tr.Model(); |
| 57 var process = model.getOrCreateProcess(1); |
| 58 var parent = process.objects.addSnapshot( |
| 59 new tr.model.ScopedId('Test', '0x1'), |
| 60 'cat', 'Test', 1000, {}); |
| 61 var child = process.objects.addSnapshot( |
| 62 new tr.model.ScopedId('Test', '0x2'), |
| 63 'cat', 'Test', 1111, { |
| 64 parent: { |
| 65 scope: 'Test', |
| 66 id_ref: '0x1' |
| 67 } |
| 68 }); |
| 69 model.joinRefs(); |
| 70 |
| 71 assert.isTrue(child.parentContext === parent); |
| 72 }); |
| 73 |
| 74 test('attributedEvents', function() { |
| 75 var model = new tr.Model(); |
| 76 var process = model.getOrCreateProcess(1); |
| 77 var context = process.objects.addSnapshot( |
| 78 new tr.model.ScopedId('Test', '0x1'), |
| 79 'cat', 'Test', 1000, {}); |
| 80 var thread = process.getOrCreateThread(1); |
| 81 var slice = new tr.model.Slice('cat', 'a', 1, 2000, {}); |
| 82 slice.contexts = [ |
| 83 { |
| 84 type: 'Test', |
| 85 snapshot: { |
| 86 scope: 'Test', |
| 87 idRef: '0x1' |
| 88 } |
| 89 } |
| 90 ]; |
| 91 thread.sliceGroup.pushSlice(slice); |
| 92 model.joinRefs(); |
| 93 |
| 94 assert.equal(context.attributedEvents.length, 1); |
| 95 assert.isTrue(context.attributedEvents.contains(slice)); |
| 96 }); |
| 97 }); |
| 98 </script> |
| OLD | NEW |