Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / trace_model / object_instance_test.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 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/test_utils.html">
9 <link rel="import" href="/tracing/trace_model/object_instance.html">
10
11 <script>
12 'use strict';
13
14 tv.unittest.testSuite(function() {
15   test('getSnapshotAtWithImplicitCreation', function() {
16     var instance = new tracing.trace_model.ObjectInstance(
17         {}, '0x1000', 'cat', 'n', 10);
18     var s10 = instance.addSnapshot(10, 'a');
19     instance.addSnapshot(40, 'b');
20     instance.wasDeleted(60);
21
22     var s1 = instance.getSnapshotAt(1);
23     assertEquals(s10, s1);
24
25     var s10 = instance.getSnapshotAt(10);
26     assertEquals('a', s10.args);
27     assertEquals(s10, instance.getSnapshotAt(15));
28
29     var s40 = instance.getSnapshotAt(40);
30     assertEquals('b', s40.args);
31     assertEquals(s40, instance.getSnapshotAt(50));
32     assertEquals(s40, instance.getSnapshotAt(59.9));
33   });
34
35   test('getSnapshotAtWithExplicitCreation', function() {
36     var instance = new tracing.trace_model.ObjectInstance(
37         {}, '0x1000', 'cat', 'n', 10);
38     instance.creationTsWasExplicit = true;
39     instance.addSnapshot(10, 'a');
40     instance.wasDeleted(60);
41
42     assertThrows(function() {
43       instance.getSnapshotAt(1);
44     });
45
46     var s10 = instance.getSnapshotAt(10);
47     assertEquals('a', s10.args);
48     assertEquals(s10, instance.getSnapshotAt(15));
49   });
50
51   test('getSnapshotBeforeFirstSnapshot', function() {
52     var instance = new tracing.trace_model.ObjectInstance(
53         {}, '0x1000', 'cat', 'n', 10);
54     var s15 = instance.addSnapshot(15, 'a');
55     instance.wasDeleted(40);
56
57     assertEquals(s15, instance.getSnapshotAt(10));
58   });
59
60   test('getSnapshotAfterLastSnapshot', function() {
61     var instance = new tracing.trace_model.ObjectInstance(
62         {}, '0x1000', 'cat', 'n', 10);
63     var s15 = instance.addSnapshot(15, 'a');
64     instance.wasDeleted(40);
65
66     assertEquals(s15, instance.getSnapshotAt(20));
67   });
68 });
69 </script>
70