Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: tools/perf/contrib/cluster_telemetry/screenshot_unittest.py

Issue 2923163007: Implemented telemetry benchmark that loads page and outputs screenshot. (Closed)
Patch Set: More detailed logging, unit test now returns if not Linux Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 # Screenshots for Cluster Telemetry purposes currently only supported on
25 # Linux platform.
26 if platform.system() != 'Linux':
nednguyen 2017/06/09 18:11:09 You would want to do @decorators.Enabled('linux')
27 return
28
29 page_set = self.CreateStorySetFromFileInUnittestDataDir('blank.html')
30 measurement = screenshot.Screenshot(self._png_outdir)
31 self.RunMeasurement(measurement, page_set, options=self._options)
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))
nednguyen 2017/06/09 18:11:09 In general, test should not leave files around aft
lchoi 2017/06/09 18:16:51 I'm pretty sure the tearDown() fn above takes care
nednguyen 2017/06/09 18:22:59 Ah right. Sorry that i missed the tearDown
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698