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

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: Addex pixel assert to unit test 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
« no previous file with comments | « tools/perf/contrib/cluster_telemetry/screenshot_ct.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 shutil
7 import tempfile
8
9 from telemetry import decorators
10 from telemetry.testing import options_for_unittests
11 from telemetry.testing import page_test_test_case
12 from telemetry.util import image_util
13 from contrib.cluster_telemetry import screenshot
14
15 class ScreenshotUnitTest(page_test_test_case.PageTestTestCase):
16
17 def setUp(self):
18 self._options = options_for_unittests.GetCopy()
19 self._png_outdir = tempfile.mkdtemp('_png_test')
20
21 def tearDown(self):
22 shutil.rmtree(self._png_outdir)
23
24 @decorators.Enabled('linux')
25 def testScreenshot(self):
26 # Screenshots for Cluster Telemetry purposes currently only supported on
27 # Linux platform.
28 page_set = self.CreateStorySetFromFileInUnittestDataDir(
29 'screenshot_test.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))
37
38 image = image_util.FromPngFile(path)
39 screenshot_pixels = image_util.Pixels(image)
40 special_colored_pixel = bytearray([217, 115, 43])
41 self.assertTrue(special_colored_pixel in screenshot_pixels)
OLDNEW
« no previous file with comments | « tools/perf/contrib/cluster_telemetry/screenshot_ct.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698