1# Lint as: python2, python3 2# Copyright 2018 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6import logging 7import time 8 9from autotest_lib.client.bin import test 10from autotest_lib.client.common_lib import error 11from autotest_lib.client.cros.multimedia import display_facade 12from autotest_lib.client.cros.multimedia import facade_resource 13 14 15class display_InternalDisplayRotation(test.test): 16 """Display test case which rotates the internal display""" 17 version = 1 18 ROTATIONS = [90, 180, 270, 0] 19 STANDARD_ROTATION = 0 20 DELAY_BEFORE_ROTATION = DELAY_AFTER_ROTATION = 3 21 22 def cleanup(self): 23 """Autotest cleanup method""" 24 # If the rotation is not standard then change rotation to standard 25 if self.display_facade: 26 if self.display_facade.get_display_rotation( 27 self.internal_display_id) != self.STANDARD_ROTATION: 28 logging.info("Setting standard rotation") 29 self.display_facade.set_display_rotation( 30 self.internal_display_id, self.STANDARD_ROTATION, 31 self.DELAY_BEFORE_ROTATION, self.DELAY_AFTER_ROTATION) 32 33 def run_once(self): 34 """Test to rotate internal display""" 35 facade = facade_resource.FacadeResource() 36 facade.start_default_chrome() 37 self.display_facade = display_facade.DisplayFacadeLocal(facade) 38 self.internal_display_id = self.display_facade.get_internal_display_id() 39 logging.info("Internal display ID is %s", self.internal_display_id) 40 rotation_before_starts = self.display_facade.get_display_rotation( 41 self.internal_display_id) 42 logging.info("Rotation before test starts is %d", 43 rotation_before_starts) 44 for angle in self.ROTATIONS: 45 logging.info("Rotation to be set %d", angle) 46 self.display_facade.set_display_rotation(self.internal_display_id, 47 angle, 48 self.DELAY_BEFORE_ROTATION, 49 self.DELAY_AFTER_ROTATION) 50 rotation = self.display_facade.get_display_rotation( 51 self.internal_display_id) 52 logging.info("Internal display rotation is set to %s", rotation) 53 if rotation != angle: 54 raise error.TestFail('Failed to set %d rotation' % angle) 55