blob: 580fdc261f8260dd2ab37bbb523e71078959a25b [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091# Copyright 2012 The Chromium Authors
[email protected]fb2b85d2012-09-12 18:45:562# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
[email protected]0c4d8e5a2014-02-17 13:04:364import glob
[email protected]fb2b85d2012-09-12 18:45:565import os
[email protected]fb2b85d2012-09-12 18:45:566
nednguyene9321b12016-04-27 20:47:107from telemetry.page import legacy_page_test
[email protected]fb2b85d2012-09-12 18:45:568
[email protected]0b209be82013-07-17 21:33:349
nednguyene9321b12016-04-27 20:47:1010class SkpicturePrinter(legacy_page_test.LegacyPageTest):
qyearsley2e10aec72016-02-03 17:53:4211
ernstm7c0eae72014-11-19 21:01:4012 def __init__(self, skp_outdir):
nednguyenff753ad62015-03-13 18:18:1313 super(SkpicturePrinter, self).__init__()
ernstm7c0eae72014-11-19 21:01:4014 self._skp_outdir = skp_outdir
[email protected]fbcf7ab2014-03-15 00:55:4215
[email protected]fb2b85d2012-09-12 18:45:5616 def CustomizeBrowserOptions(self, options):
[email protected]852511c2013-09-06 05:51:2317 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking',
18 '--no-sandbox',
[email protected]cdb0abe2014-07-03 13:13:1719 '--enable-deferred-image-decoding'])
[email protected]fb2b85d2012-09-12 18:45:5620
[email protected]f634a1152014-08-09 08:30:1721 def ValidateAndMeasurePage(self, page, tab, results):
[email protected]0c4d8e5a2014-02-17 13:04:3622 if tab.browser.platform.GetOSName() in ['android', 'chromeos']:
nednguyene9321b12016-04-27 20:47:1023 raise legacy_page_test.MeasurementFailure(
[email protected]0c4d8e5a2014-02-17 13:04:3624 'SkPicture printing not supported on this platform')
25
[email protected]fbcf7ab2014-03-15 00:55:4226 outpath = os.path.abspath(
27 os.path.join(self._skp_outdir, page.file_safe_name))
perezju2445daf2017-01-31 17:39:5828 # Replace win32 path separator char '\' with '\\'.
29 outpath = outpath.replace('\\', '\\\\')
perezjud42421be2017-02-28 09:40:2030 tab.EvaluateJavaScript(
perezju2445daf2017-01-31 17:39:5831 'chrome.gpuBenchmarking.printToSkPicture({{ outpath }});',
32 outpath=outpath)
[email protected]0c4d8e5a2014-02-17 13:04:3633 pictures = glob.glob(os.path.join(outpath, '*.skp'))
Juan Antonio Navarro Perez20d65b22019-09-05 10:44:0034 results.AddMeasurement('saved_picture_count', 'count', len(pictures))