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"""Server side bluetooth tests on adapter standalone working states.""" 6 7import logging 8 9from autotest_lib.client.common_lib import error 10from autotest_lib.server.cros.bluetooth.bluetooth_adapter_tests import ( 11 BluetoothAdapterTests) 12from autotest_lib.server.cros.multimedia import remote_facade_factory 13 14 15class bluetooth_AdapterStandalone(BluetoothAdapterTests): 16 """Server side bluetooth adapter standalone tests. 17 18 This test tries to thoroughly verify most of the important work 19 states of a standalone bluetooth adapter prior to connecting to 20 other bluetooth peripherals. 21 22 In particular, the following subtests are performed. Look at the 23 docstrings of the subtests for more details. 24 - test_start_bluetoothd 25 - test_stop_bluetoothd 26 - test_adapter_work_state 27 - test_power_on_adapter 28 - test_power_off_adapter 29 - test_reset_on_adapter 30 - test_reset_off_adapter 31 - test_UUIDs 32 - test_start_discovery 33 - test_stop_discovery 34 - test_discoverable 35 - test_nondiscoverable 36 - test_pairable 37 - test_nonpairable 38 39 Refer to BluetoothAdapterTests for all subtests performed in this test. 40 41 """ 42 43 def run_once(self, host, repeat_count=1): 44 """Running Bluetooth adapter standalone tests. 45 46 @param host: device under test host 47 @param repeat_count: the number of times to repeat the tests. 48 49 """ 50 self.host = host 51 factory = remote_facade_factory.RemoteFacadeFactory(host) 52 self.bluetooth_facade = factory.create_bluetooth_hid_facade() 53 54 for i in xrange(1, repeat_count + 1): 55 logging.info('repeat count: %d / %d', i, repeat_count) 56 57 # The bluetoothd must be running in the beginning. 58 self.test_bluetoothd_running() 59 60 # It is possible that the adapter is not powered on yet. 61 # Power it on anyway and verify that it is actually powered on. 62 self.test_power_on_adapter() 63 64 # Verify that the adapter could be powered off and powered on, 65 # and that it is in the correct working state. 66 self.test_power_off_adapter() 67 self.test_power_on_adapter() 68 self.test_adapter_work_state() 69 70 # Verify that the bluetoothd could be simply stopped and then 71 # be started again, and that it is in the correct working state. 72 self.test_stop_bluetoothd() 73 self.test_start_bluetoothd() 74 self.test_adapter_work_state() 75 76 # Verify that the adapter could be reset off and on which includes 77 # removing all cached information. 78 self.test_reset_off_adapter() 79 self.test_reset_on_adapter() 80 self.test_adapter_work_state() 81 82 # Verify that the adapter supports basic profiles. 83 self.test_UUIDs() 84 85 # Verify that the adapter could start and stop discovery. 86 self.test_start_discovery() 87 self.test_stop_discovery() 88 self.test_start_discovery() 89 90 # Verify that the adapter could set both discoverable and 91 # non-discoverable successfully. 92 self.test_discoverable() 93 self.test_nondiscoverable() 94 self.test_discoverable() 95 96 # Verify that the adapter could set pairable and non-pairable. 97 self.test_pairable() 98 self.test_nonpairable() 99 self.test_pairable() 100 101 if self.fails: 102 raise error.TestFail(self.fails) 103