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

Side by Side Diff: tools/perf/measurements/screenshot.py

Issue 641823004: telemetry: Allow page tests to be configured via constructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/master
Patch Set: Add debug output to figure out why pixel tests fail on bots. Created 6 years, 1 month 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/measurements/repaint.py ('k') | tools/perf/measurements/skpicture_printer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 import os 4 import os
5 5
6 from telemetry.page import page_test 6 from telemetry.page import page_test
7 from telemetry.page import page_test 7 from telemetry.page import page_test
8 from telemetry.value import scalar 8 from telemetry.value import scalar
9 9
10 10
11 class Screenshot(page_test.PageTest): 11 class Screenshot(page_test.PageTest):
12 def __init__(self): 12 def __init__(self):
13 super(Screenshot, self).__init__( 13 super(Screenshot, self).__init__(
14 action_name_to_run = 'RunPageInteractions', 14 action_name_to_run = 'RunPageInteractions',
15 is_action_name_to_run_optional=True) 15 is_action_name_to_run_optional=True)
16 self._png_outdir = None
16 17
17 @classmethod 18 def AddCommandLineArgs(self, parser):
18 def AddCommandLineArgs(cls, parser):
19 parser.add_option('--png-outdir', 19 parser.add_option('--png-outdir',
20 help='Output directory for the PNG files') 20 help='Output directory for the PNG files')
21 21
22 @classmethod 22 def ProcessCommandLineArgs(self, parser, args):
23 def ProcessCommandLineArgs(cls, parser, args):
24 if not args.png_outdir: 23 if not args.png_outdir:
25 parser.error('Please specify --png-outdir') 24 parser.error('Please specify --png-outdir')
26 cls._png_outdir = args.png_outdir 25 self._png_outdir = args.png_outdir
27 26
28 def ValidateAndMeasurePage(self, page, tab, results): 27 def ValidateAndMeasurePage(self, page, tab, results):
29 if not tab.screenshot_supported: 28 if not tab.screenshot_supported:
30 raise page_test.TestNotSupportedOnPlatformFailure( 29 raise page_test.TestNotSupportedOnPlatformFailure(
31 'Browser does not support screenshotting') 30 'Browser does not support screenshotting')
32 31
33 tab.WaitForDocumentReadyStateToBeComplete() 32 tab.WaitForDocumentReadyStateToBeComplete()
34 screenshot = tab.Screenshot(60) 33 screenshot = tab.Screenshot(60)
35 34
36 outpath = os.path.abspath( 35 outpath = os.path.abspath(
37 os.path.join(self._png_outdir, page.file_safe_name)) + '.png' 36 os.path.join(self._png_outdir, page.file_safe_name)) + '.png'
38 37
39 if os.path.exists(outpath): 38 if os.path.exists(outpath):
40 previous_mtime = os.path.getmtime(outpath) 39 previous_mtime = os.path.getmtime(outpath)
41 else: 40 else:
42 previous_mtime = -1 41 previous_mtime = -1
43 42
44 screenshot.WritePngFile(outpath) 43 screenshot.WritePngFile(outpath)
45 44
46 saved_picture_count = 0 45 saved_picture_count = 0
47 if os.path.exists(outpath) and os.path.getmtime(outpath) > previous_mtime: 46 if os.path.exists(outpath) and os.path.getmtime(outpath) > previous_mtime:
48 saved_picture_count = 1 47 saved_picture_count = 1
49 results.AddValue(scalar.ScalarValue( 48 results.AddValue(scalar.ScalarValue(
50 results.current_page, 'saved_picture_count', 'count', 49 results.current_page, 'saved_picture_count', 'count',
51 saved_picture_count)) 50 saved_picture_count))
OLDNEW
« no previous file with comments | « tools/perf/measurements/repaint.py ('k') | tools/perf/measurements/skpicture_printer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698