From 0c4d8e5a952c2b6788af70dc64a4d84f6ef8cf3f Mon Sep 17 00:00:00 2001 From: "skyostil@chromium.org" Date: Mon, 17 Feb 2014 13:04:36 +0000 Subject: [PATCH] Fix SkPicture printing measurement Measurement results of type 'path' are no longer supported, so just report the number of pictures that were saved. TEST=tools/perf/run_tests SkpicturePrinterUnitTest.testSkpicturePrinter Review URL: https://codereview.chromium.org/167133002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251667 0039d316-1c4b-4281-b951-d872f2087c98 --- tools/perf/measurements/skpicture_printer.py | 8 ++++- .../measurements/skpicture_printer_unittest.py | 34 ++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tools/perf/measurements/skpicture_printer_unittest.py diff --git a/tools/perf/measurements/skpicture_printer.py b/tools/perf/measurements/skpicture_printer.py index 2208d1cd41ff..e039867316ee 100644 --- a/tools/perf/measurements/skpicture_printer.py +++ b/tools/perf/measurements/skpicture_printer.py @@ -1,6 +1,7 @@ # Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +import glob import os from telemetry.page import page_measurement @@ -21,6 +22,10 @@ class SkpicturePrinter(page_measurement.PageMeasurement): '--force-compositing-mode']) def MeasurePage(self, page, tab, results): + if tab.browser.platform.GetOSName() in ['android', 'chromeos']: + raise page_measurement.MeasurementFailure( + 'SkPicture printing not supported on this platform') + skp_outdir = self.options.skp_outdir if not skp_outdir: raise Exception('Please specify --skp-outdir') @@ -30,4 +35,5 @@ class SkpicturePrinter(page_measurement.PageMeasurement): # Replace win32 path separator char '\' with '\\'. js = _JS.format(outpath.replace('\\', '\\\\')) tab.EvaluateJavaScript(js) - results.Add('output_path', 'path', outpath) + pictures = glob.glob(os.path.join(outpath, '*.skp')) + results.Add('saved_picture_count', 'count', len(pictures)) diff --git a/tools/perf/measurements/skpicture_printer_unittest.py b/tools/perf/measurements/skpicture_printer_unittest.py new file mode 100644 index 000000000000..6530ccc15de0 --- /dev/null +++ b/tools/perf/measurements/skpicture_printer_unittest.py @@ -0,0 +1,34 @@ +# Copyright 2014 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +import shutil +import tempfile + +from measurements import skpicture_printer +from telemetry.page import page_measurement_unittest_base +from telemetry.unittest import options_for_unittests + + +class SkpicturePrinterUnitTest( + page_measurement_unittest_base.PageMeasurementUnitTestBase): + def setUp(self): + self._options = options_for_unittests.GetCopy() + self._options.skp_outdir = tempfile.mkdtemp('_skp_test') + + def tearDown(self): + shutil.rmtree(self._options.skp_outdir) + + def testSkpicturePrinter(self): + ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html') + measurement = skpicture_printer.SkpicturePrinter() + results = self.RunMeasurement(measurement, ps, options=self._options) + + # Picture printing is not supported on all platforms. + if results.failures: + assert 'not supported' in results.failures[0][1] + return + + saved_picture_count = results.FindAllPageSpecificValuesNamed( + 'saved_picture_count') + self.assertEquals(len(saved_picture_count), 1) + self.assertGreater(saved_picture_count[0].GetRepresentativeNumber(), 0) -- 2.11.4.GIT