• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 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"""A Batch of of Bluetooth Classic sanity tests"""
6
7
8from autotest_lib.server.cros.bluetooth.bluetooth_adapter_quick_tests import \
9     BluetoothAdapterQuickTests
10from autotest_lib.server.cros.bluetooth.bluetooth_adapter_pairing_tests import \
11     BluetoothAdapterPairingTests
12from autotest_lib.server.cros.bluetooth.bluetooth_adapter_hidreports_tests \
13     import BluetoothAdapterHIDReportTests
14
15
16class bluetooth_AdapterCLSanity(BluetoothAdapterQuickTests,
17        BluetoothAdapterPairingTests,
18        BluetoothAdapterHIDReportTests):
19    """A Batch of Bluetooth Classic sanity tests. This test is written as a batch
20       of tests in order to reduce test time, since auto-test ramp up time is
21       costly. The batch is using BluetoothAdapterQuickTests wrapper methods to
22       start and end a test and a batch of tests.
23
24       This class can be called to run the entire test batch or to run a
25       specific test only
26    """
27
28    test_wrapper = BluetoothAdapterQuickTests.quick_test_test_decorator
29    batch_wrapper = BluetoothAdapterQuickTests.quick_test_batch_decorator
30
31
32    @test_wrapper('Discovery Test', devices={"MOUSE":1})
33    def cl_adapter_discovery_test(self):
34        """Performs pairing test with mouse peripheral"""
35        device = self.devices['MOUSE'][0]
36
37        self.test_discover_device(device.address)
38        self.test_device_name(device.address, device.name)
39
40
41    @test_wrapper('Pairing Test', devices={"MOUSE":1})
42    def cl_adapter_pairing_test(self):
43        """Performs pairing test with mouse peripheral"""
44        device = self.devices['MOUSE'][0]
45        self.pairing_test(device,
46                          check_connected_method=\
47                          self.test_mouse_right_click)
48
49
50    @test_wrapper('keyboard Pairing Test', devices={"KEYBOARD":1})
51    def cl_adapter_keyboard_pairing_test(self):
52        """Performs pairing test with keyboard peripheral"""
53        device = self.devices['KEYBOARD'][0]
54        self.pairing_test(device,
55                          check_connected_method=\
56                          self.run_keyboard_tests)
57
58
59    @test_wrapper('Pairing Suspend Resume Test', devices={"MOUSE":1})
60    def cl_adapter_pairing_suspend_resume_test(self):
61        """Performs pairing test over resume with mouse peripheral"""
62        device = self.devices['MOUSE'][0]
63        self.pairing_test(device,
64                          check_connected_method=\
65                          self.test_mouse_right_click,
66                          suspend_resume=True)
67
68
69    @test_wrapper('Pairing Twice Test', devices={"MOUSE":1})
70    def cl_adapter_pairing_twice_test(self):
71        """Performs pairing twice test with  mouse peripheral"""
72        device = self.devices['MOUSE'][0]
73        self.pairing_test(device,
74                          check_connected_method=\
75                          self.test_mouse_right_click,
76                          pairing_twice=True)
77
78
79    @test_wrapper('HID Reports Test', devices={"MOUSE":1})
80    def cl_HID_reports_test(self):
81        """Performs HID report test with mouse peripheral"""
82        device = self.devices['MOUSE'][0]
83        self.run_hid_reports_test(device)
84
85
86    @test_wrapper('HID keyboard Reports Test', devices={'KEYBOARD':1})
87    def cl_HID_keyboard_reports_test(self):
88        """Performs HID report test with keyboard peripheral"""
89        device = self.devices['KEYBOARD'][0]
90        self.run_hid_reports_test(device)
91
92
93    @test_wrapper('HID Reports Suspend Resume Test', devices={"MOUSE":1})
94    def cl_HID_reports_suspend_resume_test(self):
95        """Performs HID report test over resume with mouse peripheral"""
96        device = self.devices['MOUSE'][0]
97        self.run_hid_reports_test(device, suspend_resume=True)
98
99
100    @test_wrapper('HID Reports Reboot Test', devices={"MOUSE":1})
101    def cl_HID_reports_reboot_test(self):
102        """Performs HID report test over reboot with mouse peripheral"""
103        device = self.devices['MOUSE'][0]
104        self.run_hid_reports_test(device, reboot=True)
105
106
107    @test_wrapper('Connect Disconnect Loop Test', devices={"MOUSE":1})
108    def cl_connect_disconnect_loop_test(self):
109        """Performs connect/disconnect test with mouse peripheral"""
110        device = self.devices['MOUSE'][0]
111        self.connect_disconnect_loop(device=device, loops=3)
112
113
114    @batch_wrapper('Classic Sanity')
115    def cl_sanity_batch_run(self, num_iterations=1, test_name=None):
116        """Run the Classic sanity test batch or a specific given test.
117           The wrapper of this method is implemented in batch_decorator.
118           Using the decorator a test batch method can implement the only its
119           core tests invocations and let the decorator handle the wrapper,
120           which is taking care for whether to run a specific test or the
121           batch as a whole, and running the batch in iterations
122
123           @param num_iterations: how many interations to run
124           @param test_name: specifc test to run otherwise None to run the
125                             whole batch
126        """
127        self.cl_adapter_pairing_test()
128        self.cl_adapter_keyboard_pairing_test()
129        self.cl_adapter_pairing_suspend_resume_test()
130        self.cl_adapter_pairing_twice_test()
131        self.cl_HID_reports_test()
132        self.cl_HID_keyboard_reports_test()
133        self.cl_HID_reports_suspend_resume_test()
134        #self.cl_HID_reports_reboot_test()
135        self.cl_connect_disconnect_loop_test()
136        self.cl_adapter_discovery_test()
137
138
139    def run_once(self, host, num_iterations=1, test_name=None,
140                 flag='Quick Sanity'):
141        """Run the batch of Bluetooth Classic sanity tests
142
143        @param host: the DUT, usually a chromebook
144        @param num_iterations: the number of rounds to execute the test
145        @test_name: the test to run, or None for all tests
146        """
147
148        # Initialize and run the test batch or the requested specific test
149        self.quick_test_init(host, use_chameleon=True, flag=flag)
150        self.cl_sanity_batch_run(num_iterations, test_name)
151        self.quick_test_cleanup()
152