1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 class SmoothnessMeasurement(object):
7 def __init__(self
, tab
):
9 # Bring in the smoothness benchmark
11 os
.path
.join(os
.path
.dirname(__file__
),
12 'smoothness_measurement.js')) as f
:
14 tab
.ExecuteJavaScript(js
)
17 self
._tab
.ExecuteJavaScript(
18 'window.__renderingStats = new __RenderingStats();'
19 'window.__renderingStats.start()')
22 self
._tab
.ExecuteJavaScript('window.__renderingStats.stop()')
24 def BindToAction(self
, action
):
25 # Make the scroll test start and stop measurement automatically.
26 self
._tab
.ExecuteJavaScript(
27 'window.__renderingStats = new __RenderingStats();')
28 action
.BindMeasurementJavaScript(self
._tab
,
29 'window.__renderingStats.start();',
30 'window.__renderingStats.stop();')
33 def start_values(self
):
34 return self
._tab
.EvaluateJavaScript(
35 'window.__renderingStats.getStartValues()')
39 return self
._tab
.EvaluateJavaScript(
40 'window.__renderingStats.getEndValues()')
44 return self
._tab
.EvaluateJavaScript(
45 'window.__renderingStats.getDeltas()')