Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 import os | |
| 6 import platform | |
| 7 import shutil | |
| 8 import tempfile | |
| 9 | |
| 10 from telemetry.testing import options_for_unittests | |
| 11 from telemetry.testing import page_test_test_case | |
| 12 from contrib.cluster_telemetry import screenshot | |
| 13 | |
| 14 class ScreenshotUnitTest(page_test_test_case.PageTestTestCase): | |
| 15 | |
| 16 def setUp(self): | |
| 17 self._options = options_for_unittests.GetCopy() | |
| 18 self._png_outdir = tempfile.mkdtemp('_png_test') | |
| 19 | |
| 20 def tearDown(self): | |
| 21 shutil.rmtree(self._png_outdir) | |
| 22 | |
| 23 def testScreenshot(self): | |
| 24 page_set = self.CreateStorySetFromFileInUnittestDataDir('blank.html') | |
| 25 measurement = screenshot.Screenshot(self._png_outdir) | |
| 26 results = self.RunMeasurement(measurement, page_set, options=self._options) | |
| 27 | |
| 28 # Screenshots not supported if failure occurs on Linux | |
| 29 if results.failures and platform.system() == 'Linux': | |
|
wkorman
2017/06/08 23:14:41
Don't we want the inverse? If it's Linux, we want
| |
| 30 assert 'not supported' in results.failures[0].exc_info[1].message | |
| 31 return | |
| 32 | |
| 33 path = self._png_outdir + '/' + page_set.stories[0].file_safe_name + '.png' | |
| 34 self.assertTrue(os.path.exists(path)) | |
| 35 self.assertTrue(os.path.isfile(path)) | |
| 36 self.assertTrue(os.access(path, os.R_OK)) | |
| OLD | NEW |