Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / tools / perf / measurements / screenshot.py
blob5c4345a5a4ca397ed6c1f6b6d239f2da303d9081
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
3 # found in the LICENSE file.
4 import os
6 from telemetry.page import page_test
7 from telemetry.page import page_test
8 from telemetry.value import scalar
11 class Screenshot(page_test.PageTest):
12 def __init__(self, png_outdir):
13 super(Screenshot, self).__init__(
14 action_name_to_run = 'RunPageInteractions',
15 is_action_name_to_run_optional=True)
16 self._png_outdir = png_outdir
18 def ValidateAndMeasurePage(self, page, tab, results):
19 if not tab.screenshot_supported:
20 raise page_test.TestNotSupportedOnPlatformFailure(
21 'Browser does not support screenshotting')
23 tab.WaitForDocumentReadyStateToBeComplete()
24 screenshot = tab.Screenshot(60)
26 outpath = os.path.abspath(
27 os.path.join(self._png_outdir, page.file_safe_name)) + '.png'
29 if os.path.exists(outpath):
30 previous_mtime = os.path.getmtime(outpath)
31 else:
32 previous_mtime = -1
34 screenshot.WritePngFile(outpath)
36 saved_picture_count = 0
37 if os.path.exists(outpath) and os.path.getmtime(outpath) > previous_mtime:
38 saved_picture_count = 1
39 results.AddValue(scalar.ScalarValue(
40 results.current_page, 'saved_picture_count', 'count',
41 saved_picture_count))