• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 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 Advertisement Monitor API tests"""
6
7from autotest_lib.server.cros.bluetooth.bluetooth_adapter_quick_tests \
8     import BluetoothAdapterQuickTests
9from autotest_lib.server.cros.bluetooth.bluetooth_adapter_adv_monitor_tests \
10     import BluetoothAdapterAdvMonitorTests
11from autotest_lib.server.cros.bluetooth.bluetooth_adapter_tests \
12     import SUSPEND_POWER_DOWN_CHIPSETS
13
14
15class bluetooth_AdapterAdvMonitor(BluetoothAdapterQuickTests,
16                                  BluetoothAdapterAdvMonitorTests):
17    """A Batch of Bluetooth Advertisement Monitor tests. This test is written
18       as a batch of tests in order to reduce test time, since auto-test ramp
19       up time is costly. The batch is using BluetoothAdapterQuickTests wrapper
20       methods to start and end a test and a batch of tests.
21
22       This class can be called to run the entire test batch or to run a
23       specific test only.
24
25    """
26
27    test_wrapper = BluetoothAdapterQuickTests.quick_test_test_decorator
28    batch_wrapper = BluetoothAdapterQuickTests.quick_test_batch_decorator
29
30
31    @test_wrapper('Monitor Object Health Tests')
32    def advmon_monitor_health_tests(self):
33        """Tests advertisement monitor object health."""
34        self.advmon_test_monitor_creation()
35        self.advmon_test_monitor_validity()
36
37
38    # TODO(b/150897528) - Dru loses firmware around suspend, which causes bluez
39    #                     removes all the monitors.
40    @test_wrapper('Pattern Filter Tests',
41                  devices={'BLE_KEYBOARD':1, 'BLE_MOUSE':1},
42                  skip_models=['dru'],
43                  skip_chipsets=SUSPEND_POWER_DOWN_CHIPSETS)
44    def advmon_pattern_filter_tests(self):
45        """Tests monitor functionality for pattern filter only."""
46        self.advmon_test_pattern_filter_only()
47
48
49    @test_wrapper('Single Client Tests',
50                  devices={'BLE_KEYBOARD':1, 'BLE_MOUSE':1})
51    def advmon_single_client_tests(self):
52        """Tests monitor functionality for single client."""
53        self.advmon_test_pattern_filter_1()
54        self.advmon_test_rssi_filter_1()
55        self.advmon_test_rssi_filter_2()
56        self.advmon_test_rssi_filter_3()
57
58
59    @test_wrapper('Multi Client Tests',
60                  devices={'BLE_KEYBOARD':1, 'BLE_MOUSE':1})
61    def advmon_multi_client_tests(self):
62        """Tests monitor functionality for multiple clients."""
63        self.advmon_test_multi_client()
64
65
66    @test_wrapper('Foreground Background Combination Tests',
67                  devices={'BLE_KEYBOARD':1, 'BLE_MOUSE':1})
68    def advmon_fg_bg_combination_tests(self):
69        """Tests foreground and background scanning working together."""
70        self.advmon_test_fg_bg_combination()
71
72
73    # TODO(b/150897528) - Dru loses firmware around suspend, which causes bluez
74    #                     removes all the monitors.
75    @test_wrapper('Suspend Resume Tests',
76                  devices={
77                          'BLE_KEYBOARD': 1,
78                          'BLE_MOUSE': 1
79                  },
80                  skip_models=['dru'],
81                  skip_chipsets=SUSPEND_POWER_DOWN_CHIPSETS)
82    def advmon_suspend_resume_tests(self):
83        """Tests working of background scanning with suspend resume."""
84        self.advmon_test_suspend_resume()
85
86
87    # TODO(b/150897528) - Dru loses firmware around suspend, which causes bluez
88    #                     removes all the monitors.
89    @test_wrapper('Interleave Scan Tests',
90                  devices={'BLE_MOUSE': 1},
91                  skip_models=['dru'],
92                  skip_chipsets=SUSPEND_POWER_DOWN_CHIPSETS)
93    def advmon_interleaved_scan(self):
94        """Tests interleave scan."""
95        self.advmon_test_interleaved_scan()
96
97    @batch_wrapper('Advertisement Monitor API')
98    def advmon_batch_run(self, num_iterations=1, test_name=None):
99        """Run the Advertisement Monitor test batch or a specific given test.
100           The wrapper of this method is implemented in batch_decorator.
101           Using the decorator a test batch method can implement the only its
102           core tests invocations and let the decorator handle the wrapper,
103           which is taking care for whether to run a specific test or the
104           batch as a whole, and running the batch in iterations.
105
106           @param num_iterations: how many iterations to run.
107           @param test_name: specific test to run otherwise None to run the
108                             whole batch.
109
110        """
111        self.advmon_monitor_health_tests()
112        self.advmon_pattern_filter_tests()
113        self.advmon_single_client_tests()
114        self.advmon_multi_client_tests()
115        self.advmon_fg_bg_combination_tests()
116        self.advmon_suspend_resume_tests()
117        self.advmon_interleaved_scan()
118
119    def run_once(self,
120                 host,
121                 num_iterations=1,
122                 peer_required=True,
123                 args_dict=None,
124                 test_name=None,
125                 flag='Quick Health'):
126        """Run the batch of Bluetooth Advertisement Monitor API tests.
127
128        @param host: the DUT, usually a chromebook.
129        @param num_iterations: the number of rounds to execute the test.
130        @param test_name: the test to run, or None for all tests.
131
132        """
133
134        # Initialize and run the test batch or the requested specific test.
135        self.quick_test_init(host,
136                             use_btpeer=peer_required,
137                             flag=flag,
138                             args_dict=args_dict)
139        self.advmon_batch_run(num_iterations, test_name)
140        self.quick_test_cleanup()
141