1 # Copyright 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.
7 from telemetry
.page
import page_test
8 from telemetry
.value
import scalar
11 _JS
= 'chrome.gpuBenchmarking.printToSkPicture("{0}");'
14 class SkpicturePrinter(page_test
.PageTest
):
16 def AddCommandLineArgs(cls
, parser
):
17 parser
.add_option('-s', '--skp-outdir',
18 help='Output directory for the SKP files')
21 def ProcessCommandLineArgs(cls
, parser
, args
):
22 if not args
.skp_outdir
:
23 parser
.error('Please specify --skp-outdir')
24 cls
._skp
_outdir
= args
.skp_outdir
26 def CustomizeBrowserOptions(self
, options
):
27 options
.AppendExtraBrowserArgs(['--enable-gpu-benchmarking',
29 '--enable-deferred-image-decoding'])
31 def ValidateAndMeasurePage(self
, page
, tab
, results
):
32 if tab
.browser
.platform
.GetOSName() in ['android', 'chromeos']:
33 raise page_test
.MeasurementFailure(
34 'SkPicture printing not supported on this platform')
36 # Replace win32 path separator char '\' with '\\'.
37 outpath
= os
.path
.abspath(
38 os
.path
.join(self
._skp
_outdir
, page
.file_safe_name
))
39 js
= _JS
.format(outpath
.replace('\\', '\\\\'))
40 tab
.EvaluateJavaScript(js
)
41 pictures
= glob
.glob(os
.path
.join(outpath
, '*.skp'))
42 results
.AddValue(scalar
.ScalarValue(
43 results
.current_page
, 'saved_picture_count', 'count', len(pictures
)))