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 resolution display test using the Chameleon board.""" 6 7import logging 8import os 9import time 10 11from autotest_lib.client.bin import utils 12from autotest_lib.client.common_lib import error 13from autotest_lib.client.cros.chameleon import chameleon_port_finder 14from autotest_lib.client.cros.chameleon import chameleon_screen_test 15from autotest_lib.client.cros.chameleon import edid 16from autotest_lib.server import test 17from autotest_lib.server.cros.multimedia import remote_facade_factory 18 19 20class display_Resolution(test.test): 21 """Server side external display test. 22 23 This test talks to a Chameleon board and a DUT to set up, run, and verify 24 external display function of the DUT. 25 """ 26 version = 1 27 28 # Allowed timeout for reboot. 29 REBOOT_TIMEOUT = 30 30 # Time to allow lid transition to take effect 31 WAIT_TIME_LID_TRANSITION = 5 32 33 DEFAULT_RESOLUTION_LIST = [ 34 # Mix DP and HDMI together to test the converter cases. 35 ('DP', 1280, 800), 36 ('DP', 1440, 900), 37 ('DP', 1600, 900), 38 ('DP', 1680, 1050), 39 ('DP', 1920, 1080), 40 ('HDMI', 1280, 720), 41 ('HDMI', 1920, 1080), 42 ] 43 44 def run_once(self, host, test_mirrored=False, test_suspend_resume=False, 45 test_reboot=False, test_lid_close_open=False, 46 resolution_list=None): 47 # Check the servo object 48 if test_lid_close_open and host.servo is None: 49 raise error.TestError('Invalid servo object found on the host.') 50 if test_lid_close_open and not host.get_board_type() == 'CHROMEBOOK': 51 raise error.TestNAError('DUT is not Chromebook. Test Skipped') 52 53 factory = remote_facade_factory.RemoteFacadeFactory(host) 54 display_facade = factory.create_display_facade() 55 chameleon_board = host.chameleon 56 57 chameleon_board.reset() 58 finder = chameleon_port_finder.ChameleonVideoInputFinder( 59 chameleon_board, display_facade) 60 61 errors = [] 62 if resolution_list is None: 63 resolution_list = self.DEFAULT_RESOLUTION_LIST 64 for chameleon_port in finder.iterate_all_ports(): 65 screen_test = chameleon_screen_test.ChameleonScreenTest( 66 chameleon_port, display_facade, self.outputdir) 67 chameleon_port_name = chameleon_port.get_connector_type() 68 logging.info('Detected %s chameleon port.', chameleon_port_name) 69 for interface, width, height in resolution_list: 70 if not chameleon_port_name.startswith(interface): 71 continue 72 test_resolution = (width, height) 73 test_name = "%s_%dx%d" % ((interface,) + test_resolution) 74 75 if not edid.is_edid_supported(host, interface, width, height): 76 logging.info('Skip unsupported EDID: %s', test_name) 77 continue 78 79 if test_lid_close_open: 80 logging.info('Close lid...') 81 host.servo.lid_close() 82 time.sleep(self.WAIT_TIME_LID_TRANSITION) 83 84 if test_reboot: 85 logging.info('Reboot...') 86 boot_id = host.get_boot_id() 87 host.reboot(wait=False) 88 host.test_wait_for_shutdown(self.REBOOT_TIMEOUT) 89 90 path = os.path.join(self.bindir, 'test_data', 'edids', 91 test_name) 92 logging.info('Use EDID: %s', test_name) 93 with chameleon_port.use_edid_file(path): 94 if test_lid_close_open: 95 logging.info('Open lid...') 96 host.servo.lid_open() 97 time.sleep(self.WAIT_TIME_LID_TRANSITION) 98 99 if test_reboot: 100 host.test_wait_for_boot(boot_id) 101 102 utils.wait_for_value_changed( 103 display_facade.get_external_connector_name, 104 old_value=False) 105 106 logging.info('Set mirrored: %s', test_mirrored) 107 display_facade.set_mirrored(test_mirrored) 108 if test_suspend_resume: 109 if test_mirrored: 110 # magic sleep to wake up nyan_big in mirrored mode 111 # TODO: find root cause 112 time.sleep(6) 113 logging.info('Going to suspend...') 114 display_facade.suspend_resume() 115 logging.info('Resumed back') 116 117 screen_test.test_screen_with_image( 118 test_resolution, test_mirrored, errors) 119 120 if errors: 121 raise error.TestFail('; '.join(set(errors))) 122