1# Copyright 2014 The Chromium OS 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
5"""This is a server-side test to check the Chameleon connection."""
6
7import logging
8
9from autotest_lib.client.common_lib import error
10from autotest_lib.client.cros.chameleon import chameleon_port_finder
11from autotest_lib.server import test
12from autotest_lib.server.cros.multimedia import remote_facade_factory
13
14
15class display_ServerChameleonConnection(test.test):
16    """Chameleon connection server test.
17
18    This test talks to a Chameleon board from DUT. Try to plug the Chameleon
19    ports and see if DUT detects them.
20    """
21    version = 1
22
23    def run_once(self, host):
24        factory = remote_facade_factory.RemoteFacadeFactory(host)
25        display_facade = factory.create_display_facade()
26        chameleon_board = host.chameleon
27
28        chameleon_board.setup_and_reset(self.outputdir)
29
30        finder = chameleon_port_finder.ChameleonVideoInputFinder(
31                chameleon_board, display_facade)
32        ports = finder.find_all_ports()
33
34        connected_ports = ports.connected
35        dut_failed_ports = ports.failed
36
37        msg = str(finder)
38        logging.debug(msg)
39
40        if dut_failed_ports or not connected_ports:
41            raise error.TestFail(msg)
42