blob: c62df078dee6d41f25d2425e7a5ce15183ac2162 [file] [log] [blame]
# Copyright 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.
"""Classes to do comparison for mirrored mode."""
import logging
from autotest_lib.client.cros.chameleon import screen_capture
from autotest_lib.client.cros.chameleon import screen_comparison
class MirrorComparer(object):
"""A class to compare the resolutions and screens for mirrored mode.
Calling its member method compare() does the comparison.
def __init__(self, display_facade, output_dir):
"""Initializes the MirrorComparer objects.
@param display_facade: A display facade object
@param output_dir: The directory for output images.
self._display_facade = display_facade
int_capturer = screen_capture.CrosInternalScreenCapturer(display_facade)
ext_capturer = screen_capture.CrosExternalScreenCapturer(display_facade)
# The frame buffers of screens should be perfectly matched.
self._screen_comparer = screen_comparison.ScreenComparer(
int_capturer, ext_capturer, output_dir, 0, 0)
def compare(self):
"""Compares the resolutions and screens on all CrOS screens.
This method first checks if CrOS is under mirrored mode or not. Skip
the following tests if not in mirrored mode.
Then it checks all the resolutions identical and also all the screens
@return: None if the check passes; otherwise, a string of error message.
if not self._display_facade.is_mirrored_enabled():
message = 'Do mirror comparison but not in mirrored mode.'
return message'Checking the resolutions of all screens identical...')
# TODO(waihong): Support the case without internal screen.
internal_resolution = self._display_facade.get_internal_resolution()
# TODO(waihong): Support multiple external screens.
external_resolution = self._display_facade.get_external_resolution()
if internal_resolution != external_resolution:'Sofware-based mirroring, skip the screen comparison. '
'Resolutions: Internal %r; External %r',
internal_resolution, external_resolution)
return None
else:'Resolutions across all CrOS screens match: %dx%d',
*internal_resolution)'Checking all the screens mirrored...')