OLD | NEW |
1 # Copyright 2016 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 os | 4 import os |
5 | 5 |
6 from telemetry.page import legacy_page_test | 6 from telemetry.page import legacy_page_test |
7 | 7 |
8 | 8 |
9 class MultipageSkpicturePrinter(legacy_page_test.LegacyPageTest): | 9 class MultipageSkpicturePrinter(legacy_page_test.LegacyPageTest): |
10 | 10 |
11 def __init__(self, mskp_outdir): | 11 def __init__(self, mskp_outdir): |
12 super(MultipageSkpicturePrinter, self).__init__() | 12 super(MultipageSkpicturePrinter, self).__init__() |
13 self._mskp_outdir = mskp_outdir | 13 self._mskp_outdir = mskp_outdir |
14 | 14 |
15 def CustomizeBrowserOptions(self, options): | 15 def CustomizeBrowserOptions(self, options): |
16 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking', | 16 options.AppendExtraBrowserArgs(['--enable-gpu-benchmarking', |
17 '--no-sandbox', | 17 '--no-sandbox', |
18 '--enable-deferred-image-decoding']) | 18 '--enable-deferred-image-decoding']) |
19 | 19 |
20 def ValidateAndMeasurePage(self, page, tab, results): | 20 def ValidateAndMeasurePage(self, page, tab, results): |
21 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: | 21 if tab.browser.platform.GetOSName() in ['android', 'chromeos']: |
22 raise legacy_page_test.MeasurementFailure( | 22 raise legacy_page_test.MeasurementFailure( |
23 'Multipage SkPicture printing not supported on this platform') | 23 'Multipage SkPicture printing not supported on this platform') |
24 | 24 |
25 outpath = os.path.abspath( | 25 outpath = os.path.abspath( |
26 os.path.join(self._mskp_outdir, page.file_safe_name + '.mskp')) | 26 os.path.join(self._mskp_outdir, page.file_safe_name + '.mskp')) |
27 # Replace win32 path separator char '\' with '\\'. | 27 # Replace win32 path separator char '\' with '\\'. |
28 outpath = outpath.replace('\\', '\\\\') | 28 outpath = outpath.replace('\\', '\\\\') |
29 tab.EvaluateJavaScript2( | 29 tab.EvaluateJavaScript( |
30 'chrome.gpuBenchmarking.printPagesToSkPictures({{ outpath }});', | 30 'chrome.gpuBenchmarking.printPagesToSkPictures({{ outpath }});', |
31 outpath=outpath) | 31 outpath=outpath) |
OLD | NEW |