Chromium Code Reviews| Index: tools/perf/measurements/screenshot_unittest.py |
| diff --git a/tools/perf/measurements/screenshot_unittest.py b/tools/perf/measurements/screenshot_unittest.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..49162fd453fe9c50d212e96be2f11e90e9d71517 |
| --- /dev/null |
| +++ b/tools/perf/measurements/screenshot_unittest.py |
| @@ -0,0 +1,35 @@ |
| +# Copyright 2017 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 telemetry.testing import options_for_unittests |
| +from telemetry.testing import page_test_test_case |
| + |
| +from measurements import screenshot |
| + |
| +class ScreenshotUnitTest(page_test_test_case.PageTestTestCase): |
| + |
| + def setUp(self): |
| + self._options = options_for_unittests.GetCopy() |
| + self._png_outdir = tempfile.mkdtemp('_png_test') |
| + |
| + def tearDown(self): |
| + shutil.rmtree(self._png_outdir) |
| + |
| + def testPixelDiff(self): |
| + page_set = self.CreateStorySetFromFileInUnittestDataDir('blank.html') |
| + measurement = screenshot.Screenshot(self._png_outdir) |
| + results = self.RunMeasurement(measurement, page_set, options=self._options) |
| + |
| + # Screenshots are not supported on all platforms |
| + if results.failures: |
|
wkorman
2017/06/08 17:57:53
Looks like we still need to figure out some way to
|
| + assert 'not supported' in results.failures[0].exc_info[1].message |
| + return |
| + |
| + saved_picture_count = results.FindAllPageSpecificValuesNamed( |
| + 'saved_picture_count') |
| + self.assertEquals(len(saved_picture_count), 1) |
| + self.assertGreater(saved_picture_count[0].GetRepresentativeNumber(), 0) |