1 # Copyright 2014 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.
5 from measurements
import smoothness_controller
6 from telemetry
.page
import page_test
9 class Repaint(page_test
.PageTest
):
10 def __init__(self
, mode
='viewport', width
=None, height
=None):
11 super(Repaint
, self
).__init
__('RunRepaint', False)
12 self
._smoothness
_controller
= None
13 self
._micro
_benchmark
_id
= None
18 def CustomizeBrowserOptions(self
, options
):
19 options
.AppendExtraBrowserArgs([
20 '--enable-impl-side-painting',
21 '--enable-threaded-compositing',
22 '--enable-gpu-benchmarking'
25 def WillRunActions(self
, page
, tab
):
26 tab
.WaitForDocumentReadyStateToBeComplete()
27 self
._smoothness
_controller
= smoothness_controller
.SmoothnessController()
28 self
._smoothness
_controller
.SetUp(page
, tab
)
29 self
._smoothness
_controller
.Start(tab
)
30 # Rasterize only what's visible.
31 tab
.ExecuteJavaScript(
32 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
35 args
['mode'] = self
._mode
37 args
['width'] = self
._width
39 args
['height'] = self
._height
42 tab
.ExecuteJavaScript("""
43 window.benchmark_results = {};
44 window.benchmark_results.id =
45 chrome.gpuBenchmarking.runMicroBenchmark(
46 "invalidation_benchmark",
52 self
._micro
_benchmark
_id
= tab
.EvaluateJavaScript(
53 'window.benchmark_results.id')
54 if (not self
._micro
_benchmark
_id
):
55 raise page_test
.MeasurementFailure(
56 'Failed to schedule invalidation_benchmark.')
58 def DidRunActions(self
, page
, tab
):
59 tab
.ExecuteJavaScript("""
60 window.benchmark_results.message_handled =
61 chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
62 """ + str(self
._micro
_benchmark
_id
) + """, {
66 self
._smoothness
_controller
.Stop(tab
)
68 def ValidateAndMeasurePage(self
, page
, tab
, results
):
69 self
._smoothness
_controller
.AddResults(tab
, results
)
71 def CleanUpAfterPage(self
, _
, tab
):
72 self
._smoothness
_controller
.CleanUp(tab
)