Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: tracing/tracing/extras/chrome/blame_context/blame_context_test.html

Issue 2016213002: Introduce base classes for blame contexts (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: Add frame_blame_context_test.html; And some other revision Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tracing/tracing/extras/chrome/blame_context/blame_context_test.html
diff --git a/tracing/tracing/extras/chrome/blame_context/blame_context_test.html b/tracing/tracing/extras/chrome/blame_context/blame_context_test.html
new file mode 100644
index 0000000000000000000000000000000000000000..2df67aa18b069a36d5b183a5511009e0b945a479
--- /dev/null
+++ b/tracing/tracing/extras/chrome/blame_context/blame_context_test.html
@@ -0,0 +1,98 @@
+<!DOCTYPE html>
+<!--
+Copyright 2016 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<link rel="import" href="/tracing/extras/chrome/blame_context/blame_context.html">
+<link rel="import" href="/tracing/model/model.html">
+<link rel="import" href="/tracing/model/scoped_id.html">
+
+<script>
+'use strict';
+
+tr.b.unittest.testSuite(function() {
+ var BlameContextSnapshot = tr.e.chrome.BlameContextSnapshot;
+ var BlameContextInstance = tr.e.chrome.BlameContextInstance;
+
+ function TestBlameContextSnapshot() {
+ BlameContextSnapshot.apply(this, arguments);
+ }
+
+ TestBlameContextSnapshot.prototype = {
+ __proto__: BlameContextSnapshot.prototype,
+
+ get userFriendlyName() {
+ return 'Test';
+ }
+ };
+
+ tr.model.ObjectSnapshot.register(
+ TestBlameContextSnapshot,
+ {typeName: 'Test'});
+
+ function TestBlameContextInstance() {
+ BlameContextInstance.apply(this, arguments);
+ }
+
+ TestBlameContextInstance.prototype = {
+ __proto__: BlameContextInstance.prototype,
+
+ get isTracedByRenderer() {
+ return false;
+ },
+
+ get blameContextType() {
+ return 'Test';
+ }
+ };
+
+ tr.model.ObjectInstance.register(
+ TestBlameContextInstance,
+ {typeName: 'Test'});
+
+ test('parentContext', function() {
+ var model = new tr.Model();
+ var process = model.getOrCreateProcess(1);
+ var parent = process.objects.addSnapshot(
+ new tr.model.ScopedId('Test', '0x1'),
+ 'cat', 'Test', 1000, {});
+ var child = process.objects.addSnapshot(
+ new tr.model.ScopedId('Test', '0x2'),
+ 'cat', 'Test', 1111, {
+ parent: {
+ scope: 'Test',
+ id_ref: '0x1'
+ }
+ });
+ model.joinRefs();
+
+ assert.isTrue(child.parentContext === parent);
+ });
+
+ test('attributedEvents', function() {
+ var model = new tr.Model();
+ var process = model.getOrCreateProcess(1);
+ var context = process.objects.addSnapshot(
+ new tr.model.ScopedId('Test', '0x1'),
+ 'cat', 'Test', 1000, {});
+ var thread = process.getOrCreateThread(1);
+ var slice = new tr.model.Slice('cat', 'a', 1, 2000, {});
+ slice.contexts = [
+ {
+ type: 'Test',
+ snapshot: {
+ scope: 'Test',
+ idRef: '0x1'
+ }
+ }
+ ];
+ thread.sliceGroup.pushSlice(slice);
+ model.joinRefs();
+
+ assert.equal(context.attributedEvents.length, 1);
+ assert.isTrue(context.attributedEvents.contains(slice));
+ });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698