• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# copyright (c) 2015 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
5from __future__ import print_function
6
7import logging, threading
8import time
9
10from autotest_lib.server import test
11from autotest_lib.client.common_lib import error
12
13_CHROME_PATH = '/opt/google/chrome/chrome'
14_LONG_TIMEOUT = 120
15_DO_NOT_RUN_ON_TYPE = ['CHROMEBOX', 'CHROMEBIT', 'OTHER']
16_DO_NOT_RUN_ON_BOARD = ['monroe']
17_SLEEP_BEFORE_SUSPEND_SEC = 5
18
19class platform_InternalDisplay(test.test):
20    version = 1
21
22    def run_suspend(self):
23        """Suspend i.e. powerd_dbus_suspend and wait
24
25        @returns boot_id for the following resume
26
27        """
28        boot_id = self.host.get_boot_id()
29        thread = threading.Thread(target = self.host.suspend)
30        thread.start()
31        self.host.test_wait_for_sleep(_LONG_TIMEOUT)
32        return boot_id
33
34    def run_once(self,host):
35
36        self.host = host
37
38        board_type = self.host.get_board_type()
39        if board_type in _DO_NOT_RUN_ON_TYPE:
40            raise error.TestNAError('DUT is %s type. Test Skipped' %board_type)
41
42        board = self.host.get_board().split(':')[-1]
43        logging.info(board)
44        if board in _DO_NOT_RUN_ON_BOARD:
45            raise error.TestNAError(
46                'Monroe does not have internal display. Test Skipped')
47
48        self.host.reboot()
49        if self.host.has_internal_display() != 'internal_display':
50            raise error.TestFail('Internal display is missing after reboot.')
51
52        time.sleep(_SLEEP_BEFORE_SUSPEND_SEC)
53        boot_id = self.run_suspend()
54        logging.info('DUT suspended')
55        self.host.test_wait_for_resume(boot_id, _LONG_TIMEOUT)
56        logging.info('DUT resumed')
57        if self.host.has_internal_display() != 'internal_display':
58            raise error.TestFail(
59                'Internal display is missing after suspend & resume.')
60
61