• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 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
5import logging
6import time
7
8from autotest_lib.client.bin import test
9from autotest_lib.client.common_lib import error
10from autotest_lib.client.cros.multimedia import display_facade_native
11from autotest_lib.client.cros.multimedia import facade_resource
12
13
14class display_InternalDisplayRotation(test.test):
15    """Display test case which rotates the internal display"""
16    version = 1
17    ROTATIONS = [90, 180, 270, 0]
18    STANDARD_ROTATION = 0
19    DELAY_BEFORE_ROTATION = DELAY_AFTER_ROTATION = 3
20
21    def cleanup(self):
22        """Autotest cleanup method"""
23        # If the rotation is not standard then change rotation to standard
24        if self.display_facade:
25            if self.display_facade.get_display_rotation(
26                    self.internal_display_id) != self.STANDARD_ROTATION:
27                logging.info("Setting standard rotation")
28                self.display_facade.set_display_rotation(
29                        self.internal_display_id, self.STANDARD_ROTATION,
30                        self.DELAY_BEFORE_ROTATION, self.DELAY_AFTER_ROTATION)
31
32    def run_once(self):
33        """Test to rotate internal display"""
34        facade = facade_resource.FacadeResource()
35        facade.start_default_chrome()
36        self.display_facade = display_facade_native.DisplayFacadeNative(facade)
37        self.internal_display_id = self.display_facade.get_internal_display_id()
38        logging.info("Internal display ID is %s", self.internal_display_id)
39        rotation_before_starts = self.display_facade.get_display_rotation(
40                self.internal_display_id)
41        logging.info("Rotation before test starts is %d",
42                     rotation_before_starts)
43        for angle in self.ROTATIONS:
44            logging.info("Rotation to be set %d", angle)
45            self.display_facade.set_display_rotation(self.internal_display_id,
46                                                     angle,
47                                                     self.DELAY_BEFORE_ROTATION,
48                                                     self.DELAY_AFTER_ROTATION)
49            rotation = self.display_facade.get_display_rotation(
50                    self.internal_display_id)
51            logging.info("Internal display rotation is set to %s", rotation)
52            if rotation != angle:
53                raise error.TestFail('Failed to set %d rotation' % angle)