1 # Copyright 2016 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 screen rotation test using the Chameleon board.""" 6 7 import logging 8 9 from autotest_lib.client.common_lib import error 10 from autotest_lib.server import test 11 from autotest_lib.server.cros.chameleon import chameleon_measurer 12 13 14 class platform_RotationFps(test.test): 15 """Server side screen rotation test. 16 17 This test talks to a Chameleon board and a DUT to set up dock mode, 18 change rotation, and measure the fps. 19 """ 20 version = 1 21 22 DELAY_BEFORE_ROTATION = 5 23 DELAY_AFTER_ROTATION = 5 24 25 def run_once(self, host): 26 # Check the servo object 27 if host.servo is None: 28 raise error.TestError('Invalid servo object found on the host.') 29 if host.get_board_type() != 'CHROMEBOOK': 30 raise error.TestNAError('DUT is not Chromebook. Test Skipped') 31 32 measurer = chameleon_measurer.RemoteChameleonMeasurer( 33 host, self.outputdir) 34 display_facade = measurer.display_facade 35 36 chameleon_board = host.chameleon 37 chameleon_board.setup_and_reset(self.outputdir) 38 39 with measurer.start_dock_mode_measurement() as chameleon_port: 40 chameleon_port_name = chameleon_port.get_connector_type() 41 logging.info('Detected %s chameleon port.', chameleon_port_name) 42 index = display_facade.get_first_external_display_index() 43 44 # Ask Chameleon to capture the video during rotation 45 chameleon_port.start_capturing_video() 46 # Rotate the screen to 90 degree. 47 # Adding delays before and after rotation such that we can easily 48 # know the rotation fps, not other animation like opening a tab. 49 display_facade.set_display_rotation( 50 index, 90, self.DELAY_BEFORE_ROTATION, 51 self.DELAY_AFTER_ROTATION) 52 chameleon_port.stop_capturing_video() 53 # Restore back to 0 degree. 54 display_facade.set_display_rotation(index, 0) 55 56 # Retrieve the FPS info 57 fps_list = chameleon_port.get_captured_fps_list() 58 # Cut the fps numbers before and after rotation 59 fps_list = fps_list[-(self.DELAY_AFTER_ROTATION + 1): 60 -(self.DELAY_AFTER_ROTATION - 1)] 61 # The fps during rotation may cross the second-boundary. Sum them. 62 fps = sum(fps_list) 63 logging.info('***RESULT*** Rotation FPS is %d (max 15)', fps) 64 65 # Output the perf value 66 self.output_perf_value(description='Rotation FPS', 67 value=fps, 68 higher_is_better=True, 69 units='fps') 70