Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 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="/extras/cc/input_latency_async_slice.html"> |
| 9 | <link rel="import" href="/core/test_utils.html"> |
| 10 | <link rel="import" href="/core/trace_model/trace_model.html"> |
| 11 | |
| 12 | <script> |
| 13 | 'use strict'; |
| 14 | |
| 15 | tv.b.unittest.testSuite(function() { |
| 16 | var newAsyncSliceEx = tv.c.test_utils.newAsyncSliceEx; |
| 17 | |
| 18 | test('oldStyle', function() { |
| 19 | var sOuter = newAsyncSliceEx({ |
| 20 | title: 'InputLatency', |
| 21 | cat: 'benchmark', |
| 22 | start: 0, |
| 23 | end: 10, |
| 24 | id: '0x100', |
| 25 | isTopLevel: true, |
| 26 | args: { |
| 27 | data: { |
| 28 | INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0}, |
| 29 | INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10} |
| 30 | } |
| 31 | } |
| 32 | }); |
| 33 | |
| 34 | var sInner = newAsyncSliceEx({ |
| 35 | title: 'InputLatency:GestureScrollUpdate', |
| 36 | cat: 'benchmark', |
| 37 | start: 2, |
| 38 | end: 10, |
| 39 | id: '0x100', |
| 40 | args: { |
| 41 | 'step': 'GestureScrollUpdate' |
| 42 | } |
| 43 | }); |
| 44 | sOuter.subSlices.push(sInner); |
| 45 | assert.isTrue(sOuter instanceof tv.e.cc.InputLatencyAsyncSlice); |
| 46 | assert.isTrue(sInner instanceof tv.e.cc.InputLatencyAsyncSlice); |
| 47 | assert.equal(sOuter.inputLatency, 10); |
| 48 | }); |
| 49 | |
| 50 | test('newStyle', function() { |
| 51 | var sInfo = newAsyncSliceEx({ |
| 52 | title: 'InputLatency::GestureScrollUpdate', |
| 53 | cat: 'benchmark', |
| 54 | start: 2, |
| 55 | end: 10, |
| 56 | id: '0x100', |
| 57 | isTopLevel: true, |
| 58 | args: { |
| 59 | data: { |
| 60 | INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT: {'time' : 0}, |
| 61 | INPUT_EVENT_LATENCY_TERMINATED_FRAME_SWAP_COMPONENT: {time: 10} |
| 62 | } |
| 63 | } |
| 64 | }); |
| 65 | |
| 66 | assert.isTrue(sInfo instanceof tv.e.cc.InputLatencyAsyncSlice); |
| 67 | assert.equal(sInfo.inputLatency, 10); |
| 68 | }); |
| 69 | |
| 70 | }); |
| 71 | </script> |