blob: fa02cff3945f9f9b1630a6a09468e1e18888694d [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2013 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/core/test_utils.html">
<link rel="import" href="/tracing/model/object_instance.html">
<script>
'use strict';
tr.b.unittest.testSuite(function() {
test('getSnapshotAtWithImplicitCreation', function() {
var instance = new tr.model.ObjectInstance(
{}, '0x1000', 'cat', 'n', 10);
var s10 = instance.addSnapshot(10, 'a');
instance.addSnapshot(40, 'b');
instance.wasDeleted(60);
var s1 = instance.getSnapshotAt(1);
assert.equal(s1, s10);
var s10 = instance.getSnapshotAt(10);
assert.equal(s10.args, 'a');
assert.equal(instance.getSnapshotAt(15), s10);
var s40 = instance.getSnapshotAt(40);
assert.equal(s40.args, 'b');
assert.equal(instance.getSnapshotAt(50), s40);
assert.equal(instance.getSnapshotAt(59.9), s40);
});
test('getSnapshotAtWithExplicitCreation', function() {
var instance = new tr.model.ObjectInstance(
{}, '0x1000', 'cat', 'n', 10);
instance.creationTsWasExplicit = true;
instance.addSnapshot(10, 'a');
instance.wasDeleted(60);
assert.throws(function() {
instance.getSnapshotAt(1);
});
var s10 = instance.getSnapshotAt(10);
assert.equal(s10.args, 'a');
assert.equal(instance.getSnapshotAt(15), s10);
});
test('getSnapshotBeforeFirstSnapshot', function() {
var instance = new tr.model.ObjectInstance(
{}, '0x1000', 'cat', 'n', 10);
var s15 = instance.addSnapshot(15, 'a');
instance.wasDeleted(40);
assert.equal(instance.getSnapshotAt(10), s15);
});
test('getSnapshotAfterLastSnapshot', function() {
var instance = new tr.model.ObjectInstance(
{}, '0x1000', 'cat', 'n', 10);
var s15 = instance.addSnapshot(15, 'a');
instance.wasDeleted(40);
assert.equal(instance.getSnapshotAt(20), s15);
});
});
</script>