blob: 6374cadd6cb7dbaf0c7e77f70e77c7920a34043a [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import os
from import graphics_utils
from import method_logger
class ImportScreenShotCapturer(object):
Captures a screenshot with the required dimensions from a chromebook.
Uses utility capture but specifies the geometry/dimensions of final image.
We need this so that we can chop off things like browser address bar and
system task bar that are not only irrelevant to the test but would also add
noise to the test.
def __init__(self, destination_dir, screen_height_resolution,
top_pixels_to_crop, bottom_pixels_to_crop):
self.destination_dir = destination_dir
self.screen_height_resolution = screen_height_resolution
self.top_pixels_to_crop = top_pixels_to_crop
self.bottom_pixels_to_crop = bottom_pixels_to_crop
def __enter__(self):
return self
def capture(self, filename):
Capture the screenshot.
Use pre-configured information to create a geometry that specifies the
final dimension and position of the image.
@param filename: string, the screenshot filename.
@returns a complete path to the screenshot generated.
fullpath = os.path.join(self.destination_dir, filename)
final_height = (self.screen_height_resolution -
self.top_pixels_to_crop - self.bottom_pixels_to_crop)
return fullpath
def __exit__(self, exc_type, exc_val, exc_tb):