blob: 492a8d5b1e47f4ec9054f4570903fc6b4ddc4e63 [file] [log] [blame]
# Copyright 2016 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 logging
import time
from contextlib import contextmanager
from autotest_lib.client.cros.chameleon import chameleon
from autotest_lib.client.cros.chameleon import chameleon_port_finder
from autotest_lib.client.cros.multimedia import local_facade_factory
class _BaseChameleonMeasurer(object):
"""Base class of performing measurement using Chameleon."""
def __init__(self, cros_host, outputdir=None):
"""Initializes the object."""
raise NotImplementedError('_BaseChameleonMeasurer.__init__')
def start_mirrored_mode_measurement(self):
"""Starts the mirrored mode to measure.
It iterates the connection ports between DUT and Chameleon and uses
the first port. Sets DUT into the mirrored mode. Then yields the
connected ports.
It is used via a with statement, like the following:
measurer = LocalChameleonMeasurer(cros_host, args, chrome)
with measure.start_mirrored_mode_measurement() as chameleon_port:
# chameleon_port is automatically plugged before this line.
# chameleon_port is automatically unplugged after this line.
@yields the first connected ChameleonVideoInput which is ensured plugged
before yielding.
@raises TestFail if no connected video port.
finder = chameleon_port_finder.ChameleonVideoInputFinder(
self.chameleon, self.display_facade)
with finder.use_first_port() as chameleon_port:'Used Chameleon port: %s',
chameleon_port.get_connector_type())'Setting to mirrored mode')
# Hide the typing cursor.
# Sleep a while to wait the pop-up window faded-out.
# Get the resolution to make sure Chameleon in a good state.
resolution = chameleon_port.get_resolution()'Detected the resolution: %dx%d', *resolution)
yield chameleon_port
class LocalChameleonMeasurer(_BaseChameleonMeasurer):
"""A simple tool to measure using Chameleon for a client test.
This class can only be used in a client test. For a server test, use the
RemoteChameleonMeasurer in server/cros/chameleon/
def __init__(self, cros_host, args, chrome, outputdir=None):
"""Initializes the object."""
factory = local_facade_factory.LocalFacadeFactory(chrome)
self.display_facade = factory.create_display_facade()
self.chameleon = chameleon.create_chameleon_board(cros_host.hostname,