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