• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 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"""Server side bluetooth adapter stress tests involving suspend resume.
6First we test powering on the adapter, suspend/resume the DUT, and make sure
7the adapter is still powered on and in a working state.
8
9Next we test powering off the adapter, suspend/resume, and verify the adapter
10is still powered off.
11"""
12
13import logging
14
15from autotest_lib.client.common_lib import error
16from autotest_lib.server.cros.bluetooth import bluetooth_adapter_tests
17from autotest_lib.server.cros.multimedia import bluetooth_le_facade_adapter
18
19
20test_case_log = bluetooth_adapter_tests.test_case_log
21
22
23class bluetooth_AdapterSuspendResume(
24        bluetooth_adapter_tests.BluetoothAdapterTests):
25    """Server side bluetooth adapter suspend resume test."""
26
27    # ---------------------------------------------------------------
28    # Definitions of all test cases
29    # ---------------------------------------------------------------
30
31    @test_case_log
32    def test_case_adapter_on_SR(self):
33        """Test Case: Power on - SR"""
34        self.test_power_on_adapter()
35        self.test_bluetoothd_running()
36        self.suspend_resume()
37        self.test_bluetoothd_running()
38        self.test_adapter_work_state()
39        self.test_power_on_adapter()
40
41    @test_case_log
42    def test_case_adapter_off_SR(self):
43        """Test Case: Power on - SR"""
44        self.test_power_off_adapter()
45        self.test_bluetoothd_running()
46        self.suspend_resume()
47        self.test_power_off_adapter()
48        self.test_bluetoothd_running()
49
50
51    def run_once(self, host, num_iterations=1):
52        """Running Bluetooth adapter suspend resume autotest.
53
54        @param host: device under test host.
55        @param num_iterations: number of times to perform suspend resume tests.
56
57        """
58        self.host = host
59        ble_adapter = bluetooth_le_facade_adapter.BluetoothLEFacadeRemoteAdapter
60        self.bluetooth_le_facade = ble_adapter(self.host)
61        self.bluetooth_facade = self.bluetooth_le_facade
62
63        for i in xrange(num_iterations):
64            logging.debug('Starting loop #%d', i)
65            self.test_case_adapter_on_SR()
66            self.test_case_adapter_off_SR()
67
68        if self.fails:
69            raise error.TestFail(self.fails)
70