| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import glob | |
| 5 import os | 4 import os |
| 6 | 5 |
| 7 from telemetry.page import legacy_page_test | 6 from telemetry.page import legacy_page_test |
| 8 from telemetry.value import scalar | |
| 9 | 7 |
| 10 | 8 |
| 11 _JS = 'chrome.gpuBenchmarking.printToSkPicture("{0}");' | 9 _JS = 'chrome.gpuBenchmarking.printPagesToSkPictures("{0}");' |
| 12 | 10 |
| 13 | 11 |
| 14 class SkpicturePrinter(legacy_page_test.LegacyPageTest): | 12 class MultipageSkpicturePrinter(legacy_page_test.LegacyPageTest): |
| 15 | 13 |
| 16 def __init__(self, skp_outdir): | 14 def __init__(self, mskp_outdir): |
| 17 super(SkpicturePrinter, self).__init__() | 15 super(MultipageSkpicturePrinter, self).__init__() |
| 18 self._skp_outdir = skp_outdir | 16 self._mskp_outdir = mskp_outdir |
| 19 | 17 |
| 20 def CustomizeBrowserOptions(self, options): | 18 def CustomizeBrowserOptions(self, options): |
| 21 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking', | 19 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking', |
| 22 '--no-sandbox', | 20 '--no-sandbox', |
| 23 '--enable-deferred-image-decoding']) | 21 '--enable-deferred-image-decoding']) |
| 24 | 22 |
| 25 def ValidateAndMeasurePage(self, page, tab, results): | 23 def ValidateAndMeasurePage(self, page, tab, results): |
| 26 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: | 24 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: |
| 27 raise legacy_page_test.MeasurementFailure( | 25 raise legacy_page_test.MeasurementFailure( |
| 28 'SkPicture printing not supported on this platform') | 26 'Multipage SkPicture printing not supported on this platform') |
| 29 | 27 |
| 30 # Replace win32 path separator char '\' with '\\'. | 28 # Replace win32 path separator char '\' with '\\'. |
| 31 outpath = os.path.abspath( | 29 outpath = os.path.abspath( |
| 32 os.path.join(self._skp_outdir, page.file_safe_name)) | 30 os.path.join(self._mskp_outdir, page.file_safe_name + '.mskp')) |
| 33 js = _JS.format(outpath.replace('\\', '\\\\')) | 31 js = _JS.format(outpath.replace('\\', '\\\\')) |
| 34 tab.EvaluateJavaScript(js) | 32 tab.EvaluateJavaScript(js) |
| 35 pictures = glob.glob(os.path.join(outpath, '*.skp')) | |
| 36 results.AddValue(scalar.ScalarValue( | |
| 37 results.current_page, 'saved_picture_count', 'count', len(pictures))) | |
| OLD | NEW |