blob: d76a26c41188da3c774af9088954760d99947e4d [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright 2015 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/model/global_memory_dump.html">
<link rel="import" href="/tracing/model/heap_dump.html">
<link rel="import" href="/tracing/model/model.html">
<link rel="import" href="/tracing/model/process_memory_dump.html">
<link rel="import" href="/tracing/model/stack_frame.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
var Model = tr.Model;
var GlobalMemoryDump = tr.model.GlobalMemoryDump;
var ProcessMemoryDump = tr.model.ProcessMemoryDump;
var StackFrame = tr.model.StackFrame;
var HeapEntry = tr.model.HeapEntry;
var HeapDump = tr.model.HeapDump;
test('heapDumps', function() {
var model = new tr.Model();
var process = model.getOrCreateProcess(89);
var gmd = new GlobalMemoryDump(model, 42);
model.globalMemoryDumps.push(gmd);
var pmd = new ProcessMemoryDump(gmd, process, 42);
process.memoryDumps.push(pmd);
var rootFrame = new StackFrame(undefined, tr.b.GUID.allocate(), undefined);
var childFrame = new StackFrame(rootFrame, tr.b.GUID.allocate(), 'draw');
rootFrame.addChild(childFrame);
var dump = new HeapDump(pmd);
assert.strictEqual(dump.processMemoryDump, pmd);
assert.lengthOf(dump.entries, 0);
var entry1 = dump.addEntry(childFrame, 'HTMLImportLoader', 1024);
assert.strictEqual(entry1.heapDump, dump);
assert.strictEqual(entry1.leafStackFrame, childFrame);
assert.strictEqual(entry1.objectTypeName, 'HTMLImportLoader');
assert.equal(entry1.size, 1024);
var entry2 = dump.addEntry(undefined, undefined, 1048576);
assert.strictEqual(entry2.heapDump, dump);
assert.isUndefined(entry2.leafStackFrame);
assert.isUndefined(entry2.objectTypeName);
assert.equal(entry2.size, 1048576);
assert.deepEqual(dump.entries, [entry1, entry2]);
});
});
</script>