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
):
11 super(Repaint
, self
).__init
__('RunRepaint', False)
12 self
._smoothness
_controller
= None
13 self
._micro
_benchmark
_id
= None
16 def AddCommandLineArgs(cls
, parser
):
17 parser
.add_option('--mode', type='string',
19 help='Invalidation mode. '
20 'Supported values: fixed_size, layer, random, viewport.')
21 parser
.add_option('--width', type='int',
23 help='Width of invalidations for fixed_size mode.')
24 parser
.add_option('--height', type='int',
26 help='Height of invalidations for fixed_size mode.')
28 def CustomizeBrowserOptions(self
, options
):
29 options
.AppendExtraBrowserArgs([
30 '--enable-impl-side-painting',
31 '--enable-threaded-compositing',
32 '--enable-gpu-benchmarking'
35 def WillRunActions(self
, page
, tab
):
36 tab
.WaitForDocumentReadyStateToBeComplete()
37 self
._smoothness
_controller
= smoothness_controller
.SmoothnessController()
38 self
._smoothness
_controller
.SetUp(page
, tab
)
39 self
._smoothness
_controller
.Start(tab
)
40 # Rasterize only what's visible.
41 tab
.ExecuteJavaScript(
42 'chrome.gpuBenchmarking.setRasterizeOnlyVisibleContent();')
45 args
['mode'] = self
.options
.mode
46 if self
.options
.width
:
47 args
['width'] = self
.options
.width
48 if self
.options
.height
:
49 args
['height'] = self
.options
.height
52 tab
.ExecuteJavaScript("""
53 window.benchmark_results = {};
54 window.benchmark_results.id =
55 chrome.gpuBenchmarking.runMicroBenchmark(
56 "invalidation_benchmark",
62 self
._micro
_benchmark
_id
= tab
.EvaluateJavaScript(
63 'window.benchmark_results.id')
64 if (not self
._micro
_benchmark
_id
):
65 raise page_test
.MeasurementFailure(
66 'Failed to schedule invalidation_benchmark.')
68 def DidRunActions(self
, page
, tab
):
69 tab
.ExecuteJavaScript("""
70 window.benchmark_results.message_handled =
71 chrome.gpuBenchmarking.sendMessageToMicroBenchmark(
72 """ + str(self
._micro
_benchmark
_id
) + """, {
76 self
._smoothness
_controller
.Stop(tab
)
78 def ValidateAndMeasurePage(self
, page
, tab
, results
):
79 self
._smoothness
_controller
.AddResults(tab
, results
)
81 def CleanUpAfterPage(self
, _
, tab
):
82 self
._smoothness
_controller
.CleanUp(tab
)