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
):
15 def __init__(self
, skp_outdir
):
16 super(SkpicturePrinter
, self
).__init
__()
17 self
._skp
_outdir
= skp_outdir
19 def CustomizeBrowserOptions(self
, options
):
20 options
.AppendExtraBrowserArgs(['--enable-gpu-benchmarking',
22 '--enable-deferred-image-decoding'])
24 def ValidateAndMeasurePage(self
, page
, tab
, results
):
25 if tab
.browser
.platform
.GetOSName() in ['android', 'chromeos']:
26 raise page_test
.MeasurementFailure(
27 'SkPicture printing not supported on this platform')
29 # Replace win32 path separator char '\' with '\\'.
30 outpath
= os
.path
.abspath(
31 os
.path
.join(self
._skp
_outdir
, page
.file_safe_name
))
32 js
= _JS
.format(outpath
.replace('\\', '\\\\'))
33 tab
.EvaluateJavaScript(js
)
34 pictures
= glob
.glob(os
.path
.join(outpath
, '*.skp'))
35 results
.AddValue(scalar
.ScalarValue(
36 results
.current_page
, 'saved_picture_count', 'count', len(pictures
)))