diff options
234 files changed, 37242 insertions, 25847 deletions
diff --git a/acts/framework/acts/controllers/OWNERS b/acts/framework/acts/controllers/OWNERS index 9b32fd0c5d..ef0ddca385 100644 --- a/acts/framework/acts/controllers/OWNERS +++ b/acts/framework/acts/controllers/OWNERS @@ -1,2 +1,3 @@ per-file fuchsia_device.py = tturney@google.com,jmbrenna@google.com per-file bluetooth_pts_device.py = tturney@google.com +per-file cellular_simulator.py = iguarna@google.com, chaoyangf@google.com, codycaldwell@google.com, yixiang@google.com
\ No newline at end of file diff --git a/acts/framework/acts/controllers/access_point.py b/acts/framework/acts/controllers/access_point.py index 15a3ca05f1..38e59d7248 100755 --- a/acts/framework/acts/controllers/access_point.py +++ b/acts/framework/acts/controllers/access_point.py @@ -120,6 +120,7 @@ class AccessPoint(object): self.log = logger.create_logger(lambda msg: '[Access Point|%s] %s' % (self.ssh_settings.hostname, msg)) self.device_pdu_config = configs.get('PduDevice', None) + self.identifier = self.ssh_settings.hostname if 'ap_subnet' in configs: self._AP_2G_SUBNET_STR = configs['ap_subnet']['2g'] @@ -573,25 +574,38 @@ class AccessPoint(object): if ra_count_str: return int(ra_count_str.split()[1]) - def is_pingable(self): - """Attempts to ping the access point. - - Returns: - True if ping is successful, else False + def ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=56, + additional_ping_params=None): + """Pings from AP to dest_ip, returns dict of ping stats (see utils.ping) """ - return utils.is_pingable(self.ssh_settings.hostname) - - def is_sshable(self): - """Attempts to run command via ssh. - - Returns: - True if no exceptions, else False - """ - try: - self.ssh.run('echo') - except connection.Error: - return False - return True + return utils.ping(self.ssh, + dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) + + def can_ping(self, + dest_ip, + count=1, + interval=1000, + timeout=1000, + size=56, + additional_ping_params=None): + """Returns whether ap can ping dest_ip (see utils.can_ping)""" + return utils.can_ping(self.ssh, + dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) def hard_power_cycle(self, pdus, @@ -608,12 +622,12 @@ class AccessPoint(object): unreachable ping_timeout: int, time to wait for AccessPoint to responsd to pings ssh_timeout: int, time to wait for AccessPoint to allow SSH - hostapd_configs (optional): list, containing hostapd settings. If + hostapd_configs (optional): list, containing hostapd settings. If present, these networks will be spun up after the AP has rebooted. This list can either contain HostapdConfig objects, or - dictionaries with the start_ap params - (i.e { 'hostapd_config': <HostapdConfig>, - 'setup_bridge': <bool>, + dictionaries with the start_ap params + (i.e { 'hostapd_config': <HostapdConfig>, + 'setup_bridge': <bool>, 'additional_parameters': <dict> } ). Raise: Error, if no PduDevice is provided in AccessPoint config. @@ -637,7 +651,7 @@ class AccessPoint(object): self.log.info('Verifying AccessPoint is unreachable.') timeout = time.time() + unreachable_timeout while time.time() < timeout: - if not self.is_pingable(): + if not utils.can_ping(job, self.ssh_settings.hostname): self.log.info('AccessPoint is unreachable as expected.') break else: @@ -657,7 +671,7 @@ class AccessPoint(object): self.log.info('Waiting for AccessPoint to respond to pings.') timeout = time.time() + ping_timeout while time.time() < timeout: - if self.is_pingable(): + if utils.can_ping(job, self.ssh_settings.hostname): self.log.info('AccessPoint responded to pings.') break else: @@ -672,13 +686,15 @@ class AccessPoint(object): self.log.info('Waiting for AccessPoint to allow ssh connection.') timeout = time.time() + ssh_timeout while time.time() < timeout: - if self.is_sshable(): - self.log.info('AccessPoint available via ssh.') - break - else: + try: + self.ssh.run('echo') + except connection.Error: self.log.debug('AccessPoint is not allowing ssh connection. ' 'Retrying in 1 second.') time.sleep(1) + else: + self.log.info('AccessPoint available via ssh.') + break else: raise ConnectionError('Timed out waiting for AccessPoint (%s) to ' 'allow ssh connection.' % diff --git a/acts/framework/acts/controllers/adb.py b/acts/framework/acts/controllers/adb.py index 68ba9556bd..1d15e07e58 100644 --- a/acts/framework/acts/controllers/adb.py +++ b/acts/framework/acts/controllers/adb.py @@ -260,17 +260,12 @@ class AdbProxy(object): def shell_nb(self, command): return self._exec_adb_cmd_nb('shell', shlex.quote(command)) - def pull(self, - command, - ignore_status=False, - timeout=DEFAULT_ADB_PULL_TIMEOUT): - return self._exec_adb_cmd( - 'pull', command, ignore_status=ignore_status, timeout=timeout) - def __getattr__(self, name): def adb_call(*args, **kwargs): usage_metadata_logger.log_usage(self.__module__, name) clean_name = name.replace('_', '-') + if clean_name in ['pull', 'push'] and 'timeout' not in kwargs: + kwargs['timeout'] = DEFAULT_ADB_PULL_TIMEOUT arg_str = ' '.join(str(elem) for elem in args) return self._exec_adb_cmd(clean_name, arg_str, **kwargs) diff --git a/acts/framework/acts/controllers/anritsu_lib/OWNERS b/acts/framework/acts/controllers/anritsu_lib/OWNERS new file mode 100644 index 0000000000..e4010df218 --- /dev/null +++ b/acts/framework/acts/controllers/anritsu_lib/OWNERS @@ -0,0 +1,4 @@ +iguarna@google.com +chaoyangf@google.com +yixiang@google.com +codycaldwell@google.com
\ No newline at end of file diff --git a/acts/framework/acts/controllers/anritsu_lib/md8475_cellular_simulator.py b/acts/framework/acts/controllers/anritsu_lib/md8475_cellular_simulator.py index 98a779a89f..eea1c8a291 100644 --- a/acts/framework/acts/controllers/anritsu_lib/md8475_cellular_simulator.py +++ b/acts/framework/acts/controllers/anritsu_lib/md8475_cellular_simulator.py @@ -18,7 +18,7 @@ import math import ntpath import time import acts.controllers.cellular_simulator as cc -from acts.test_utils.power.tel_simulations import LteSimulation +from acts.controllers.cellular_lib import LteSimulation from acts.controllers.anritsu_lib import md8475a from acts.controllers.anritsu_lib import _anritsu_utils as anritsu diff --git a/acts/framework/acts/controllers/buds_lib/apollo_lib.py b/acts/framework/acts/controllers/buds_lib/apollo_lib.py index 9b971ffa24..7b0f80f370 100644 --- a/acts/framework/acts/controllers/buds_lib/apollo_lib.py +++ b/acts/framework/acts/controllers/buds_lib/apollo_lib.py @@ -46,7 +46,7 @@ import subprocess import time import serial -from acts import tracelogger +from acts.controllers.buds_lib import tako_trace_logger from acts.controllers.buds_lib import logserial from acts.controllers.buds_lib.b29_lib import B29Device from acts.controllers.buds_lib.dev_utils import apollo_log_decoder @@ -55,7 +55,7 @@ from acts.controllers.buds_lib.dev_utils import apollo_sink_events from logging import Logger from retry import retry -logging = tracelogger.TakoTraceLogger(Logger('apollo')) +logging = tako_trace_logger.TakoTraceLogger(Logger('apollo')) BAUD_RATE = 115200 BYTE_SIZE = 8 diff --git a/acts/framework/acts/controllers/buds_lib/b29_lib.py b/acts/framework/acts/controllers/buds_lib/b29_lib.py index bb4ea7d76c..df6a16361c 100644 --- a/acts/framework/acts/controllers/buds_lib/b29_lib.py +++ b/acts/framework/acts/controllers/buds_lib/b29_lib.py @@ -28,12 +28,12 @@ fBvw0sXkgwCBkshU_l4SxWkKgAxVmk/edit for details about available operations. import os import re import time +from logging import Logger -from acts import tracelogger from acts import utils -from logging import Logger +from acts.controllers.buds_lib import tako_trace_logger -logging = tracelogger.TakoTraceLogger(Logger(__file__)) +logging = tako_trace_logger.TakoTraceLogger(Logger(__file__)) DEVICE_REGEX = ( r'_(?P<device_serial>[A-Z0-9]+)-(?P<interface>\w+)\s->\s' r'(\.\./){2}(?P<port>\w+)' diff --git a/acts/framework/acts/controllers/buds_lib/logserial.py b/acts/framework/acts/controllers/buds_lib/logserial.py index 58bf15431d..6b18e3cfc0 100644 --- a/acts/framework/acts/controllers/buds_lib/logserial.py +++ b/acts/framework/acts/controllers/buds_lib/logserial.py @@ -21,15 +21,15 @@ import subprocess import sys import time import uuid +from logging import Logger from threading import Thread import serial from serial.tools import list_ports -from acts import tracelogger -from logging import Logger +from acts.controllers.buds_lib import tako_trace_logger -logging = tracelogger.TakoTraceLogger(Logger(__file__)) +logging = tako_trace_logger.TakoTraceLogger(Logger(__file__)) RETRIES = 0 diff --git a/acts/framework/acts/controllers/buds_lib/tako_trace_logger.py b/acts/framework/acts/controllers/buds_lib/tako_trace_logger.py new file mode 100644 index 0000000000..ff3184056c --- /dev/null +++ b/acts/framework/acts/controllers/buds_lib/tako_trace_logger.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import logging + +from acts import tracelogger + + +class TakoTraceLogger(tracelogger.TraceLogger): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.d = self.debug + self.e = self.error + self.i = self.info + self.t = self.step + self.w = self.warning + + def _logger_level(self, level_name): + level = logging.getLevelName(level_name) + return lambda *args, **kwargs: self._logger.log(level, *args, **kwargs) + + def step(self, msg, *args, **kwargs): + """Delegate a step call to the underlying logger.""" + self._log_with(self._logger_level('STEP'), 1, msg, *args, **kwargs) + + def device(self, msg, *args, **kwargs): + """Delegate a device call to the underlying logger.""" + self._log_with(self._logger_level('DEVICE'), 1, msg, *args, **kwargs) + + def suite(self, msg, *args, **kwargs): + """Delegate a device call to the underlying logger.""" + self._log_with(self._logger_level('SUITE'), 1, msg, *args, **kwargs) + + def case(self, msg, *args, **kwargs): + """Delegate a case call to the underlying logger.""" + self._log_with(self._logger_level('CASE'), 1, msg, *args, **kwargs) + + def flush_log(self): + """This function exists for compatibility with Tako's logserial module. + + Note that flushing the log is handled automatically by python's logging + module. + """ + pass diff --git a/acts/framework/acts/controllers/buds_lib/test_actions/audio_utils.py b/acts/framework/acts/controllers/buds_lib/test_actions/audio_utils.py index 42f8c46309..e94fc52e4a 100644 --- a/acts/framework/acts/controllers/buds_lib/test_actions/audio_utils.py +++ b/acts/framework/acts/controllers/buds_lib/test_actions/audio_utils.py @@ -19,8 +19,8 @@ import datetime import time -from acts import tracelogger from acts import utils +from acts.controllers.buds_lib import tako_trace_logger class AudioUtilsError(Exception): @@ -36,7 +36,7 @@ class AudioUtils(object): """ def __init__(self): - self.logger = tracelogger.TakoTraceLogger() + self.logger = tako_trace_logger.TakoTraceLogger() def play_audio_into_device(self, audio_file_path, audio_player, dut): """Open mic on DUT, play audio into DUT, close mic on DUT. diff --git a/acts/framework/acts/controllers/buds_lib/test_actions/base_test_actions.py b/acts/framework/acts/controllers/buds_lib/test_actions/base_test_actions.py index 7b6cbc4c0d..8f4b37a1bb 100644 --- a/acts/framework/acts/controllers/buds_lib/test_actions/base_test_actions.py +++ b/acts/framework/acts/controllers/buds_lib/test_actions/base_test_actions.py @@ -22,7 +22,7 @@ import datetime import inspect import time -from acts import tracelogger +from acts.controllers.buds_lib import tako_trace_logger from acts.libs.utils.timer import TimeRecorder # All methods start with "_" are considered hidden. @@ -37,7 +37,7 @@ def timed_action(method): func_name = self._convert_default_action_name(method.__name__) if not func_name: func_name = method.__name__ - self.logger.step('%s...' % func_name) + self.log_step('%s...' % func_name) self.timer.start_timer(func_name, True) result = method(self, *args, **kw) # TODO: Method run time collected can be used for automatic KPI checks @@ -135,9 +135,11 @@ class BaseTestAction(object): def __init__(self, logger=None): if logger is None: - self.logger = tracelogger.TakoTraceLogger() + self.logger = tako_trace_logger.TakoTraceLogger() + self.log_step = self.logger.step else: self.logger = logger + self.log_step = self.logger.info self.timer = TimeRecorder() self._fill_default_action_map() @@ -172,15 +174,16 @@ class BaseTestAction(object): exceptions """ num_acts = len(self._action_map) - self.logger.i('I can do %d action%s:' % + + self.logger.info('I can do %d action%s:' % (num_acts, 's' if num_acts != 1 else '')) for act in self._action_map.keys(): - self.logger.i(' - %s' % act) + self.logger.info(' - %s' % act) return True @timed_action def sleep(self, seconds): - self.logger.i('%s seconds' % seconds) + self.logger.info('%s seconds' % seconds) time.sleep(seconds) diff --git a/acts/framework/acts/controllers/buds_lib/test_actions/bt_utils.py b/acts/framework/acts/controllers/buds_lib/test_actions/bt_utils.py index 258240228a..f0ac04140c 100644 --- a/acts/framework/acts/controllers/buds_lib/test_actions/bt_utils.py +++ b/acts/framework/acts/controllers/buds_lib/test_actions/bt_utils.py @@ -31,11 +31,12 @@ device that supports the following calls: """ import queue import time +from logging import Logger -from acts import tracelogger -from acts.utils import wait_until +from acts import asserts +from acts.controllers.buds_lib import tako_trace_logger from acts.utils import TimeoutError -from logging import Logger +from acts.utils import wait_until # Add connection profile for future devices in this dictionary WEARABLE_BT_PROTOCOLS = { @@ -69,7 +70,7 @@ class BTUtils(object): def __init__(self): self.default_timeout = 60 - self.logger = tracelogger.TakoTraceLogger(Logger(__file__)) + self.logger = tako_trace_logger.TakoTraceLogger(Logger(__file__)) def bt_pair_and_connect(self, pri_device, sec_device): """Pair and connect a pri_device to a sec_device. @@ -198,8 +199,9 @@ class BTUtils(object): return True, 0 self.logger.debug('Unpairing from %s' % target_address) start_time = end_time = time.time() - assert (True is pri_device.droid.bluetoothUnbond(target_address), - 'Failed to request device unpairing.') + asserts.assert_true( + pri_device.droid.bluetoothUnbond(target_address), + 'Failed to request device unpairing.') # Check that devices have unpaired successfully. self.logger.debug('Verifying devices are unpaired') @@ -290,4 +292,3 @@ class BTUtils(object): if expected[key] != actual[key]: return False return True - diff --git a/acts/framework/acts/controllers/cellular_lib/AndroidCellularDut.py b/acts/framework/acts/controllers/cellular_lib/AndroidCellularDut.py new file mode 100644 index 0000000000..aaef6f5a0a --- /dev/null +++ b/acts/framework/acts/controllers/cellular_lib/AndroidCellularDut.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.controllers.cellular_lib import BaseCellularDut +from acts.test_utils.tel import tel_test_utils as tel_utils +from acts.test_utils.tel import tel_defines + + +class AndroidCellularDut(BaseCellularDut.BaseCellularDut): + """ Android implementation of the cellular DUT class.""" + def __init__(self, ad, logger): + """ Keeps a handler to the android device. + + Args: + ad: Android device handler + logger: a handler to the logger object + """ + self.ad = ad + self.log = logger + + def toggle_airplane_mode(self, new_state=True): + """ Turns airplane mode on / off. + + Args: + new_state: True if airplane mode needs to be enabled. + """ + tel_utils.toggle_airplane_mode(self.log, self.ad, new_state) + + def toggle_data_roaming(self, new_state=True): + """ Enables or disables cellular data roaming. + + Args: + new_state: True if data roaming needs to be enabled. + """ + tel_utils.toggle_cell_data_roaming(self.ad, new_state) + + def get_rx_tx_power_levels(self): + """ Obtains Rx and Tx power levels measured from the DUT. + + Returns: + A tuple where the first element is an array with the RSRP value + in each Rx chain, and the second element is the Tx power in dBm. + Values for invalid or disabled Rx / Tx chains are set to None. + """ + return tel_utils.get_rx_tx_power_levels(self.log, self.ad) + + def set_apn(self, name, apn, type='default'): + """ Sets the Access Point Name. + + Args: + name: the APN name + apn: the APN + type: the APN type + """ + self.ad.droid.telephonySetAPN(name, apn, type) + + def set_preferred_network_type(self, type): + """ Sets the preferred RAT. + + Args: + type: an instance of class PreferredNetworkType + """ + if type == BaseCellularDut.PreferredNetworkType.LTE_ONLY: + formatted_type = tel_defines.NETWORK_MODE_LTE_ONLY + elif type == BaseCellularDut.PreferredNetworkType.WCDMA_ONLY: + formatted_type = tel_defines.NETWORK_MODE_WCDMA_ONLY + elif type == BaseCellularDut.PreferredNetworkType.GSM_ONLY: + formatted_type = tel_defines.NETWORK_MODE_GSM_ONLY + else: + raise ValueError('Invalid RAT type.') + + if not self.ad.droid.telephonySetPreferredNetworkTypesForSubscription( + formatted_type, self.ad.droid.subscriptionGetDefaultSubId()): + self.log.error("Could not set preferred network type.") + else: + self.log.info("Preferred network type set.") + + def get_telephony_signal_strength(self): + """ Wrapper for the method with the same name in tel_utils. + + Will be deprecated and replaced by get_rx_tx_power_levels. """ + tel_utils.get_telephony_signal_strength(self.ad) diff --git a/acts/framework/acts/controllers/cellular_lib/BaseCellularDut.py b/acts/framework/acts/controllers/cellular_lib/BaseCellularDut.py new file mode 100644 index 0000000000..31c19fa9c5 --- /dev/null +++ b/acts/framework/acts/controllers/cellular_lib/BaseCellularDut.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from enum import Enum + + +class PreferredNetworkType(Enum): + """ Available preferred network types that can be passed to + set_preferred_network_type""" + LTE_ONLY = 'lte-only' + GSM_ONLY = 'gsm-only' + WCDMA_ONLY = 'wcdma-only' + + +class BaseCellularDut(): + """ Base class for DUTs used with cellular simulators. """ + def toggle_airplane_mode(self, new_state=True): + """ Turns airplane mode on / off. + + Args: + new_state: True if airplane mode needs to be enabled. + """ + raise NotImplementedError() + + def toggle_data_roaming(self, new_state=True): + """ Enables or disables cellular data roaming. + + Args: + new_state: True if data roaming needs to be enabled. + """ + raise NotImplementedError() + + def get_rx_tx_power_levels(self): + """ Obtains Rx and Tx power levels measured from the DUT. + + Returns: + A tuple where the first element is an array with the RSRP value + in each Rx chain, and the second element is the Tx power in dBm. + Values for invalid or disabled Rx / Tx chains are set to None. + """ + raise NotImplementedError() + + def set_apn(self, name, apn, type='default'): + """ Sets the Access Point Name. + + Args: + name: the APN name + apn: the APN + type: the APN type + """ + raise NotImplementedError() + + def set_preferred_network_type(self, type): + """ Sets the preferred RAT. + + Args: + type: an instance of class PreferredNetworkType + """ + raise NotImplementedError() + + def get_telephony_signal_strength(self): + """ Wrapper for the method with the same name in tel_utils. + + Will be deprecated and replaced by get_rx_tx_power_levels. """ + raise NotImplementedError() diff --git a/acts/framework/acts/test_utils/power/tel_simulations/BaseSimulation.py b/acts/framework/acts/controllers/cellular_lib/BaseSimulation.py index 7d38caeb95..9cc091f2a0 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/BaseSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/BaseSimulation.py @@ -19,10 +19,6 @@ from enum import Enum import numpy as np from acts.controllers import cellular_simulator -from acts.test_utils.tel.tel_test_utils import get_telephony_signal_strength -from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode -from acts.test_utils.tel.tel_test_utils import toggle_cell_data_roaming -from acts.test_utils.tel.tel_test_utils import get_rx_tx_power_levels class BaseSimulation(): @@ -106,7 +102,7 @@ class BaseSimulation(): Args: simulator: a cellular simulator controller log: a logger handle - dut: the android device handler + dut: a device handler implementing BaseCellularDut test_config: test configuration obtained from the config file calibration_table: a dictionary containing path losses for different bands. @@ -168,13 +164,13 @@ class BaseSimulation(): # Set to default APN log.info("Configuring APN.") - dut.droid.telephonySetAPN("test", "test", "default") + self.dut.set_apn('test', 'test') # Enable roaming on the phone - toggle_cell_data_roaming(self.dut, True) + self.dut.toggle_data_roaming(True) # Make sure airplane mode is on so the phone won't attach right away - toggle_airplane_mode(self.log, self.dut, True) + self.dut.toggle_airplane_mode(True) # Wait for airplane mode setting to propagate time.sleep(2) @@ -197,7 +193,7 @@ class BaseSimulation(): """ # Turn on airplane mode - toggle_airplane_mode(self.log, self.dut, True) + self.dut.toggle_airplane_mode(True) # Wait for airplane mode setting to propagate time.sleep(2) @@ -215,7 +211,7 @@ class BaseSimulation(): try: # Turn off airplane mode - toggle_airplane_mode(self.log, self.dut, False) + self.dut.toggle_airplane_mode(False) # Wait for the phone to attach. self.simulator.wait_until_attached(timeout=self.attach_timeout) @@ -227,7 +223,7 @@ class BaseSimulation(): "UE failed to attach on attempt number {}.".format(i + 1)) # Turn airplane mode on to prepare the phone for a retry. - toggle_airplane_mode(self.log, self.dut, True) + self.dut.toggle_airplane_mode(True) # Wait for APM to propagate time.sleep(3) @@ -256,7 +252,7 @@ class BaseSimulation(): # Set the DUT to airplane mode so it doesn't see the # cellular network going off - toggle_airplane_mode(self.log, self.dut, True) + self.dut.toggle_airplane_mode(True) # Wait for APM to propagate time.sleep(2) @@ -271,7 +267,7 @@ class BaseSimulation(): # Set the DUT to airplane mode so it doesn't see the # cellular network going off - toggle_airplane_mode(self.log, self.dut, True) + self.dut.toggle_airplane_mode(True) # Wait for APM to propagate time.sleep(2) @@ -312,7 +308,7 @@ class BaseSimulation(): # Verify signal level try: - rx_power, tx_power = get_rx_tx_power_levels(self.log, self.dut) + rx_power, tx_power = self.dut.get_rx_tx_power_levels() if not tx_power or not rx_power[0]: raise RuntimeError('The method return invalid Tx/Rx values.') @@ -617,35 +613,24 @@ class BaseSimulation(): restoration_config.output_power = self.primary_config.output_power # Set BTS to a good output level to minimize measurement error - initial_screen_timeout = self.dut.droid.getScreenTimeout() new_config = self.BtsConfig() new_config.output_power = self.simulator.MAX_DL_POWER - 5 self.simulator.configure_bts(new_config) - # Set phone sleep time out - self.dut.droid.setScreenTimeout(1800) - self.dut.droid.goToSleepNow() - time.sleep(2) - # Starting IP traffic self.start_traffic_for_calibration() down_power_measured = [] for i in range(0, self.NUM_DL_CAL_READS): # For some reason, the RSRP gets updated on Screen ON event - self.dut.droid.wakeUpNow() - time.sleep(4) - signal_strength = get_telephony_signal_strength(self.dut) + signal_strength = self.dut.get_telephony_signal_strength() down_power_measured.append(signal_strength[rat]) - self.dut.droid.goToSleepNow() time.sleep(5) # Stop IP traffic self.stop_traffic_for_calibration() - # Reset phone and bts to original settings - self.dut.droid.goToSleepNow() - self.dut.droid.setScreenTimeout(initial_screen_timeout) + # Reset bts to original settings self.simulator.configure_bts(restoration_config) time.sleep(2) @@ -691,16 +676,10 @@ class BaseSimulation(): # Set BTS1 to maximum input allowed in order to perform # uplink calibration target_power = self.MAX_PHONE_OUTPUT_POWER - initial_screen_timeout = self.dut.droid.getScreenTimeout() new_config = self.BtsConfig() new_config.input_power = self.MAX_BTS_INPUT_POWER self.simulator.configure_bts(new_config) - # Set phone sleep time out - self.dut.droid.setScreenTimeout(1800) - self.dut.droid.wakeUpNow() - time.sleep(2) - # Start IP traffic self.start_traffic_for_calibration() @@ -729,9 +708,7 @@ class BaseSimulation(): # Stop IP traffic self.stop_traffic_for_calibration() - # Reset phone and bts to original settings - self.dut.droid.goToSleepNow() - self.dut.droid.setScreenTimeout(initial_screen_timeout) + # Reset bts to original settings self.simulator.configure_bts(restoration_config) time.sleep(2) diff --git a/acts/framework/acts/test_utils/power/tel_simulations/GsmSimulation.py b/acts/framework/acts/controllers/cellular_lib/GsmSimulation.py index 6dc2082cd6..20c731b8fa 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/GsmSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/GsmSimulation.py @@ -20,12 +20,12 @@ import time from acts.controllers.anritsu_lib.md8475a import BtsGprsMode from acts.controllers.anritsu_lib.md8475a import BtsNumber from acts.controllers.anritsu_lib import md8475_cellular_simulator as anritsusim -from acts.test_utils.power.tel_simulations.BaseSimulation import BaseSimulation +from acts.controllers.cellular_lib import BaseCellularDut +from acts.controllers.cellular_lib.BaseSimulation import BaseSimulation from acts.test_utils.tel.anritsu_utils import GSM_BAND_DCS1800 from acts.test_utils.tel.anritsu_utils import GSM_BAND_EGSM900 from acts.test_utils.tel.anritsu_utils import GSM_BAND_GSM850 from acts.test_utils.tel.anritsu_utils import GSM_BAND_RGSM900 -from acts.test_utils.tel.tel_defines import NETWORK_MODE_GSM_ONLY class GsmSimulation(BaseSimulation): @@ -63,7 +63,7 @@ class GsmSimulation(BaseSimulation): Args: simulator: a cellular simulator controller log: a logger handle - dut: the android device handler + dut: a device handler implementing BaseCellularDut test_config: test configuration obtained from the config file calibration_table: a dictionary containing path losses for different bands. @@ -82,12 +82,8 @@ class GsmSimulation(BaseSimulation): super().__init__(simulator, log, dut, test_config, calibration_table) - if not dut.droid.telephonySetPreferredNetworkTypesForSubscription( - NETWORK_MODE_GSM_ONLY, - dut.droid.subscriptionGetDefaultSubId()): - log.error("Coold not set preferred network type.") - else: - log.info("Preferred network type set.") + self.dut.set_preferred_network_type( + BaseCellularDut.PreferredNetworkType.GSM_ONLY) def setup_simulator(self): """ Do initial configuration in the simulator. """ diff --git a/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py b/acts/framework/acts/controllers/cellular_lib/LteCaSimulation.py index addc3a8aab..3f98a34e60 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/LteCaSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/LteCaSimulation.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. import re -from acts.test_utils.power.tel_simulations import LteSimulation +from acts.controllers.cellular_lib import LteSimulation class LteCaSimulation(LteSimulation.LteSimulation): @@ -80,7 +80,7 @@ class LteCaSimulation(LteSimulation.LteSimulation): Args: simulator: the cellular instrument controller log: a logger handle - dut: the android device handler + dut: a device handler implementing BaseCellularDut test_config: test configuration obtained from the config file calibration_table: a dictionary containing path losses for different bands. diff --git a/acts/framework/acts/test_utils/power/tel_simulations/LteImsSimulation.py b/acts/framework/acts/controllers/cellular_lib/LteImsSimulation.py index 71102463cf..e13eb297ba 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/LteImsSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/LteImsSimulation.py @@ -13,7 +13,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from acts.test_utils.power.tel_simulations.LteSimulation import LteSimulation +from acts.controllers.cellular_lib.LteSimulation import LteSimulation import acts.test_utils.tel.anritsu_utils as anritsu_utils import acts.controllers.anritsu_lib.md8475a as md8475a diff --git a/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py b/acts/framework/acts/controllers/cellular_lib/LteSimulation.py index 44bcbf67dd..9627e9fa26 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/LteSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/LteSimulation.py @@ -17,8 +17,8 @@ import math from enum import Enum -from acts.test_utils.power.tel_simulations.BaseSimulation import BaseSimulation -from acts.test_utils.tel.tel_defines import NETWORK_MODE_LTE_ONLY +from acts.controllers.cellular_lib.BaseSimulation import BaseSimulation +from acts.controllers.cellular_lib import BaseCellularDut class TransmissionMode(Enum): @@ -459,7 +459,7 @@ class LteSimulation(BaseSimulation): Args: simulator: a cellular simulator controller log: a logger handle - dut: the android device handler + dut: a device handler implementing BaseCellularDut test_config: test configuration obtained from the config file calibration_table: a dictionary containing path losses for different bands. @@ -468,12 +468,8 @@ class LteSimulation(BaseSimulation): super().__init__(simulator, log, dut, test_config, calibration_table) - if not dut.droid.telephonySetPreferredNetworkTypesForSubscription( - NETWORK_MODE_LTE_ONLY, - dut.droid.subscriptionGetDefaultSubId()): - log.error("Couldn't set preferred network type.") - else: - log.info("Preferred network type set.") + self.dut.set_preferred_network_type( + BaseCellularDut.PreferredNetworkType.LTE_ONLY) # Get TBS pattern setting from the test configuration if self.KEY_TBS_PATTERN not in test_config: diff --git a/acts/framework/acts/controllers/cellular_lib/OWNERS b/acts/framework/acts/controllers/cellular_lib/OWNERS new file mode 100644 index 0000000000..e4010df218 --- /dev/null +++ b/acts/framework/acts/controllers/cellular_lib/OWNERS @@ -0,0 +1,4 @@ +iguarna@google.com +chaoyangf@google.com +yixiang@google.com +codycaldwell@google.com
\ No newline at end of file diff --git a/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py b/acts/framework/acts/controllers/cellular_lib/UmtsSimulation.py index 4d4aeebf8b..b301a6b6f5 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/UmtsSimulation.py +++ b/acts/framework/acts/controllers/cellular_lib/UmtsSimulation.py @@ -20,8 +20,8 @@ import time from acts.controllers.anritsu_lib import md8475_cellular_simulator as anritsusim from acts.controllers.anritsu_lib.md8475a import BtsNumber from acts.controllers.anritsu_lib.md8475a import BtsPacketRate -from acts.test_utils.power.tel_simulations.BaseSimulation import BaseSimulation -from acts.test_utils.tel.tel_defines import NETWORK_MODE_WCDMA_ONLY +from acts.controllers.cellular_lib.BaseSimulation import BaseSimulation +from acts.controllers.cellular_lib import BaseCellularDut class UmtsSimulation(BaseSimulation): @@ -98,7 +98,7 @@ class UmtsSimulation(BaseSimulation): Args: simulator: a cellular simulator controller log: a logger handle - dut: the android device handler + dut: a device handler implementing BaseCellularDut test_config: test configuration obtained from the config file calibration_table: a dictionary containing path losses for different bands. @@ -117,12 +117,8 @@ class UmtsSimulation(BaseSimulation): super().__init__(simulator, log, dut, test_config, calibration_table) - if not dut.droid.telephonySetPreferredNetworkTypesForSubscription( - NETWORK_MODE_WCDMA_ONLY, - dut.droid.subscriptionGetDefaultSubId()): - log.error("Coold not set preferred network type.") - else: - log.info("Preferred network type set.") + self.dut.set_preferred_network_type( + BaseCellularDut.PreferredNetworkType.WCDMA_ONLY) self.release_version = None self.packet_rate = None diff --git a/acts/framework/acts/test_utils/power/tel_simulations/__init__.py b/acts/framework/acts/controllers/cellular_lib/__init__.py index e69de29bb2..e69de29bb2 100644 --- a/acts/framework/acts/test_utils/power/tel_simulations/__init__.py +++ b/acts/framework/acts/controllers/cellular_lib/__init__.py diff --git a/acts/framework/acts/controllers/cellular_simulator.py b/acts/framework/acts/controllers/cellular_simulator.py index 2408611996..99adbd87be 100644 --- a/acts/framework/acts/controllers/cellular_simulator.py +++ b/acts/framework/acts/controllers/cellular_simulator.py @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. from acts import logger -from acts.test_utils.power import tel_simulations as sims +from acts.controllers import cellular_lib as sims class AbstractCellularSimulator: diff --git a/acts/framework/acts/controllers/fuchsia_device.py b/acts/framework/acts/controllers/fuchsia_device.py index 322b653a32..12ce3f5289 100644 --- a/acts/framework/acts/controllers/fuchsia_device.py +++ b/acts/framework/acts/controllers/fuchsia_device.py @@ -51,6 +51,7 @@ from acts.controllers.fuchsia_lib.kernel_lib import FuchsiaKernelLib from acts.controllers.fuchsia_lib.location.regulatory_region_lib import FuchsiaRegulatoryRegionLib from acts.controllers.fuchsia_lib.logging_lib import FuchsiaLoggingLib from acts.controllers.fuchsia_lib.netstack.netstack_lib import FuchsiaNetstackLib +from acts.controllers.fuchsia_lib.ram_lib import FuchsiaRamLib from acts.controllers.fuchsia_lib.syslog_lib import FuchsiaSyslogError from acts.controllers.fuchsia_lib.syslog_lib import start_syslog from acts.controllers.fuchsia_lib.sysinfo_lib import FuchsiaSysInfoLib @@ -60,7 +61,7 @@ from acts.controllers.fuchsia_lib.wlan_deprecated_configuration_lib import Fuchs from acts.controllers.fuchsia_lib.wlan_lib import FuchsiaWlanLib from acts.controllers.fuchsia_lib.wlan_ap_policy_lib import FuchsiaWlanApPolicyLib from acts.controllers.fuchsia_lib.wlan_policy_lib import FuchsiaWlanPolicyLib -from acts.libs.proc.job import Error +from acts.libs.proc import job MOBLY_CONTROLLER_CONFIG_NAME = "FuchsiaDevice" ACTS_CONTROLLER_REFERENCE_NAME = "fuchsia_devices" @@ -280,6 +281,10 @@ class FuchsiaDevice: self.netstack_lib = FuchsiaNetstackLib(self.address, self.test_counter, self.client_id) + # Grab commands from FuchsiaLightLib + self.ram_lib = FuchsiaRamLib(self.address, self.test_counter, + self.client_id) + # Grab commands from FuchsiaProfileServerLib self.sdp_lib = FuchsiaProfileServerLib(self.address, self.test_counter, self.client_id) @@ -343,52 +348,6 @@ class FuchsiaDevice: """ return self.client_id + "." + str(test_id) - def verify_ping(self, timeout=30): - """Verify the fuchsia device can be pinged. - - Args: - timeout: int, seconds to retry before raising an exception - - Raise: - ConnecitonError, if device still can't be pinged after timeout. - """ - end_time = time.time() + timeout - while time.time() < end_time: - if utils.is_pingable(self.ip): - break - else: - self.log.debug('Device is not pingable. Retrying in 1 second.') - time.sleep(1) - else: - raise ConnectionError('Device never came back online.') - - def verify_ssh(self, timeout=30): - """Verify the fuchsia device can be reached via ssh. - - In self.reboot, this function is used to verify SSH is up before - attempting to restart SL4F, as that has more risky thread implications - if it fails. Also, create_ssh_connection has a short backoff loop, - but was not intended for waiting for SSH to come up. - - Args: - timeout: int, seconds to retry before raising an exception - - Raise: - ConnecitonError, if device still can't reached after timeout. - """ - end_time = time.time() + timeout - while time.time() < end_time: - try: - self.send_command_ssh('\n') - except Exception: - self.log.debug( - 'Could not SSH to device. Retrying in 1 second.') - time.sleep(1) - else: - break - else: - raise ConnectionError('Failed to connect to device via SSH.') - def reboot(self, use_ssh=False, unreachable_timeout=30, @@ -455,7 +414,7 @@ class FuchsiaDevice: self.log.info('Verifying device is unreachable.') timeout = time.time() + unreachable_timeout while (time.time() < timeout): - if utils.is_pingable(self.ip): + if utils.can_ping(job, self.ip): self.log.debug('Device is still pingable. Retrying.') else: if reboot_type == FUCHSIA_REBOOT_TYPE_HARD: @@ -475,11 +434,30 @@ class FuchsiaDevice: device_pdu.on(str(device_pdu_port)) self.log.info('Waiting for device to respond to pings.') - self.verify_ping(timeout=ping_timeout) + end_time = time.time() + ping_timeout + while time.time() < end_time: + if utils.can_ping(job, self.ip): + break + else: + self.log.debug('Device is not pingable. Retrying in 1 second.') + time.sleep(1) + else: + raise ConnectionError('Device never came back online.') self.log.info('Device responded to pings.') self.log.info('Waiting for device to allow ssh connection.') - self.verify_ssh(timeout=ssh_timeout) + end_time = time.time() + ssh_timeout + while time.time() < end_time: + try: + self.send_command_ssh('\n') + except Exception: + self.log.debug( + 'Could not SSH to device. Retrying in 1 second.') + time.sleep(1) + else: + break + else: + raise ConnectionError('Failed to connect to device via SSH.') self.log.info('Device now available via ssh.') # Creating new log process, start it, start new persistent ssh session, @@ -545,7 +523,13 @@ class FuchsiaDevice: ssh_conn.close() return command_result - def ping(self, dest_ip, count=3, interval=1000, timeout=1000, size=25): + def ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): """Pings from a Fuchsia device to an IPv4 address or hostname Args: @@ -555,6 +539,8 @@ class FuchsiaDevice: timeout: (int) How long to wait before having the icmp packet timeout (ms). size: (int) Size of the icmp packet. + additional_ping_params: (str) command option flags to + append to the command string Returns: A dictionary for the results of the ping. The dictionary contains @@ -570,10 +556,12 @@ class FuchsiaDevice: rtt_max = None rtt_avg = None self.log.debug("Pinging %s..." % dest_ip) + if not additional_ping_params: + additional_ping_params = '' ping_result = self.send_command_ssh( - 'ping -c %s -i %s -t %s -s %s %s' % - (count, interval, timeout, size, dest_ip)) - if isinstance(ping_result, Error): + 'ping -c %s -i %s -t %s -s %s %s %s' % + (count, interval, timeout, size, additional_ping_params, dest_ip)) + if isinstance(ping_result, job.Error): ping_result = ping_result.result if ping_result.stderr: @@ -595,6 +583,22 @@ class FuchsiaDevice: 'stderr': ping_result.stderr } + def can_ping(self, + dest_ip, + count=1, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): + """Returns whether fuchsia device can ping a given dest address""" + ping_result = self.ping(dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) + return ping_result['status'] + def print_clients(self): """Gets connected clients from SL4F server""" self.log.debug("Request to print clients") @@ -860,10 +864,23 @@ class FuchsiaDevice: acts_logger.epoch_to_log_line_timestamp(begin_time)) out_name = "FuchsiaDevice%s_%s" % ( self.serial, time_stamp.replace(" ", "_").replace(":", "-")) + bugreport_out_name = f"{out_name}.zip" out_name = "%s.txt" % out_name full_out_path = os.path.join(br_path, out_name) + full_br_out_path = os.path.join(br_path, bugreport_out_name) self.log.info("Taking bugreport for %s on FuchsiaDevice%s." % (test_name, self.serial)) + if self.ssh_config is not None: + try: + subprocess.run([ + f"ssh -F {self.ssh_config} {self.ip} bugreport > {full_br_out_path}" + ], + shell=True) + self.log.info( + "Bugreport saved at: {}".format(full_br_out_path)) + except Exception as err: + self.log.error("Failed to take bugreport with: {}".format(err)) + system_objects = self.send_command_ssh('iquery --find /hub').stdout system_objects = system_objects.split() diff --git a/acts/framework/acts/controllers/fuchsia_lib/base_lib.py b/acts/framework/acts/controllers/fuchsia_lib/base_lib.py index 04352f30b8..23035fca8e 100644 --- a/acts/framework/acts/controllers/fuchsia_lib/base_lib.py +++ b/acts/framework/acts/controllers/fuchsia_lib/base_lib.py @@ -28,6 +28,7 @@ import time from urllib.parse import urlparse from acts import utils +from acts.libs.proc import job class DeviceOffline(Exception): @@ -61,7 +62,7 @@ class BaseLib(): Returns: Dictionary, Result of sl4f command executed. """ - if not utils.is_pingable(urlparse(self.address).hostname): + if not utils.can_ping(job, urlparse(self.address).hostname): raise DeviceOffline("FuchsiaDevice %s is not reachable via the " "network." % urlparse(self.address).hostname) test_data = json.dumps({ @@ -75,7 +76,7 @@ class BaseLib(): data=test_data, timeout=response_timeout).json() except requests.exceptions.Timeout as e: - if not utils.is_pingable(urlparse(self.address).hostname): + if not utils.can_ping(job, urlparse(self.address).hostname): raise DeviceOffline( "FuchsiaDevice %s is not reachable via the " "network." % urlparse(self.address).hostname) diff --git a/acts/framework/acts/controllers/fuchsia_lib/ram_lib.py b/acts/framework/acts/controllers/fuchsia_lib/ram_lib.py new file mode 100644 index 0000000000..ce8bb73afd --- /dev/null +++ b/acts/framework/acts/controllers/fuchsia_lib/ram_lib.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.controllers.fuchsia_lib.base_lib import BaseLib + + +class FuchsiaRamLib(BaseLib): + def __init__(self, addr, tc, client_id): + self.address = addr + self.test_counter = tc + self.client_id = client_id + + def measureBandwidth(self, cycles_to_measure, channels): + """ Measures the DDR bandwidth on the specified channels. + + Args: + cycles_to_measure: How many bus cycles to perform the measurement over. + channels: An array of 8 uint64, specifying which ports to aggregate + for each channel. + + Returns: + BandwidthInfo struct, prints an error message if error. + """ + test_cmd = "ram_facade.MeasureBandwidth" + test_args = { + "values": { + "cycles_to_measure": cycles_to_measure, + "channels": channels + } + } + test_id = self.build_id(self.test_counter) + self.test_counter += 1 + + return self.send_command(test_id, test_cmd, test_args) + + def getDdrWindowingResults(self): + """ Retrieves the results from the DDR Windowing tool, which runs in + the bootloader. + + Returns: + The register value, prints an error message if error. + """ + test_cmd = "ram_facade.GetDdrWindowingResults" + test_args = {} + test_id = self.build_id(self.test_counter) + self.test_counter += 1 + + return self.send_command(test_id, test_cmd, test_args) diff --git a/acts/framework/acts/controllers/fuchsia_lib/utils_lib.py b/acts/framework/acts/controllers/fuchsia_lib/utils_lib.py index 782d96e631..96a71319be 100644 --- a/acts/framework/acts/controllers/fuchsia_lib/utils_lib.py +++ b/acts/framework/acts/controllers/fuchsia_lib/utils_lib.py @@ -23,6 +23,7 @@ import time from acts import utils from acts.controllers.fuchsia_lib.base_lib import DeviceOffline +from acts.libs.proc import job logging.getLogger("paramiko").setLevel(logging.WARNING) # paramiko-ng will throw INFO messages when things get disconnect or cannot @@ -87,7 +88,7 @@ def create_ssh_connection(ip_address, Returns: A paramiko ssh object """ - if not utils.is_pingable(ip_address): + if not utils.can_ping(job, ip_address): raise DeviceOffline("Device %s is not reachable via " "the network." % ip_address) ssh_key = get_private_key(ip_address=ip_address, ssh_config=ssh_config) diff --git a/acts/framework/acts/controllers/iperf_server.py b/acts/framework/acts/controllers/iperf_server.py index 2b7d970442..78cb787458 100755 --- a/acts/framework/acts/controllers/iperf_server.py +++ b/acts/framework/acts/controllers/iperf_server.py @@ -243,8 +243,8 @@ class IPerfResult(object): """ if not self._has_data(): return None - instantaneous_rates = self.instantaneous_rates[ - iperf_ignored_interval:-1] + instantaneous_rates = self.instantaneous_rates[iperf_ignored_interval: + -1] avg_rate = math.fsum(instantaneous_rates) / len(instantaneous_rates) sqd_deviations = ([(rate - avg_rate)**2 for rate in instantaneous_rates]) @@ -295,25 +295,6 @@ class IPerfServerBase(object): """ raise NotImplementedError('stop() must be specified.') - def get_interface_ip_addresses(self, interface): - """Gets all of the ip addresses, ipv4 and ipv6, associated with a - particular interface name. - - Args: - interface: The interface name on the device, ie eth0 - - Returns: - A list of dictionaries of the the various IP addresses: - ipv4_private_local_addresses: Any 192.168, 172.16, or 10 - addresses - ipv4_public_addresses: Any IPv4 public addresses - ipv6_link_local_addresses: Any fe80:: addresses - ipv6_private_local_addresses: Any fd00:: addresses - ipv6_public_addresses: Any publicly routable addresses - """ - raise NotImplementedError('get_interface_ip_addresses' - ' must be specified.') - def _get_full_file_path(self, tag=None): """Returns the full file path for the IPerfServer log file. @@ -432,24 +413,6 @@ class IPerfServer(IPerfServerBase): return self._current_log_file - def get_interface_ip_addresses(self, interface): - """Gets all of the ip addresses, ipv4 and ipv6, associated with a - particular interface name. - - Args: - interface: The interface name on the device, ie eth0 - - Returns: - A list of dictionaries of the the various IP addresses: - ipv4_private_local_addresses: Any 192.168, 172.16, or 10 - addresses - ipv4_public_addresses: Any IPv4 public addresses - ipv6_link_local_addresses: Any fe80:: addresses - ipv6_private_local_addresses: Any fd00:: addresses - ipv6_public_addresses: Any publicly routable addresses - """ - return utils.get_interface_ip_addresses(job, interface) - def __del__(self): self.stop() @@ -523,6 +486,7 @@ class IPerfServerOverSsh(IPerfServerBase): """ if not self._ssh_session: self.start_ssh() + return utils.get_interface_ip_addresses(self._ssh_session, interface) def renew_test_interface_ip_address(self): @@ -748,22 +712,3 @@ class IPerfServerOverAdb(IPerfServerBase): self._iperf_process = None return log_file - - def get_interface_ip_addresses(self, interface): - """Gets all of the ip addresses, ipv4 and ipv6, associated with a - particular interface name. - - Args: - interface: The interface name on the device, ie eth0 - - Returns: - A list of dictionaries of the the various IP addresses: - ipv4_private_local_addresses: Any 192.168, 172.16, or 10 - addresses - ipv4_public_addresses: Any IPv4 public addresses - ipv6_link_local_addresses: Any fe80:: addresses - ipv6_private_local_addresses: Any fd00:: addresses - ipv6_public_addresses: Any publicly routable addresses - """ - return utils.get_interface_ip_addresses(self._android_device_or_serial, - interface) diff --git a/acts/framework/acts/controllers/rohdeschwarz_lib/OWNERS b/acts/framework/acts/controllers/rohdeschwarz_lib/OWNERS new file mode 100644 index 0000000000..e4010df218 --- /dev/null +++ b/acts/framework/acts/controllers/rohdeschwarz_lib/OWNERS @@ -0,0 +1,4 @@ +iguarna@google.com +chaoyangf@google.com +yixiang@google.com +codycaldwell@google.com
\ No newline at end of file diff --git a/acts/framework/acts/controllers/rohdeschwarz_lib/cmw500_cellular_simulator.py b/acts/framework/acts/controllers/rohdeschwarz_lib/cmw500_cellular_simulator.py index 91e71b767a..6a6c3ffd0a 100644 --- a/acts/framework/acts/controllers/rohdeschwarz_lib/cmw500_cellular_simulator.py +++ b/acts/framework/acts/controllers/rohdeschwarz_lib/cmw500_cellular_simulator.py @@ -17,7 +17,7 @@ import time from acts.controllers.rohdeschwarz_lib import cmw500 from acts.controllers import cellular_simulator as cc -from acts.test_utils.power.tel_simulations import LteSimulation +from acts.controllers.cellular_lib import LteSimulation CMW_TM_MAPPING = { LteSimulation.TransmissionMode.TM1: cmw500.TransmissionModes.TM1, diff --git a/acts/framework/acts/controllers/sl4a_lib/event_dispatcher.py b/acts/framework/acts/controllers/sl4a_lib/event_dispatcher.py index c37635e188..e8a49ff166 100644 --- a/acts/framework/acts/controllers/sl4a_lib/event_dispatcher.py +++ b/acts/framework/acts/controllers/sl4a_lib/event_dispatcher.py @@ -215,8 +215,10 @@ class EventDispatcher: # Block forever on event wait return e_queue.get(True) except queue.Empty: - raise queue.Empty('Timeout after {}s waiting for event: {}'.format( - timeout, event_name)) + msg = 'Timeout after {}s waiting for event: {}'.format( + timeout, event_name) + self.log.error(msg) + raise queue.Empty(msg) def wait_for_event(self, event_name, @@ -273,9 +275,10 @@ class EventDispatcher: if time.time() > deadline: for ignored_event in ignored_events: self.get_event_q(event_name).put(ignored_event) - raise queue.Empty( - 'Timeout after {}s waiting for event: {}'.format( - timeout, event_name)) + msg = 'Timeout after {}s waiting for event: {}'.format( + timeout, event_name) + self.log.error(msg) + raise queue.Empty(msg) def pop_events(self, regex_pattern, timeout, freq=1): """Pop events whose names match a regex pattern. @@ -312,8 +315,10 @@ class EventDispatcher: break time.sleep(freq) if len(results) == 0: - raise queue.Empty('Timeout after {}s waiting for event: {}'.format( - timeout, regex_pattern)) + msg = 'Timeout after {}s waiting for event: {}'.format( + timeout, regex_pattern) + self.log.error(msg) + raise queue.Empty(msg) return sorted(results, key=lambda event: event['time']) diff --git a/acts/framework/acts/controllers/spectracom_lib/__init__.py b/acts/framework/acts/controllers/spectracom_lib/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/acts/controllers/spectracom_lib/__init__.py diff --git a/acts/framework/acts/controllers/spectracom_lib/gsg6.py b/acts/framework/acts/controllers/spectracom_lib/gsg6.py new file mode 100644 index 0000000000..6b96456f3d --- /dev/null +++ b/acts/framework/acts/controllers/spectracom_lib/gsg6.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Python module for Spectracom/Orolia GSG-6 GNSS simulator.""" + +from acts.controllers import abstract_inst + + +class GSG6Error(abstract_inst.SocketInstrumentError): + """GSG-6 Instrument Error Class.""" + + +class GSG6(abstract_inst.SocketInstrument): + """GSG-6 Class, inherted from abstract_inst SocketInstrument.""" + + def __init__(self, ip_addr, ip_port): + """Init method for GSG-6. + + Args: + ip_addr: IP Address. + Type, str. + ip_port: TCPIP Port. + Type, str. + """ + super(GSG6, self).__init__(ip_addr, ip_port) + + self.idn = '' + + def connect(self): + """Init and Connect to GSG-6.""" + self._connect_socket() + + self.get_idn() + + infmsg = 'Connected to GSG-6, with ID: {}'.format(self.idn) + self._logger.debug(infmsg) + + def close(self): + """Close GSG-6.""" + self._close_socket() + + self._logger.debug('Closed connection to GSG-6') + + def get_idn(self): + """Get the Idenification of GSG-6. + + Returns: + GSG-6 Identifier + """ + self.idn = self._query('*IDN?') + + return self.idn + + def start_scenario(self, scenario=''): + """Start to run scenario. + + Args: + scenario: Scenario to run. + Type, str. + Default, '', which will run current selected one. + """ + if scenario: + cmd = 'SOUR:SCEN:LOAD ' + scenario + self._send(cmd) + + self._send('SOUR:SCEN:CONT START') + + if scenario: + infmsg = 'Started running scenario {}'.format(scenario) + else: + infmsg = 'Started running current scenario' + + self._logger.debug(infmsg) + + def stop_scenario(self): + """Stop the running scenario.""" + + self._send('SOUR:SCEN:CONT STOP') + + self._logger.debug('Stopped running scenario') + + def preset(self): + """Preset GSG-6 to default status.""" + self._send('*RST') + + self._logger.debug('Reset GSG-6') + + def set_power(self, power_level): + """set GSG-6 transmit power on all bands. + + Args: + power_level: transmit power level + Type, float. + Decimal, unit [dBm] + + Raises: + GSG6Error: raise when power level is not in [-160, -65] range. + """ + if not -160 <= power_level <= -65: + errmsg = ('"power_level" must be within [-160, -65], ' + 'current input is {}').format(str(power_level)) + raise GSG6Error(error=errmsg, command='set_power') + + self._send(':SOUR:POW ' + str(round(power_level, 1))) + + infmsg = 'Set GSG-6 transmit power to "{}"'.format( + round(power_level, 1)) + self._logger.debug(infmsg) diff --git a/acts/framework/acts/controllers/spirent_lib/__init__.py b/acts/framework/acts/controllers/spirent_lib/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/acts/controllers/spirent_lib/__init__.py diff --git a/acts/framework/acts/controllers/spirent_lib/gss6450.py b/acts/framework/acts/controllers/spirent_lib/gss6450.py new file mode 100644 index 0000000000..aa84575b5a --- /dev/null +++ b/acts/framework/acts/controllers/spirent_lib/gss6450.py @@ -0,0 +1,381 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Python module for Spirent GSS6450 GNSS RPS.""" + +import datetime +import numbers +from acts.controllers import abstract_inst + + +class GSS6450Error(abstract_inst.SocketInstrumentError): + """GSS6450 Instrument Error Class.""" + + +class GSS6450(abstract_inst.RequestInstrument): + """GSS6450 Class, inherted from abstract_inst RequestInstrument.""" + + def __init__(self, ip_addr): + """Init method for GSS6450. + + Args: + ip_addr: IP Address. + Type, str. + """ + super(GSS6450, self).__init__(ip_addr) + + self.idn = 'Spirent-GSS6450' + + def _put(self, cmd): + """Send put command via GSS6450 HTTP Request and get response. + + Args: + cmd: parameters listed in SHM_PUT. + Type, Str. + + Returns: + resp: Response from the _query method. + Type, Str. + """ + put_cmd = 'shm_put.shtml?' + cmd + resp = self._query(put_cmd) + + return resp + + def _get(self, cmd): + """Send get command via GSS6450 HTTP Request and get response. + + Args: + cmd: parameters listed in SHM_GET. + Type, Str. + + Returns: + resp: Response from the _query method. + Type, Str. + """ + get_cmd = 'shm_get.shtml?' + cmd + resp = self._query(get_cmd) + + return resp + + def get_scenario_filename(self): + """Get the scenario filename of GSS6450. + + Returns: + filename: RPS Scenario file name. + Type, Str. + """ + resp_raw = self._get('-f') + filename = resp_raw.split(':')[-1].strip(' ') + self._logger.debug('Got scenario file name: "%s".', filename) + + return filename + + def get_scenario_description(self): + """Get the scenario description of GSS6450. + + Returns: + description: RPS Scenario description. + Type, Str. + """ + resp_raw = self._get('-d') + description = resp_raw.split('-d')[-1].strip(' ') + + if description: + self._logger.debug('Got scenario description: "%s".', description) + else: + self._logger.warning('Got scenario description with empty string.') + + return description + + def get_scenario_location(self): + """Get the scenario location of GSS6450. + + Returns: + location: RPS Scenario location. + Type, Str. + """ + resp_raw = self._get('-i') + location = resp_raw.split('-i')[-1].strip(' ') + + if location: + self._logger.debug('Got scenario location: "%s".', location) + else: + self._logger.warning('Got scenario location with empty string.') + + return location + + def get_operation_mode(self): + """Get the operation mode of GSS6450. + + Returns: + mode: RPS Operation Mode. + Type, Str. + Option, STOPPED/PLAYING/RECORDING + """ + resp_raw = self._get('-m') + mode = resp_raw.split('-m')[-1].strip(' ') + self._logger.debug('Got operation mode: "%s".', mode) + + return mode + + def get_battery_level(self): + """Get the battery level of GSS6450. + + Returns: + batterylevel: RPS Battery Level. + Type, float. + """ + resp_raw = self._get('-l') + batterylevel = float(resp_raw.split('-l')[-1].strip(' ')) + self._logger.debug('Got battery level: %s%%.', batterylevel) + + return batterylevel + + def get_rfport_voltage(self): + """Get the RF port voltage of GSS6450. + + Returns: + voltageout: RPS RF port voltage. + Type, str + """ + resp_raw = self._get('-v') + voltageout = resp_raw.split('-v')[-1].strip(' ') + self._logger.debug('Got RF port voltage: "%s".', voltageout) + + return voltageout + + def get_storage_media(self): + """Get the storage media of GSS6450. + + Returns: + media: RPS storage. + Type, str + + Raises: + GSS6450Error: raise when request response is not support. + """ + resp_raw = self._get('-M') + resp_num = resp_raw.split('-M')[-1].strip(' ') + + if resp_num == '1': + media = '1-INTERNAL' + elif resp_num == '2': + media = '2-REMOVABLE' + else: + errmsg = ('"{}" is not recognized as GSS6450 valid storage media' + ' type'.format(resp_num)) + raise GSS6450Error(error=errmsg, command='get_storage_media') + + self._logger.debug('Got current storage media: %s.', media) + + return media + + def get_attenuation(self): + """Get the attenuation of GSS6450. + + Returns: + attenuation: RPS attenuation level, in dB. + Type, list of float. + """ + resp_raw = self._get('-a') + resp_str = resp_raw.split('-a')[-1].strip(' ') + self._logger.debug('Got attenuation: %s dB.', resp_str) + attenuation = [float(itm) for itm in resp_str.split(',')] + + return attenuation + + def get_elapsed_time(self): + """Get the running scenario elapsed time of GSS6450. + + Returns: + etime: RPS elapsed time. + Type, datetime.timedelta. + """ + resp_raw = self._get('-e') + resp_str = resp_raw.split('-e')[-1].strip(' ') + self._logger.debug('Got senario elapsed time: "%s".', resp_str) + etime_tmp = datetime.datetime.strptime(resp_str, '%H:%M:%S') + etime = datetime.timedelta(hours=etime_tmp.hour, + minutes=etime_tmp.minute, + seconds=etime_tmp.second) + + return etime + + def get_playback_offset(self): + """Get the running scenario playback offset of GSS6450. + + Returns: + offset: RPS playback offset. + Type, datetime.timedelta. + """ + resp_raw = self._get('-o') + offset_tmp = float(resp_raw.split('-o')[-1].strip(' ')) + self._logger.debug('Got senario playback offset: %s sec.', offset_tmp) + offset = datetime.timedelta(seconds=offset_tmp) + + return offset + + def play_scenario(self, scenario=''): + """Start to play scenario in GSS6450. + + Args: + scenario: Scenario to play. + Type, str. + Default, '', which will run current selected one. + """ + if scenario: + cmd = '-f{},-wP'.format(scenario) + else: + cmd = '-wP' + + _ = self._put(cmd) + + if scenario: + infmsg = 'Started playing scenario: "{}".'.format(scenario) + else: + infmsg = 'Started playing current scenario.' + + self._logger.debug(infmsg) + + def record_scenario(self, scenario=''): + """Start to record scenario in GSS6450. + + Args: + scenario: Scenario to record. + Type, str. + Default, '', which will run current selected one. + """ + if scenario: + cmd = '-f{},-wR'.format(scenario) + else: + cmd = '-wR' + + _ = self._put(cmd) + + if scenario: + infmsg = 'Started recording scenario: "{}".'.format(scenario) + else: + infmsg = 'Started recording scenario.' + + self._logger.debug(infmsg) + + def stop_scenario(self): + """Start to stop playing/recording scenario in GSS6450.""" + _ = self._put('-wS') + + self._logger.debug('Stopped playing/recording scanrio.') + + def set_rfport_voltage(self, voltageout): + """Set the RF port voltage of GSS6450. + + Args: + voltageout: RPS RF port voltage. + Type, str + + Raises: + GSS6450Error: raise when voltageout input is not valid. + """ + if voltageout == 'OFF': + voltage_cmd = '0' + elif voltageout == '3.3V': + voltage_cmd = '3' + elif voltageout == '5V': + voltage_cmd = '5' + else: + errmsg = ('"{}" is not recognized as GSS6450 valid RF port voltage' + ' type'.format(voltageout)) + raise GSS6450Error(error=errmsg, command='set_rfport_voltage') + + _ = self._put('-v{},-wV'.format(voltage_cmd)) + self._logger.debug('Set RF port voltage: "%s".', voltageout) + + def set_attenuation(self, attenuation): + """Set the attenuation of GSS6450. + + Args: + attenuation: RPS attenuation level, in dB. + Type, numerical. + + Raises: + GSS6450Error: raise when attenuation is not in range. + """ + if not 0 <= attenuation <= 31: + errmsg = ('"attenuation" must be within [0, 31], ' + 'current input is {}').format(str(attenuation)) + raise GSS6450Error(error=errmsg, command='set_attenuation') + + attenuation_raw = round(attenuation) + + if attenuation_raw != attenuation: + warningmsg = ('"attenuation" must be integer, current input ' + 'will be rounded to {}'.format(attenuation_raw)) + self._logger.warning(warningmsg) + + _ = self._put('-a{},-wA'.format(attenuation_raw)) + + self._logger.debug('Set attenuation: %s dB.', attenuation_raw) + + def set_playback_offset(self, offset): + """Set the playback offset of GSS6450. + + Args: + offset: RPS playback offset. + Type, datetime.timedelta, or numerical. + + Raises: + GSS6450Error: raise when offset is not numeric or timedelta. + """ + if isinstance(offset, datetime.timedelta): + offset_raw = offset.total_seconds() + elif isinstance(offset, numbers.Number): + offset_raw = offset + else: + raise GSS6450Error(error=('"offset" must be numerical value or ' + 'datetime.timedelta'), + command='set_playback_offset') + + _ = self._put('-o{}'.format(offset_raw)) + + self._logger.debug('Set playback offset: %s sec.', offset_raw) + + def set_storage_media(self, media): + """Set the storage media of GSS6450. + + Args: + media: RPS storage Media, Internal or External. + Type, str. Option, 'internal', 'removable' + + Raises: + GSS6450Error: raise when media option is not support. + """ + if media == 'internal': + raw_media = '1' + elif media == 'removable': + raw_media = '2' + else: + raise GSS6450Error( + error=('"media" input must be in ["internal", "removable"]. ' + ' Current input is {}'.format(media)), + command='set_storage_media') + + _ = self._put('-M{}-wM'.format(raw_media)) + + resp_raw = self.get_storage_media() + if raw_media != resp_raw[0]: + raise GSS6450Error( + error=('Setting media "{}" is not the same as queried media ' + '"{}".'.format(media, resp_raw)), + command='set_storage_media') diff --git a/acts/framework/acts/test_utils/abstract_devices/wlan_device.py b/acts/framework/acts/test_utils/abstract_devices/wlan_device.py index aacb9fb2d1..01a9231949 100644 --- a/acts/framework/acts/test_utils/abstract_devices/wlan_device.py +++ b/acts/framework/acts/test_utils/abstract_devices/wlan_device.py @@ -58,6 +58,7 @@ class WlanDevice(object): def __init__(self, device): self.device = device self.log = logging + self.identifier = None def wifi_toggle_state(self, state): """Base generic WLAN interface. Only called if not overridden by @@ -138,7 +139,23 @@ class WlanDevice(object): raise NotImplementedError("{} must be defined.".format( inspect.currentframe().f_code.co_name)) - def ping(self, dest_ip, count=3, interval=1000, timeout=1000, size=25): + def can_ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): + raise NotImplementedError("{} must be defined.".format( + inspect.currentframe().f_code.co_name)) + + def ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): raise NotImplementedError("{} must be defined.".format( inspect.currentframe().f_code.co_name)) @@ -166,6 +183,7 @@ class AndroidWlanDevice(WlanDevice): """ def __init__(self, android_device): super().__init__(android_device) + self.identifier = android_device.serial def wifi_toggle_state(self, state): awutils.wifi_toggle_state(self.device, state) @@ -237,12 +255,21 @@ class AndroidWlanDevice(WlanDevice): return 'BSSID' in wifi_info and wifi_info['SSID'] == ssid return 'BSSID' in wifi_info - def ping(self, dest_ip, count=3, interval=1000, timeout=1000, size=25): + def can_ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): return adb_shell_ping(self.device, dest_ip=dest_ip, count=count, timeout=timeout) + def ping(self, dest_ip, count=3, interval=1000, timeout=1000, size=25): + pass + def hard_power_cycle(self, pdus): pass @@ -264,6 +291,7 @@ class FuchsiaWlanDevice(WlanDevice): """ def __init__(self, fuchsia_device): super().__init__(fuchsia_device) + self.identifier = fuchsia_device.ip def wifi_toggle_state(self, state): """Stub for Fuchsia implementation.""" @@ -319,13 +347,34 @@ class FuchsiaWlanDevice(WlanDevice): def status(self): return self.device.wlan_lib.wlanStatus() - def ping(self, dest_ip, count=3, interval=1000, timeout=1000, size=25): - ping_result = self.device.ping(dest_ip, - count=count, - interval=interval, - timeout=timeout, - size=size) - return ping_result['status'] + def can_ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): + return self.device.can_ping( + dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) + + def ping(self, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=25, + additional_ping_params=None): + return self.device.ping(dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) def get_wlan_interface_id_list(self): """Function to list available WLAN interfaces. @@ -362,7 +411,7 @@ class FuchsiaWlanDevice(WlanDevice): def is_connected(self, ssid=None): """ Determines if wlan_device is connected to wlan network. - + Args: ssid (optional): string, to check if device is connect to a specific network. diff --git a/acts/framework/acts/test_utils/bt/BtSarBaseTest.py b/acts/framework/acts/test_utils/bt/BtSarBaseTest.py index 0dec882e99..509140778b 100644 --- a/acts/framework/acts/test_utils/bt/BtSarBaseTest.py +++ b/acts/framework/acts/test_utils/bt/BtSarBaseTest.py @@ -38,6 +38,8 @@ FORCE_SAR_ADB_COMMAND = ('am broadcast -n' 'com.google.android.apps.scone/.coex.TestReceiver -a ' 'com.google.android.apps.scone.coex.SIMULATE_STATE ') +SLEEP_DURATION = 2 + DEFAULT_DURATION = 5 DEFAULT_MAX_ERROR_THRESHOLD = 2 DEFAULT_AGG_MAX_ERROR_THRESHOLD = 2 @@ -91,7 +93,11 @@ class BtSarBaseTest(BaseTestClass): max_error_threshold=DEFAULT_MAX_ERROR_THRESHOLD, agg_error_threshold=DEFAULT_AGG_MAX_ERROR_THRESHOLD, tpc_threshold=[2, 8], - ) + sar_margin={ + 'BDR': 0, + 'EDR': 0, + 'BLE': 0 + }) self.attenuator = self.attenuators[0] self.dut = self.android_devices[0] @@ -118,7 +124,7 @@ class BtSarBaseTest(BaseTestClass): for file in self.custom_files: if 'custom_sar_table_{}.csv'.format(custom_file_suffix) in file: - self.custom_sar_path = file + self.custom_sar_path = file break else: raise RuntimeError('Custom Sar File is missing') @@ -213,24 +219,74 @@ class BtSarBaseTest(BaseTestClass): Args: df: Processed SAR table sweep results """ - self.plot.add_line(df.index, - df['expected_tx_power'], - legend='expected', - marker='circle') - self.plot.add_line(df.index, - df['measured_tx_power'], - legend='measured', - marker='circle') - self.plot.add_line(df.index, - df['delta'], - legend='delta', - marker='circle') - - results_file_path = os.path.join( - self.log_path, '{}.html'.format(self.current_test_name)) + self.plot.add_line( + df.index, + df['expected_tx_power'], + legend='expected', + marker='circle') + self.plot.add_line( + df.index, + df['measured_tx_power'], + legend='measured', + marker='circle') + self.plot.add_line( + df.index, df['delta'], legend='delta', marker='circle') + + results_file_path = os.path.join(self.log_path, '{}.html'.format( + self.current_test_name)) self.plot.generate_figure() wifi_utils.BokehFigure.save_figures([self.plot], results_file_path) + def sweep_power_cap(self): + sar_df = self.bt_sar_df + sar_df['BDR_power_cap'] = -128 + sar_df['EDR_power_cap'] = -128 + sar_df['BLE_power_cap'] = -128 + + if self.sar_version_2: + power_column_dict = { + 'BDR': 'BluetoothBDRPower', + 'EDR': 'BluetoothEDRPower', + 'BLE': 'BluetoothLEPower' + } + else: + power_column_dict = {'EDR': self.power_column} + + power_cap_error = False + + for type, column_name in power_column_dict.items(): + + self.log.info("Performing sanity test on {}".format(type)) + # Iterating through the BT SAR scenarios + for scenario in range(0, self.bt_sar_df.shape[0]): + # Reading BT SAR table row into dict + read_scenario = sar_df.loc[scenario].to_dict() + start_time = self.dut.adb.shell('date +%s.%m') + time.sleep(SLEEP_DURATION) + + # Setting SAR state to the read BT SAR row + self.set_sar_state(self.dut, read_scenario, self.country_code) + + # Reading device power cap from logcat after forcing SAR State + scenario_power_cap = self.get_current_power_cap( + self.dut, start_time, type=type) + sar_df.loc[scenario, '{}_power_cap'.format( + type)] = scenario_power_cap + self.log.info( + 'scenario: {}, ' + 'sar_power: {}, power_cap:{}'.format( + scenario, sar_df.loc[scenario, column_name], + sar_df.loc[scenario, '{}_power_cap'.format(type)])) + + if not sar_df['{}_power_cap'.format(type)].equals(sar_df[column_name]): + power_cap_error = True + + results_file_path = os.path.join(self.log_path, '{}.csv'.format( + self.current_test_name)) + sar_df.to_csv(results_file_path) + + return power_cap_error + def sweep_table(self, client_ad=None, server_ad=None, @@ -264,11 +320,11 @@ class BtSarBaseTest(BaseTestClass): # Sorts the table if self.sort_order: if self.sort_order.lower() == 'ascending': - sar_df = sar_df.sort_values(by=[self.power_column], - ascending=True) + sar_df = sar_df.sort_values( + by=[self.power_column], ascending=True) else: - sar_df = sar_df.sort_values(by=[self.power_column], - ascending=False) + sar_df = sar_df.sort_values( + by=[self.power_column], ascending=False) sar_df = sar_df.reset_index(drop=True) # Sweeping BT SAR table @@ -277,7 +333,7 @@ class BtSarBaseTest(BaseTestClass): read_scenario = sar_df.loc[scenario].to_dict() start_time = self.dut.adb.shell('date +%s.%m') - time.sleep(1) + time.sleep(SLEEP_DURATION) #Setting SAR State self.set_sar_state(self.dut, read_scenario, self.country_code) @@ -286,10 +342,10 @@ class BtSarBaseTest(BaseTestClass): sar_df.loc[scenario, 'power_cap'] = self.get_current_power_cap( self.dut, start_time, type='BLE') - sar_df.loc[scenario, - 'ble_rssi'] = run_ble_throughput_and_read_rssi( - client_ad, server_ad, client_conn_id, - gatt_server, gatt_callback) + sar_df.loc[ + scenario, 'ble_rssi'] = run_ble_throughput_and_read_rssi( + client_ad, server_ad, client_conn_id, gatt_server, + gatt_callback) self.log.info('scenario:{}, power_cap:{}, ble_rssi:{}'.format( scenario, sar_df.loc[scenario, 'power_cap'], @@ -300,21 +356,18 @@ class BtSarBaseTest(BaseTestClass): processed_bqr_results = bt_utils.get_bt_metric( self.android_devices, self.duration) - sar_df.loc[scenario, - 'slave_rssi'] = processed_bqr_results['rssi'][ - self.bt_device_controller.serial] - sar_df.loc[scenario, - 'master_rssi'] = processed_bqr_results['rssi'][ - self.dut.serial] + sar_df.loc[scenario, 'slave_rssi'] = processed_bqr_results[ + 'rssi'][self.bt_device_controller.serial] + sar_df.loc[scenario, 'master_rssi'] = processed_bqr_results[ + 'rssi'][self.dut.serial] sar_df.loc[scenario, 'pwlv'] = processed_bqr_results['pwlv'][ self.dut.serial] self.log.info( 'scenario:{}, power_cap:{}, s_rssi:{}, m_rssi:{}, m_pwlv:{}' .format(scenario, sar_df.loc[scenario, 'power_cap'], sar_df.loc[scenario, 'slave_rssi'], - sar_df.loc[scenario, - 'master_rssi'], sar_df.loc[scenario, - 'pwlv'])) + sar_df.loc[scenario, 'master_rssi'], + sar_df.loc[scenario, 'pwlv'])) self.log.info('BT SAR Table swept') @@ -351,12 +404,10 @@ class BtSarBaseTest(BaseTestClass): ble_otp = min(0, float(self.otp['BLE']['10'])) # EDR TX Power for PL10 - edr_tx_power_pl10 = self.calibration_params['target_power']['EDR'][ - '10'] - edr_otp + edr_tx_power_pl10 = self.calibration_params['target_power']['EDR']['10'] - edr_otp # BDR TX Power for PL10 - bdr_tx_power_pl10 = self.calibration_params['target_power']['BDR'][ - '10'] - bdr_otp + bdr_tx_power_pl10 = self.calibration_params['target_power']['BDR']['10'] - bdr_otp # RSSI being measured is BDR offset = bdr_tx_power_pl10 - edr_tx_power_pl10 @@ -369,8 +420,8 @@ class BtSarBaseTest(BaseTestClass): # Adding a target power column if 'ble_rssi' in sar_df.columns: - sar_df['target_power'] = self.calibration_params[ - 'target_power']['BLE']['10'] - ble_otp + sar_df[ + 'target_power'] = self.calibration_params['target_power']['BLE']['10'] - ble_otp else: sar_df['target_power'] = sar_df['pwlv'].astype(str).map( self.calibration_params['target_power']['EDR']) - edr_otp @@ -383,11 +434,11 @@ class BtSarBaseTest(BaseTestClass): ]].min(axis=1) if hasattr(self, 'pl10_atten'): - sar_df['measured_tx_power'] = sar_df['slave_rssi'] + sar_df[ - 'pathloss'] + self.pl10_atten - offset + sar_df[ + 'measured_tx_power'] = sar_df['slave_rssi'] + sar_df['pathloss'] + self.pl10_atten - offset else: - sar_df['measured_tx_power'] = sar_df['ble_rssi'] + sar_df[ - 'pathloss'] + FIXED_ATTENUATION + sar_df[ + 'measured_tx_power'] = sar_df['ble_rssi'] + sar_df['pathloss'] + FIXED_ATTENUATION else: @@ -403,11 +454,11 @@ class BtSarBaseTest(BaseTestClass): sar_df[ 'expected_tx_power'] = sar_df['ftm_power'] - sar_df['backoff'] - sar_df['measured_tx_power'] = sar_df['slave_rssi'] + sar_df[ - 'pathloss'] + self.pl10_atten + sar_df[ + 'measured_tx_power'] = sar_df['slave_rssi'] + sar_df['pathloss'] + self.pl10_atten - sar_df['delta'] = sar_df['expected_tx_power'] - sar_df[ - 'measured_tx_power'] + sar_df[ + 'delta'] = sar_df['expected_tx_power'] - sar_df['measured_tx_power'] self.log.info('Sweep results processed') @@ -426,22 +477,28 @@ class BtSarBaseTest(BaseTestClass): Args: sar_df: processed BT SAR table """ + if self.sar_version_2: + breach_error_result = ( + sar_df['expected_tx_power'] + self.sar_margin[type] > + sar_df['measured_tx_power']).all() + if not breach_error_result: + asserts.fail('Measured TX power exceeds expected') - # checks for errors at particular points in the sweep - max_error_result = abs( - sar_df['delta']) > self.max_error_threshold[type] - if False in max_error_result: - asserts.fail('Maximum Error Threshold Exceeded') + else: + # checks for errors at particular points in the sweep + max_error_result = abs( + sar_df['delta']) > self.max_error_threshold[type] + if max_error_result: + asserts.fail('Maximum Error Threshold Exceeded') - # checks for error accumulation across the sweep - if sar_df['delta'].sum() > self.agg_error_threshold[type]: - asserts.fail( - 'Aggregate Error Threshold Exceeded. Error: {} Threshold: {}'. - format(sar_df['delta'].sum(), self.agg_error_threshold)) + # checks for error accumulation across the sweep + if sar_df['delta'].sum() > self.agg_error_threshold[type]: + asserts.fail( + 'Aggregate Error Threshold Exceeded. Error: {} Threshold: {}'. + format(sar_df['delta'].sum(), self.agg_error_threshold)) - else: - self.sar_test_result.metric_value = 1 - asserts.explicit_pass('Measured and Expected Power Values in line') + self.sar_test_result.metric_value = 1 + asserts.explicit_pass('Measured and Expected Power Values in line') def set_sar_state(self, ad, signal_dict, country_code='us'): """Sets the SAR state corresponding to the BT SAR signal. @@ -480,9 +537,8 @@ class BtSarBaseTest(BaseTestClass): sar_state_command = FORCE_SAR_ADB_COMMAND for key in device_state_dict: enforced_state[key[0]] = device_state_dict[key] - sar_state_command = '{} --ei {} {}'.format(sar_state_command, - key[1], - device_state_dict[key]) + sar_state_command = '{} --ei {} {}'.format( + sar_state_command, key[1], device_state_dict[key]) if self.sar_version_2: sar_state_command = '{} --es country_iso "{}"'.format( sar_state_command, country_code.lower()) @@ -511,7 +567,7 @@ class BtSarBaseTest(BaseTestClass): stat: the desired BT stat. """ # Waiting for logcat to update - time.sleep(1) + time.sleep(SLEEP_DURATION) bt_adb_log = ad.adb.logcat('-b all -t %s' % begin_time) for line in bt_adb_log.splitlines(): if re.findall(regex, line): @@ -604,14 +660,14 @@ class BtSarBaseTest(BaseTestClass): """ device_state_regex = 'updateDeviceState: DeviceState: ([\s*\S+\s]+)' - time.sleep(2) + time.sleep(SLEEP_DURATION) device_state = self.parse_bt_logs(ad, begin_time, device_state_regex) if device_state: return device_state raise ValueError("Couldn't fetch device state") - def read_sar_table(self, ad): + def read_sar_table(self, ad, output_path=''): """Extracts the BT SAR table from the phone. Extracts the BT SAR table from the phone into the android device @@ -619,13 +675,15 @@ class BtSarBaseTest(BaseTestClass): Args: ad: android_device object. - + output_path: path to custom sar table Returns: df : BT SAR table (as pandas DataFrame). """ - output_path = os.path.join(ad.device_log_path, self.sar_file_name) - ad.adb.pull('{} {}'.format(self.sar_file_path, output_path)) - df = pd.read_csv(os.path.join(ad.device_log_path, self.sar_file_name)) + if not output_path: + output_path = os.path.join(ad.device_log_path, self.sar_file_name) + ad.adb.pull('{} {}'.format(self.sar_file_path, output_path)) + + df = pd.read_csv(output_path) self.log.info('BT SAR table read from the phone') return df @@ -650,7 +708,8 @@ class BtSarBaseTest(BaseTestClass): ad.push_system_file(src_path, self.sar_file_path) self.log.info('BT SAR table pushed') ad.reboot() - self.bt_sar_df = self.read_sar_table(self.dut) + + self.bt_sar_df = self.read_sar_table(self.dut, src_path) def set_PL10_atten_level(self, ad): """Finds the attenuation level at which the phone is at PL10 @@ -669,11 +728,11 @@ class BtSarBaseTest(BaseTestClass): for atten in range(self.atten_min, self.atten_max, BT_SAR_ATTEN_STEP): self.attenuator.set_atten(atten) # Sleep required for BQR to reflect the change in parameters - time.sleep(2) + time.sleep(SLEEP_DURATION) metrics = bt_utils.get_bt_metric(ad) if metrics['pwlv'][ad.serial] == 10: - self.log.info('PL10 located at {}'.format(atten + - BT_SAR_ATTEN_STEP)) + self.log.info( + 'PL10 located at {}'.format(atten + BT_SAR_ATTEN_STEP)) return atten + BT_SAR_ATTEN_STEP self.log.warn( diff --git a/acts/framework/acts/test_utils/bt/bt_test_utils.py b/acts/framework/acts/test_utils/bt/bt_test_utils.py index 3b9ec13ab1..a7e51bd076 100644 --- a/acts/framework/acts/test_utils/bt/bt_test_utils.py +++ b/acts/framework/acts/test_utils/bt/bt_test_utils.py @@ -243,13 +243,7 @@ def connect_phone_to_headset(android, android.droid.bluetoothConnectBonded(headset_mac_address) else: #Headset is connected, but A2DP profile is not - android.droid.bluetoothFactoryReset() - headset.reset() - headset.power_on() - enable_bluetooth(android.droid, android.ed) - headset.enter_pairing_mode() - android.droid.bluetoothStartPairingHelper() - android.droid.bluetoothDiscoverAndBond(headset_mac_address) + android.droid.bluetoothA2dpConnect(headset_mac_address) log.info('Waiting for connection...') time.sleep(connection_check_period) # Check for connection. diff --git a/acts/framework/acts/test_utils/instrumentation/config_wrapper.py b/acts/framework/acts/test_utils/instrumentation/config_wrapper.py new file mode 100644 index 0000000000..4bd1aa37f2 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/config_wrapper.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections +import os + + +class InvalidParamError(Exception): + pass + + +class ConfigWrapper(collections.UserDict): + """Class representing a test or preparer config.""" + + def __init__(self, config=None): + """Initialize a ConfigWrapper + + Args: + config: A dict representing the preparer/test parameters + """ + if config is None: + config = {} + super().__init__( + { + key: (ConfigWrapper(val) if isinstance(val, dict) else val) + for key, val in config.items() + } + ) + + def get(self, param_name, default=None, verify_fn=lambda _: True, + failure_msg=''): + """Get parameter from config, verifying that the value is valid + with verify_fn. + + Args: + param_name: Name of the param to fetch + default: Default value of param. + verify_fn: Callable to verify the param value. If it returns False, + an exception will be raised. + failure_msg: Exception message upon verify_fn failure. + """ + result = self.data.get(param_name, default) + if not verify_fn(result): + raise InvalidParamError('Invalid value "%s" for param %s. %s' + % (result, param_name, failure_msg)) + return result + + def get_config(self, param_name): + """Get a sub-config from config. Returns an empty ConfigWrapper if no + such sub-config is found. + """ + return self.get(param_name, default=ConfigWrapper()) + + def get_int(self, param_name, default=0): + """Get integer parameter from config. Will raise an exception + if result is not of type int. + """ + return self.get(param_name, default=default, + verify_fn=lambda val: type(val) is int, + failure_msg='Param must be of type int.') + + def get_numeric(self, param_name, default=0): + """Get int or float parameter from config. Will raise an exception if + result is not of type int or float. + """ + return self.get(param_name, default=default, + verify_fn=lambda val: type(val) in (int, float), + failure_msg='Param must be of type int or float.') diff --git a/acts/framework/acts/test_utils/instrumentation/device/apps/__init__.py b/acts/framework/acts/test_utils/instrumentation/device/apps/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/apps/__init__.py diff --git a/acts/framework/acts/test_utils/instrumentation/device/apps/app_installer.py b/acts/framework/acts/test_utils/instrumentation/device/apps/app_installer.py new file mode 100644 index 0000000000..1688f0b7f0 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/apps/app_installer.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re + +from acts.libs.proc import job + +PKG_NAME_PATTERN = r"^package:\s+name='(?P<pkg_name>.*?)'" +PM_PATH_PATTERN = r"^package:(?P<apk_path>.*)" + + +class AppInstaller(object): + """Class that represents an app on an Android device. Includes methods + for install, uninstall, and getting info. + """ + def __init__(self, ad, apk_path): + """Initializes an AppInstaller. + + Args: + ad: device to install the apk + apk_path: path to the apk + """ + self._ad = ad + self._apk_path = apk_path + self._pkg_name = None + + @staticmethod + def pull_from_device(ad, pkg_name, dest): + """Initializes an AppInstaller by pulling the apk file from the device, + given the package name + + Args: + ad: device on which the apk is installed + pkg_name: package name + dest: destination directory + (Note: If path represents a directory, it must already exist as + a directory) + + Returns: AppInstaller object representing the pulled apk, or None if + package not installed + """ + if not ad.is_apk_installed(pkg_name): + ad.log.warning('Unable to find package %s on device. Pull aborted.' + % pkg_name) + return None + path_on_device = re.compile(PM_PATH_PATTERN).search( + ad.adb.shell('pm path %s' % pkg_name)).group('apk_path') + ad.pull_files(path_on_device, dest) + if os.path.isdir(dest): + dest = os.path.join(dest, os.path.basename(path_on_device)) + return AppInstaller(ad, dest) + + @property + def apk_path(self): + return self._apk_path + + @property + def pkg_name(self): + """Get the package name corresponding to the apk from aapt + + Returns: The package name, or empty string if not found. + """ + if self._pkg_name is None: + dump = job.run( + 'aapt dump badging %s' % self.apk_path, + ignore_status=True).stdout + match = re.compile(PKG_NAME_PATTERN).search(dump) + self._pkg_name = match.group('pkg_name') if match else '' + return self._pkg_name + + def install(self, *extra_args): + """Installs the apk on the device. + + Args: + extra_args: Additional flags to the ADB install command. + Note that '-r' is included by default. + """ + self._ad.log.info('Installing app %s from %s' % + (self.pkg_name, self.apk_path)) + args = '-r %s' % ' '.join(extra_args) + self._ad.adb.install('%s %s' % (args, self.apk_path)) + + def uninstall(self, *extra_args): + """Uninstalls the apk from the device. + + Args: + extra_args: Additional flags to the uninstall command. + """ + self._ad.log.info('Uninstalling app %s' % self.pkg_name) + if not self.is_installed(): + self._ad.log.warning('Unable to uninstall app %s. App is not ' + 'installed.' % self.pkg_name) + return + self._ad.adb.shell( + 'pm uninstall %s %s' % (' '.join(extra_args), self.pkg_name)) + + def is_installed(self): + """Verifies that the apk is installed on the device. + + Returns: True if the apk is installed on the device. + """ + if not self.pkg_name: + self._ad.log.warning('No package name found for %s' % self.apk_path) + return False + return self._ad.is_apk_installed(self.pkg_name) diff --git a/acts/framework/acts/test_utils/instrumentation/device/apps/dismiss_dialogs.py b/acts/framework/acts/test_utils/instrumentation/device/apps/dismiss_dialogs.py new file mode 100644 index 0000000000..909326abcd --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/apps/dismiss_dialogs.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +from acts.test_utils.instrumentation.device.apps.app_installer import \ + AppInstaller +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import InstrumentationCommandBuilder + +DISMISS_DIALOGS_RUNNER = '.DismissDialogsInstrumentation' +SCREENSHOTS_DIR = 'dialog-dismissal' +DISMISS_DIALOGS_TIMEOUT = 300 + + +class DialogDismissalUtil(object): + """Utility for dismissing app dialogs.""" + def __init__(self, dut, util_apk): + self._dut = dut + self._dismiss_dialogs_apk = AppInstaller(dut, util_apk) + self._dismiss_dialogs_apk.install('-g') + + def dismiss_dialogs(self, apps, screenshots=True, quit_on_error=True): + """Dismiss dialogs for the given apps. + + Args: + apps: List of apps to dismiss dialogs + screenshots: Boolean to enable screenshots upon dialog dismissal + quit_on_error: Boolean to indicate if tool should quit on failure + """ + if not apps: + return + if not isinstance(apps, list): + apps = [apps] + self._dut.log.info('Dismissing app dialogs for %s' % apps) + cmd_builder = InstrumentationCommandBuilder() + cmd_builder.set_manifest_package(self._dismiss_dialogs_apk.pkg_name) + cmd_builder.set_runner(DISMISS_DIALOGS_RUNNER) + cmd_builder.add_flag('-w') + cmd_builder.add_key_value_param('apps', ','.join(apps)) + cmd_builder.add_key_value_param('screenshots', screenshots) + cmd_builder.add_key_value_param('quitOnError', quit_on_error) + self._dut.adb.shell(cmd_builder.build(), + timeout=DISMISS_DIALOGS_TIMEOUT) + + # Pull screenshots if screenshots=True + if screenshots: + self._dut.pull_files( + os.path.join(self._dut.external_storage_path, SCREENSHOTS_DIR), + self._dut.device_log_path + ) + + def close(self): + """Clean up util by uninstalling the dialog dismissal APK.""" + self._dismiss_dialogs_apk.uninstall() diff --git a/acts/framework/acts/test_utils/instrumentation/device/apps/hotword_model_extractor.py b/acts/framework/acts/test_utils/instrumentation/device/apps/hotword_model_extractor.py new file mode 100644 index 0000000000..57386b97ad --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/apps/hotword_model_extractor.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import tempfile +import zipfile + +from acts.test_utils.instrumentation.device.apps.app_installer \ + import AppInstaller + +DEFAULT_MODEL_NAME = 'en_us.mmap' +MODEL_DIR = 'res/raw' + + +class HotwordModelExtractor(object): + """ + Extracts a voice model data file from the Hotword APK and pushes it + onto the device. + """ + def __init__(self, dut): + self._dut = dut + + def extract_to_dut(self, hotword_pkg, model_name=DEFAULT_MODEL_NAME): + with tempfile.TemporaryDirectory() as tmp_dir: + extracted_model = self._extract(hotword_pkg, model_name, tmp_dir) + if not extracted_model: + return + device_dir = self._dut.adb.shell('echo $EXTERNAL_STORAGE') + self._dut.adb.push( + extracted_model, os.path.join(device_dir, model_name)) + + def _extract(self, hotword_pkg, model_name, dest): + """Extracts the model file from the given Hotword APK. + + Args: + hotword_pkg: Package name of the Hotword APK + model_name: File name of the model file. + dest: Destination directory + + Returns: Full path to the extracted model file. + """ + self._dut.log.info('Extracting voice model from Hotword APK.') + hotword_apk = AppInstaller.pull_from_device( + self._dut, hotword_pkg, dest) + if not hotword_apk: + self._dut.log.warning('Cannot extract Hotword voice model: ' + 'Hotword APK not installed.') + return None + + model_rel_path = os.path.join(MODEL_DIR, model_name) + with zipfile.ZipFile(hotword_apk.apk_path) as hotword_zip: + try: + return hotword_zip.extract(model_rel_path, dest) + except KeyError: + self._dut.log.warning( + 'Cannot extract Hotword voice model: Model file %s not ' + 'found.' % model_rel_path) + return None diff --git a/acts/framework/acts/test_utils/instrumentation/device/apps/permissions.py b/acts/framework/acts/test_utils/instrumentation/device/apps/permissions.py new file mode 100644 index 0000000000..3973751573 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/apps/permissions.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.device.apps.app_installer import \ + AppInstaller +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import InstrumentationCommandBuilder + +PERMISSION_RUNNER = '.PermissionInstrumentation' + + +class PermissionsUtil(object): + """Utility for granting all revoked runtime permissions.""" + def __init__(self, dut, util_apk): + self._dut = dut + self._permissions_apk = AppInstaller(dut, util_apk) + self._permissions_apk.install() + + def grant_all(self): + """Grant all runtime permissions with PermissionUtils.""" + self._dut.log.info('Granting all revoked runtime permissions.') + cmd_builder = InstrumentationCommandBuilder() + cmd_builder.set_manifest_package(self._permissions_apk.pkg_name) + cmd_builder.set_runner(PERMISSION_RUNNER) + cmd_builder.add_flag('-w') + cmd_builder.add_flag('-r') + cmd_builder.add_key_value_param('command', 'grant-all') + self._dut.adb.shell(cmd_builder.build()) + + def close(self): + """Clean up util by uninstalling the permissions APK.""" + self._permissions_apk.uninstall() diff --git a/acts/framework/acts/test_utils/instrumentation/device/command/adb_command_types.py b/acts/framework/acts/test_utils/instrumentation/device/command/adb_command_types.py new file mode 100644 index 0000000000..072e1aecf7 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/command/adb_command_types.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.device.command.intent_builder import \ + IntentBuilder + + +class DeviceState(object): + """Class for adb commands for setting device properties to a value.""" + + def __init__(self, base_cmd, on_val='1', off_val='0'): + """Create a DeviceState. + + Args: + base_cmd: The base adb command. Needs to accept an argument/value to + generate the full command. + on_val: Value used for the 'on' state + off_val: Value used for the 'off' state + """ + self._base_cmd = base_cmd + self._on_val = on_val + self._off_val = off_val + + def set_value(self, *values): + """Returns the adb command with the given arguments/values. + + Args: + values: The value(s) to run the command with + """ + try: + return self._base_cmd % values + except TypeError: + return str.strip(' '.join( + [self._base_cmd] + [str(value) for value in values])) + + def toggle(self, enabled): + """Returns the command corresponding to the desired state. + + Args: + enabled: True for the 'on' state. + """ + return self.set_value(self._on_val if enabled else self._off_val) + + +class DeviceSetprop(DeviceState): + """Class for setprop commands.""" + + def __init__(self, prop, on_val='1', off_val='0'): + """Create a DeviceSetprop. + + Args: + prop: Property name + on_val: Value used for the 'on' state + off_val: Value used for the 'off' state + """ + super().__init__('setprop %s' % prop, on_val, off_val) + + +class DeviceSetting(DeviceState): + """Class for commands to set a settings.db entry to a value.""" + + def __init__(self, namespace, setting, on_val='1', off_val='0'): + """Create a DeviceSetting. + + Args: + namespace: Namespace of the setting + setting: Setting name + on_val: Value used for the 'on' state + off_val: Value used for the 'off' state + """ + super().__init__('settings put %s %s' % (namespace, setting), + on_val, off_val) + + +class DeviceGServices(DeviceState): + """Class for overriding a GServices value.""" + + OVERRIDE_GSERVICES_INTENT = ('com.google.gservices.intent.action.' + 'GSERVICES_OVERRIDE') + + def __init__(self, setting, on_val='true', off_val='false'): + """Create a DeviceGServices. + + Args: + setting: Name of the GServices setting + on_val: Value used for the 'on' state + off_val: Value used for the 'off' state + """ + super().__init__(None, on_val, off_val) + self._intent_builder = IntentBuilder('am broadcast') + self._intent_builder.set_action(self.OVERRIDE_GSERVICES_INTENT) + self._setting = setting + + def set_value(self, value): + """Returns the adb command with the given value.""" + self._intent_builder.add_key_value_param(self._setting, value) + return self._intent_builder.build() + + +class DeviceBinaryCommandSeries(object): + """Class for toggling multiple settings at once.""" + + def __init__(self, binary_commands): + """Create a DeviceBinaryCommandSeries. + + Args: + binary_commands: List of commands for setting toggleable options + """ + self.cmd_list = binary_commands + + def toggle(self, enabled): + """Returns the list of command corresponding to the desired state. + + Args: + enabled: True for the 'on' state. + """ + return [cmd.toggle(enabled) for cmd in self.cmd_list] diff --git a/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/__init__.py b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/__init__.py diff --git a/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/common.py b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/common.py new file mode 100644 index 0000000000..bf853dc118 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/common.py @@ -0,0 +1,147 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.device.command.adb_command_types \ + import DeviceBinaryCommandSeries +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetprop +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetting +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceState + +GLOBAL = 'global' +SYSTEM = 'system' +SECURE = 'secure' + +"""Common device settings for power testing.""" + +# TODO: add descriptions to each setting + +# Network/Connectivity + +airplane_mode = DeviceBinaryCommandSeries( + [ + DeviceSetting(GLOBAL, 'airplane_mode_on'), + DeviceState( + 'am broadcast -a android.intent.action.AIRPLANE_MODE --ez state', + 'true', 'false') + ] +) + +mobile_data = DeviceBinaryCommandSeries( + [ + DeviceSetting(GLOBAL, 'mobile_data'), + DeviceState('svc data', 'enable', 'disable') + ] +) + +cellular = DeviceSetting(GLOBAL, 'cell_on') + +wifi = DeviceBinaryCommandSeries( + [ + DeviceSetting(GLOBAL, 'wifi_on'), + DeviceState('svc wifi', 'enable', 'disable') + ] +) + +ethernet = DeviceState('ifconfig eth0', 'up', 'down') + +bluetooth = DeviceState('service call bluetooth_manager', '6', '8') + +nfc = DeviceState('svc nfc', 'enable', 'disable') + + +# Calling + +disable_dialing = DeviceSetprop('ro.telephony.disable-call', 'true', 'false') + + +# Screen + +screen_adaptive_brightness = DeviceSetting(SYSTEM, 'screen_brightness_mode') + +screen_brightness = DeviceSetting(SYSTEM, 'screen_brightness') + +screen_always_on = DeviceState('svc power stayon', 'true', 'false') + +screen_timeout_ms = DeviceSetting(SYSTEM, 'screen_off_timeout') + +doze_mode = DeviceSetting(SECURE, 'doze_enabled') + +doze_always_on = DeviceSetting(SECURE, 'doze_always_on') + +wake_gesture = DeviceSetting(SECURE, 'wake_gesture_enabled') + +screensaver = DeviceSetting(SECURE, 'screensaver_enabled') + +notification_led = DeviceSetting(SYSTEM, 'notification_light_pulse') + + +# Accelerometer + +auto_rotate = DeviceSetting(SYSTEM, 'accelerometer_rotation') + + +# Time + +auto_time = DeviceSetting(GLOBAL, 'auto_time') + +auto_timezone = DeviceSetting(GLOBAL, 'auto_timezone') + +timezone = DeviceSetprop('persist.sys.timezone') + + +# Location + +location_gps = DeviceSetting(SECURE, 'location_providers_allowed', + '+gps', '-gps') + +location_network = DeviceSetting(SECURE, 'location_providers_allowed', + '+network', '-network') + + +# Power + +battery_saver_mode = DeviceSetting(GLOBAL, 'low_power') + +battery_saver_trigger = DeviceSetting(GLOBAL, 'low_power_trigger_level') + +enable_full_batterystats_history = 'dumpsys batterystats --enable full-history' + +disable_doze = 'dumpsys deviceidle disable' + + +# Sensors + +disable_sensors = 'dumpsys sensorservice restrict blah' + +MOISTURE_DETECTION_SETTING_FILE = '/sys/class/power_supply/usb/moisture_detection_enabled' +disable_moisture_detection = 'echo 0 > %s' % MOISTURE_DETECTION_SETTING_FILE + +## Ambient EQ: https://support.google.com/googlenest/answer/9137130?hl=en +ambient_eq = DeviceSetting(SECURE, 'display_white_balance_enabled') + +# Miscellaneous + +test_harness = DeviceBinaryCommandSeries( + [ + DeviceSetprop('ro.monkey'), + DeviceSetprop('ro.test_harness') + ] +) + +dismiss_keyguard = 'wm dismiss-keyguard' diff --git a/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/goog.py b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/goog.py new file mode 100644 index 0000000000..48f6bf1bf1 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/command/adb_commands/goog.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.device.command.adb_command_types \ + import DeviceBinaryCommandSeries +from acts.test_utils.instrumentation.device.command.adb_command_types \ + import DeviceGServices +from acts.test_utils.instrumentation.device.command.adb_command_types \ + import DeviceState + +"""Google-internal device settings for power testing.""" + +# TODO: add descriptions to each setting + +# Location + +location_collection = DeviceGServices( + 'location:collection_enabled', on_val='1', off_val='0') + +location_opt_in = DeviceBinaryCommandSeries( + [ + DeviceState('content insert --uri content://com.google.settings/' + 'partner --bind name:s:use_location_for_services ' + '--bind value:s:%s'), + DeviceState('content insert --uri content://com.google.settings/' + 'partner --bind name:s:network_location_opt_in ' + '--bind value:s:%s') + ] +) + +# Cast + +cast_broadcast = DeviceGServices('gms:cast:mdns_device_scanner:is_enabled') + + +# Apps + +disable_playstore = 'pm disable-user com.android.vending' + + +# Volta + +disable_volta = 'pm disable-user com.google.android.volta' + + +# CHRE + +disable_chre = 'setprop ctl.stop vendor.chre' + + +# MusicIQ + +disable_musiciq = 'pm disable-user com.google.intelligence.sense' + + +# Hotword + +disable_hotword = ( + 'am start -a com.android.intent.action.MANAGE_VOICE_KEYPHRASES ' + '--ei com.android.intent.extra.VOICE_KEYPHRASE_ACTION 2 ' + '--es com.android.intent.extra.VOICE_KEYPHRASE_HINT_TEXT "demo" ' + '--es com.android.intent.extra.VOICE_KEYPHRASE_LOCALE "en-US" ' + 'com.android.hotwordenrollment.okgoogle/' + 'com.android.hotwordenrollment.okgoogle.EnrollmentActivity') diff --git a/acts/framework/acts/test_utils/instrumentation/device/command/intent_builder.py b/acts/framework/acts/test_utils/instrumentation/device/command/intent_builder.py new file mode 100644 index 0000000000..a1cc529f7a --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/device/command/intent_builder.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections + +TYPE_TO_FLAG = collections.defaultdict(lambda: '--es') +TYPE_TO_FLAG.update({bool: '--ez', int: '--ei', float: '--ef', str: '--es'}) + + +class IntentBuilder(object): + """Helper class to build am broadcast <INTENT> commands.""" + + def __init__(self, base_cmd=''): + """Initializes the intent command builder. + + Args: + base_cmd: The base am command, e.g. am broadcast, am start + """ + self._base_cmd = base_cmd + self._action = None + self._component = None + self._data_uri = None + self._flags = [] + self._key_value_params = collections.OrderedDict() + + def set_action(self, action): + """Set the intent action, as marked by the -a flag""" + self._action = action + + def set_component(self, package, component=None): + """Set the package and/or component, as marked by the -n flag. + Only the package name will be used if no component is specified. + """ + if component: + self._component = '%s/%s' % (package, component) + else: + self._component = package + + def set_data_uri(self, data_uri): + """Set the data URI, as marked by the -d flag""" + self._data_uri = data_uri + + def add_flag(self, flag): + """Add any additional flags to the intent argument""" + self._flags.append(flag) + + def add_key_value_param(self, key, value=None): + """Add any extra data as a key-value pair""" + self._key_value_params[key] = value + + def build(self): + """Returns the full intent command string.""" + cmd = [self._base_cmd] + if self._action: + cmd.append('-a %s' % self._action) + if self._component: + cmd.append('-n %s' % self._component) + if self._data_uri: + cmd.append('-d %s' % self._data_uri) + cmd += self._flags + for key, value in self._key_value_params.items(): + if value is None: + cmd.append('--esn %s' % key) + else: + str_value = str(value) + if isinstance(value, bool): + str_value = str_value.lower() + cmd.append(' '.join((TYPE_TO_FLAG[type(value)], key, + str_value))) + return ' '.join(cmd).strip() diff --git a/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py b/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py new file mode 100644 index 0000000000..5b9fda3b54 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/instrumentation_base_test.py @@ -0,0 +1,264 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os + +import yaml +from acts.keys import Config +from acts.test_utils.instrumentation import instrumentation_proto_parser \ + as proto_parser +from acts.test_utils.instrumentation.config_wrapper import ConfigWrapper +from acts.test_utils.instrumentation.device.command.adb_commands import common + +from acts import base_test +from acts import context +from acts import utils + +RESOLVE_FILE_MARKER = 'FILE' +FILE_NOT_FOUND = 'File is missing from ACTS config' +DEFAULT_INSTRUMENTATION_CONFIG_FILE = 'instrumentation_config.yaml' + + +class InstrumentationTestError(Exception): + pass + + +class InstrumentationBaseTest(base_test.BaseTestClass): + """Base class for tests based on am instrument.""" + + def __init__(self, configs): + """Initialize an InstrumentationBaseTest + + Args: + configs: Dict representing the test configuration + """ + super().__init__(configs) + # Take instrumentation config path directly from ACTS config if found, + # otherwise try to find the instrumentation config in the same directory + # as the ACTS config + instrumentation_config_path = '' + if 'instrumentation_config' in self.user_params: + instrumentation_config_path = ( + self.user_params['instrumentation_config'][0]) + elif Config.key_config_path.value in self.user_params: + instrumentation_config_path = os.path.join( + self.user_params[Config.key_config_path.value], + DEFAULT_INSTRUMENTATION_CONFIG_FILE) + self._instrumentation_config = ConfigWrapper() + if os.path.exists(instrumentation_config_path): + self._instrumentation_config = self._load_instrumentation_config( + instrumentation_config_path) + self._class_config = self._instrumentation_config.get_config( + self.__class__.__name__) + else: + self.log.warning( + 'Instrumentation config file %s does not exist' % + instrumentation_config_path) + + def _load_instrumentation_config(self, path): + """Load the instrumentation config file into an + InstrumentationConfigWrapper object. + + Args: + path: Path to the instrumentation config file. + + Returns: The loaded instrumentation config as an + InstrumentationConfigWrapper + """ + try: + with open(path, mode='r', encoding='utf-8') as f: + config_dict = yaml.safe_load(f) + except Exception as e: + raise InstrumentationTestError( + 'Cannot open or parse instrumentation config file %s' + % path) from e + + # Write out a copy of the instrumentation config + with open(os.path.join( + self.log_path, 'instrumentation_config.yaml'), + mode='w', encoding='utf-8') as f: + yaml.safe_dump(config_dict, f) + + return ConfigWrapper(config_dict) + + def setup_class(self): + """Class setup""" + self.ad_dut = self.android_devices[0] + + def teardown_test(self): + """Test teardown. Takes bugreport and cleans up device.""" + self._ad_take_bugreport(self.ad_dut, 'teardown_class', + utils.get_current_epoch_time()) + self._cleanup_device() + + def _prepare_device(self): + """Prepares the device for testing.""" + pass + + def _cleanup_device(self): + """Clean up device after test completion.""" + pass + + def _get_merged_config(self, config_name): + """Takes the configs with config_name from the base, testclass, and + testcase levels and merges them together. When the same parameter is + defined in different contexts, the value from the most specific context + is taken. + + Example: + self._instrumentation_config = { + 'sample_config': { + 'val_a': 5, + 'val_b': 7 + }, + 'ActsTestClass': { + 'sample_config': { + 'val_b': 3, + 'val_c': 6 + }, + 'acts_test_case': { + 'sample_config': { + 'val_c': 10, + 'val_d': 2 + } + } + } + } + + self._get_merged_config('sample_config') returns + { + 'val_a': 5, + 'val_b': 3, + 'val_c': 10, + 'val_d': 2 + } + + Args: + config_name: Name of the config to fetch + Returns: The merged config, as a ConfigWrapper + """ + merged_config = self._instrumentation_config.get_config( + config_name) + merged_config.update(self._class_config.get_config(config_name)) + if self.current_test_name: + case_config = self._class_config.get_config(self.current_test_name) + merged_config.update(case_config.get_config(config_name)) + return merged_config + + def get_files_from_config(self, config_key): + """Get a list of file paths on host from self.user_params with the + given key. Verifies that each file exists. + + Args: + config_key: Key in which the files are found. + + Returns: list of str file paths + """ + if config_key not in self.user_params: + raise InstrumentationTestError( + 'Cannot get files for key "%s": Key missing from config.' + % config_key) + files = self.user_params[config_key] + for f in files: + if not os.path.exists(f): + raise InstrumentationTestError( + 'Cannot get files for key "%s": No file exists for %s.' % + (config_key, f)) + return files + + def get_file_from_config(self, config_key): + """Get a single file path on host from self.user_params with the given + key. See get_files_from_config for details. + """ + return self.get_files_from_config(config_key)[-1] + + def adb_run(self, cmds): + """Run the specified command, or list of commands, with the ADB shell. + + Args: + cmds: A string or list of strings representing ADB shell command(s) + + Returns: dict mapping command to resulting stdout + """ + if isinstance(cmds, str): + cmds = [cmds] + out = {} + for cmd in cmds: + out[cmd] = self.ad_dut.adb.shell(cmd) + return out + + def adb_run_async(self, cmds): + """Run the specified command, or list of commands, with the ADB shell. + (async) + + Args: + cmds: A string or list of strings representing ADB shell command(s) + + Returns: dict mapping command to resulting subprocess.Popen object + """ + if isinstance(cmds, str): + cmds = [cmds] + procs = {} + for cmd in cmds: + procs[cmd] = self.ad_dut.adb.shell_nb(cmd) + return procs + + def dump_instrumentation_result_proto(self): + """Dump the instrumentation result proto as a human-readable txt file + in the log directory. + + Returns: The parsed instrumentation_data_pb2.Session + """ + session = proto_parser.get_session_from_device(self.ad_dut) + proto_txt_path = os.path.join( + context.get_current_context().get_full_output_path(), + 'instrumentation_proto.txt') + with open(proto_txt_path, 'w') as f: + f.write(str(session)) + return session + + # Basic setup methods + + def mode_airplane(self): + """Mode for turning on airplane mode only.""" + self.log.info('Enabling airplane mode.') + self.adb_run(common.airplane_mode.toggle(True)) + self.adb_run(common.auto_time.toggle(False)) + self.adb_run(common.auto_timezone.toggle(False)) + self.adb_run(common.location_gps.toggle(False)) + self.adb_run(common.location_network.toggle(False)) + self.adb_run(common.wifi.toggle(False)) + self.adb_run(common.bluetooth.toggle(False)) + + def mode_wifi(self): + """Mode for turning on airplane mode and wifi.""" + self.log.info('Enabling airplane mode and wifi.') + self.adb_run(common.airplane_mode.toggle(True)) + self.adb_run(common.location_gps.toggle(False)) + self.adb_run(common.location_network.toggle(False)) + self.adb_run(common.wifi.toggle(True)) + self.adb_run(common.bluetooth.toggle(False)) + + def mode_bluetooth(self): + """Mode for turning on airplane mode and bluetooth.""" + self.log.info('Enabling airplane mode and bluetooth.') + self.adb_run(common.airplane_mode.toggle(True)) + self.adb_run(common.auto_time.toggle(False)) + self.adb_run(common.auto_timezone.toggle(False)) + self.adb_run(common.location_gps.toggle(False)) + self.adb_run(common.location_network.toggle(False)) + self.adb_run(common.wifi.toggle(False)) + self.adb_run(common.bluetooth.toggle(True)) diff --git a/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py b/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py new file mode 100644 index 0000000000..bdff9b4061 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/instrumentation_proto_parser.py @@ -0,0 +1,124 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import collections +import os +import tempfile + +from acts.test_utils.instrumentation.proto.gen import instrumentation_data_pb2 + +DEFAULT_INST_LOG_DIR = 'instrument-logs' + +START_TIMESTAMP = 'start' +END_TIMESTAMP = 'end' + + +class ProtoParserError(Exception): + """Class for exceptions raised by the proto parser.""" + + +def pull_proto(ad, dest_dir, source_path=None): + """Pull latest instrumentation result proto from device. + + Args: + ad: AndroidDevice object + dest_dir: Directory on the host where the proto will be sent + source_path: Path on the device where the proto is generated. If None, + pull the latest proto from DEFAULT_INST_PROTO_DIR. + + Returns: Path to the retrieved proto file + """ + if source_path: + filename = os.path.basename(source_path) + else: + default_full_proto_dir = os.path.join( + ad.external_storage_path, DEFAULT_INST_LOG_DIR) + filename = ad.adb.shell('ls %s -t | head -n1' % default_full_proto_dir) + if not filename: + raise ProtoParserError( + 'No instrumentation result protos found at default location.') + source_path = os.path.join(default_full_proto_dir, filename) + ad.pull_files(source_path, dest_dir) + dest_path = os.path.join(dest_dir, filename) + if not os.path.exists(dest_path): + raise ProtoParserError( + 'Failed to pull instrumentation result proto: %s -> %s' + % (source_path, dest_path)) + return dest_path + + +def get_session_from_local_file(proto_file): + """Get a instrumentation_data_pb2.Session object from a proto file on the + host. + + Args: + proto_file: Path to the proto file (on host) + + Returns: A instrumentation_data_pb2.Session + """ + with open(proto_file, 'rb') as f: + return instrumentation_data_pb2.Session.FromString(f.read()) + + +def get_session_from_device(ad, proto_file=None): + """Get a instrumentation_data_pb2.Session object from a proto file on + device. + + Args: + ad: AndroidDevice object + proto_file: Path to the proto file (on device). If None, defaults to + latest proto from DEFAULT_INST_PROTO_DIR. + + Returns: A instrumentation_data_pb2.Session + """ + with tempfile.TemporaryDirectory() as tmp_dir: + pulled_proto = pull_proto(ad, tmp_dir, proto_file) + return get_session_from_local_file(pulled_proto) + + +def get_test_timestamps(session): + """Parse an instrumentation_data_pb2.Session to get the timestamps for each + test. + + Args: + session: an instrumentation_data.Session object + + Returns: a dict in the format + { + <test name> : (<begin_time>, <end_time>), + ... + } + """ + timestamps = collections.defaultdict(dict) + for test_status in session.test_status: + entries = test_status.results.entries + # Timestamp entries have the key 'timestamp-message' + if any(entry.key == 'timestamps-message' for entry in entries): + test_name = None + timestamp = None + timestamp_type = None + for entry in entries: + if entry.key == 'test': + test_name = entry.value_string + if entry.key == 'timestamp': + timestamp = entry.value_long + if entry.key == 'start-timestamp': + timestamp_type = START_TIMESTAMP + if entry.key == 'end-timestamp': + timestamp_type = END_TIMESTAMP + if test_name and timestamp and timestamp_type: + timestamps[test_name][timestamp_type] = timestamp + return timestamps diff --git a/acts/framework/acts/test_utils/instrumentation/power/__init__.py b/acts/framework/acts/test_utils/instrumentation/power/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/power/__init__.py diff --git a/acts/framework/acts/test_utils/instrumentation/power/instrumentation_power_test.py b/acts/framework/acts/test_utils/instrumentation/power/instrumentation_power_test.py new file mode 100644 index 0000000000..92b9ad70e3 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/power/instrumentation_power_test.py @@ -0,0 +1,486 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import shutil +import tempfile +import time + +import tzlocal +from acts.controllers.android_device import SL4A_APK_NAME +from acts.metrics.loggers.blackbox import BlackboxMappedMetricLogger +from acts.test_utils.instrumentation import instrumentation_proto_parser \ + as proto_parser +from acts.test_utils.instrumentation.device.apps.app_installer import \ + AppInstaller +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceGServices +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetprop +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetting +from acts.test_utils.instrumentation.device.command.adb_commands import common +from acts.test_utils.instrumentation.device.command.adb_commands import goog +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import DEFAULT_NOHUP_LOG +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import InstrumentationTestCommandBuilder +from acts.test_utils.instrumentation.instrumentation_base_test \ + import InstrumentationBaseTest +from acts.test_utils.instrumentation.instrumentation_base_test \ + import InstrumentationTestError +from acts.test_utils.instrumentation.instrumentation_proto_parser import \ + DEFAULT_INST_LOG_DIR +from acts.test_utils.instrumentation.power.power_metrics import Measurement +from acts.test_utils.instrumentation.power.power_metrics import PowerMetrics +from acts.test_utils.instrumentation.device.apps.permissions import PermissionsUtil + +from acts import asserts +from acts import context + +ACCEPTANCE_THRESHOLD = 'acceptance_threshold' +AUTOTESTER_LOG = 'autotester.log' +DEFAULT_PUSH_FILE_TIMEOUT = 180 +DISCONNECT_USB_FILE = 'disconnectusb.log' +POLLING_INTERVAL = 0.5 + + +class InstrumentationPowerTest(InstrumentationBaseTest): + """Instrumentation test for measuring and validating power metrics. + + Params: + metric_logger: Blackbox metric logger used to store test metrics. + _instr_cmd_builder: Builder for the instrumentation command + """ + + def __init__(self, configs): + super().__init__(configs) + + self.metric_logger = BlackboxMappedMetricLogger.for_test_case() + self._test_apk = None + self._sl4a_apk = None + self._instr_cmd_builder = None + self._power_metrics = None + + def setup_class(self): + super().setup_class() + self.monsoon = self.monsoons[0] + self._setup_monsoon() + + def setup_test(self): + """Test setup""" + super().setup_test() + self._prepare_device() + self._instr_cmd_builder = self.power_instrumentation_command_builder() + return True + + def _prepare_device(self): + """Prepares the device for power testing.""" + super()._prepare_device() + self._cleanup_test_files() + self._permissions_util = PermissionsUtil( + self.ad_dut, + self.get_file_from_config('permissions_apk')) + self._permissions_util.grant_all() + self._install_test_apk() + + def _cleanup_device(self): + """Clean up device after power testing.""" + if self._test_apk: + self._test_apk.uninstall() + self._permissions_util.close() + self._cleanup_test_files() + + def base_device_configuration(self): + """Run the base setup commands for power testing.""" + self.log.info('Running base device setup commands.') + + self.ad_dut.adb.ensure_root() + self.adb_run(common.dismiss_keyguard) + self.ad_dut.ensure_screen_on() + + # Test harness flag + self.adb_run(common.test_harness.toggle(True)) + + # Calling + self.adb_run(common.disable_dialing.toggle(True)) + + # Screen + self.adb_run(common.screen_always_on.toggle(True)) + self.adb_run(common.screen_adaptive_brightness.toggle(False)) + + brightness_level = None + if 'brightness_level' in self._instrumentation_config: + brightness_level = self._instrumentation_config['brightness_level'] + + if brightness_level is None: + raise ValueError('no brightness level defined (or left as None) ' + 'and it is needed.') + + self.adb_run(common.screen_brightness.set_value(brightness_level)) + self.adb_run(common.screen_timeout_ms.set_value(1800000)) + self.adb_run(common.notification_led.toggle(False)) + self.adb_run(common.screensaver.toggle(False)) + self.adb_run(common.wake_gesture.toggle(False)) + self.adb_run(common.doze_mode.toggle(False)) + self.adb_run(common.doze_always_on.toggle(False)) + + # Sensors + self.adb_run(common.auto_rotate.toggle(False)) + self.adb_run(common.disable_sensors) + self.adb_run(common.ambient_eq.toggle(False)) + + if self.file_exists(common.MOISTURE_DETECTION_SETTING_FILE): + self.adb_run(common.disable_moisture_detection) + + # Time + self.adb_run(common.auto_time.toggle(False)) + self.adb_run(common.auto_timezone.toggle(False)) + self.adb_run(common.timezone.set_value(str(tzlocal.get_localzone()))) + + # Location + self.adb_run(common.location_gps.toggle(False)) + self.adb_run(common.location_network.toggle(False)) + + # Power + self.adb_run(common.battery_saver_mode.toggle(False)) + self.adb_run(common.battery_saver_trigger.set_value(0)) + self.adb_run(common.enable_full_batterystats_history) + self.adb_run(common.disable_doze) + + # Camera + self.adb_run(DeviceSetprop( + 'camera.optbar.hdr', 'true', 'false').toggle(True)) + + # Gestures + gestures = { + 'doze_pulse_on_pick_up': False, + 'doze_pulse_on_double_tap': False, + 'camera_double_tap_power_gesture_disabled': True, + 'camera_double_twist_to_flip_enabled': False, + 'assist_gesture_enabled': False, + 'assist_gesture_silence_alerts_enabled': False, + 'assist_gesture_wake_enabled': False, + 'system_navigation_keys_enabled': False, + 'camera_lift_trigger_enabled': False, + 'doze_always_on': False, + 'aware_enabled': False, + 'doze_wake_screen_gesture': False, + 'skip_gesture': False, + 'silence_gesture': False + } + self.adb_run( + [DeviceSetting(common.SECURE, k).toggle(v) + for k, v in gestures.items()]) + + # GServices + self.adb_run(goog.location_collection.toggle(False)) + self.adb_run(goog.cast_broadcast.toggle(False)) + self.adb_run(DeviceGServices( + 'location:compact_log_enabled').toggle(True)) + self.adb_run(DeviceGServices('gms:magictether:enable').toggle(False)) + self.adb_run(DeviceGServices('ocr.cc_ocr_enabled').toggle(False)) + self.adb_run(DeviceGServices( + 'gms:phenotype:phenotype_flag:debug_bypass_phenotype').toggle(True)) + self.adb_run(DeviceGServices( + 'gms_icing_extension_download_enabled').toggle(False)) + + # Comms + self.adb_run(common.wifi.toggle(False)) + self.adb_run(common.bluetooth.toggle(False)) + self.adb_run(common.airplane_mode.toggle(True)) + + # Misc. Google features + self.adb_run(goog.disable_playstore) + self.adb_run(goog.disable_volta) + self.adb_run(goog.disable_chre) + self.adb_run(goog.disable_musiciq) + self.adb_run(goog.disable_hotword) + + # Enable clock dump info + self.adb_run('echo 1 > /d/clk/debug_suspend') + + def _setup_monsoon(self): + """Set up the Monsoon controller for this testclass/testcase.""" + self.log.info('Setting up Monsoon %s' % self.monsoon.serial) + monsoon_config = self._get_merged_config('Monsoon') + self._monsoon_voltage = monsoon_config.get_numeric('voltage', 4.2) + self.monsoon.set_voltage_safe(self._monsoon_voltage) + if 'max_current' in monsoon_config: + self.monsoon.set_max_current( + monsoon_config.get_numeric('max_current')) + + self.monsoon.usb('on') + self.monsoon.set_on_disconnect(self._on_disconnect) + self.monsoon.set_on_reconnect(self._on_reconnect) + + self._disconnect_usb_timeout = monsoon_config.get_numeric( + 'usb_disconnection_timeout', 240) + + self._measurement_args = dict( + duration=monsoon_config.get_numeric('duration'), + hz=monsoon_config.get_numeric('frequency'), + measure_after_seconds=monsoon_config.get_numeric('delay') + ) + + def _on_disconnect(self): + """Callback invoked by device disconnection from the Monsoon.""" + self.ad_dut.log.info('Disconnecting device.') + self.ad_dut.stop_services() + # Uninstall SL4A + self._sl4a_apk = AppInstaller.pull_from_device( + self.ad_dut, SL4A_APK_NAME, tempfile.mkdtemp(prefix='sl4a')) + self._sl4a_apk.uninstall() + time.sleep(1) + + def _on_reconnect(self): + """Callback invoked by device reconnection to the Monsoon""" + # Reinstall SL4A + if not self.ad_dut.is_sl4a_installed() and self._sl4a_apk: + self._sl4a_apk.install() + shutil.rmtree(os.path.dirname(self._sl4a_apk.apk_path)) + self._sl4a_apk = None + self.ad_dut.start_services() + # Release wake lock to put device into sleep. + self.ad_dut.droid.goToSleepNow() + self.ad_dut.log.info('Device reconnected.') + + def _install_test_apk(self): + """Installs test apk on the device.""" + test_apk_file = self.get_file_from_config('test_apk') + self._test_apk = AppInstaller(self.ad_dut, test_apk_file) + self._test_apk.install('-g') + if not self._test_apk.is_installed(): + raise InstrumentationTestError('Failed to install test APK.') + + def _cleanup_test_files(self): + """Remove test-generated files from the device.""" + self.ad_dut.log.info('Cleaning up test generated files.') + for file_name in [DISCONNECT_USB_FILE, DEFAULT_INST_LOG_DIR, + DEFAULT_NOHUP_LOG, AUTOTESTER_LOG]: + path = os.path.join(self.ad_dut.external_storage_path, file_name) + self.adb_run('rm -rf %s' % path) + + def trigger_scan_on_external_storage(self): + cmd = 'am broadcast -a android.intent.action.MEDIA_MOUNTED ' + cmd = cmd + '-d file://%s ' % self.ad_dut.external_storage_path + cmd = cmd + '--receiver-include-background' + return self.adb_run(cmd) + + def file_exists(self, file_path): + cmd = '(test -f %s && echo yes) || echo no' % file_path + result = self.adb_run(cmd) + if result[cmd] == 'yes': + return True + elif result[cmd] == 'no': + return False + raise ValueError('Couldn\'t determine if %s exists. ' + 'Expected yes/no, got %s' % (file_path, result[cmd])) + + def push_to_external_storage(self, file_path, dest=None, + timeout=DEFAULT_PUSH_FILE_TIMEOUT): + """Pushes a file to {$EXTERNAL_STORAGE} and returns its final location. + + Args: + file_path: The file to be pushed. + dest: Where within {$EXTERNAL_STORAGE} it should be pushed. + timeout: Float number of seconds to wait for the file to be pushed. + + Returns: The absolute path where the file was pushed. + """ + if dest is None: + dest = os.path.basename(file_path) + + dest_path = os.path.join(self.ad_dut.external_storage_path, dest) + self.log.info('clearing %s before pushing %s' % (dest_path, file_path)) + self.ad_dut.adb.shell('rm -rf %s', dest_path) + self.log.info('pushing file %s to %s' % (file_path, dest_path)) + self.ad_dut.adb.push(file_path, dest_path, timeout=timeout) + return dest_path + + # Test runtime utils + + def power_instrumentation_command_builder(self): + """Return the default command builder for power tests""" + builder = InstrumentationTestCommandBuilder.default() + builder.set_manifest_package(self._test_apk.pkg_name) + builder.set_nohup() + return builder + + def _wait_for_disconnect_signal(self): + """Poll the device for a disconnect USB signal file. This will indicate + to the Monsoon that the device is ready to be disconnected. + """ + self.log.info('Waiting for USB disconnect signal') + disconnect_file = os.path.join( + self.ad_dut.external_storage_path, DISCONNECT_USB_FILE) + start_time = time.time() + while time.time() < start_time + self._disconnect_usb_timeout: + if self.ad_dut.adb.shell('ls %s' % disconnect_file): + return + time.sleep(POLLING_INTERVAL) + raise InstrumentationTestError('Timeout while waiting for USB ' + 'disconnect signal.') + + def measure_power(self): + """Measures power consumption with the Monsoon. See monsoon_lib API for + details. + """ + if not hasattr(self, '_measurement_args'): + raise InstrumentationTestError('Missing Monsoon measurement args.') + + # Start measurement after receiving disconnect signal + self._wait_for_disconnect_signal() + power_data_path = os.path.join( + context.get_current_context().get_full_output_path(), 'power_data') + self.log.info('Starting Monsoon measurement.') + self.monsoon.usb('auto') + measure_start_time = time.time() + result = self.monsoon.measure_power( + **self._measurement_args, output_path=power_data_path) + self.monsoon.usb('on') + self.log.info('Monsoon measurement complete.') + + # Gather relevant metrics from measurements + session = self.dump_instrumentation_result_proto() + self._power_metrics = PowerMetrics(self._monsoon_voltage, + start_time=measure_start_time) + self._power_metrics.generate_test_metrics( + PowerMetrics.import_raw_data(power_data_path), + proto_parser.get_test_timestamps(session)) + self._log_metrics() + return result + + def run_and_measure(self, instr_class, instr_method=None, req_params=None, + extra_params=None): + """Convenience method for setting up the instrumentation test command, + running it on the device, and starting the Monsoon measurement. + + Args: + instr_class: Fully qualified name of the instrumentation test class + instr_method: Name of the instrumentation test method + req_params: List of required parameter names + extra_params: List of ad-hoc parameters to be passed defined as + tuples of size 2. + + Returns: summary of Monsoon measurement + """ + if instr_method: + self._instr_cmd_builder.add_test_method(instr_class, instr_method) + else: + self._instr_cmd_builder.add_test_class(instr_class) + params = {} + instr_call_config = self._get_merged_config('instrumentation_call') + # Add required parameters + for param_name in req_params or []: + params[param_name] = instr_call_config.get( + param_name, verify_fn=lambda x: x is not None, + failure_msg='%s is a required parameter.' % param_name) + # Add all other parameters + params.update(instr_call_config) + for name, value in params.items(): + self._instr_cmd_builder.add_key_value_param(name, value) + + if extra_params: + for name, value in extra_params: + self._instr_cmd_builder.add_key_value_param(name, value) + + instr_cmd = self._instr_cmd_builder.build() + self.log.info('Running instrumentation call: %s' % instr_cmd) + self.adb_run_async(instr_cmd) + return self.measure_power() + + def _log_metrics(self): + """Record the collected metrics with the metric logger.""" + self.log.info('Obtained metrics summaries:') + for k, m in self._power_metrics.test_metrics.items(): + self.log.info('%s %s' % (k, str(m.summary))) + + for metric_name in PowerMetrics.ALL_METRICS: + for instr_test_name in self._power_metrics.test_metrics: + metric_value = getattr( + self._power_metrics.test_metrics[instr_test_name], + metric_name).value + # TODO: Refactor this into instr_test_name.metric_name + self.metric_logger.add_metric( + '%s__%s' % (metric_name, instr_test_name), metric_value) + + def validate_power_results(self, *instr_test_names): + """Compare power measurements with target values and set the test result + accordingly. + + Args: + instr_test_names: Name(s) of the instrumentation test method. + If none specified, defaults to all test methods run. + + Raises: + signals.TestFailure if one or more metrics do not satisfy threshold + """ + summaries = {} + failure = False + all_thresholds = self._get_merged_config(ACCEPTANCE_THRESHOLD) + + if not instr_test_names: + instr_test_names = all_thresholds.keys() + + for instr_test_name in instr_test_names: + try: + test_metrics = self._power_metrics.test_metrics[instr_test_name] + except KeyError: + raise InstrumentationTestError( + 'Unable to find test method %s in instrumentation output. ' + 'Check instrumentation call results in ' + 'instrumentation_proto.txt.' + % instr_test_name) + + summaries[instr_test_name] = {} + test_thresholds = all_thresholds.get_config(instr_test_name) + for metric_name, metric in test_thresholds.items(): + try: + actual_result = getattr(test_metrics, metric_name) + except AttributeError: + continue + + if 'unit_type' not in metric or 'unit' not in metric: + continue + unit_type = metric['unit_type'] + unit = metric['unit'] + + lower_value = metric.get_numeric('lower_limit', float('-inf')) + upper_value = metric.get_numeric('upper_limit', float('inf')) + if 'expected_value' in metric and 'percent_deviation' in metric: + expected_value = metric.get_numeric('expected_value') + percent_deviation = metric.get_numeric('percent_deviation') + lower_value = expected_value * (1 - percent_deviation / 100) + upper_value = expected_value * (1 + percent_deviation / 100) + + lower_bound = Measurement(lower_value, unit_type, unit) + upper_bound = Measurement(upper_value, unit_type, unit) + summary_entry = { + 'expected': '[%s, %s]' % (lower_bound, upper_bound), + 'actual': str(actual_result.to_unit(unit)) + } + summaries[instr_test_name][metric_name] = summary_entry + if not lower_bound <= actual_result <= upper_bound: + failure = True + self.log.info('Summary of measurements: %s' % summaries) + asserts.assert_false( + failure, + msg='One or more measurements do not meet the specified criteria', + extras=summaries) + asserts.explicit_pass( + msg='All measurements meet the criteria', + extras=summaries) diff --git a/acts/framework/acts/test_utils/instrumentation/power/power_metrics.py b/acts/framework/acts/test_utils/instrumentation/power/power_metrics.py new file mode 100644 index 0000000000..b41ae61741 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/power/power_metrics.py @@ -0,0 +1,298 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import math + +from acts.test_utils.instrumentation import instrumentation_proto_parser \ + as parser +from acts.test_utils.instrumentation.instrumentation_base_test \ + import InstrumentationTestError + +# Unit type constants +CURRENT = 'current' +POWER = 'power' +TIME = 'time' + +# Unit constants +MILLIAMP = 'mA' +AMP = 'A' +AMPERE = AMP +MILLIWATT = 'mW' +WATT = 'W' +MILLISECOND = 'ms' +SECOND = 's' +MINUTE = 'm' +HOUR = 'h' + +CONVERSION_TABLES = { + CURRENT: { + MILLIAMP: 0.001, + AMP: 1 + }, + POWER: { + MILLIWATT: 0.001, + WATT: 1 + }, + TIME: { + MILLISECOND: 0.001, + SECOND: 1, + MINUTE: 60, + HOUR: 3600 + } +} + + +class Measurement(object): + """Base class for describing power measurement values. Each object contains + an value and a unit. Enables some basic arithmetic operations with other + measurements of the same unit type. + + Attributes: + _value: Numeric value of the measurement + _unit_type: Unit type of the measurement (e.g. current, power) + _unit: Unit of the measurement (e.g. W, mA) + """ + + def __init__(self, value, unit_type, unit): + if unit_type not in CONVERSION_TABLES: + raise TypeError('%s is not a valid unit type' % unit_type) + self._value = value + self._unit_type = unit_type + self._unit = unit + + # Convenience constructor methods + @staticmethod + def amps(amps): + """Create a new current measurement, in amps.""" + return Measurement(amps, CURRENT, AMP) + + @staticmethod + def watts(watts): + """Create a new power measurement, in watts.""" + return Measurement(watts, POWER, WATT) + + @staticmethod + def seconds(seconds): + """Create a new time measurement, in seconds.""" + return Measurement(seconds, TIME, SECOND) + + # Comparison methods + + def __eq__(self, other): + return self.value == other.to_unit(self._unit).value + + def __lt__(self, other): + return self.value < other.to_unit(self._unit).value + + def __le__(self, other): + return self == other or self < other + + # Addition and subtraction with other measurements + + def __add__(self, other): + """Adds measurements of compatible unit types. The result will be in the + same units as self. + """ + return Measurement(self.value + other.to_unit(self._unit).value, + self._unit_type, self._unit) + + def __sub__(self, other): + """Subtracts measurements of compatible unit types. The result will be + in the same units as self. + """ + return Measurement(self.value - other.to_unit(self._unit).value, + self._unit_type, self._unit) + + # String representation + + def __str__(self): + return '%g%s' % (self._value, self._unit) + + def __repr__(self): + return str(self) + + @property + def unit(self): + return self._unit + + @property + def value(self): + return self._value + + def to_unit(self, new_unit): + """Create an equivalent measurement under a different unit. + e.g. 0.5W -> 500mW + + Args: + new_unit: Target unit. Must be compatible with current unit. + + Returns: A new measurement with the converted value and unit. + """ + try: + new_value = self._value * ( + CONVERSION_TABLES[self._unit_type][self._unit] / + CONVERSION_TABLES[self._unit_type][new_unit]) + except KeyError: + raise TypeError('Incompatible units: %s, %s' % + (self._unit, new_unit)) + return Measurement(new_value, self._unit_type, new_unit) + + +class PowerMetrics(object): + """Class for processing raw power metrics generated by Monsoon measurements. + Provides useful metrics such as average current, max current, and average + power. Can generate individual test metrics. + + See section "Numeric metrics" below for available metrics. + """ + + def __init__(self, voltage, start_time=0): + """Create a PowerMetrics. + + Args: + voltage: Voltage of the measurement + start_time: Start time of the measurement. Used for generating + test-specific metrics. + """ + self._voltage = voltage + self._start_time = start_time + self._num_samples = 0 + self._sum_currents = 0 + self._sum_squares = 0 + self._max_current = None + self._min_current = None + self.test_metrics = {} + + @staticmethod + def import_raw_data(path): + """Create a generator from a Monsoon data file. + + Args: + path: path to raw data file + + Returns: generator that yields (timestamp, sample) per line + """ + with open(path, 'r') as f: + for line in f: + time, sample = line.split() + yield float(time[:-1]), float(sample) + + def update_metrics(self, sample): + """Update the running metrics with the current sample. + + Args: + sample: A current sample in Amps. + """ + self._num_samples += 1 + self._sum_currents += sample + self._sum_squares += sample ** 2 + if self._max_current is None or sample > self._max_current: + self._max_current = sample + if self._min_current is None or sample < self._min_current: + self._min_current = sample + + def generate_test_metrics(self, raw_data, test_timestamps=None): + """Split the data into individual test metrics, based on the timestamps + given as a dict. + + Args: + raw_data: raw data as list or generator of (timestamp, sample) + test_timestamps: dict following the output format of + instrumentation_proto_parser.get_test_timestamps() + """ + + # Initialize metrics for each test + if test_timestamps is None: + test_timestamps = {} + test_starts = {} + test_ends = {} + for test_name, times in test_timestamps.items(): + self.test_metrics[test_name] = PowerMetrics( + self._voltage, self._start_time) + try: + test_starts[test_name] = Measurement( + times[parser.START_TIMESTAMP], TIME, MILLISECOND) \ + .to_unit(SECOND).value - self._start_time + except KeyError: + raise InstrumentationTestError( + 'Missing start timestamp for test scenario "%s". Refer to ' + 'instrumentation_proto.txt for details.' % test_name) + try: + test_ends[test_name] = Measurement( + times[parser.END_TIMESTAMP], TIME, MILLISECOND) \ + .to_unit(SECOND).value - self._start_time + except KeyError: + raise InstrumentationTestError( + 'Missing end timestamp for test scenario "%s". Test ' + 'scenario may have terminated with errors. Refer to ' + 'instrumentation_proto.txt for details.' % test_name) + + # Assign data to tests based on timestamps + for timestamp, sample in raw_data: + self.update_metrics(sample) + for test_name in test_timestamps: + if test_starts[test_name] <= timestamp <= test_ends[test_name]: + self.test_metrics[test_name].update_metrics(sample) + + # Numeric metrics + + ALL_METRICS = ('avg_current', 'max_current', 'min_current', 'stdev_current', + 'avg_power') + + @property + def avg_current(self): + """Average current, in milliamps.""" + if not self._num_samples: + return Measurement.amps(0).to_unit(MILLIAMP) + return (Measurement.amps(self._sum_currents / self._num_samples) + .to_unit(MILLIAMP)) + + @property + def max_current(self): + """Max current, in milliamps.""" + return Measurement.amps(self._max_current or 0).to_unit(MILLIAMP) + + @property + def min_current(self): + """Min current, in milliamps.""" + return Measurement.amps(self._min_current or 0).to_unit(MILLIAMP) + + @property + def stdev_current(self): + """Standard deviation of current values, in milliamps.""" + if self._num_samples < 2: + return Measurement.amps(0).to_unit(MILLIAMP) + stdev = math.sqrt( + (self._sum_squares - ( + self._num_samples * self.avg_current.to_unit(AMP).value ** 2)) + / (self._num_samples - 1)) + return Measurement.amps(stdev).to_unit(MILLIAMP) + + def current_to_power(self, current): + """Converts a current value to a power value.""" + return (Measurement.watts(current.to_unit(AMP).value * self._voltage)) + + @property + def avg_power(self): + """Average power, in milliwatts.""" + return self.current_to_power(self.avg_current).to_unit(MILLIWATT) + + @property + def summary(self): + """A summary of test metrics""" + return {'average_current': str(self.avg_current), + 'max_current': str(self.max_current), + 'average_power': str(self.avg_power)} diff --git a/acts/framework/acts/test_utils/instrumentation/proto/gen/instrumentation_data_pb2.py b/acts/framework/acts/test_utils/instrumentation/proto/gen/instrumentation_data_pb2.py new file mode 100644 index 0000000000..783cd22b09 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/proto/gen/instrumentation_data_pb2.py @@ -0,0 +1,345 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: instrumentation_data.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='instrumentation_data.proto', + package='android.am', + syntax='proto2', + serialized_pb=_b('\n\x1ainstrumentation_data.proto\x12\nandroid.am\"\xcf\x01\n\x12ResultsBundleEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x14\n\x0cvalue_string\x18\x02 \x01(\t\x12\x11\n\tvalue_int\x18\x03 \x01(\x11\x12\x13\n\x0bvalue_float\x18\x04 \x01(\x02\x12\x14\n\x0cvalue_double\x18\x05 \x01(\x01\x12\x12\n\nvalue_long\x18\x06 \x01(\x12\x12/\n\x0cvalue_bundle\x18\x07 \x01(\x0b\x32\x19.android.am.ResultsBundle\x12\x13\n\x0bvalue_bytes\x18\x08 \x01(\x0c\"@\n\rResultsBundle\x12/\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x1e.android.am.ResultsBundleEntry\"M\n\nTestStatus\x12\x13\n\x0bresult_code\x18\x03 \x01(\x11\x12*\n\x07results\x18\x04 \x01(\x0b\x32\x19.android.am.ResultsBundle\"\x98\x01\n\rSessionStatus\x12\x32\n\x0bstatus_code\x18\x01 \x01(\x0e\x32\x1d.android.am.SessionStatusCode\x12\x12\n\nerror_text\x18\x02 \x01(\t\x12\x13\n\x0bresult_code\x18\x03 \x01(\x11\x12*\n\x07results\x18\x04 \x01(\x0b\x32\x19.android.am.ResultsBundle\"i\n\x07Session\x12+\n\x0btest_status\x18\x01 \x03(\x0b\x32\x16.android.am.TestStatus\x12\x31\n\x0esession_status\x18\x02 \x01(\x0b\x32\x19.android.am.SessionStatus*>\n\x11SessionStatusCode\x12\x14\n\x10SESSION_FINISHED\x10\x00\x12\x13\n\x0fSESSION_ABORTED\x10\x01\x42\x19\n\x17\x63om.android.commands.am') +) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +_SESSIONSTATUSCODE = _descriptor.EnumDescriptor( + name='SessionStatusCode', + full_name='android.am.SessionStatusCode', + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name='SESSION_FINISHED', index=0, number=0, + options=None, + type=None), + _descriptor.EnumValueDescriptor( + name='SESSION_ABORTED', index=1, number=1, + options=None, + type=None), + ], + containing_type=None, + options=None, + serialized_start=659, + serialized_end=721, +) +_sym_db.RegisterEnumDescriptor(_SESSIONSTATUSCODE) + +SessionStatusCode = enum_type_wrapper.EnumTypeWrapper(_SESSIONSTATUSCODE) +SESSION_FINISHED = 0 +SESSION_ABORTED = 1 + + + +_RESULTSBUNDLEENTRY = _descriptor.Descriptor( + name='ResultsBundleEntry', + full_name='android.am.ResultsBundleEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='android.am.ResultsBundleEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_string', full_name='android.am.ResultsBundleEntry.value_string', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_int', full_name='android.am.ResultsBundleEntry.value_int', index=2, + number=3, type=17, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_float', full_name='android.am.ResultsBundleEntry.value_float', index=3, + number=4, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_double', full_name='android.am.ResultsBundleEntry.value_double', index=4, + number=5, type=1, cpp_type=5, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_long', full_name='android.am.ResultsBundleEntry.value_long', index=5, + number=6, type=18, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_bundle', full_name='android.am.ResultsBundleEntry.value_bundle', index=6, + number=7, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='value_bytes', full_name='android.am.ResultsBundleEntry.value_bytes', index=7, + number=8, type=12, cpp_type=9, label=1, + has_default_value=False, default_value=_b(""), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=43, + serialized_end=250, +) + + +_RESULTSBUNDLE = _descriptor.Descriptor( + name='ResultsBundle', + full_name='android.am.ResultsBundle', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='entries', full_name='android.am.ResultsBundle.entries', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=252, + serialized_end=316, +) + + +_TESTSTATUS = _descriptor.Descriptor( + name='TestStatus', + full_name='android.am.TestStatus', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='result_code', full_name='android.am.TestStatus.result_code', index=0, + number=3, type=17, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='results', full_name='android.am.TestStatus.results', index=1, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=318, + serialized_end=395, +) + + +_SESSIONSTATUS = _descriptor.Descriptor( + name='SessionStatus', + full_name='android.am.SessionStatus', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='status_code', full_name='android.am.SessionStatus.status_code', index=0, + number=1, type=14, cpp_type=8, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='error_text', full_name='android.am.SessionStatus.error_text', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='result_code', full_name='android.am.SessionStatus.result_code', index=2, + number=3, type=17, cpp_type=1, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='results', full_name='android.am.SessionStatus.results', index=3, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=398, + serialized_end=550, +) + + +_SESSION = _descriptor.Descriptor( + name='Session', + full_name='android.am.Session', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='test_status', full_name='android.am.Session.test_status', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='session_status', full_name='android.am.Session.session_status', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto2', + extension_ranges=[], + oneofs=[ + ], + serialized_start=552, + serialized_end=657, +) + +_RESULTSBUNDLEENTRY.fields_by_name['value_bundle'].message_type = _RESULTSBUNDLE +_RESULTSBUNDLE.fields_by_name['entries'].message_type = _RESULTSBUNDLEENTRY +_TESTSTATUS.fields_by_name['results'].message_type = _RESULTSBUNDLE +_SESSIONSTATUS.fields_by_name['status_code'].enum_type = _SESSIONSTATUSCODE +_SESSIONSTATUS.fields_by_name['results'].message_type = _RESULTSBUNDLE +_SESSION.fields_by_name['test_status'].message_type = _TESTSTATUS +_SESSION.fields_by_name['session_status'].message_type = _SESSIONSTATUS +DESCRIPTOR.message_types_by_name['ResultsBundleEntry'] = _RESULTSBUNDLEENTRY +DESCRIPTOR.message_types_by_name['ResultsBundle'] = _RESULTSBUNDLE +DESCRIPTOR.message_types_by_name['TestStatus'] = _TESTSTATUS +DESCRIPTOR.message_types_by_name['SessionStatus'] = _SESSIONSTATUS +DESCRIPTOR.message_types_by_name['Session'] = _SESSION +DESCRIPTOR.enum_types_by_name['SessionStatusCode'] = _SESSIONSTATUSCODE + +ResultsBundleEntry = _reflection.GeneratedProtocolMessageType('ResultsBundleEntry', (_message.Message,), dict( + DESCRIPTOR = _RESULTSBUNDLEENTRY, + __module__ = 'instrumentation_data_pb2' + # @@protoc_insertion_point(class_scope:android.am.ResultsBundleEntry) + )) +_sym_db.RegisterMessage(ResultsBundleEntry) + +ResultsBundle = _reflection.GeneratedProtocolMessageType('ResultsBundle', (_message.Message,), dict( + DESCRIPTOR = _RESULTSBUNDLE, + __module__ = 'instrumentation_data_pb2' + # @@protoc_insertion_point(class_scope:android.am.ResultsBundle) + )) +_sym_db.RegisterMessage(ResultsBundle) + +TestStatus = _reflection.GeneratedProtocolMessageType('TestStatus', (_message.Message,), dict( + DESCRIPTOR = _TESTSTATUS, + __module__ = 'instrumentation_data_pb2' + # @@protoc_insertion_point(class_scope:android.am.TestStatus) + )) +_sym_db.RegisterMessage(TestStatus) + +SessionStatus = _reflection.GeneratedProtocolMessageType('SessionStatus', (_message.Message,), dict( + DESCRIPTOR = _SESSIONSTATUS, + __module__ = 'instrumentation_data_pb2' + # @@protoc_insertion_point(class_scope:android.am.SessionStatus) + )) +_sym_db.RegisterMessage(SessionStatus) + +Session = _reflection.GeneratedProtocolMessageType('Session', (_message.Message,), dict( + DESCRIPTOR = _SESSION, + __module__ = 'instrumentation_data_pb2' + # @@protoc_insertion_point(class_scope:android.am.Session) + )) +_sym_db.RegisterMessage(Session) + + +DESCRIPTOR.has_options = True +DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\027com.android.commands.am')) +# @@protoc_insertion_point(module_scope) diff --git a/acts/framework/acts/test_utils/instrumentation/proto/instrumentation_data.proto b/acts/framework/acts/test_utils/instrumentation/proto/instrumentation_data.proto new file mode 100644 index 0000000000..8e29f96455 --- /dev/null +++ b/acts/framework/acts/test_utils/instrumentation/proto/instrumentation_data.proto @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +syntax = "proto2"; +package android.am; + +option java_package = "com.android.commands.am"; + +message ResultsBundleEntry { + optional string key = 1; + + optional string value_string = 2; + optional sint32 value_int = 3; + optional float value_float = 4; + optional double value_double = 5; + optional sint64 value_long = 6; + optional ResultsBundle value_bundle = 7; + optional bytes value_bytes = 8; +} + +message ResultsBundle { + repeated ResultsBundleEntry entries = 1; +} + +message TestStatus { + optional sint32 result_code = 3; + optional ResultsBundle results = 4; +} + +enum SessionStatusCode { + /** + * The command ran successfully. This does not imply that the tests passed. + */ + SESSION_FINISHED = 0; + + /** + * There was an unrecoverable error running the tests. + */ + SESSION_ABORTED = 1; +} + +message SessionStatus { + optional SessionStatusCode status_code = 1; + optional string error_text = 2; + optional sint32 result_code = 3; + optional ResultsBundle results = 4; +} + +message Session { + repeated TestStatus test_status = 1; + optional SessionStatus session_status = 2; +} + + diff --git a/acts/framework/acts/test_utils/net/connectivity_const.py b/acts/framework/acts/test_utils/net/connectivity_const.py index b0836dbc3a..60d4f67e7c 100644 --- a/acts/framework/acts/test_utils/net/connectivity_const.py +++ b/acts/framework/acts/test_utils/net/connectivity_const.py @@ -66,6 +66,8 @@ MULTIPATH_PREFERENCE_PERFORMANCE = 1 << 2 # Private DNS constants DNS_GOOGLE = "dns.google" +DNS_QUAD9 = "dns.quad9.net" +DNS_CLOUDFLARE = "1dot1dot1dot1.cloudflare-dns.com" PRIVATE_DNS_MODE_OFF = "off" PRIVATE_DNS_MODE_OPPORTUNISTIC = "opportunistic" PRIVATE_DNS_MODE_STRICT = "hostname" @@ -143,3 +145,4 @@ class VpnReqParams(object): ipsec_server_type = "ipsec_server_type" wifi_network = "wifi_network" vpn_identity = "vpn_identity" + vpn_server_hostname = "vpn_server_hostname" diff --git a/acts/framework/acts/test_utils/net/connectivity_test_utils.py b/acts/framework/acts/test_utils/net/connectivity_test_utils.py index 4b7668c315..153630ff7f 100644 --- a/acts/framework/acts/test_utils/net/connectivity_test_utils.py +++ b/acts/framework/acts/test_utils/net/connectivity_test_utils.py @@ -15,53 +15,94 @@ from acts import asserts from acts.test_utils.net import connectivity_const as cconst +from queue import Empty -def start_natt_keepalive(ad, src_ip, src_port, dst_ip, interval = 10): - """ Start NAT-T keep alive on dut """ +def _listen_for_keepalive_event(ad, key, msg, ka_event): + """Listen for keepalive event and return status - ad.log.info("Starting NATT Keepalive") - status = None - - key = ad.droid.connectivityStartNattKeepalive( - interval, src_ip, src_port, dst_ip) - - ad.droid.connectivityNattKeepaliveStartListeningForEvent(key, "Started") + Args: + ad: DUT object + key: keepalive key + msg: Error message + event: Keepalive event type + """ + ad.droid.socketKeepaliveStartListeningForEvent(key, ka_event) try: - event = ad.ed.pop_event("PacketKeepaliveCallback") - status = event["data"]["packetKeepaliveEvent"] + event = ad.ed.pop_event("SocketKeepaliveCallback") + status = event["data"]["socketKeepaliveEvent"] == ka_event except Empty: - msg = "Failed to receive confirmation of starting natt keepalive" asserts.fail(msg) finally: - ad.droid.connectivityNattKeepaliveStopListeningForEvent( - key, "Started") + ad.droid.socketKeepaliveStopListeningForEvent(key, ka_event) + if ka_event != "Started": + ad.droid.removeSocketKeepaliveReceiverKey(key) + if status: + ad.log.info("'%s' keepalive event successful" % ka_event) + return status - if status != "Started": - ad.log.error("Received keepalive status: %s" % status) - ad.droid.connectivityRemovePacketKeepaliveReceiverKey(key) - return None - return key +def start_natt_socket_keepalive(ad, udp_encap, src_ip, dst_ip, interval = 10): + """Start NATT SocketKeepalive on DUT -def stop_natt_keepalive(ad, key): - """ Stop NAT-T keep alive on dut """ + Args: + ad: DUT object + udp_encap: udp_encap socket key + src_ip: IP addr of the client + dst_ip: IP addr of the keepalive server + interval: keepalive time interval + """ + ad.log.info("Starting Natt Socket Keepalive") + key = ad.droid.startNattSocketKeepalive(udp_encap, src_ip, dst_ip, interval) + msg = "Failed to receive confirmation of starting natt socket keeaplive" + status = _listen_for_keepalive_event(ad, key, msg, "Started") + return key if status else None - ad.log.info("Stopping NATT keepalive") - status = False - ad.droid.connectivityStopNattKeepalive(key) +def start_tcp_socket_keepalive(ad, socket, time_interval = 10): + """Start TCP socket keepalive on DUT - ad.droid.connectivityNattKeepaliveStartListeningForEvent(key, "Stopped") - try: - event = ad.ed.pop_event("PacketKeepaliveCallback") - status = event["data"]["packetKeepaliveEvent"] == "Stopped" - except Empty: - msg = "Failed to receive confirmation of stopping natt keepalive" - asserts.fail(msg) - finally: - ad.droid.connectivityNattKeepaliveStopListeningForEvent( - key, "Stopped") + Args: + ad: DUT object + socket: TCP socket key + time_interval: Keepalive time interval + """ + ad.log.info("Starting TCP Socket Keepalive") + key = ad.droid.startTcpSocketKeepalive(socket, time_interval) + msg = "Failed to receive confirmation of starting tcp socket keeaplive" + status = _listen_for_keepalive_event(ad, key, msg, "Started") + return key if status else None - ad.droid.connectivityRemovePacketKeepaliveReceiverKey(key) - return status +def socket_keepalive_error(ad, key): + """Verify Error callback + + Args: + ad: DUT object + key: Keepalive key + """ + ad.log.info("Verify Error callback on keepalive: %s" % key) + msg = "Failed to receive confirmation of Error callback" + return _listen_for_keepalive_event(ad, key, msg, "Error") + +def socket_keepalive_data_received(ad, key): + """Verify OnDataReceived callback + + Args: + ad: DUT object + key: Keepalive key + """ + ad.log.info("Verify OnDataReceived callback on keepalive: %s" % key) + msg = "Failed to receive confirmation of OnDataReceived callback" + return _listen_for_keepalive_event(ad, key, msg, "OnDataReceived") + +def stop_socket_keepalive(ad, key): + """Stop SocketKeepalive on DUT + + Args: + ad: DUT object + key: Keepalive key + """ + ad.log.info("Stopping Socket keepalive: %s" % key) + ad.droid.stopSocketKeepalive(key) + msg = "Failed to receive confirmation of stopping socket keepalive" + return _listen_for_keepalive_event(ad, key, msg, "Stopped") def set_private_dns(ad, dns_mode, hostname=None): """ Set private DNS mode on dut """ diff --git a/acts/framework/acts/test_utils/net/net_test_utils.py b/acts/framework/acts/test_utils/net/net_test_utils.py index 09571c29a1..7e6efa5ce6 100644 --- a/acts/framework/acts/test_utils/net/net_test_utils.py +++ b/acts/framework/acts/test_utils/net/net_test_utils.py @@ -14,13 +14,16 @@ # See the License for the specific language governing permissions and # limitations under the License. import logging +import os -from acts.controllers import adb from acts import asserts +from acts import signals +from acts import utils +from acts.controllers import adb from acts.controllers.adb_lib.error import AdbError from acts.logger import epoch_to_log_line_timestamp -from acts.utils import get_current_epoch_time from acts.logger import normalize_log_line_timestamp +from acts.utils import get_current_epoch_time from acts.utils import start_standing_subprocess from acts.utils import stop_standing_subprocess from acts.test_utils.net import connectivity_const as cconst @@ -43,6 +46,9 @@ USB_CHARGE_MODE = "svc usb setFunctions" USB_TETHERING_MODE = "svc usb setFunctions rndis" DEVICE_IP_ADDRESS = "ip address" +GCE_SSH = "gcloud compute ssh " +GCE_SCP = "gcloud compute scp " + def verify_lte_data_and_tethering_supported(ad): """Verify if LTE data is enabled and tethering supported""" @@ -228,7 +234,6 @@ def generate_legacy_vpn_profile(ad, return vpn_profile - def generate_ikev2_vpn_profile(ad, vpn_params, vpn_type, server_addr, log_path): """Generate VPN profile for IKEv2 VPN. @@ -252,8 +257,8 @@ def generate_ikev2_vpn_profile(ad, vpn_params, vpn_type, server_addr, log_path): vpn_profile[VPN_CONST.PWD] = vpn_params["vpn_password"] vpn_profile[VPN_CONST.IPSEC_ID] = vpn_params["vpn_identity"] cert_name = download_load_certs( - ad, vpn_params, vpn_type, server_addr, "IKEV2_IPSEC_USER_PASS", - log_path) + ad, vpn_params, vpn_type, vpn_params["server_addr"], + "IKEV2_IPSEC_USER_PASS", log_path) vpn_profile[VPN_CONST.IPSEC_CA_CERT] = cert_name.split('.')[0] ad.droid.installCertificate( vpn_profile, cert_name, vpn_params['cert_password']) @@ -262,9 +267,11 @@ def generate_ikev2_vpn_profile(ad, vpn_params, vpn_type, server_addr, log_path): vpn_profile[VPN_CONST.IPSEC_SECRET] = vpn_params["psk_secret"] else: vpn_profile[VPN_CONST.IPSEC_ID] = "%s@%s" % ( - vpn_params["vpn_identity"], vpn_params["server_addr"]) + vpn_params["vpn_identity"], server_addr) + logging.info("ID: %s@%s" % (vpn_params["vpn_identity"], server_addr)) cert_name = download_load_certs( - ad, vpn_params, vpn_type, server_addr, "IKEV2_IPSEC_RSA", log_path) + ad, vpn_params, vpn_type, vpn_params["server_addr"], + "IKEV2_IPSEC_RSA", log_path) vpn_profile[VPN_CONST.IPSEC_USER_CERT] = cert_name.split('.')[0] vpn_profile[VPN_CONST.IPSEC_CA_CERT] = cert_name.split('.')[0] ad.droid.installCertificate( @@ -272,7 +279,6 @@ def generate_ikev2_vpn_profile(ad, vpn_params, vpn_type, server_addr, log_path): return vpn_profile - def start_tcpdump(ad, test_name): """Start tcpdump on all interfaces @@ -335,6 +341,85 @@ def stop_tcpdump(ad, file_name = "tcpdump_%s_%s.pcap" % (ad.serial, test_name) return "%s/%s" % (log_path, file_name) +def start_tcpdump_gce_server(ad, test_name, dest_port, gce): + """ Start tcpdump on gce server + + Args: + ad: android device object + test_name: test case name + dest_port: port to collect tcpdump + gce: dictionary of gce instance + + Returns: + process id and pcap file path from gce server + """ + ad.log.info("Starting tcpdump on gce server") + + # pcap file name + fname = "/tmp/%s_%s_%s_%s" % \ + (test_name, ad.model, ad.serial, + time.strftime('%Y-%m-%d_%H-%M-%S', time.localtime(time.time()))) + + # start tcpdump + tcpdump_cmd = "sudo bash -c \'tcpdump -i %s -w %s.pcap port %s > \ + %s.txt 2>&1 & echo $!\'" % (gce["interface"], fname, dest_port, fname) + gcloud_ssh_cmd = "%s --project=%s --zone=%s %s@%s --command " % \ + (GCE_SSH, gce["project"], gce["zone"], gce["username"], gce["hostname"]) + gce_ssh_cmd = '%s "%s"' % (gcloud_ssh_cmd, tcpdump_cmd) + utils.exe_cmd(gce_ssh_cmd) + + # get process id + ps_cmd = '%s "ps aux | grep tcpdump | grep %s"' % (gcloud_ssh_cmd, fname) + tcpdump_pid = utils.exe_cmd(ps_cmd).decode("utf-8", "ignore").split() + if not tcpdump_pid: + raise signals.TestFailure("Failed to start tcpdump on gce server") + return tcpdump_pid[1], fname + +def stop_tcpdump_gce_server(ad, tcpdump_pid, fname, gce): + """ Stop and pull tcpdump file from gce server + + Args: + ad: android device object + tcpdump_pid: process id for tcpdump file + fname: tcpdump file path + gce: dictionary of gce instance + + Returns: + pcap file from gce server + """ + ad.log.info("Stop and pull pcap file from gce server") + + # stop tcpdump + tcpdump_cmd = "sudo kill %s" % tcpdump_pid + gcloud_ssh_cmd = "%s --project=%s --zone=%s %s@%s --command " % \ + (GCE_SSH, gce["project"], gce["zone"], gce["username"], gce["hostname"]) + gce_ssh_cmd = '%s "%s"' % (gcloud_ssh_cmd, tcpdump_cmd) + utils.exe_cmd(gce_ssh_cmd) + + # verify tcpdump is stopped + ps_cmd = '%s "ps aux | grep tcpdump"' % gcloud_ssh_cmd + res = utils.exe_cmd(ps_cmd).decode("utf-8", "ignore") + if tcpdump_pid in res.split(): + raise signals.TestFailure("Failed to stop tcpdump on gce server") + if not fname: + return None + + # pull pcap file + gcloud_scp_cmd = "%s --project=%s --zone=%s %s@%s:" % \ + (GCE_SCP, gce["project"], gce["zone"], gce["username"], gce["hostname"]) + pull_file = '%s%s.pcap %s/' % (gcloud_scp_cmd, fname, ad.device_log_path) + utils.exe_cmd(pull_file) + if not os.path.exists( + "%s/%s.pcap" % (ad.device_log_path, fname.split('/')[-1])): + raise signals.TestFailure("Failed to pull tcpdump from gce server") + + # delete pcaps + utils.exe_cmd('%s "sudo rm %s.*"' % (gcloud_ssh_cmd, fname)) + + # return pcap file + pcap_file = "%s/%s.pcap" % (ad.device_log_path, fname.split('/')[-1]) + return pcap_file + def is_ipaddress_ipv6(ip_address): """Verify if the given string is a valid IPv6 address. @@ -425,4 +510,3 @@ def wait_for_new_iface(old_ifaces): return new_ifaces.pop() time.sleep(1) asserts.fail("Timeout waiting for tethering interface on host") - diff --git a/acts/framework/acts/test_utils/net/socket_test_utils.py b/acts/framework/acts/test_utils/net/socket_test_utils.py index a8a05fc206..42e4537de3 100644 --- a/acts/framework/acts/test_utils/net/socket_test_utils.py +++ b/acts/framework/acts/test_utils/net/socket_test_utils.py @@ -258,6 +258,18 @@ def close_server_socket(ad, socket): status = ad.droid.closeTcpServerSocket(socket) asserts.assert_true(status, "Failed to socket") +def shutdown_socket(ad, socket): + """ Shutdown socket + + Args: + 1. ad - androidandroid device object + 2. socket - socket key + """ + fd = ad.droid.getFileDescriptorOfSocket(socket) + asserts.assert_true(fd, "Failed to get FileDescriptor key") + status = ad.droid.shutdownFileDescriptor(fd) + asserts.assert_true(status, "Failed to shutdown socket") + def send_recv_data_sockets(client, server, client_sock, server_sock): """ Send data over TCP socket from client to server. Verify that server received the data diff --git a/acts/framework/acts/test_utils/power/cellular/cellular_power_base_test.py b/acts/framework/acts/test_utils/power/cellular/cellular_power_base_test.py index 6ffc7843b9..1e422f535e 100644 --- a/acts/framework/acts/test_utils/power/cellular/cellular_power_base_test.py +++ b/acts/framework/acts/test_utils/power/cellular/cellular_power_base_test.py @@ -21,11 +21,12 @@ import acts.controllers.cellular_simulator as simulator from acts.controllers.anritsu_lib import md8475_cellular_simulator as anritsu from acts.controllers.rohdeschwarz_lib import cmw500_cellular_simulator as cmw from acts.controllers.rohdeschwarz_lib import cmx500_cellular_simulator as cmx -from acts.test_utils.power.tel_simulations.GsmSimulation import GsmSimulation -from acts.test_utils.power.tel_simulations.LteSimulation import LteSimulation -from acts.test_utils.power.tel_simulations.UmtsSimulation import UmtsSimulation -from acts.test_utils.power.tel_simulations.LteCaSimulation import LteCaSimulation -from acts.test_utils.power.tel_simulations.LteImsSimulation import LteImsSimulation +from acts.controllers.cellular_lib import AndroidCellularDut +from acts.controllers.cellular_lib import GsmSimulation +from acts.controllers.cellular_lib import LteSimulation +from acts.controllers.cellular_lib import UmtsSimulation +from acts.controllers.cellular_lib import LteCaSimulation +from acts.controllers.cellular_lib import LteImsSimulation from acts.test_utils.tel import tel_test_utils as telutils @@ -366,11 +367,11 @@ class PowerCellularLabBaseTest(PBT.PowerBaseTest): """ simulation_dictionary = { - self.PARAM_SIM_TYPE_LTE: LteSimulation, - self.PARAM_SIM_TYPE_UMTS: UmtsSimulation, - self.PARAM_SIM_TYPE_GSM: GsmSimulation, - self.PARAM_SIM_TYPE_LTE_CA: LteCaSimulation, - self.PARAM_SIM_TYPE_LTE_IMS: LteImsSimulation + self.PARAM_SIM_TYPE_LTE: LteSimulation.LteSimulation, + self.PARAM_SIM_TYPE_UMTS: UmtsSimulation.UmtsSimulation, + self.PARAM_SIM_TYPE_GSM: GsmSimulation.GsmSimulation, + self.PARAM_SIM_TYPE_LTE_CA: LteCaSimulation.LteCaSimulation, + self.PARAM_SIM_TYPE_LTE_IMS: LteImsSimulation.LteImsSimulation } if not sim_type in simulation_dictionary: @@ -391,9 +392,11 @@ class PowerCellularLabBaseTest(PBT.PowerBaseTest): if sim_type not in self.calibration_table: self.calibration_table[sim_type] = {} + cellular_dut = AndroidCellularDut.AndroidCellularDut( + self.dut, self.log) # Instantiate a new simulation self.simulation = simulation_class(self.cellular_simulator, self.log, - self.dut, self.test_params, + cellular_dut, self.test_params, self.calibration_table[sim_type]) def ensure_valid_calibration_table(self, calibration_table): diff --git a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py index 82d655fff1..122709f5f0 100644 --- a/acts/framework/acts/test_utils/wifi/WifiBaseTest.py +++ b/acts/framework/acts/test_utils/wifi/WifiBaseTest.py @@ -316,11 +316,6 @@ class WifiBaseTest(BaseTestClass): ent_network_pwd=False, radius_conf_pwd=None, ap_count=1): - asserts.assert_true( - len(self.user_params["AccessPoint"]) == 2, - "Exactly two access points must be specified. \ - Each access point has 2 radios, one each for 2.4GHZ \ - and 5GHz. A test can choose to use one or both APs.") config_count = 1 count = 0 diff --git a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py index df303ced44..ed85f5b754 100644 --- a/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py +++ b/acts/framework/acts/test_utils/wifi/aware/AwareBaseTest.py @@ -32,7 +32,8 @@ class AwareBaseTest(BaseTestClass): device_startup_offset = 2 def setup_test(self): - required_params = ("aware_default_power_mode", ) + required_params = ("aware_default_power_mode", + "dbs_supported_models",) self.unpack_userparams(required_params) for ad in self.android_devices: @@ -40,15 +41,14 @@ class AwareBaseTest(BaseTestClass): not ad.droid.doesDeviceSupportWifiAwareFeature(), "Device under test does not support Wi-Fi Aware - skipping test" ) - wutils.wifi_toggle_state(ad, True) + aware_avail = ad.droid.wifiIsAwareAvailable() ad.droid.wifiP2pClose() + wutils.wifi_toggle_state(ad, True) utils.set_location_service(ad, True) - aware_avail = ad.droid.wifiIsAwareAvailable() if not aware_avail: self.log.info('Aware not available. Waiting ...') autils.wait_for_event(ad, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) - ad.ed.clear_all_events() ad.aware_capabilities = autils.get_aware_capabilities(ad) self.reset_device_parameters(ad) self.reset_device_statistics(ad) @@ -58,6 +58,7 @@ class AwareBaseTest(BaseTestClass): # set randomization interval to 0 (disable) to reduce likelihood of # interference in tests autils.configure_mac_random_interval(ad, 0) + ad.ed.clear_all_events() def teardown_test(self): for ad in self.android_devices: diff --git a/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py b/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py index 2623f9bfcb..e2977999c1 100644 --- a/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/aware/aware_test_utils.py @@ -468,6 +468,28 @@ def verify_socket_connect(dut_s, dut_c, ipv6_s, ipv6_c, port): return True +def run_ping6(dut, target_ip, duration=60): + """Run ping test and return the latency result + + Args: + dut: the dut which run the ping cmd + target_ip: target IP Address for ping + duration: the duration time of the ping + + return: dict contains "min/avg/max/mdev" result + """ + cmd = "ping6 -w %d %s" % (duration, target_ip) + ping_result = dut.adb.shell(cmd, timeout=duration + 1) + res = re.match(".*mdev = (\S+) .*", ping_result, re.S) + asserts.assert_true(res, "Cannot reach the IP address %s", target_ip) + title = ["min", "avg", "max", "mdev"] + result = res.group(1).split("/") + latency_result = {} + for i in range(len(title)): + latency_result[title[i]] = result[i] + return latency_result + + ######################################################### # Aware primitives ######################################################### diff --git a/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py b/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py index 7aca3c6ca9..1c5a53f120 100644 --- a/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py +++ b/acts/framework/acts/test_utils/wifi/p2p/WifiP2pBaseTest.py @@ -24,16 +24,32 @@ from acts.base_test import BaseTestClass from acts.test_utils.wifi import wifi_test_utils as wutils from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts +WAIT_TIME = 60 + + class WifiP2pBaseTest(BaseTestClass): def __init__(self, controllers): if not hasattr(self, 'android_devices'): super(WifiP2pBaseTest, self).__init__(controllers) def setup_class(self): + for ad in self.android_devices: + ad.droid.wakeLockAcquireBright() + ad.droid.wakeUpNow() + required_params = () + optional_params = ("skip_read_factory_mac", ) + self.unpack_userparams(required_params, + optional_params, + skip_read_factory_mac=0) + self.dut1 = self.android_devices[0] self.dut2 = self.android_devices[1] - self.dut1_mac = self.get_p2p_mac_address(self.dut1) - self.dut2_mac = self.get_p2p_mac_address(self.dut2) + if self.skip_read_factory_mac: + self.dut1_mac = None + self.dut2_mac = None + else: + self.dut1_mac = self.get_p2p_mac_address(self.dut1) + self.dut2_mac = self.get_p2p_mac_address(self.dut2) #init location before init p2p acts.utils.set_location_service(self.dut1, True) @@ -44,7 +60,7 @@ class WifiP2pBaseTest(BaseTestClass): self.dut1.droid.wifiP2pInitialize() time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) asserts.assert_true(self.dut1.droid.wifiP2pIsEnabled(), - "DUT1's p2p should be initialized but it didn't") + "DUT1's p2p should be initialized but it didn't") self.dut1.name = "Android_" + self.dut1.serial self.dut1.droid.wifiP2pSetDeviceName(self.dut1.name) wutils.wifi_test_device_init(self.dut2) @@ -52,7 +68,7 @@ class WifiP2pBaseTest(BaseTestClass): self.dut2.droid.wifiP2pInitialize() time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) asserts.assert_true(self.dut2.droid.wifiP2pIsEnabled(), - "DUT2's p2p should be initialized but it didn't") + "DUT2's p2p should be initialized but it didn't") self.dut2.name = "Android_" + self.dut2.serial self.dut2.droid.wifiP2pSetDeviceName(self.dut2.name) @@ -63,12 +79,12 @@ class WifiP2pBaseTest(BaseTestClass): utils.sync_device_time(self.dut3) self.dut3.droid.wifiP2pInitialize() time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - asserts.assert_true(self.dut3.droid.wifiP2pIsEnabled(), - "DUT3's p2p should be initialized but it didn't") + asserts.assert_true( + self.dut3.droid.wifiP2pIsEnabled(), + "DUT3's p2p should be initialized but it didn't") self.dut3.name = "Android_" + self.dut3.serial self.dut3.droid.wifiP2pSetDeviceName(self.dut3.name) - def teardown_class(self): self.dut1.droid.wifiP2pClose() self.dut2.droid.wifiP2pClose() @@ -78,11 +94,12 @@ class WifiP2pBaseTest(BaseTestClass): if len(self.android_devices) > 2: self.dut3.droid.wifiP2pClose() acts.utils.set_location_service(self.dut3, False) + for ad in self.android_devices: + ad.droid.wakeLockRelease() + ad.droid.goToSleepNow() def setup_test(self): for ad in self.android_devices: - ad.droid.wakeLockAcquireBright() - ad.droid.wakeUpNow() ad.ed.clear_all_events() def teardown_test(self): @@ -90,13 +107,11 @@ class WifiP2pBaseTest(BaseTestClass): # Clear p2p group info ad.droid.wifiP2pRequestPersistentGroupInfo() event = ad.ed.pop_event("WifiP2pOnPersistentGroupInfoAvailable", - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.DEFAULT_TIMEOUT) for network in event['data']: ad.droid.wifiP2pDeletePersistentGroup(network['NetworkId']) # Clear p2p local service ad.droid.wifiP2pClearLocalServices() - ad.droid.wakeLockRelease() - ad.droid.goToSleepNow() def on_fail(self, test_name, begin_time): for ad in self.android_devices: @@ -105,5 +120,7 @@ class WifiP2pBaseTest(BaseTestClass): def get_p2p_mac_address(self, dut): """Gets the current MAC address being used for Wi-Fi Direct.""" + dut.reboot() + time.sleep(WAIT_TIME) out = dut.adb.shell("ifconfig p2p0") return re.match(".* HWaddr (\S+).*", out, re.S).group(1) diff --git a/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_const.py b/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_const.py index b50a5d35fc..87f405967e 100644 --- a/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_const.py +++ b/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_const.py @@ -28,6 +28,11 @@ DEFAULT_TIMEOUT = 30 DEFAULT_SLEEPTIME = 5 DEFAULT_FUNCTION_SWITCH_TIME = 10 DEFAULT_SERVICE_WAITING_TIME = 20 +DEFAULT_GROUP_CLIENT_LOST_TIME = 60 + +P2P_CONNECT_NEGOTIATION = 0 +P2P_CONNECT_JOIN = 1 +P2P_CONNECT_INVITATION = 2 ###################################################### # Wifi P2p sl4a Event String ###################################################### @@ -40,7 +45,7 @@ ONGOING_PEER_SET_SUCCESS_EVENT = "WifiP2psetP2pPeerConfigureOnSuccess" CONNECT_SUCCESS_EVENT = "WifiP2pConnectOnSuccess" CREATE_GROUP_SUCCESS_EVENT = "WifiP2pCreateGroupOnSuccess" SET_CHANNEL_SUCCESS_EVENT = "WifiP2pSetChannelsOnSuccess" - +GROUP_INFO_AVAILABLE_EVENT = "WifiP2pOnGroupInfoAvailable" ###################################################### # Wifi P2p local service event @@ -60,14 +65,15 @@ UPNP_EVENT_SERVICELIST_KEY = "ServiceList" # Wifi P2p local service type #################################################### P2P_LOCAL_SERVICE_UPNP = 0 -P2P_LOCAL_SERVICE_IPP = 1 -P2P_LOCAL_SERVICE_AFP = 2 +P2P_LOCAL_SERVICE_IPP = 1 +P2P_LOCAL_SERVICE_AFP = 2 ###################################################### # Wifi P2p group capability ###################################################### P2P_GROUP_CAPAB_GROUP_OWNER = 1 + ###################################################### # Wifi P2p UPnP MediaRenderer local service ###################################################### @@ -78,17 +84,19 @@ class UpnpTestData(): uuid = "6859dede-8574-59ab-9332-123456789011" rootdevice = "upnp:rootdevice" + ###################################################### # Wifi P2p Bonjour IPP & AFP local service ###################################################### class IppTestData(): - ippInstanceName = "MyPrinter"; - ippRegistrationType = "_ipp._tcp"; - ippDomainName = "myprinter._ipp._tcp.local."; - ipp_txtRecord = {"txtvers":"1", "pdl": "application/postscript"} + ippInstanceName = "MyPrinter" + ippRegistrationType = "_ipp._tcp" + ippDomainName = "myprinter._ipp._tcp.local." + ipp_txtRecord = {"txtvers": "1", "pdl": "application/postscript"} + class AfpTestData(): - afpInstanceName = "Example"; - afpRegistrationType = "_afpovertcp._tcp"; - afpDomainName = "example._afpovertcp._tcp.local."; + afpInstanceName = "Example" + afpRegistrationType = "_afpovertcp._tcp" + afpDomainName = "example._afpovertcp._tcp.local." afp_txtRecord = {} diff --git a/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_test_utils.py b/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_test_utils.py index 21486b07ae..a4456a59bd 100755 --- a/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/p2p/wifi_p2p_test_utils.py @@ -25,6 +25,7 @@ from acts import utils from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts import acts.utils + def is_discovered(event, ad): """Check an Android device exist in WifiP2pOnPeersAvailable event or not. @@ -41,7 +42,8 @@ def is_discovered(event, ad): return True return False -def check_disconnect(ad): + +def check_disconnect(ad, timeout=p2pconsts.DEFAULT_TIMEOUT): """Check an Android device disconnect or not Args: @@ -49,8 +51,7 @@ def check_disconnect(ad): """ ad.droid.wifiP2pRequestConnectionInfo() # wait disconnect event - ad.ed.pop_event(p2pconsts.DISCONNECTED_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + ad.ed.pop_event(p2pconsts.DISCONNECTED_EVENT, timeout) def p2p_disconnect(ad): @@ -63,6 +64,7 @@ def p2p_disconnect(ad): ad.droid.wifiP2pRemoveGroup() check_disconnect(ad) + def p2p_connection_ping_test(ad, target_ip_address): """Let an Android device to start ping target_ip_address @@ -70,10 +72,13 @@ def p2p_connection_ping_test(ad, target_ip_address): ad: The android device target_ip_address: ip address which would like to ping """ - ad.log.debug("Run Ping Test, %s ping %s "% (ad.serial, target_ip_address)) + ad.log.debug("Run Ping Test, %s ping %s " % (ad.serial, target_ip_address)) asserts.assert_true( - acts.utils.adb_shell_ping(ad, count=3, dest_ip=target_ip_address, - timeout=20),"%s ping failed" % (ad.serial)) + acts.utils.adb_shell_ping(ad, + count=6, + dest_ip=target_ip_address, + timeout=20), "%s ping failed" % (ad.serial)) + def is_go(ad): """Check an Android p2p role is Go or not @@ -87,12 +92,12 @@ def is_go(ad): ad.log.debug("is go check") ad.droid.wifiP2pRequestConnectionInfo() ad_connect_info_event = ad.ed.pop_event( - p2pconsts.CONNECTION_INFO_AVAILABLE_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.CONNECTION_INFO_AVAILABLE_EVENT, p2pconsts.DEFAULT_TIMEOUT) if ad_connect_info_event['data']['isGroupOwner']: return True return False + def p2p_go_ip(ad): """Get GO IP address @@ -104,13 +109,40 @@ def p2p_go_ip(ad): ad.log.debug("p2p go ip") ad.droid.wifiP2pRequestConnectionInfo() ad_connect_info_event = ad.ed.pop_event( - p2pconsts.CONNECTION_INFO_AVAILABLE_EVENT, - p2pconsts.DEFAULT_TIMEOUT) - ad.log.debug("p2p go ip: %s" % ad_connect_info_event['data']['groupOwnerHostAddress']) + p2pconsts.CONNECTION_INFO_AVAILABLE_EVENT, p2pconsts.DEFAULT_TIMEOUT) + ad.log.debug("p2p go ip: %s" % + ad_connect_info_event['data']['groupOwnerHostAddress']) return ad_connect_info_event['data']['groupOwnerHostAddress'] + +def p2p_get_current_group(ad): + """Get current group information + + Args: + ad: The android device + Return: + p2p group information + """ + ad.log.debug("get current group") + ad.droid.wifiP2pRequestGroupInfo() + ad_group_info_event = ad.ed.pop_event(p2pconsts.GROUP_INFO_AVAILABLE_EVENT, + p2pconsts.DEFAULT_TIMEOUT) + ad.log.debug( + "p2p group: SSID:%s, password:%s, owner address: %s, interface: %s" % + (ad_group_info_event['data']['NetworkName'], + ad_group_info_event['data']['Passphrase'], + ad_group_info_event['data']['OwnerAddress'], + ad_group_info_event['data']['Interface'])) + return ad_group_info_event['data'] + + #trigger p2p connect to ad2 from ad1 -def p2p_connect(ad1, ad2, isReconnect, wpsSetup, isJoinExistingGroup=False): +def p2p_connect(ad1, + ad2, + isReconnect, + wpsSetup, + p2p_connect_type=p2pconsts.P2P_CONNECT_NEGOTIATION, + go_ad=None): """trigger p2p connect to ad2 from ad1 Args: @@ -119,70 +151,86 @@ def p2p_connect(ad1, ad2, isReconnect, wpsSetup, isJoinExistingGroup=False): isReconnect: boolean, if persist group is exist, isReconnect is true, otherswise is false. wpsSetup: which wps connection would like to use + p2p_connect_type: enumeration, which type this p2p connection is + go_ad: The group owner android device which is used for the invitation connection """ - ad1.log.info("Create p2p connection from %s to %s via wps: %s" % - (ad1.name, ad2.name, wpsSetup)) - if isJoinExistingGroup: + ad1.log.info("Create p2p connection from %s to %s via wps: %s type %d" % + (ad1.name, ad2.name, wpsSetup, p2p_connect_type)) + if p2p_connect_type == p2pconsts.P2P_CONNECT_INVITATION: + if go_ad is None: + go_ad = ad1 + find_p2p_device(ad1, ad2) + find_p2p_group_owner(ad2, go_ad) + elif p2p_connect_type == p2pconsts.P2P_CONNECT_JOIN: find_p2p_group_owner(ad1, ad2) else: find_p2p_device(ad1, ad2) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) - wifi_p2p_config = {WifiP2PEnums.WifiP2pConfig.DEVICEADDRESS_KEY: - ad2.deviceAddress, WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: - {WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: wpsSetup}} + wifi_p2p_config = { + WifiP2PEnums.WifiP2pConfig.DEVICEADDRESS_KEY: ad2.deviceAddress, + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: { + WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: wpsSetup + } + } ad1.droid.wifiP2pConnect(wifi_p2p_config) ad1.ed.pop_event(p2pconsts.CONNECT_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.DEFAULT_TIMEOUT) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) if not isReconnect: ad1.droid.requestP2pPeerConfigure() ad1_peerConfig = ad1.ed.pop_event( - p2pconsts.ONGOING_PEER_INFO_AVAILABLE_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.ONGOING_PEER_INFO_AVAILABLE_EVENT, + p2pconsts.DEFAULT_TIMEOUT) ad1.log.debug(ad1_peerConfig['data']) ad2.droid.requestP2pPeerConfigure() ad2_peerConfig = ad2.ed.pop_event( - p2pconsts.ONGOING_PEER_INFO_AVAILABLE_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.ONGOING_PEER_INFO_AVAILABLE_EVENT, + p2pconsts.DEFAULT_TIMEOUT) ad2.log.debug(ad2_peerConfig['data']) if wpsSetup == WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_DISPLAY: - asserts.assert_true(WifiP2PEnums.WpsInfo.WPS_PIN_KEY - in ad1_peerConfig['data'][ - WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY], - "Can't get pin value"); - ad2_peerConfig['data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ - WifiP2PEnums.WpsInfo.WPS_PIN_KEY] = ad1_peerConfig[ - 'data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ - WifiP2PEnums.WpsInfo.WPS_PIN_KEY] - ad2.droid.setP2pPeerConfigure(ad2_peerConfig['data']) - ad2.ed.pop_event(p2pconsts.ONGOING_PEER_SET_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT); - ad2.droid.wifiP2pAcceptConnection() + asserts.assert_true( + WifiP2PEnums.WpsInfo.WPS_PIN_KEY in ad1_peerConfig['data'][ + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY], + "Can't get pin value") + ad2_peerConfig['data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ + WifiP2PEnums.WpsInfo.WPS_PIN_KEY] = ad1_peerConfig['data'][ + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ + WifiP2PEnums.WpsInfo.WPS_PIN_KEY] + ad2.droid.setP2pPeerConfigure(ad2_peerConfig['data']) + ad2.ed.pop_event(p2pconsts.ONGOING_PEER_SET_SUCCESS_EVENT, + p2pconsts.DEFAULT_TIMEOUT) + ad2.droid.wifiP2pAcceptConnection() elif wpsSetup == WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_KEYPAD: - asserts.assert_true( WifiP2PEnums.WpsInfo.WPS_PIN_KEY - in ad2_peerConfig['data'][ - WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY], - "Can't get pin value"); - ad1_peerConfig['data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ - WifiP2PEnums.WpsInfo.WPS_PIN_KEY] = ad2_peerConfig[ - 'data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ - WifiP2PEnums.WpsInfo.WPS_PIN_KEY] - ad1.droid.setP2pPeerConfigure(ad1_peerConfig['data']) - ad1.ed.pop_event(p2pconsts.ONGOING_PEER_SET_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT) - #Need to Accpet first in ad1 to avoid connect time out in ad2, - #the timeout just 1 sec in ad2 - ad1.droid.wifiP2pAcceptConnection() - time.sleep(p2pconsts.DEFAULT_SLEEPTIME) - ad2.droid.wifiP2pConfirmConnection() + asserts.assert_true( + WifiP2PEnums.WpsInfo.WPS_PIN_KEY in ad2_peerConfig['data'][ + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY], + "Can't get pin value") + ad1_peerConfig['data'][WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ + WifiP2PEnums.WpsInfo.WPS_PIN_KEY] = ad2_peerConfig['data'][ + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY][ + WifiP2PEnums.WpsInfo.WPS_PIN_KEY] + ad1.droid.setP2pPeerConfigure(ad1_peerConfig['data']) + ad1.ed.pop_event(p2pconsts.ONGOING_PEER_SET_SUCCESS_EVENT, + p2pconsts.DEFAULT_TIMEOUT) + #Need to Accept first in ad1 to avoid connect time out in ad2, + #the timeout just 1 sec in ad2 + ad1.droid.wifiP2pAcceptConnection() + time.sleep(p2pconsts.DEFAULT_SLEEPTIME) + ad2.droid.wifiP2pConfirmConnection() elif wpsSetup == WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC: - ad2.droid.wifiP2pAcceptConnection() + ad2.droid.wifiP2pAcceptConnection() + if p2p_connect_type == p2pconsts.P2P_CONNECT_INVITATION: + time.sleep(p2pconsts.DEFAULT_SLEEPTIME) + go_ad.droid.wifiP2pAcceptConnection() #wait connected event - ad1.ed.pop_event(p2pconsts.CONNECTED_EVENT, - p2pconsts.DEFAULT_TIMEOUT) - ad2.ed.pop_event(p2pconsts.CONNECTED_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + if p2p_connect_type == p2pconsts.P2P_CONNECT_INVITATION: + go_ad.ed.pop_event(p2pconsts.CONNECTED_EVENT, + p2pconsts.DEFAULT_TIMEOUT) + else: + ad1.ed.pop_event(p2pconsts.CONNECTED_EVENT, p2pconsts.DEFAULT_TIMEOUT) + ad2.ed.pop_event(p2pconsts.CONNECTED_EVENT, p2pconsts.DEFAULT_TIMEOUT) + def p2p_connect_with_config(ad1, ad2, network_name, passphrase, band): """trigger p2p connect to ad2 from ad1 with config @@ -194,28 +242,27 @@ def p2p_connect_with_config(ad1, ad2, network_name, passphrase, band): passphrase: the passphrase of the desired group. band: the operating band of the desired group. """ - ad1.log.info("Create p2p connection from %s to %s" % - (ad1.name, ad2.name)) + ad1.log.info("Create p2p connection from %s to %s" % (ad1.name, ad2.name)) find_p2p_device(ad1, ad2) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) wifi_p2p_config = { - WifiP2PEnums.WifiP2pConfig.NETWORK_NAME: network_name, - WifiP2PEnums.WifiP2pConfig.PASSPHRASE: passphrase, - WifiP2PEnums.WifiP2pConfig.GROUP_BAND: band, - WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: { - WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC - } + WifiP2PEnums.WifiP2pConfig.NETWORK_NAME: network_name, + WifiP2PEnums.WifiP2pConfig.PASSPHRASE: passphrase, + WifiP2PEnums.WifiP2pConfig.GROUP_BAND: band, + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: { + WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: + WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC + } } ad1.droid.wifiP2pConnect(wifi_p2p_config) ad1.ed.pop_event(p2pconsts.CONNECT_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.DEFAULT_TIMEOUT) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) #wait connected event - ad1.ed.pop_event(p2pconsts.CONNECTED_EVENT, - p2pconsts.DEFAULT_TIMEOUT) - ad2.ed.pop_event(p2pconsts.CONNECTED_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + ad1.ed.pop_event(p2pconsts.CONNECTED_EVENT, p2pconsts.DEFAULT_TIMEOUT) + ad2.ed.pop_event(p2pconsts.CONNECTED_EVENT, p2pconsts.DEFAULT_TIMEOUT) + def find_p2p_device(ad1, ad2): """Check an Android device ad1 can discover an Android device ad2 @@ -227,13 +274,14 @@ def find_p2p_device(ad1, ad2): ad1.droid.wifiP2pDiscoverPeers() ad2.droid.wifiP2pDiscoverPeers() p2p_find_result = False - while not p2p_find_result: + while not p2p_find_result: ad1_event = ad1.ed.pop_event(p2pconsts.PEER_AVAILABLE_EVENT, - p2pconsts.P2P_FIND_TIMEOUT) + p2pconsts.P2P_FIND_TIMEOUT) ad1.log.debug(ad1_event['data']) p2p_find_result = is_discovered(ad1_event, ad2) asserts.assert_true(p2p_find_result, - "DUT didn't discovered peer:%s device"% (ad2.name)) + "DUT didn't discovered peer:%s device" % (ad2.name)) + def find_p2p_group_owner(ad1, ad2): """Check an Android device ad1 can discover an Android device ad2 which @@ -243,21 +291,23 @@ def find_p2p_group_owner(ad1, ad2): ad1: The android device ad2: The android device which is a group owner """ - ad2.droid.wifiP2pStopPeerDiscovery(); + ad2.droid.wifiP2pStopPeerDiscovery() time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) ad1.droid.wifiP2pDiscoverPeers() p2p_find_result = False while not p2p_find_result: ad1_event = ad1.ed.pop_event(p2pconsts.PEER_AVAILABLE_EVENT, - p2pconsts.P2P_FIND_TIMEOUT) + p2pconsts.P2P_FIND_TIMEOUT) ad1.log.debug(ad1_event['data']) for device in ad1_event['data']['Peers']: - if (device['Name'] == ad2.name and - int(device['GroupCapability']) & p2pconsts.P2P_GROUP_CAPAB_GROUP_OWNER): + if (device['Name'] == ad2.name and int(device['GroupCapability']) + & p2pconsts.P2P_GROUP_CAPAB_GROUP_OWNER): ad2.deviceAddress = device['Address'] p2p_find_result = True - asserts.assert_true(p2p_find_result, - "DUT didn't discovered group owner peer:%s device"% (ad2.name)) + asserts.assert_true( + p2p_find_result, + "DUT didn't discovered group owner peer:%s device" % (ad2.name)) + def createP2pLocalService(ad, serviceCategory): """Based on serviceCategory to create p2p local service @@ -270,15 +320,16 @@ def createP2pLocalService(ad, serviceCategory): testData = genTestData(serviceCategory) if serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_UPNP: ad.droid.wifiP2pCreateUpnpServiceInfo(testData[0], testData[1], - testData[2]) - elif (serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_IPP or - serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_AFP): + testData[2]) + elif (serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_IPP + or serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_AFP): ad.droid.wifiP2pCreateBonjourServiceInfo(testData[0], testData[1], - testData[2]) + testData[2]) ad.droid.wifiP2pAddLocalService() + def requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, - serviceType, queryString1, queryString2): + serviceType, queryString1, queryString2): """Based on serviceType and query info, check service request result same as expect or not on an Android device ad_serviceReceiver. And remove p2p service request after result check. @@ -292,8 +343,8 @@ def requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, """ expectData = genExpectTestData(serviceType, queryString1, queryString2) find_p2p_device(ad_serviceReceiver, ad_serviceProvider) - ad_serviceReceiver.droid.wifiP2pStopPeerDiscovery(); - ad_serviceReceiver.droid.wifiP2pClearServiceRequests(); + ad_serviceReceiver.droid.wifiP2pStopPeerDiscovery() + ad_serviceReceiver.droid.wifiP2pClearServiceRequests() time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) ad_serviceReceiver.droid.wifiP2pDiscoverServices() @@ -301,18 +352,19 @@ def requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, service_id = 0 if (serviceType == WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_BONJOUR): - ad_serviceReceiver.log.info("Request bonjour service in \ + ad_serviceReceiver.log.info( + "Request bonjour service in \ %s with Query String %s and %s " % - (ad_serviceReceiver.name, queryString1, queryString2)) + (ad_serviceReceiver.name, queryString1, queryString2)) ad_serviceReceiver.log.info("expectData %s" % expectData) if queryString1 != None: service_id = ad_serviceReceiver.droid.wifiP2pAddDnssdServiceRequest( - queryString1,queryString2) + queryString1, queryString2) else: service_id = ad_serviceReceiver.droid.wifiP2pAddServiceRequest( - serviceType) + serviceType) ad_serviceReceiver.log.info("request bonjour service id %s" % - service_id) + service_id) ad_serviceReceiver.droid.wifiP2pSetDnsSdResponseListeners() ad_serviceReceiver.droid.wifiP2pDiscoverServices() ad_serviceReceiver.log.info("Check Service Listener") @@ -320,45 +372,47 @@ def requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, try: dnssd_events = ad_serviceReceiver.ed.pop_all(p2pconsts.DNSSD_EVENT) dnssd_txrecord_events = ad_serviceReceiver.ed.pop_all( - p2pconsts.DNSSD_TXRECORD_EVENT) + p2pconsts.DNSSD_TXRECORD_EVENT) dns_service = WifiP2PEnums.WifiP2pDnsSdServiceResponse() for dnssd_event in dnssd_events: - if dnssd_event['data']['SourceDeviceAddress' - ] == ad_serviceProvider.deviceAddress: + if dnssd_event['data'][ + 'SourceDeviceAddress'] == ad_serviceProvider.deviceAddress: dns_service.InstanceName = dnssd_event['data'][ - p2pconsts.DNSSD_EVENT_INSTANCENAME_KEY] + p2pconsts.DNSSD_EVENT_INSTANCENAME_KEY] dns_service.RegistrationType = dnssd_event['data'][ - p2pconsts.DNSSD_EVENT_REGISTRATIONTYPE_KEY] + p2pconsts.DNSSD_EVENT_REGISTRATIONTYPE_KEY] dns_service.FullDomainName = "" dns_service.TxtRecordMap = "" serviceData[dns_service.toString()] = 1 for dnssd_txrecord_event in dnssd_txrecord_events: - if dnssd_txrecord_event['data']['SourceDeviceAddress' - ] == ad_serviceProvider.deviceAddress: + if dnssd_txrecord_event['data'][ + 'SourceDeviceAddress'] == ad_serviceProvider.deviceAddress: dns_service.InstanceName = "" dns_service.RegistrationType = "" dns_service.FullDomainName = dnssd_txrecord_event['data'][ - p2pconsts.DNSSD_TXRECORD_EVENT_FULLDOMAINNAME_KEY] + p2pconsts.DNSSD_TXRECORD_EVENT_FULLDOMAINNAME_KEY] dns_service.TxtRecordMap = dnssd_txrecord_event['data'][ - p2pconsts.DNSSD_TXRECORD_EVENT_TXRECORDMAP_KEY] + p2pconsts.DNSSD_TXRECORD_EVENT_TXRECORDMAP_KEY] serviceData[dns_service.toString()] = 1 ad_serviceReceiver.log.info("serviceData %s" % serviceData) if len(serviceData) == 0: - ad_serviceReceiver.droid.wifiP2pRemoveServiceRequest(service_id) - return -1; + ad_serviceReceiver.droid.wifiP2pRemoveServiceRequest( + service_id) + return -1 except queue.Empty as error: - ad_serviceReceiver.log.info("dnssd event is empty",) + ad_serviceReceiver.log.info("dnssd event is empty", ) elif (serviceType == - WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP): - ad_serviceReceiver.log.info("Request upnp service in %s with Query String %s "% - (ad_serviceReceiver.name, queryString1)) + WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP): + ad_serviceReceiver.log.info( + "Request upnp service in %s with Query String %s " % + (ad_serviceReceiver.name, queryString1)) ad_serviceReceiver.log.info("expectData %s" % expectData) if queryString1 != None: service_id = ad_serviceReceiver.droid.wifiP2pAddUpnpServiceRequest( - queryString1) + queryString1) else: service_id = ad_serviceReceiver.droid.wifiP2pAddServiceRequest( - WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP) + WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP) ad_serviceReceiver.droid.wifiP2pSetUpnpResponseListeners() ad_serviceReceiver.droid.wifiP2pDiscoverServices() ad_serviceReceiver.log.info("Check Service Listener") @@ -366,27 +420,33 @@ def requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, try: upnp_events = ad_serviceReceiver.ed.pop_all(p2pconsts.UPNP_EVENT) for upnp_event in upnp_events: - if upnp_event['data']['Device']['Address' - ] == ad_serviceProvider.deviceAddress: + if upnp_event['data']['Device'][ + 'Address'] == ad_serviceProvider.deviceAddress: for service in upnp_event['data'][ p2pconsts.UPNP_EVENT_SERVICELIST_KEY]: serviceData[service] = 1 ad_serviceReceiver.log.info("serviceData %s" % serviceData) if len(serviceData) == 0: - ad_serviceReceiver.droid.wifiP2pRemoveServiceRequest(service_id) - return -1; + ad_serviceReceiver.droid.wifiP2pRemoveServiceRequest( + service_id) + return -1 except queue.Empty as error: - ad_serviceReceiver.log.info("p2p upnp event is empty",) + ad_serviceReceiver.log.info("p2p upnp event is empty", ) ad_serviceReceiver.log.info("Check ServiceList") - asserts.assert_true(checkServiceQueryResult(serviceData,expectData), - "ServiceList not same as Expect"); + asserts.assert_true(checkServiceQueryResult(serviceData, expectData), + "ServiceList not same as Expect") # After service checked, remove the service_id ad_serviceReceiver.droid.wifiP2pRemoveServiceRequest(service_id) return 0 -def requestServiceAndCheckResultWithRetry(ad_serviceProvider, ad_serviceReceiver, - serviceType, queryString1, queryString2, retryCount=3): + +def requestServiceAndCheckResultWithRetry(ad_serviceProvider, + ad_serviceReceiver, + serviceType, + queryString1, + queryString2, + retryCount=3): """ allow failures for requestServiceAndCheckResult. Service discovery might fail unexpectedly because the request packet might not be recevied by the service responder due to p2p state switch. @@ -401,14 +461,16 @@ def requestServiceAndCheckResultWithRetry(ad_serviceProvider, ad_serviceReceiver """ ret = 0 while retryCount > 0: - ret = requestServiceAndCheckResult(ad_serviceProvider, ad_serviceReceiver, - serviceType, queryString1, queryString2) + ret = requestServiceAndCheckResult(ad_serviceProvider, + ad_serviceReceiver, serviceType, + queryString1, queryString2) if (ret == 0): break retryCount -= 1 asserts.assert_equal(0, ret, "cannot find any services with retries.") + def checkServiceQueryResult(serviceList, expectServiceList): """Check serviceList same as expectServiceList or not @@ -427,6 +489,7 @@ def checkServiceQueryResult(serviceList, expectServiceList): del tempExpectServiceList[service] return len(tempExpectServiceList) == 0 and len(tempServiceList) == 0 + def genTestData(serviceCategory): """Based on serviceCategory to generator Test Data @@ -439,8 +502,10 @@ def genTestData(serviceCategory): if serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_UPNP: testData.append(p2pconsts.UpnpTestData.uuid) testData.append(p2pconsts.UpnpTestData.serviceType) - testData.append([p2pconsts.UpnpTestData.AVTransport, - p2pconsts.UpnpTestData.ConnectionManager]) + testData.append([ + p2pconsts.UpnpTestData.AVTransport, + p2pconsts.UpnpTestData.ConnectionManager + ]) elif serviceCategory == p2pconsts.P2P_LOCAL_SERVICE_IPP: testData.append(p2pconsts.IppTestData.ippInstanceName) testData.append(p2pconsts.IppTestData.ippRegistrationType) @@ -452,6 +517,7 @@ def genTestData(serviceCategory): return testData + def genExpectTestData(serviceType, queryString1, queryString2): """Based on serviceCategory to generator expect serviceList @@ -477,7 +543,7 @@ def genExpectTestData(serviceType, queryString1, queryString2): return expectServiceList ipp_service.InstanceName = p2pconsts.IppTestData.ippInstanceName ipp_service.RegistrationType = ( - p2pconsts.IppTestData.ippRegistrationType + ".local.") + p2pconsts.IppTestData.ippRegistrationType + ".local.") ipp_service.FullDomainName = "" ipp_service.TxtRecordMap = "" expectServiceList[ipp_service.toString()] = 1 @@ -492,7 +558,7 @@ def genExpectTestData(serviceType, queryString1, queryString2): return expectServiceList ipp_service.InstanceName = p2pconsts.IppTestData.ippInstanceName ipp_service.RegistrationType = ( - p2pconsts.IppTestData.ippRegistrationType + ".local.") + p2pconsts.IppTestData.ippRegistrationType + ".local.") ipp_service.FullDomainName = "" ipp_service.TxtRecordMap = "" expectServiceList[ipp_service.toString()] = 1 @@ -505,7 +571,7 @@ def genExpectTestData(serviceType, queryString1, queryString2): afp_service.InstanceName = p2pconsts.AfpTestData.afpInstanceName afp_service.RegistrationType = ( - p2pconsts.AfpTestData.afpRegistrationType + ".local.") + p2pconsts.AfpTestData.afpRegistrationType + ".local.") afp_service.FullDomainName = "" afp_service.TxtRecordMap = "" expectServiceList[afp_service.toString()] = 1 @@ -519,23 +585,24 @@ def genExpectTestData(serviceType, queryString1, queryString2): return expectServiceList elif serviceType == WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP: upnp_service = "uuid:" + p2pconsts.UpnpTestData.uuid + "::" + ( - p2pconsts.UpnpTestData.rootdevice) + p2pconsts.UpnpTestData.rootdevice) expectServiceList[upnp_service] = 1 if queryString1 != "upnp:rootdevice": upnp_service = "uuid:" + p2pconsts.UpnpTestData.uuid + ( - "::" + p2pconsts.UpnpTestData.AVTransport) + "::" + p2pconsts.UpnpTestData.AVTransport) expectServiceList[upnp_service] = 1 upnp_service = "uuid:" + p2pconsts.UpnpTestData.uuid + ( - "::" + p2pconsts.UpnpTestData.ConnectionManager) + "::" + p2pconsts.UpnpTestData.ConnectionManager) expectServiceList[upnp_service] = 1 upnp_service = "uuid:" + p2pconsts.UpnpTestData.uuid + ( - "::" + p2pconsts.UpnpTestData.serviceType) + "::" + p2pconsts.UpnpTestData.serviceType) expectServiceList[upnp_service] = 1 - upnp_service = "uuid:"+p2pconsts.UpnpTestData.uuid + upnp_service = "uuid:" + p2pconsts.UpnpTestData.uuid expectServiceList[upnp_service] = 1 return expectServiceList + def p2p_create_group(ad): """Create a group as Group Owner @@ -544,9 +611,10 @@ def p2p_create_group(ad): """ ad.droid.wifiP2pCreateGroup() ad.ed.pop_event(p2pconsts.CREATE_GROUP_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.DEFAULT_TIMEOUT) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) + def p2p_create_group_with_config(ad, network_name, passphrase, band): """Create a group as Group Owner @@ -554,19 +622,22 @@ def p2p_create_group_with_config(ad, network_name, passphrase, band): ad: The android device """ wifi_p2p_config = { - WifiP2PEnums.WifiP2pConfig.NETWORK_NAME: network_name, - WifiP2PEnums.WifiP2pConfig.PASSPHRASE: passphrase, - WifiP2PEnums.WifiP2pConfig.GROUP_BAND: band, - WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: { - WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC - } + WifiP2PEnums.WifiP2pConfig.NETWORK_NAME: network_name, + WifiP2PEnums.WifiP2pConfig.PASSPHRASE: passphrase, + WifiP2PEnums.WifiP2pConfig.GROUP_BAND: band, + WifiP2PEnums.WifiP2pConfig.WPSINFO_KEY: { + WifiP2PEnums.WpsInfo.WPS_SETUP_KEY: + WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC + } } ad.droid.wifiP2pCreateGroupWithConfig(wifi_p2p_config) ad.ed.pop_event(p2pconsts.CREATE_GROUP_SUCCESS_EVENT, - p2pconsts.DEFAULT_TIMEOUT) + p2pconsts.DEFAULT_TIMEOUT) time.sleep(p2pconsts.DEFAULT_SLEEPTIME) -def wifi_p2p_set_channels_for_current_group(ad, listening_chan, operating_chan): + +def wifi_p2p_set_channels_for_current_group(ad, listening_chan, + operating_chan): """Sets the listening channel and operating channel of the current group created with initialize. @@ -579,8 +650,8 @@ def wifi_p2p_set_channels_for_current_group(ad, listening_chan, operating_chan): ad.ed.pop_event(p2pconsts.SET_CHANNEL_SUCCESS_EVENT, p2pconsts.DEFAULT_TIMEOUT) -class WifiP2PEnums(): +class WifiP2PEnums(): class WifiP2pConfig(): DEVICEADDRESS_KEY = "deviceAddress" WPSINFO_KEY = "wpsInfo" @@ -612,12 +683,12 @@ class WifiP2PEnums(): class WifiP2pDnsSdServiceResponse(): def __init__(self): pass + InstanceName = "" RegistrationType = "" FullDomainName = "" TxtRecordMap = {} + def toString(self): return self.InstanceName + self.RegistrationType + ( - self.FullDomainName + str(self.TxtRecordMap)) - - + self.FullDomainName + str(self.TxtRecordMap)) diff --git a/acts/framework/acts/test_utils/wifi/wifi_constants.py b/acts/framework/acts/test_utils/wifi/wifi_constants.py index 21f13d2fc1..3a4990571c 100644 --- a/acts/framework/acts/test_utils/wifi/wifi_constants.py +++ b/acts/framework/acts/test_utils/wifi/wifi_constants.py @@ -37,18 +37,37 @@ SOFTAP_CALLBACK_EVENT = "WifiManagerSoftApCallback-" # Callback Event for softap state change # WifiManagerSoftApCallback-[callbackId]-OnStateChanged SOFTAP_STATE_CHANGED = "-OnStateChanged" -# Cllback Event for client number change: -# WifiManagerSoftApCallback-[callbackId]-OnNumClientsChanged -SOFTAP_NUMBER_CLIENTS_CHANGED = "-OnNumClientsChanged" -SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY = "NumClients" SOFTAP_STATE_CHANGE_CALLBACK_KEY = "State" WIFI_AP_DISABLING_STATE = 10 WIFI_AP_DISABLED_STATE = 11 WIFI_AP_ENABLING_STATE = 12 WIFI_AP_ENABLED_STATE = 13 WIFI_AP_FAILED_STATE = 14 -DEFAULT_SOFTAP_TIMEOUT_S = 600 # 10 minutes +# Callback Event for client number change: +# WifiManagerSoftApCallback-[callbackId]-OnNumClientsChanged +SOFTAP_NUMBER_CLIENTS_CHANGED = "-OnNumClientsChanged" +SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY = "NumClients" +SOFTAP_CLIENTS_MACS_CALLBACK_KEY = "MacAddresses" +# Callback Event for softap info change +SOFTAP_INFO_CHANGED = "-OnInfoChanged" +SOFTAP_INFO_FREQUENCY_CALLBACK_KEY = "frequency" +SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY = "bandwidth" +# Callback Event for softap client blocking +SOFTAP_BLOCKING_CLIENT_CONNECTING = "-OnBlockedClientConnecting" +SOFTAP_BLOCKING_CLIENT_REASON_KEY = "BlockedReason" +SOFTAP_BLOCKING_CLIENT_WIFICLIENT_KEY = "WifiClient" +SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER = 0 +SAP_CLIENT_BLOCK_REASON_CODE_NO_MORE_STAS = 1 + +# Callback Event for softap capability +SOFTAP_CAPABILITY_CHANGED = "-OnCapabilityChanged" +SOFTAP_CAPABILITY_MAX_SUPPORTED_CLIENTS = "maxSupportedClients" +SOFTAP_CAPABILITY_FEATURE_ACS = "acsOffloadSupported" +SOFTAP_CAPABILITY_FEATURE_CLIENT_CONTROL = "clientForceDisconnectSupported" +SOFTAP_CAPABILITY_FEATURE_WPA3_SAE = "wpa3SaeSupported" + +DEFAULT_SOFTAP_TIMEOUT_S = 600 # 10 minutes # AP related constants AP_MAIN = "main_AP" diff --git a/acts/framework/acts/test_utils/wifi/wifi_performance_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_performance_test_utils.py index 39896bc1f5..1666e63e70 100644 --- a/acts/framework/acts/test_utils/wifi/wifi_performance_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/wifi_performance_test_utils.py @@ -84,7 +84,8 @@ class LinkLayerStats(): def update_stats(self): if self.llstats_enabled: try: - llstats_output = self.dut.adb.shell(self.LLSTATS_CMD, timeout=0.1) + llstats_output = self.dut.adb.shell(self.LLSTATS_CMD, + timeout=0.1) except: llstats_output = '' else: @@ -682,12 +683,53 @@ def get_ping_stats_nb(src_device, dest_address, ping_duration, ping_interval, ping_interval, ping_size) +# Iperf utilities @nonblocking def start_iperf_client_nb(iperf_client, iperf_server_address, iperf_args, tag, timeout): return iperf_client.start(iperf_server_address, iperf_args, tag, timeout) +def get_iperf_arg_string(duration, + reverse_direction, + interval=1, + traffic_type='TCP', + socket_size=None, + num_processes=1, + udp_throughput='1000M', + ipv6=False): + """Function to format iperf client arguments. + + This function takes in iperf client parameters and returns a properly + formatter iperf arg string to be used in throughput tests. + + Args: + duration: iperf duration in seconds + reverse_direction: boolean controlling the -R flag for iperf clients + interval: iperf print interval + traffic_type: string specifying TCP or UDP traffic + socket_size: string specifying TCP window or socket buffer, e.g., 2M + num_processes: int specifying number of iperf processes + udp_throughput: string specifying TX throughput in UDP tests, e.g. 100M + ipv6: boolean controlling the use of IP V6 + Returns: + iperf_args: string of formatted iperf args + """ + iperf_args = '-i {} -t {} -J '.format(interval, duration) + if ipv6: + iperf_args = iperf_args + '-6 ' + if traffic_type.upper() == 'UDP': + iperf_args = iperf_args + '-u -b {} -l 1400 -P {}'.format( + udp_throughput, num_processes) + elif traffic_type.upper() == 'TCP': + iperf_args = iperf_args + '-P {}'.format(num_processes) + if socket_size: + iperf_args = iperf_args + '-w {}'.format(socket_size) + if reverse_direction: + iperf_args = iperf_args + ' -R' + return iperf_args + + # Rssi Utilities def empty_rssi_result(): return collections.OrderedDict([('data', []), ('mean', None), @@ -699,7 +741,8 @@ def get_connected_rssi(dut, polling_frequency=SHORT_SLEEP, first_measurement_delay=0, disconnect_warning=True, - ignore_samples=0): + ignore_samples=0, + interface=None): """Gets all RSSI values reported for the connected access point/BSSID. Args: @@ -716,7 +759,7 @@ def get_connected_rssi(dut, # yapf: disable connected_rssi = collections.OrderedDict( [('time_stamp', []), - ('bssid', []), ('frequency', []), + ('bssid', []), ('ssid', []), ('frequency', []), ('signal_poll_rssi', empty_rssi_result()), ('signal_poll_avg_rssi', empty_rssi_result()), ('chain_0_rssi', empty_rssi_result()), @@ -729,7 +772,11 @@ def get_connected_rssi(dut, measurement_start_time = time.time() connected_rssi['time_stamp'].append(measurement_start_time - t0) # Get signal poll RSSI - status_output = dut.adb.shell(WPA_CLI_STATUS) + if interface is None: + status_output = dut.adb.shell(WPA_CLI_STATUS) + else: + status_output = dut.adb.shell( + 'wpa_cli -i {} status'.format(interface)) match = re.search('bssid=.*', status_output) if match: current_bssid = match.group(0).split('=')[1] @@ -740,7 +787,17 @@ def get_connected_rssi(dut, if disconnect_warning and previous_bssid != 'disconnected': logging.warning('WIFI DISCONNECT DETECTED!') previous_bssid = current_bssid - signal_poll_output = dut.adb.shell(SIGNAL_POLL) + match = re.search('\s+ssid=.*', status_output) + if match: + ssid = match.group(0).split('=')[1] + connected_rssi['ssid'].append(ssid) + else: + connected_rssi['ssid'].append('disconnected') + if interface is None: + signal_poll_output = dut.adb.shell(SIGNAL_POLL) + else: + signal_poll_output = dut.adb.shell( + 'wpa_cli -i {} signal_poll'.format(interface)) match = re.search('FREQUENCY=.*', signal_poll_output) if match: frequency = int(match.group(0).split('=')[1]) @@ -764,8 +821,12 @@ def get_connected_rssi(dut, else: connected_rssi['signal_poll_avg_rssi']['data'].append( RSSI_ERROR_VAL) + # Get per chain RSSI - per_chain_rssi = dut.adb.shell(STATION_DUMP) + if interface is None: + per_chain_rssi = dut.adb.shell(STATION_DUMP) + else: + per_chain_rssi = '' match = re.search('.*signal avg:.*', per_chain_rssi) if match: per_chain_rssi = per_chain_rssi[per_chain_rssi.find('[') + @@ -808,10 +869,11 @@ def get_connected_rssi_nb(dut, polling_frequency=SHORT_SLEEP, first_measurement_delay=0, disconnect_warning=True, - ignore_samples=0): + ignore_samples=0, + interface=None): return get_connected_rssi(dut, num_measurements, polling_frequency, first_measurement_delay, disconnect_warning, - ignore_samples) + ignore_samples, interface) def get_scan_rssi(dut, tracked_bssids, num_measurements=1): @@ -1106,41 +1168,6 @@ def get_server_address(ssh_connection, dut_ip, subnet_mask): logging.error('No IP address found in requested subnet') -def get_iperf_arg_string(duration, - reverse_direction, - interval=1, - traffic_type='TCP', - tcp_window=None, - tcp_processes=1, - udp_throughput='1000M'): - """Function to format iperf client arguments. - - This function takes in iperf client parameters and returns a properly - formatter iperf arg string to be used in throughput tests. - - Args: - duration: iperf duration in seconds - reverse_direction: boolean controlling the -R flag for iperf clients - interval: iperf print interval - traffic_type: string specifying TCP or UDP traffic - tcp_window: string specifying TCP window, e.g., 2M - tcp_processes: int specifying number of tcp processes - udp_throughput: string specifying TX throughput in UDP tests, e.g. 100M - Returns: - iperf_args: string of formatted iperf args - """ - iperf_args = '-i {} -t {} -J '.format(interval, duration) - if traffic_type.upper() == 'UDP': - iperf_args = iperf_args + '-u -b {} -l 1400'.format(udp_throughput) - elif traffic_type.upper() == 'TCP': - iperf_args = iperf_args + '-P {}'.format(tcp_processes) - if tcp_window: - iperf_args = iperf_args + '-w {}'.format(tcp_window) - if reverse_direction: - iperf_args = iperf_args + ' -R' - return iperf_args - - def get_dut_temperature(dut): """Function to get dut temperature. diff --git a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py index 0f75b5a378..22cc69c717 100755 --- a/acts/framework/acts/test_utils/wifi/wifi_test_utils.py +++ b/acts/framework/acts/test_utils/wifi/wifi_test_utils.py @@ -16,6 +16,7 @@ import logging import os +import re import shutil import time @@ -49,7 +50,7 @@ SPEED_OF_LIGHT = 299792458 DEFAULT_PING_ADDR = "https://www.google.com/robots.txt" -roaming_attn = { +ROAMING_ATTN = { "AP1_on_AP2_off": [ 0, 0, @@ -73,24 +74,46 @@ roaming_attn = { class WifiEnums(): - SSID_KEY = "SSID" + SSID_KEY = "SSID" # Used for Wifi & SoftAp SSID_PATTERN_KEY = "ssidPattern" NETID_KEY = "network_id" - BSSID_KEY = "BSSID" + BSSID_KEY = "BSSID" # Used for Wifi & SoftAp BSSID_PATTERN_KEY = "bssidPattern" - PWD_KEY = "password" + PWD_KEY = "password" # Used for Wifi & SoftAp frequency_key = "frequency" - APBAND_KEY = "apBand" - HIDDEN_KEY = "hiddenSSID" + HIDDEN_KEY = "hiddenSSID" # Used for Wifi & SoftAp IS_APP_INTERACTION_REQUIRED = "isAppInteractionRequired" IS_USER_INTERACTION_REQUIRED = "isUserInteractionRequired" - IS_METERED = "isMetered" + IS_SUGGESTION_METERED = "isMetered" PRIORITY = "priority" - SECURITY = "security" - - WIFI_CONFIG_APBAND_2G = 0 - WIFI_CONFIG_APBAND_5G = 1 - WIFI_CONFIG_APBAND_AUTO = -1 + SECURITY = "security" # Used for Wifi & SoftAp + + # Used for SoftAp + AP_BAND_KEY = "apBand" + AP_CHANNEL_KEY = "apChannel" + AP_MAXCLIENTS_KEY = "MaxNumberOfClients" + AP_SHUTDOWNTIMEOUT_KEY = "ShutdownTimeoutMillis" + AP_SHUTDOWNTIMEOUTENABLE_KEY = "AutoShutdownEnabled" + AP_CLIENTCONTROL_KEY = "ClientControlByUserEnabled" + AP_ALLOWEDLIST_KEY = "AllowedClientList" + AP_BLOCKEDLIST_KEY = "BlockedClientList" + + WIFI_CONFIG_SOFTAP_BAND_2G = 1 + WIFI_CONFIG_SOFTAP_BAND_5G = 2 + WIFI_CONFIG_SOFTAP_BAND_2G_5G = 3 + WIFI_CONFIG_SOFTAP_BAND_6G = 4 + WIFI_CONFIG_SOFTAP_BAND_2G_6G = 5 + WIFI_CONFIG_SOFTAP_BAND_5G_6G = 6 + WIFI_CONFIG_SOFTAP_BAND_ANY = 7 + + # DO NOT USE IT for new test case! Replaced by WIFI_CONFIG_SOFTAP_BAND_ + WIFI_CONFIG_APBAND_2G = WIFI_CONFIG_SOFTAP_BAND_2G + WIFI_CONFIG_APBAND_5G = WIFI_CONFIG_SOFTAP_BAND_5G + WIFI_CONFIG_APBAND_AUTO = WIFI_CONFIG_SOFTAP_BAND_2G_5G + + WIFI_CONFIG_APBAND_2G_OLD = 0 + WIFI_CONFIG_APBAND_5G_OLD = 1 + WIFI_CONFIG_APBAND_AUTO_OLD = -1 WIFI_WPS_INFO_PBC = 0 WIFI_WPS_INFO_DISPLAY = 1 @@ -98,6 +121,12 @@ class WifiEnums(): WIFI_WPS_INFO_LABEL = 3 WIFI_WPS_INFO_INVALID = 4 + class SoftApSecurityType(): + OPEN = "NONE" + WPA2 = "WPA2_PSK" + WPA3_SAE_TRANSITION = "WPA3_SAE_TRANSITION" + WPA3_SAE = "WPA3_SAE" + class CountryCode(): CHINA = "CN" JAPAN = "JP" @@ -147,6 +176,7 @@ class WifiEnums(): FQDN = "FQDN" FRIENDLY_NAME = "providerFriendlyName" ROAMING_IDS = "roamingConsortiumIds" + OCSP = "ocsp" # End of Macros for EAP # Macros for wifi p2p. @@ -642,6 +672,7 @@ def _wifi_toggle_state(ad, new_state=None): ad.ed.clear_all_events() # Setting wifi state. ad.droid.wifiToggleState(new_state) + time.sleep(2) fail_msg = "Failed to set Wi-Fi state to %s on %s." % (new_state, ad.serial) try: @@ -923,7 +954,7 @@ def start_wifi_tethering(ad, ssid, password, band=None, hidden=None): if password: config[WifiEnums.PWD_KEY] = password if band: - config[WifiEnums.APBAND_KEY] = band + config[WifiEnums.AP_BAND_KEY] = band if hidden: config[WifiEnums.HIDDEN_KEY] = hidden asserts.assert_true( @@ -943,20 +974,121 @@ def start_wifi_tethering(ad, ssid, password, band=None, hidden=None): ad.droid.wifiStopTrackingTetherStateChange() -def save_wifi_soft_ap_config(ad, wifi_config, band=None, hidden=None): - """ Save a soft ap configuration """ +def save_wifi_soft_ap_config(ad, wifi_config, band=None, hidden=None, + security=None, password=None, + channel=None, max_clients=None, + shutdown_timeout_enable=None, + shutdown_timeout_millis=None, + client_control_enable=None, + allowedList=None, blockedList=None): + """ Save a soft ap configuration and verified + Args: + ad: android_device to set soft ap configuration. + wifi_config: a soft ap configuration object, at least include SSID. + band: specifies the band for the soft ap. + hidden: specifies the soft ap need to broadcast its SSID or not. + security: specifies the security type for the soft ap. + password: specifies the password for the soft ap. + channel: specifies the channel for the soft ap. + max_clients: specifies the maximum connected client number. + shutdown_timeout_enable: specifies the auto shut down enable or not. + shutdown_timeout_millis: specifies the shut down timeout value. + client_control_enable: specifies the client control enable or not. + allowedList: specifies allowed clients list. + blockedList: specifies blocked clients list. + """ + if security and password: + wifi_config[WifiEnums.SECURITY] = security + wifi_config[WifiEnums.PWD_KEY] = password if band: - wifi_config[WifiEnums.APBAND_KEY] = band + wifi_config[WifiEnums.AP_BAND_KEY] = band if hidden: wifi_config[WifiEnums.HIDDEN_KEY] = hidden + if channel and band: + wifi_config[WifiEnums.AP_BAND_KEY] = band + wifi_config[WifiEnums.AP_CHANNEL_KEY] = channel + if max_clients: + wifi_config[WifiEnums.AP_MAXCLIENTS_KEY] = max_clients + if shutdown_timeout_enable: + wifi_config[ + WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY] = shutdown_timeout_enable + if shutdown_timeout_millis: + wifi_config[ + WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] = shutdown_timeout_millis + if client_control_enable: + wifi_config[WifiEnums.AP_CLIENTCONTROL_KEY] = client_control_enable + if allowedList: + wifi_config[WifiEnums.AP_ALLOWEDLIST_KEY] = allowedList + if blockedList: + wifi_config[WifiEnums.AP_BLOCKEDLIST_KEY] = blockedList + + if WifiEnums.AP_CHANNEL_KEY in wifi_config and wifi_config[ + WifiEnums.AP_CHANNEL_KEY] == 0: + del wifi_config[WifiEnums.AP_CHANNEL_KEY] + + if WifiEnums.SECURITY in wifi_config and wifi_config[ + WifiEnums.SECURITY] == WifiEnums.SoftApSecurityType.OPEN: + del wifi_config[WifiEnums.SECURITY] + del wifi_config[WifiEnums.PWD_KEY] + asserts.assert_true(ad.droid.wifiSetWifiApConfiguration(wifi_config), "Failed to set WifiAp Configuration") wifi_ap = ad.droid.wifiGetApConfiguration() asserts.assert_true( wifi_ap[WifiEnums.SSID_KEY] == wifi_config[WifiEnums.SSID_KEY], - "Hotspot SSID doesn't match with expected SSID") + "Hotspot SSID doesn't match") + if WifiEnums.SECURITY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.SECURITY] == wifi_config[WifiEnums.SECURITY], + "Hotspot Security doesn't match") + if WifiEnums.PWD_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.PWD_KEY] == wifi_config[WifiEnums.PWD_KEY], + "Hotspot Password doesn't match") + if WifiEnums.HIDDEN_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.HIDDEN_KEY] == wifi_config[WifiEnums.HIDDEN_KEY], + "Hotspot hidden setting doesn't match") + + if WifiEnums.AP_BAND_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_BAND_KEY] == wifi_config[WifiEnums.AP_BAND_KEY], + "Hotspot Band doesn't match") + if WifiEnums.AP_CHANNEL_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_CHANNEL_KEY] == wifi_config[ + WifiEnums.AP_CHANNEL_KEY], "Hotspot Channel doesn't match") + if WifiEnums.AP_MAXCLIENTS_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_MAXCLIENTS_KEY] == wifi_config[ + WifiEnums.AP_MAXCLIENTS_KEY], "Hotspot Max Clients doesn't match") + if WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY] == wifi_config[ + WifiEnums.AP_SHUTDOWNTIMEOUTENABLE_KEY], + "Hotspot ShutDown feature flag doesn't match") + if WifiEnums.AP_SHUTDOWNTIMEOUT_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_SHUTDOWNTIMEOUT_KEY] == wifi_config[ + WifiEnums.AP_SHUTDOWNTIMEOUT_KEY], + "Hotspot ShutDown timeout setting doesn't match") + if WifiEnums.AP_CLIENTCONTROL_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_CLIENTCONTROL_KEY] == wifi_config[ + WifiEnums.AP_CLIENTCONTROL_KEY], + "Hotspot Client control flag doesn't match") + if WifiEnums.AP_ALLOWEDLIST_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_ALLOWEDLIST_KEY] == wifi_config[ + WifiEnums.AP_ALLOWEDLIST_KEY], + "Hotspot Allowed List doesn't match") + if WifiEnums.AP_BLOCKEDLIST_KEY in wifi_config: + asserts.assert_true( + wifi_ap[WifiEnums.AP_BLOCKEDLIST_KEY] == wifi_config[ + WifiEnums.AP_BLOCKEDLIST_KEY], + "Hotspot Blocked List doesn't match") def start_wifi_tethering_saved_config(ad): """ Turn on wifi hotspot with a config that is already saved """ @@ -974,7 +1106,6 @@ def start_wifi_tethering_saved_config(ad): def stop_wifi_tethering(ad): """Stops wifi tethering on an android_device. - Args: ad: android_device to stop wifi tethering on. """ @@ -1029,7 +1160,7 @@ def toggle_wifi_and_wait_for_reconnection(ad, num_of_tries=num_of_tries) -def _toggle_wifi_and_wait_for_reconnection(ad, network, num_of_tries=1): +def _toggle_wifi_and_wait_for_reconnection(ad, network, num_of_tries=3): """Toggle wifi state and then wait for Android device to reconnect to the provided wifi network. @@ -1345,11 +1476,8 @@ def _wifi_connect(ad, network, num_of_tries=1, check_connectivity=True): ad.serial) ad.log.info("Connected to Wi-Fi network %s.", actual_ssid) - # Wait for data connection to stabilize. - time.sleep(5) - if check_connectivity: - internet = validate_connection(ad, DEFAULT_PING_ADDR, 10) + internet = validate_connection(ad, DEFAULT_PING_ADDR) if not internet: raise signals.TestFailure("Failed to connect to internet on %s" % expected_ssid) @@ -1422,9 +1550,6 @@ def _wifi_connect_by_id(ad, network_id, num_of_tries=1): ad.log.info("Connected to Wi-Fi network %s with %d network id.", expected_ssid, network_id) - # Wait for data connection to stabilize. - time.sleep(5) - internet = validate_connection(ad, DEFAULT_PING_ADDR) if not internet: raise signals.TestFailure("Failed to connect to internet on %s" % @@ -1652,9 +1777,6 @@ def _wifi_passpoint_connect(ad, passpoint_network, num_of_tries=1): "Connected to the wrong network on %s." % ad.serial) ad.log.info("Connected to Wi-Fi passpoint network %s.", actual_ssid) - # Wait for data connection to stabilize. - time.sleep(5) - internet = validate_connection(ad, DEFAULT_PING_ADDR) if not internet: raise signals.TestFailure("Failed to connect to internet on %s" % @@ -1782,7 +1904,8 @@ def convert_pem_key_to_pkcs8(in_file, out_file): utils.exe_cmd(cmd) -def validate_connection(ad, ping_addr=DEFAULT_PING_ADDR, wait_time=2): +def validate_connection(ad, ping_addr=DEFAULT_PING_ADDR, wait_time=15, + ping_gateway=True): """Validate internet connection by pinging the address provided. Args: @@ -1794,9 +1917,22 @@ def validate_connection(ad, ping_addr=DEFAULT_PING_ADDR, wait_time=2): ping output if successful, NULL otherwise. """ # wait_time to allow for DHCP to complete. - time.sleep(wait_time) - ping = ad.droid.httpPing(ping_addr) - ad.log.info("Http ping result: %s.", ping) + for i in range(wait_time): + if ad.droid.connectivityNetworkIsConnected(): + break + time.sleep(1) + ping = False + try: + ping = ad.droid.httpPing(ping_addr) + ad.log.info("Http ping result: %s.", ping) + except: + pass + if not ping and ping_gateway: + ad.log.info("Http ping failed. Pinging default gateway") + gw = ad.droid.connectivityGetIPv4DefaultGateway() + result = ad.adb.shell("ping -c 6 {}".format(gw)) + ad.log.info("Default gateway ping result: %s" % result) + ping = False if "100% packet loss" in result else True return ping @@ -1952,12 +2088,13 @@ def group_attenuators(attenuators): return [attn0, attn1] -def set_attns(attenuator, attn_val_name): +def set_attns(attenuator, attn_val_name, roaming_attn=ROAMING_ATTN): """Sets attenuation values on attenuators used in this test. Args: attenuator: The attenuator object. attn_val_name: Name of the attenuation value pair to use. + roaming_attn: Dictionary specifying the attenuation params. """ logging.info("Set attenuation values to %s", roaming_attn[attn_val_name]) try: @@ -1970,7 +2107,11 @@ def set_attns(attenuator, attn_val_name): attn_val_name) raise -def set_attns_steps(attenuators, atten_val_name, steps=10, wait_time=12): +def set_attns_steps(attenuators, + atten_val_name, + roaming_attn=ROAMING_ATTN, + steps=10, + wait_time=12): """Set attenuation values on attenuators used in this test. It will change the attenuation values linearly from current value to target value step by step. @@ -1979,6 +2120,7 @@ def set_attns_steps(attenuators, atten_val_name, steps=10, wait_time=12): attenuators: The list of attenuator objects that you want to change their attenuation value. atten_val_name: Name of the attenuation value pair to use. + roaming_attn: Dictionary specifying the attenuation params. steps: Number of attenuator changes to reach the target value. wait_time: Sleep time for each change of attenuator. """ @@ -1994,7 +2136,11 @@ def set_attns_steps(attenuators, atten_val_name, steps=10, wait_time=12): time.sleep(wait_time) -def trigger_roaming_and_validate(dut, attenuator, attn_val_name, expected_con): +def trigger_roaming_and_validate(dut, + attenuator, + attn_val_name, + expected_con, + roaming_attn=ROAMING_ATTN): """Sets attenuators to trigger roaming and validate the DUT connected to the BSSID expected. @@ -2002,14 +2148,13 @@ def trigger_roaming_and_validate(dut, attenuator, attn_val_name, expected_con): attenuator: The attenuator object. attn_val_name: Name of the attenuation value pair to use. expected_con: The network information of the expected network. + roaming_attn: Dictionary specifying the attenaution params. """ expected_con = { WifiEnums.SSID_KEY: expected_con[WifiEnums.SSID_KEY], WifiEnums.BSSID_KEY: expected_con["bssid"], } - set_attns(attenuator, attn_val_name) - logging.info("Wait %ss for roaming to finish.", ROAMING_TIMEOUT) - time.sleep(ROAMING_TIMEOUT) + set_attns_steps(attenuator, attn_val_name, roaming_attn) verify_wifi_connection_info(dut, expected_con) expected_bssid = expected_con[WifiEnums.BSSID_KEY] @@ -2038,6 +2183,13 @@ def start_softap_and_verify(ad, band): Returns: dict, the softAP config. """ + # Register before start the test. + callbackId = ad.dut.droid.registerSoftApCallback() + # Check softap info value is default + frequency, bandwdith = get_current_softap_info(ad.dut, callbackId, True) + asserts.assert_true(frequency == 0, "Softap frequency is not reset") + asserts.assert_true(bandwdith == 0, "Softap bandwdith is not reset") + config = create_softap_config() start_wifi_tethering(ad.dut, config[WifiEnums.SSID_KEY], @@ -2046,6 +2198,15 @@ def start_softap_and_verify(ad, band): "SoftAp is not reported as running") start_wifi_connection_scan_and_ensure_network_found(ad.dut_client, config[WifiEnums.SSID_KEY]) + + # Check softap info can get from callback succeed and assert value should be + # valid. + frequency, bandwdith = get_current_softap_info(ad.dut, callbackId, True) + asserts.assert_true(frequency > 0, "Softap frequency is not valid") + asserts.assert_true(bandwdith > 0, "Softap bandwdith is not valid") + # Unregister callback + ad.dut.droid.unregisterSoftApCallback(callbackId) + return config def wait_for_expected_number_of_softap_clients(ad, callbackId, @@ -2057,11 +2218,28 @@ def wait_for_expected_number_of_softap_clients(ad, callbackId, """ eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( callbackId) + wifi_constants.SOFTAP_NUMBER_CLIENTS_CHANGED - asserts.assert_equal(ad.ed.pop_event(eventStr, - SHORT_TIMEOUT)['data'][wifi_constants. - SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY], - expected_num_of_softap_clients, - "Number of softap clients doesn't match with expected number") + clientData = ad.ed.pop_event(eventStr, SHORT_TIMEOUT)['data'] + clientCount = clientData[wifi_constants.SOFTAP_NUMBER_CLIENTS_CALLBACK_KEY] + clientMacAddresses = clientData[wifi_constants.SOFTAP_CLIENTS_MACS_CALLBACK_KEY] + asserts.assert_equal(clientCount, expected_num_of_softap_clients, + "The number of softap clients doesn't match the expected number") + asserts.assert_equal(len(clientMacAddresses), expected_num_of_softap_clients, + "The number of mac addresses doesn't match the expected number") + for macAddress in clientMacAddresses: + asserts.assert_true(checkMacAddress(macAddress), "An invalid mac address was returned") + +def checkMacAddress(input): + """Validate whether a string is a valid mac address or not. + + Args: + input: The string to validate. + + Returns: True/False, returns true for a valid mac address and false otherwise. + """ + macValidationRegex = "[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$" + if re.match(macValidationRegex, input.lower()): + return True + return False def wait_for_expected_softap_state(ad, callbackId, expected_softap_state): """Wait for the expected softap state change. @@ -2096,6 +2274,41 @@ def get_current_number_of_softap_clients(ad, callbackId): return None return num_of_clients +def get_current_softap_info(ad, callbackId, least_one): + """pop up all of softap info changed event from queue. + Args: + callbackId: Id of the callback associated with registering. + least_one: Wait for the info callback event before pop all. + Returns: + Returns last updated information of softap. + """ + eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( + callbackId) + wifi_constants.SOFTAP_INFO_CHANGED + ad.log.info("softap info dump from eventStr %s", + eventStr) + frequency = 0 + bandwidth = 0 + if (least_one): + event = ad.ed.pop_event(eventStr, SHORT_TIMEOUT) + frequency = event['data'][wifi_constants. + SOFTAP_INFO_FREQUENCY_CALLBACK_KEY] + bandwidth = event['data'][wifi_constants. + SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY] + ad.log.info("softap info updated, frequency is %s, bandwidth is %s", + frequency, bandwidth) + + events = ad.ed.pop_all(eventStr) + for event in events: + frequency = event['data'][wifi_constants. + SOFTAP_INFO_FREQUENCY_CALLBACK_KEY] + bandwidth = event['data'][wifi_constants. + SOFTAP_INFO_BANDWIDTH_CALLBACK_KEY] + ad.log.info("softap info, frequency is %s, bandwidth is %s", + frequency, bandwidth) + return frequency, bandwidth + + + def get_ssrdumps(ad, test_name=""): """Pulls dumps in the ssrdump dir Args: @@ -2155,30 +2368,33 @@ def stop_pcap(pcap, procs, test_status=None): if test_status: shutil.rmtree(os.path.dirname(fname)) -def verify_mac_not_found_in_pcap(mac, packets): +def verify_mac_not_found_in_pcap(ad, mac, packets): """Verify that a mac address is not found in the captured packets. Args: + ad: android device object mac: string representation of the mac address packets: packets obtained by rdpcap(pcap_fname) """ for pkt in packets: logging.debug("Packet Summary = %s", pkt.summary()) if mac in pkt.summary(): - asserts.fail("Caught Factory MAC: %s in packet sniffer." - "Packet = %s" % (mac, pkt.show())) + asserts.fail("Device %s caught Factory MAC: %s in packet sniffer." + "Packet = %s" % (ad.serial, mac, pkt.show())) -def verify_mac_is_found_in_pcap(mac, packets): +def verify_mac_is_found_in_pcap(ad, mac, packets): """Verify that a mac address is found in the captured packets. Args: + ad: android device object mac: string representation of the mac address packets: packets obtained by rdpcap(pcap_fname) """ for pkt in packets: if mac in pkt.summary(): return - asserts.fail("Did not find MAC = %s in packet sniffer." % mac) + asserts.fail("Did not find MAC = %s in packet sniffer." + "for device %s" % (mac, ad.serial)) def start_cnss_diags(ads): for ad in ads: diff --git a/acts/framework/acts/tracelogger.py b/acts/framework/acts/tracelogger.py index c7d920fcdb..d230fadd0f 100644 --- a/acts/framework/acts/tracelogger.py +++ b/acts/framework/acts/tracelogger.py @@ -14,11 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import datetime import inspect -import logging import os -import xml.etree.cElementTree as et class TraceLogger(object): @@ -65,41 +62,3 @@ class TraceLogger(object): def __getattr__(self, name): return getattr(self._logger, name) - - -class TakoTraceLogger(TraceLogger): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) - self.d = self.debug - self.e = self.error - self.i = self.info - self.t = self.step - self.w = self.warning - - def _logger_level(self, level_name): - level = logging.getLevelName(level_name) - return lambda *args, **kwargs: self._logger.log(level, *args, **kwargs) - - def step(self, msg, *args, **kwargs): - """Delegate a step call to the underlying logger.""" - self._log_with(self._logger_level('STEP'), 1, msg, *args, **kwargs) - - def device(self, msg, *args, **kwargs): - """Delegate a device call to the underlying logger.""" - self._log_with(self._logger_level('DEVICE'), 1, msg, *args, **kwargs) - - def suite(self, msg, *args, **kwargs): - """Delegate a device call to the underlying logger.""" - self._log_with(self._logger_level('SUITE'), 1, msg, *args, **kwargs) - - def case(self, msg, *args, **kwargs): - """Delegate a case call to the underlying logger.""" - self._log_with(self._logger_level('CASE'), 1, msg, *args, **kwargs) - - def flush_log(self): - """This function exists for compatibility with Tako's logserial module. - - Note that flushing the log is handled automatically by python's logging - module. - """ - pass diff --git a/acts/framework/acts/utils.py b/acts/framework/acts/utils.py index c38f7c145d..3f57c91bdb 100755 --- a/acts/framework/acts/utils.py +++ b/acts/framework/acts/utils.py @@ -556,7 +556,6 @@ def timeout(sec): Raises: TimeoutError is raised when time out happens. """ - def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): @@ -952,10 +951,7 @@ def adb_shell_ping(ad, default www.google.com timeout: timeout for icmp pings to complete. """ - if is_valid_ipv6_address(dest_ip): - ping_cmd = "ping6 -W 1" - else: - ping_cmd = "ping -W 1" + ping_cmd = "ping -W 1" if count: ping_cmd += " -c %d" % count if dest_ip: @@ -1288,7 +1284,6 @@ class SuppressLogOutput(object): """Context manager used to suppress all logging output for the specified logger and level(s). """ - def __init__(self, logger=logging.getLogger(), log_levels=None): """Create a SuppressLogOutput context manager @@ -1321,7 +1316,6 @@ class BlockingTimer(object): """Context manager used to block until a specified amount of time has elapsed. """ - def __init__(self, secs): """Initializes a BlockingTimer @@ -1393,7 +1387,7 @@ def get_interface_ip_addresses(comm_channel, interface): Returns: A list of dictionaries of the the various IP addresses: - ipv4_private_local_addresses: Any 192.168, 172.16, 10, or 169.254 + ipv4_private_local_addresses: Any 192.168, 172.16, or 10 addresses ipv4_public_addresses: Any IPv4 public addresses ipv6_link_local_addresses: Any fe80:: addresses @@ -1501,6 +1495,14 @@ def get_interface_based_on_ip(comm_channel, desired_ip_address): all_ips_and_interfaces = comm_channel.run( '(ip -o -4 addr show; ip -o -6 addr show) | ' 'awk \'{print $2" "$4}\'').stdout + #ipv4_addresses = comm_channel.run( + # 'ip -o -4 addr show| awk \'{print $2": "$4}\'').stdout + #ipv6_addresses = comm_channel._ssh_session.run( + # 'ip -o -6 addr show| awk \'{print $2": "$4}\'').stdout + #if desired_ip_address in ipv4_addresses: + # ip_addresses_to_search = ipv4_addresses + #elif desired_ip_address in ipv6_addresses: + # ip_addresses_to_search = ipv6_addresses for ip_address_and_interface in all_ips_and_interfaces.split('\n'): if desired_ip_address in ip_address_and_interface: return ip_address_and_interface.split()[1][:-1] @@ -1510,54 +1512,189 @@ def get_interface_based_on_ip(comm_channel, desired_ip_address): def renew_linux_ip_address(comm_channel, interface): comm_channel.run('sudo ifconfig %s down' % interface) comm_channel.run('sudo ifconfig %s up' % interface) - comm_channel.run('sudo killall dhcpcd 2>/dev/null; echo""') - is_dhcpcd_dead = False - dhcpcd_counter = 0 - dhcpcd_checker_max_times = 3 - while not is_dhcpcd_dead: - if dhcpcd_counter == dhcpcd_checker_max_times: - raise TimeoutError('Unable to stop dhcpcd') - time.sleep(1) - if 'dhcpcd' in comm_channel.run('ps axu').stdout: - dhcpcd_counter += 1 - else: - is_dhcpcd_dead = True - comm_channel.run('sudo dhcpcd -q -b') comm_channel.run('sudo dhclient -r %s' % interface) comm_channel.run('sudo dhclient %s' % interface) -def is_pingable(ip): - """Returns whether an ip is pingable or not. +def get_ping_command(dest_ip, + count=3, + interval=1000, + timeout=1000, + size=56, + os_type='Linux', + additional_ping_params=None): + """Builds ping command string based on address type, os, and params. Args: - ip: string, ip address to ping + dest_ip: string, address to ping (ipv4 or ipv6) + count: int, number of requests to send + interval: int, time in seconds between requests + timeout: int, time in seconds to wait for response + size: int, number of bytes to send, + os_type: string, os type of the source device (supports 'Linux', + 'Darwin') + additional_ping_params: string, command option flags to + append to the command string + Returns: - True if ping was successful, else False + List of string, represetning the ping command. """ - if is_valid_ipv4_address(ip): + if is_valid_ipv4_address(dest_ip): ping_binary = 'ping' - elif is_valid_ipv6_address(ip): + elif is_valid_ipv6_address(dest_ip): ping_binary = 'ping6' else: - raise ValueError('Invalid ip addr: %s' % ip) + raise ValueError('Invalid ip addr: %s' % dest_ip) - os_type = platform.system() if os_type == 'Darwin': - if is_valid_ipv6_address(ip): + if is_valid_ipv6_address(dest_ip): # ping6 on MacOS doesn't support timeout + logging.warn( + 'Ignoring timeout, as ping6 on MacOS does not support it.') timeout_flag = [] else: - timeout_flag = ['-t', '1'] + timeout_flag = ['-t', str(timeout / 1000)] elif os_type == 'Linux': - timeout_flag = ['-W', '1'] + timeout_flag = ['-W', str(timeout / 1000)] else: raise ValueError('Invalid OS. Only Linux and MacOS are supported.') - ping_cmd = [ping_binary, *timeout_flag, '-c', '1', ip] + if not additional_ping_params: + additional_ping_params = '' + + ping_cmd = [ + ping_binary, *timeout_flag, '-c', + str(count), '-i', + str(interval / 1000), '-s', + str(size), additional_ping_params, dest_ip + ] + return ' '.join(ping_cmd) + + +def ping(comm_channel, + dest_ip, + count=3, + interval=1000, + timeout=1000, + size=56, + additional_ping_params=None): + """ Generic linux ping function, supports local (acts.libs.proc.job) and + SshConnections (acts.libs.proc.job over ssh) to Linux based OSs and MacOS. + + NOTES: This will work with Android over SSH, but does not function over ADB + as that has a unique return format. + + Args: + comm_channel: communication channel over which to send ping command. + Must have 'run' function that returns at least command, stdout, + stderr, and exit_status (see acts.libs.proc.job) + dest_ip: address to ping (ipv4 or ipv6) + count: int, number of packets to send + interval: int, time in milliseconds between pings + timeout: int, time in milliseconds to wait for response + size: int, size of packets in bytes + additional_ping_params: string, command option flags to + append to the command string + + Returns: + Dict containing: + command: string + exit_status: int (0 or 1) + stdout: string + stderr: string + transmitted: int, number of packets transmitted + received: int, number of packets received + packet_loss: int, percentage packet loss + time: int, time of ping command execution (in milliseconds) + rtt_min: float, minimum round trip time + rtt_avg: float, average round trip time + rtt_max: float, maximum round trip time + rtt_mdev: float, round trip time standard deviation + + Any values that cannot be parsed are left as None + """ + from acts.controllers.utils_lib.ssh.connection import SshConnection + is_local = comm_channel == job + os_type = platform.system() if is_local else 'Linux' + ping_cmd = get_ping_command(dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + os_type=os_type, + additional_ping_params=additional_ping_params) + + if (type(comm_channel) is SshConnection or is_local): + logging.debug( + 'Running ping with parameters (count: %s, interval: %s, timeout: ' + '%s, size: %s)' % (count, interval, timeout, size)) + ping_result = comm_channel.run(ping_cmd, ignore_status=True) + else: + raise ValueError('Unsupported comm_channel: %s' % type(comm_channel)) + + if isinstance(ping_result, job.Error): + ping_result = ping_result.result + + transmitted = None + received = None + packet_loss = None + time = None + rtt_min = None + rtt_avg = None + rtt_max = None + rtt_mdev = None + + summary = re.search( + '([0-9]+) packets transmitted.*?([0-9]+) received.*?([0-9]+)% packet ' + 'loss.*?time ([0-9]+)', ping_result.stdout) + if summary: + transmitted = summary[1] + received = summary[2] + packet_loss = summary[3] + time = summary[4] + + rtt_stats = re.search('= ([0-9.]+)/([0-9.]+)/([0-9.]+)/([0-9.]+)', + ping_result.stdout) + if rtt_stats: + rtt_min = rtt_stats[1] + rtt_avg = rtt_stats[2] + rtt_max = rtt_stats[3] + rtt_mdev = rtt_stats[4] + + return { + 'command': ping_result.command, + 'exit_status': ping_result.exit_status, + 'stdout': ping_result.stdout, + 'stderr': ping_result.stderr, + 'transmitted': transmitted, + 'received': received, + 'packet_loss': packet_loss, + 'time': time, + 'rtt_min': rtt_min, + 'rtt_avg': rtt_avg, + 'rtt_max': rtt_max, + 'rtt_mdev': rtt_mdev + } + - result = job.run(ping_cmd, timeout=10, ignore_status=True) - return result.exit_status == 0 +def can_ping(comm_channel, + dest_ip, + count=1, + interval=1000, + timeout=1000, + size=56, + additional_ping_params=None): + """Returns whether device connected via comm_channel can ping a dest + address""" + ping_results = ping(comm_channel, + dest_ip, + count=count, + interval=interval, + timeout=timeout, + size=size, + additional_ping_params=additional_ping_params) + + return ping_results['exit_status'] == 0 def ip_in_subnet(ip, subnet): diff --git a/acts/framework/tests/acts_utils_test.py b/acts/framework/tests/acts_utils_test.py index a08bf370bd..900a1e97a5 100755 --- a/acts/framework/tests/acts_utils_test.py +++ b/acts/framework/tests/acts_utils_test.py @@ -173,6 +173,7 @@ FUCHSIA_INIT_NETSTACK = ('acts.controllers.fuchsia_lib.netstack.' class ByPassSetupWizardTests(unittest.TestCase): """This test class for unit testing acts.utils.bypass_setup_wizard.""" + def test_start_standing_subproc(self): with self.assertRaisesRegex(utils.ActsUtilsError, 'Process .* has terminated'): @@ -306,6 +307,7 @@ class BypassSetupWizardReturn: class ConcurrentActionsTest(unittest.TestCase): """Tests acts.utils.run_concurrent_actions and related functions.""" + @staticmethod def function_returns_passed_in_arg(arg): return arg @@ -389,6 +391,7 @@ class ConcurrentActionsTest(unittest.TestCase): class SuppressLogOutputTest(unittest.TestCase): """Tests SuppressLogOutput""" + def test_suppress_log_output(self): """Tests that the SuppressLogOutput context manager removes handlers of the specified levels upon entry and re-adds handlers upon exit. @@ -411,6 +414,7 @@ class SuppressLogOutputTest(unittest.TestCase): class IpAddressUtilTest(unittest.TestCase): + def test_positive_ipv4_normal_address(self): ip_address = "192.168.1.123" self.assertTrue(utils.is_valid_ipv4_address(ip_address)) @@ -501,22 +505,20 @@ class IpAddressUtilTest(unittest.TestCase): utils.get_interface_ip_addresses(SshConnection('mock_settings'), 'wlan1'), CORRECT_EMPTY_IP_LIST) - @mock.patch('acts.controllers.adb.AdbProxy') + @mock.patch('acts.controllers.adb.AdbProxy.shell') def test_android_get_interface_ip_addresses_full(self, adb_mock): adb_mock().shell.side_effect = [ MOCK_IP_ADDRESSES, MOCK_IFCONFIG_OUTPUT ] self.assertEqual( utils.get_interface_ip_addresses(AndroidDevice(), 'eno1'), - CORRECT_FULL_IP_LIST) + CORRECT_FULL_IP_LIST) - @mock.patch('acts.controllers.adb.AdbProxy') + @mock.patch('acts.controllers.adb.AdbProxy.shell') def test_android_get_interface_ip_addresses_empty(self, adb_mock): - adb_mock().shell.side_effect = [ - MOCK_IP_ADDRESSES, MOCK_IFCONFIG_OUTPUT - ] - self.assertEqual( - utils.get_interface_ip_addresses(AndroidDevice(), 'wlan1'), + adb_mock.side_effect = [MOCK_IP_ADDRESSES, MOCK_IFCONFIG_OUTPUT] + self.assertTrue( + utils.get_interface_ip_addresses(AndroidDevice(), 'wlan1') == CORRECT_EMPTY_IP_LIST) @mock.patch(FUCHSIA_INIT_SERVER) diff --git a/acts/framework/tests/test_utils/instrumentation/__init__.py b/acts/framework/tests/test_utils/instrumentation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/__init__.py diff --git a/acts/framework/tests/test_utils/instrumentation/config_wrapper_test.py b/acts/framework/tests/test_utils/instrumentation/config_wrapper_test.py new file mode 100755 index 0000000000..18a420fed0 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/config_wrapper_test.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import mock +import unittest + +from acts.test_utils.instrumentation.config_wrapper import ConfigWrapper +from acts.test_utils.instrumentation.config_wrapper import InvalidParamError + + +REAL_PATHS = ['realpath/1', 'realpath/2'] +MOCK_CONFIG = { + 'big_int': 50000, + 'small_int': 5, + 'float': 7.77, + 'string': 'insert text here', + 'real_paths_only': REAL_PATHS, + 'real_and_fake_paths': [ + 'realpath/1', 'fakepath/0' + ], + 'inner_config': { + 'inner_val': 16 + } +} + + +class ConfigWrapperTest(unittest.TestCase): + """Unit tests for the Config Wrapper.""" + def setUp(self): + self.mock_config = ConfigWrapper(MOCK_CONFIG) + + def test_get_returns_correct_value(self): + """Test that get() returns the correct param value.""" + self.assertEqual(self.mock_config.get('big_int'), + MOCK_CONFIG['big_int']) + + def test_get_missing_param_returns_default(self): + """Test that get() returns the default value if no param with the + requested name is found. + """ + default_val = 17 + self.assertEqual(self.mock_config.get('missing', default=default_val), + default_val) + + def test_get_with_custom_verification_method(self): + """Test that get() verifies the param with the user-provided test + function. + """ + verifier = lambda i: i > 100 + msg = 'Value too small' + self.assertEqual(self.mock_config.get('big_int', verify_fn=verifier, + failure_msg=msg), + MOCK_CONFIG['big_int']) + with self.assertRaisesRegex(InvalidParamError, msg): + self.mock_config.get('small_int', verify_fn=verifier, + failure_msg=msg) + + def test_get_config(self): + """Test that get_config() returns an empty ConfigWrapper if no + sub-config exists with the given name. + """ + ret = self.mock_config.get_config('missing') + self.assertIsInstance(ret, ConfigWrapper) + self.assertFalse(ret) + + def test_get_int(self): + """Test that get_int() returns the value if it is an int, and raises + an exception if it isn't. + """ + self.assertEqual(self.mock_config.get_int('small_int'), + MOCK_CONFIG['small_int']) + with self.assertRaisesRegex(InvalidParamError, 'of type int'): + self.mock_config.get_int('float') + + def test_get_numeric(self): + """Test that get_numeric() returns the value if it is an int or float, + and raises an exception if it isn't. + """ + self.assertEqual(self.mock_config.get_numeric('small_int'), + MOCK_CONFIG['small_int']) + self.assertEqual(self.mock_config.get_numeric('float'), + MOCK_CONFIG['float']) + with self.assertRaisesRegex(InvalidParamError, 'of type int or float'): + self.mock_config.get_numeric('string') + + def test_config_wrapper_wraps_recursively(self): + """Test that dict values within the input config get transformed into + ConfigWrapper objects themselves. + """ + self.assertTrue( + isinstance(self.mock_config.get('inner_config'), ConfigWrapper)) + self.assertEqual( + self.mock_config.get('inner_config').get_int('inner_val'), 16) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/data/sample.instrumentation_data_proto b/acts/framework/tests/test_utils/instrumentation/data/sample.instrumentation_data_proto new file mode 100644 index 0000000000..42892d5f08 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/data/sample.instrumentation_data_proto @@ -0,0 +1,6 @@ +a]INSTRUMENTATION_FAILED: com.google.android.powertests/androidx.test.runner.AndroidJUnitRunner +¬"§ +† +Error}Unable to find instrumentation info for: ComponentInfo{com.google.android.powertests/androidx.test.runner.AndroidJUnitRunner} + +idActivityManagerService
\ No newline at end of file diff --git a/acts/framework/tests/test_utils/instrumentation/data/sample_instrumentation_proto.txt b/acts/framework/tests/test_utils/instrumentation/data/sample_instrumentation_proto.txt new file mode 100644 index 0000000000..6de10d7e0e --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/data/sample_instrumentation_proto.txt @@ -0,0 +1,17 @@ +test_status { + result_code: -1 + results { + entries { + key: "Error" + value_string: "Unable to find instrumentation info for: ComponentInfo{com.google.android.powertests/androidx.test.runner.AndroidJUnitRunner}" + } + entries { + key: "id" + value_string: "ActivityManagerService" + } + } +} +session_status { + status_code: SESSION_ABORTED + error_text: "INSTRUMENTATION_FAILED: com.google.android.powertests/androidx.test.runner.AndroidJUnitRunner" +} diff --git a/acts/framework/tests/test_utils/instrumentation/data/sample_monsoon_data b/acts/framework/tests/test_utils/instrumentation/data/sample_monsoon_data new file mode 100644 index 0000000000..2a70273694 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/data/sample_monsoon_data @@ -0,0 +1,10 @@ +0s 3.67 +1s 3.69 +2s 0.95 +3s 3.06 +4s 2.17 +5s 1.62 +6s 3.95 +7s 2.47 +8s 1.11 +9s 0.47 diff --git a/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp.instrumentation_data_proto b/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp.instrumentation_data_proto new file mode 100644 index 0000000000..ecc75a50c7 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp.instrumentation_data_proto @@ -0,0 +1,94 @@ + +Æ"Á +6 +class-com.google.android.powertests.PartialWakelock + +current + +idAndroidJUnitRunner + +numtests +9 +stream/ +com.google.android.powertests.PartialWakelock: + +testpartialWakelock +À#"Ž +6 +class-com.google.android.powertests.PartialWakelock + +start-timestamp + +testpartialWakelock + + timestamp0Ôá—¤›[ + +timestamps-message*¬"--------- beginning of main +08-28 15:05:16.598 10178 7664 7664 I MonitoringInstr: Activities that are still in CREATED to STOPPED: 0 +08-28 15:05:16.601 10178 7664 7696 D com.google.android.powertests.PartialWakelock: fixture setup +08-28 15:05:16.601 10178 7664 7696 I com.android.test.power.utils.Screen: Setting Screen Off +08-28 15:05:16.684 10117 2426 7573 I ChromeSync: [Persistence,AffiliationManager] Fetching affiliations from the server. +08-28 15:05:16.721 10117 2426 7573 E ChromeSync: [Sync,SyncIntentOperation] Error handling the intent: Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.google.android.powertests flg=0x4000010 cmp=com.google.android.gms/.chimera.GmsIntentOperationService (has extras) }. +08-28 15:05:16.736 10117 2426 31227 I Icing : IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=AppsCorpus serviceId=32 +08-28 15:05:16.737 10117 2426 16984 I Icing : IndexChimeraService.getServiceInterface callingPackage=com.google.android.gms componentName=AppsCorpus serviceId=36 +--------- beginning of system +08-28 15:05:16.774 1000 940 2043 W ProcessStats: Tracking association SourceState{7e3b0a1 com.google.android.gms.persistent/10117 ImpFg #71619} whose proc state 2 is better than process ProcessState{55175ae com.google.android.gms/10117 pkg=com.google.android.gms} proc state 3 (73 skipped) +08-28 15:05:16.808 10117 2426 6018 I Icing : Usage reports ok 0, Failed Usage reports 0, indexed 0, rejected 0 +08-28 15:05:16.840 1000 940 2512 I ActivityManager: Force stopping com.googlecode.android_scripting appid=1000 user=0: from pid 7728 +08-28 15:05:16.841 1000 940 2512 I ActivityManager: Killing 6654:com.googlecode.android_scripting/1000 (adj 965): stop com.googlecode.android_scripting +08-28 15:05:16.824 10117 2426 6018 I chatty : uid=10117(com.google.android.gms) lowpool[42] identical 1 line +08-28 15:05:16.846 10117 2426 6018 I Icing : Usage reports ok 0, Failed Usage reports 0, indexed 0, rejected 0 +08-28 15:05:16.852 radio 1559 1559 E PhoneInterfaceManager: [PhoneIntfMgr] getCarrierPackageNamesForIntent: No UICC +08-28 15:05:16.852 radio 1559 1559 D CarrierSvcBindHelper: No carrier app for: 0 +08-28 15:05:16.859 nfc 2452 2452 D RegisteredNfcFServicesCache: Service unchanged, not updating +08-28 15:05:16.863 media 796 905 D NuPlayerDriver: reset(0xe199b100) at state 4 +08-28 15:05:16.865 root 629 629 I Zygote : Process 6654 exited due to signal 9 (Killed) +08-28 15:05:16.865 media 796 6689 D NuPlayerDriver: notifyResetComplete(0xe199b100) +08-28 15:05:16.873 10117 2426 6018 I Icing : Usage reports ok 0, Failed Usage reports 0, indexed 0, rejected 0 +08-28 15:05:16.887 1000 940 1069 I libprocessgroup: Successfully killed process cgroup uid 1000 pid 6654 in 44ms +08-28 15:05:17.172 1000 647 647 I /vendor/bin/hw/android.hardware.health@2.0-service.marlin: SRAM data: 2812000 +08-28 15:05:17.668 1000 647 647 I chatty : uid=1000(system) health@2.0-serv identical 20 lines +08-28 15:05:17.672 1000 647 647 I /vendor/bin/hw/android.hardware.health@2.0-service.marlin: SRAM data: 2812000 +08-28 15:05:17.697 10117 2426 28502 I Icing : Indexing com.google.android.gms-apps from com.google.android.gms +08-28 15:05:17.717 1000 647 647 I /vendor/bin/hw/android.hardware.health@2.0-service.marlin: SRAM data: 2812000 +08-28 15:05:17.769 1000 647 647 I chatty : uid=1000(system) health@2.0-serv identical 2 lines +08-28 15:05:17.773 1000 647 647 I /vendor/bin/hw/android.hardware.health@2.0-service.marlin: SRAM data: 2812000 +08-28 15:05:17.775 10117 2426 28502 I Icing : Indexing done com.google.android.gms-apps +08-28 15:05:17.778 1000 647 647 I /vendor/bin/hw/android.hardware.health@2.0-service.marlin: SRAM data: 2812000 +08-28 15:05:17.786 1000 940 2043 I WindowManager: sleepRelease() calling goToSleep(GO_TO_SLEEP_REASON_SLEEP_BUTTON) +08-28 15:05:17.787 1000 940 2043 I PowerManagerService: Going to sleep due to sleep_button (uid 1000)... +08-28 15:05:17.788 1000 940 940 W UsageStatsService: Event reported without a package name, eventType:16 +08-28 15:05:17.802 10178 7664 7696 D com.google.android.powertests.PartialWakelock: before +08-28 15:05:17.839 1000 940 1115 V DisplayPowerController: Brightness [131] reason changing to: 'manual', previous reason: 'manual [ dim ]'. + +"Œ +6 +class-com.google.android.powertests.PartialWakelock + +
end-timestamp + +testpartialWakelock + + timestamp0žÍ™¤›[ + +timestamps-message +–"“ +6 +class-com.google.android.powertests.PartialWakelock + +current + +idAndroidJUnitRunner + +numtests + +stream. + +testpartialWakelock-") +' +stream + +Time: 16.333 + +OK (1 test) + diff --git a/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp_proto.txt b/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp_proto.txt new file mode 100644 index 0000000000..5ac75cd3aa --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/data/sample_timestamp_proto.txt @@ -0,0 +1,110 @@ +test_status { + result_code: 1 + results { + entries { + key: "class" + value_string: "com.google.android.powertests.PartialWakelock" + } + entries { + key: "current" + value_int: 1 + } + entries { + key: "id" + value_string: "AndroidJUnitRunner" + } + entries { + key: "numtests" + value_int: 1 + } + entries { + key: "stream" + value_string: "\ncom.google.android.powertests.PartialWakelock:" + } + entries { + key: "test" + value_string: "partialWakelock" + } + } +} +test_status { + results { + entries { + key: "class" + value_string: "com.google.android.powertests.PartialWakelock" + } + entries { + key: "start-timestamp" + } + entries { + key: "test" + value_string: "partialWakelock" + } + entries { + key: "timestamp" + value_long: 1567029917802 + } + entries { + key: "timestamps-message" + } + } +} +test_status { + results { + entries { + key: "class" + value_string: "com.google.android.powertests.PartialWakelock" + } + entries { + key: "end-timestamp" + } + entries { + key: "test" + value_string: "partialWakelock" + } + entries { + key: "timestamp" + value_long: 1567029932879 + } + entries { + key: "timestamps-message" + } + } +} +test_status { + results { + entries { + key: "class" + value_string: "com.google.android.powertests.PartialWakelock" + } + entries { + key: "current" + value_int: 1 + } + entries { + key: "id" + value_string: "AndroidJUnitRunner" + } + entries { + key: "numtests" + value_int: 1 + } + entries { + key: "stream" + value_string: "." + } + entries { + key: "test" + value_string: "partialWakelock" + } + } +} +session_status { + result_code: -1 + results { + entries { + key: "stream" + value_string: "\n\nTime: 16.333\n\nOK (1 test)\n\n" + } + } +} diff --git a/acts/framework/tests/test_utils/instrumentation/device/__init__.py b/acts/framework/tests/test_utils/instrumentation/device/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/__init__.py diff --git a/acts/framework/tests/test_utils/instrumentation/device/apps/__init__.py b/acts/framework/tests/test_utils/instrumentation/device/apps/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/apps/__init__.py diff --git a/acts/framework/tests/test_utils/instrumentation/device/apps/dismiss_dialogs_test.py b/acts/framework/tests/test_utils/instrumentation/device/apps/dismiss_dialogs_test.py new file mode 100644 index 0000000000..3b362747a2 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/apps/dismiss_dialogs_test.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +import mock +from acts.test_utils.instrumentation.device.apps.dismiss_dialogs import \ + DialogDismissalUtil + + +class MockDialogDismissalUtil(DialogDismissalUtil): + """Mock DialogDismissalUtil for unit testing""" + def __init__(self): + self._dut = mock.MagicMock() + self._dismiss_dialogs_apk = mock.MagicMock() + self._dismiss_dialogs_apk.pkg_name = 'dismiss.dialogs' + + +class DialogDismissalUtilTest(unittest.TestCase): + def setUp(self): + self._dismiss_dialogs_util = MockDialogDismissalUtil() + + def test_dismiss_dialog_zero_apps(self): + """Test that no command is run if the apps arg is empty.""" + apps = [] + self._dismiss_dialogs_util.dismiss_dialogs(apps) + self._dismiss_dialogs_util._dut.adb.shell.assert_not_called() + + def test_dismiss_dialog_single_app(self): + """ + Test that the correct command is run when a single app is specified. + """ + apps = ['sample.app.one'] + self._dismiss_dialogs_util.dismiss_dialogs(apps) + expected_cmd = ( + 'am instrument -w -f -e apps sample.app.one ' + 'dismiss.dialogs/.DismissDialogsInstrumentation ' + '-e screenshots true -e quitOnError true' + ) + self._dismiss_dialogs_util._dut.adb.shell.assert_called_with( + expected_cmd) + + def test_dismiss_dialog_multiple_apps(self): + """ + Test that the correct command is run when multiple apps are specified. + """ + apps = ['sample.app.one', 'sample.app.two'] + self._dismiss_dialogs_util.dismiss_dialogs(apps) + expected_cmd = ( + 'am instrument -w -f -e apps sample.app.one,sample.app.two ' + 'dismiss.dialogs/.DismissDialogsInstrumentation ' + '-e screenshots true -e quitOnError true' + ) + self._dismiss_dialogs_util._dut.adb.shell.assert_called_with( + expected_cmd) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/device/apps/hotword_model_extractor_test.py b/acts/framework/tests/test_utils/instrumentation/device/apps/hotword_model_extractor_test.py new file mode 100644 index 0000000000..053da31291 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/apps/hotword_model_extractor_test.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import unittest + +import mock +from acts.test_utils.instrumentation.device.apps.hotword_model_extractor import \ + HotwordModelExtractor +from acts.test_utils.instrumentation.device.apps.hotword_model_extractor import \ + MODEL_DIR + +GOOD_PACKAGE = 'good_package' +GOOD_MODEL = 'good_model' +BAD_PACKAGE = 'bad_package' +BAD_MODEL = 'bad_model' + + +def mock_pull_from_device(_, hotword_pkg, __): + """Mocks the AppInstaller.pull_from_device method.""" + return mock.MagicMock() if hotword_pkg == GOOD_PACKAGE else None + + +class MockZipFile(object): + """Class for mocking zipfile.ZipFile""" + def extract(self, path, _): + if path == os.path.join(MODEL_DIR, GOOD_MODEL): + return path + raise KeyError + + def __enter__(self): + return self + + def __exit__(self, *_): + pass + + +@mock.patch('acts.test_utils.instrumentation.device.apps.app_installer.' + 'AppInstaller.pull_from_device', side_effect=mock_pull_from_device) +@mock.patch('zipfile.ZipFile', return_value=MockZipFile()) +class HotwordModelExtractorTest(unittest.TestCase): + """Unit tests for HotwordModelExtractor.""" + def setUp(self): + self.extractor = HotwordModelExtractor(mock.MagicMock()) + + def test_package_not_installed(self, *_): + result = self.extractor._extract(BAD_PACKAGE, GOOD_MODEL, '') + self.assertIsNone(result) + + def test_voice_model_not_found(self, *_): + result = self.extractor._extract(GOOD_PACKAGE, BAD_MODEL, '') + self.assertIsNone(result) + + def test_extract_model(self, *_): + result = self.extractor._extract(GOOD_PACKAGE, GOOD_MODEL, '') + self.assertEqual(result, 'res/raw/good_model') + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/device/apps/permissions_test.py b/acts/framework/tests/test_utils/instrumentation/device/apps/permissions_test.py new file mode 100644 index 0000000000..ec4ebc7b9c --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/apps/permissions_test.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +import mock +from acts.test_utils.instrumentation.device.apps.permissions import \ + PermissionsUtil + + +class MockPermissionsUtil(PermissionsUtil): + """Mock PermissionsUtil for unit testing""" + def __init__(self): + self._dut = mock.MagicMock() + self._permissions_apk = mock.MagicMock() + self._permissions_apk.pkg_name = 'permissions.util' + + +class PermissionsUtilTest(unittest.TestCase): + def setUp(self): + self._permissions_util = MockPermissionsUtil() + + def test_grant_all(self): + """Test the grant-all command.""" + self._permissions_util.grant_all() + expected_cmd = ( + 'am instrument -w -r -f -e command grant-all ' + 'permissions.util/.PermissionInstrumentation' + ) + self._permissions_util._dut.adb.shell.assert_called_with( + expected_cmd) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/device/command/adb_command_types_test.py b/acts/framework/tests/test_utils/instrumentation/device/command/adb_command_types_test.py new file mode 100755 index 0000000000..127575bd8d --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/command/adb_command_types_test.py @@ -0,0 +1,152 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceBinaryCommandSeries +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceGServices +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetprop +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceSetting +from acts.test_utils.instrumentation.device.command.adb_command_types import \ + DeviceState + + +class AdbCommandTypesTest(unittest.TestCase): + + def test_device_state(self): + """Tests that DeviceState returns the correct ADB command with + set_value. + """ + base_cmd = 'run command with vals' + val1 = 15 + val2 = 24 + device_state = DeviceState(base_cmd) + self.assertEqual(device_state.set_value(val1, val2), + 'run command with vals 15 24') + + def test_device_state_with_base_cmd_as_format_string(self): + """Tests that DeviceState returns the correct ADB command if the base + command is given as a format string. + """ + base_cmd = 'echo %s > /test/data' + val = 23 + device_state = DeviceState(base_cmd) + self.assertEqual(device_state.set_value(val), 'echo 23 > /test/data') + + def test_device_binary_state(self): + """Tests that DeviceState returns the correct ADB commands with toggle. + """ + on_cmd = 'enable this service' + off_cmd = 'disable the service' + device_binary_state = DeviceState('', on_cmd, off_cmd) + self.assertEqual(device_binary_state.toggle(True), on_cmd) + self.assertEqual(device_binary_state.toggle(False), off_cmd) + + def test_device_setprop(self): + """Tests that DeviceSetprop returns the correct ADB command with + set_value. + """ + prop = 'some.property' + val = 3 + device_setprop = DeviceSetprop(prop) + self.assertEqual(device_setprop.set_value(val), + 'setprop some.property 3') + + def test_device_binary_setprop(self): + """Tests that DeviceSetprop returns the correct ADB commands with + toggle. + """ + prop = 'some.other.property' + on_val = True + off_val = False + device_binary_setprop = DeviceSetprop(prop, on_val, off_val) + self.assertEqual(device_binary_setprop.toggle(True), + 'setprop some.other.property True') + self.assertEqual(device_binary_setprop.toggle(False), + 'setprop some.other.property False') + + def test_device_setting(self): + """Tests that DeviceSetting returns the correct ADB command with + set_value. + """ + namespace = 'global' + setting = 'some_new_setting' + val = 10 + device_setting = DeviceSetting(namespace, setting) + self.assertEqual(device_setting.set_value(val), + 'settings put global some_new_setting 10') + + def test_device_binary_setting(self): + """Tests that DeviceSetting returns the correct ADB commands with + toggle. + """ + namespace = 'system' + setting = 'some_other_setting' + on_val = 'on' + off_val = 'off' + device_binary_setting = DeviceSetting( + namespace, setting, on_val, off_val) + self.assertEqual( + device_binary_setting.toggle(True), + 'settings put system some_other_setting on') + self.assertEqual( + device_binary_setting.toggle(False), + 'settings put system some_other_setting off') + + def test_device_gservices(self): + """Tests that DeviceGServices returns the correct ADB command with + set_value. + """ + setting = 'some_gservice' + val = 22 + device_gservices = DeviceGServices(setting) + self.assertEqual( + device_gservices.set_value(val), + 'am broadcast -a ' + 'com.google.gservices.intent.action.GSERVICES_OVERRIDE ' + '--ei some_gservice 22') + + def test_device_binary_command_series(self): + """Tests that DeviceBinaryCommandSuite returns the correct ADB + commands. + """ + on_cmds = [ + 'settings put global test_setting on', + 'setprop test.prop 1', + 'svc test_svc enable' + ] + off_cmds = [ + 'settings put global test_setting off', + 'setprop test.prop 0', + 'svc test_svc disable' + ] + device_binary_command_series = DeviceBinaryCommandSeries( + [ + DeviceSetting('global', 'test_setting', 'on', 'off'), + DeviceSetprop('test.prop'), + DeviceState('svc test_svc', 'enable', 'disable') + ] + ) + self.assertEqual(device_binary_command_series.toggle(True), on_cmds) + self.assertEqual(device_binary_command_series.toggle(False), off_cmds) + + +if __name__ == "__main__": + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/device/command/instrumentation_command_builder_test.py b/acts/framework/tests/test_utils/instrumentation/device/command/instrumentation_command_builder_test.py new file mode 100755 index 0000000000..954c908654 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/command/instrumentation_command_builder_test.py @@ -0,0 +1,132 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import InstrumentationCommandBuilder +from acts.test_utils.instrumentation.device.command.instrumentation_command_builder \ + import InstrumentationTestCommandBuilder + + +class InstrumentationCommandBuilderTest(unittest.TestCase): + + def test__runner_and_manifest_package_definition(self): + builder = InstrumentationCommandBuilder() + builder.set_manifest_package('package') + builder.set_runner('runner') + call = builder.build() + self.assertIn('package/runner', call) + + def test__manifest_package_must_be_defined(self): + builder = InstrumentationCommandBuilder() + + with self.assertRaisesRegex(Exception, '.*package cannot be none.*'): + builder.build() + + def test__runner_must_be_defined(self): + builder = InstrumentationCommandBuilder() + + with self.assertRaisesRegex(Exception, '.*runner cannot be none.*'): + builder.build() + + def test_proto_flag_without_set_proto_path(self): + builder = InstrumentationCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + + call = builder.build() + self.assertIn('-f', call) + + def test_proto_flag_with_set_proto_path(self): + builder = InstrumentationCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + builder.set_proto_path('/some/proto/path') + + call = builder.build() + self.assertIn('-f /some/proto/path', call) + + def test_set_nohup(self): + builder = InstrumentationCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + builder.set_nohup() + + call = builder.build() + self.assertEqual( + call, 'nohup am instrument -f some.manifest.package/runner >> ' + '$EXTERNAL_STORAGE/nohup.log 2>&1') + + def test__key_value_param_definition(self): + builder = InstrumentationCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + + builder.add_key_value_param('my_key_1', 'my_value_1') + builder.add_key_value_param('my_key_2', 'my_value_2') + + call = builder.build() + self.assertIn('-e my_key_1 my_value_1', call) + self.assertIn('-e my_key_2 my_value_2', call) + + def test__flags(self): + builder = InstrumentationCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + + builder.add_flag('--flag1') + builder.add_flag('--flag2') + + call = builder.build() + self.assertIn('--flag1', call) + self.assertIn('--flag2', call) + + +class InstrumentationTestCommandBuilderTest(unittest.TestCase): + """Test class for + acts/test_utils/instrumentation/instrumentation_call_builder.py + """ + + def test__test_packages_can_not_be_added_if_classes_were_added_first(self): + builder = InstrumentationTestCommandBuilder() + builder.add_test_class('some.tests.Class') + + with self.assertRaisesRegex(Exception, '.*only a list of classes.*'): + builder.add_test_package('some.tests.package') + + def test__test_classes_can_not_be_added_if_packages_were_added_first(self): + builder = InstrumentationTestCommandBuilder() + builder.add_test_package('some.tests.package') + + with self.assertRaisesRegex(Exception, '.*only a list of classes.*'): + builder.add_test_class('some.tests.Class') + + def test__test_classes_and_test_methods_can_be_combined(self): + builder = InstrumentationTestCommandBuilder() + builder.set_runner('runner') + builder.set_manifest_package('some.manifest.package') + builder.add_test_class('some.tests.Class1') + builder.add_test_method('some.tests.Class2', 'favoriteTestMethod') + + call = builder.build() + self.assertIn('some.tests.Class1', call) + self.assertIn('some.tests.Class2', call) + self.assertIn('favoriteTestMethod', call) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/device/command/intent_builder_test.py b/acts/framework/tests/test_utils/instrumentation/device/command/intent_builder_test.py new file mode 100644 index 0000000000..e69b1a237d --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/device/command/intent_builder_test.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +from acts.test_utils.instrumentation.device.command.intent_builder import \ + IntentBuilder + + +class IntentBuilderTest(unittest.TestCase): + """Unit tests for IntentBuilder""" + + def test_set_action(self): + """Test that a set action yields the correct intent call""" + builder = IntentBuilder('am start') + builder.set_action('android.intent.action.SOME_ACTION') + self.assertEqual(builder.build(), + 'am start -a android.intent.action.SOME_ACTION') + + def test_set_component_with_package_only(self): + """Test that the intent call is built properly with only the package + name specified. + """ + builder = IntentBuilder('am broadcast') + builder.set_component('android.package.name') + self.assertEqual(builder.build(), + 'am broadcast -n android.package.name') + + def test_set_component_with_package_and_component(self): + """Test that the intent call is built properly with both the package + and component name specified. + """ + builder = IntentBuilder('am start') + builder.set_component('android.package.name', '.AndroidComponent') + self.assertEqual( + builder.build(), + 'am start -n android.package.name/.AndroidComponent') + + def test_set_data_uri(self): + """Test that a set data URI yields the correct intent call""" + builder = IntentBuilder() + builder.set_data_uri('file://path/to/file') + self.assertEqual(builder.build(), '-d file://path/to/file') + + def test_add_flag(self): + """Test that additional flags are added properly""" + builder = IntentBuilder('am start') + builder.add_flag('--flag-numero-uno') + builder.add_flag('--flag-numero-dos') + self.assertEqual( + builder.build(), 'am start --flag-numero-uno --flag-numero-dos') + + def test_add_key_value_with_empty_value(self): + """Test that a param with an empty value is added properly.""" + builder = IntentBuilder('am broadcast') + builder.add_key_value_param('empty_param') + self.assertEqual(builder.build(), 'am broadcast --esn empty_param') + + def test_add_key_value_with_nonempty_values(self): + """Test that a param with various non-empty values is added properly.""" + builder = IntentBuilder('am start') + builder.add_key_value_param('bool_param', False) + builder.add_key_value_param('string_param', 'enabled') + builder.add_key_value_param('int_param', 5) + builder.add_key_value_param('float_param', 12.1) + self.assertEqual( + builder.build(), + 'am start --ez bool_param false --es string_param enabled ' + '--ei int_param 5 --ef float_param 12.1') + + def test_full_intent_command(self): + """Test a full intent command with all possible components.""" + builder = IntentBuilder('am broadcast') + builder.set_action('android.intent.action.TEST_ACTION') + builder.set_component('package.name', '.ComponentName') + builder.set_data_uri('file://path/to/file') + builder.add_key_value_param('empty') + builder.add_key_value_param('numeric_param', 11.6) + builder.add_key_value_param('bool_param', True) + builder.add_flag('--unit-test') + self.assertEqual( + builder.build(), + 'am broadcast -a android.intent.action.TEST_ACTION ' + '-n package.name/.ComponentName -d file://path/to/file --unit-test ' + '--esn empty --ef numeric_param 11.6 --ez bool_param true') + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py b/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py new file mode 100755 index 0000000000..ab982c1bd6 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/instrumentation_base_test_test.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import copy +import unittest + +from acts.test_utils.instrumentation.config_wrapper import ConfigWrapper +from acts.test_utils.instrumentation.instrumentation_base_test import \ + InstrumentationBaseTest + +MOCK_INSTRUMENTATION_CONFIG = { + 'MockController': { + 'param1': 1, + 'param2': 4 + }, + 'MockInstrumentationBaseTest': { + 'MockController': { + 'param2': 2, + 'param3': 5 + }, + 'test_case': { + 'MockController': { + 'param3': 3 + } + } + } +} + + +class MockInstrumentationBaseTest(InstrumentationBaseTest): + """Mock test class to initialize required attributes.""" + def __init__(self): + self.current_test_name = None + self._instrumentation_config = ConfigWrapper( + MOCK_INSTRUMENTATION_CONFIG) + self._class_config = self._instrumentation_config.get_config( + self.__class__.__name__) + + +class InstrumentationBaseTestTest(unittest.TestCase): + def setUp(self): + self.instrumentation_test = MockInstrumentationBaseTest() + + def test_get_controller_config_for_test_case(self): + """Test that _get_controller_config returns the corresponding + controller config for the current test case. + """ + self.instrumentation_test.current_test_name = 'test_case' + config = self.instrumentation_test._get_merged_config( + 'MockController') + self.assertEqual(config.get('param1'), 1) + self.assertEqual(config.get('param2'), 2) + self.assertEqual(config.get('param3'), 3) + + def test_get_controller_config_for_test_class(self): + """Test that _get_controller_config returns the controller config for + the current test class (while no test case is running). + """ + config = self.instrumentation_test._get_merged_config( + 'MockController') + self.assertEqual(config.get('param1'), 1) + self.assertEqual(config.get('param2'), 2) + self.assertEqual(config.get('param3'), 5) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py b/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py new file mode 100644 index 0000000000..c276fc5c2d --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/instrumentation_proto_parser_test.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import unittest + +import mock +from acts.test_utils.instrumentation import instrumentation_proto_parser \ + as parser +from acts.test_utils.instrumentation.instrumentation_proto_parser import \ + ProtoParserError +from acts.test_utils.instrumentation.proto.gen import instrumentation_data_pb2 + + +DEST_DIR = 'dest/proto_dir' +SOURCE_PATH = 'source/proto/protofile' +SAMPLE_PROTO = 'data/sample.instrumentation_data_proto' +SAMPLE_TIMESTAMP_PROTO = 'data/sample_timestamp.instrumentation_data_proto' + + +class InstrumentationProtoParserTest(unittest.TestCase): + """Unit tests for instrumentation proto parser.""" + + def setUp(self): + self.ad = mock.MagicMock() + self.ad.external_storage_path = '' + + @mock.patch('os.path.exists', return_value=True) + def test_pull_proto_returns_correct_path_given_source(self, *_): + self.assertEqual(parser.pull_proto(self.ad, DEST_DIR, SOURCE_PATH), + 'dest/proto_dir/protofile') + + @mock.patch('os.path.exists', return_value=True) + def test_pull_proto_returns_correct_path_from_default_location(self, *_): + self.ad.adb.shell.return_value = 'default' + self.assertEqual(parser.pull_proto(self.ad, DEST_DIR), + 'dest/proto_dir/default') + + def test_pull_proto_fails_if_no_default_proto_found(self, *_): + self.ad.adb.shell.return_value = None + with self.assertRaisesRegex( + ProtoParserError, 'No instrumentation result'): + parser.pull_proto(self.ad, DEST_DIR) + + @mock.patch('os.path.exists', return_value=False) + def test_pull_proto_fails_if_adb_pull_fails(self, *_): + with self.assertRaisesRegex(ProtoParserError, 'Failed to pull'): + parser.pull_proto(self.ad, DEST_DIR, SOURCE_PATH) + + def test_parser_converts_valid_proto(self): + proto_file = os.path.join(os.path.dirname(__file__), SAMPLE_PROTO) + self.assertIsInstance(parser.get_session_from_local_file(proto_file), + instrumentation_data_pb2.Session) + + def test_get_test_timestamps(self): + proto_file = os.path.join(os.path.dirname(__file__), + SAMPLE_TIMESTAMP_PROTO) + session = parser.get_session_from_local_file(proto_file) + timestamps = parser.get_test_timestamps(session) + self.assertEqual( + timestamps['partialWakelock'][parser.START_TIMESTAMP], + 1567029917802) + self.assertEqual( + timestamps['partialWakelock'][parser.END_TIMESTAMP], 1567029932879) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/power/__init__.py b/acts/framework/tests/test_utils/instrumentation/power/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/power/__init__.py diff --git a/acts/framework/tests/test_utils/instrumentation/power/instrumentation_power_test_test.py b/acts/framework/tests/test_utils/instrumentation/power/instrumentation_power_test_test.py new file mode 100644 index 0000000000..3a617e2bef --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/power/instrumentation_power_test_test.py @@ -0,0 +1,280 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import unittest + +import mock +from acts.test_utils.instrumentation.config_wrapper import ConfigWrapper +from acts.test_utils.instrumentation.power.instrumentation_power_test \ + import ACCEPTANCE_THRESHOLD +from acts.test_utils.instrumentation.power.instrumentation_power_test \ + import InstrumentationPowerTest +from acts.test_utils.instrumentation.power.power_metrics import PowerMetrics + +from acts import signals + + +class MockInstrumentationPowerTest(InstrumentationPowerTest): + """Mock test class to initialize required attributes.""" + + # avg: 2.214, stdev: 1.358, max: 4.78, min: 0.61 + SAMPLE_DATA = [1.64, 2.98, 1.72, 3.45, 1.31, 4.78, 3.43, 0.61, 1.19, 1.03] + + def __init__(self): + self.log = mock.Mock() + self.metric_logger = mock.Mock() + self.current_test_name = 'test_case' + self._power_metrics = PowerMetrics(4.2) + self._power_metrics.test_metrics = { + 'instrTest1': PowerMetrics(4.2), + 'instrTest2': PowerMetrics(4.2) + } + self._power_metrics.test_metrics['instrTest1'].generate_test_metrics( + list(zip(range(10), self.SAMPLE_DATA)) + ) + self._power_metrics.test_metrics['instrTest2'].generate_test_metrics( + list(zip(range(10), self.SAMPLE_DATA)) + ) + self._instrumentation_config = ConfigWrapper() + self._class_config = ConfigWrapper( + { + self.current_test_name: { + ACCEPTANCE_THRESHOLD: {} + } + } + ) + + def set_criteria(self, criteria): + """Set the acceptance criteria for metrics validation.""" + test_config = self._class_config[self.current_test_name] + test_config[ACCEPTANCE_THRESHOLD] = ConfigWrapper(criteria) + + +class InstrumentationPowerTestTest(unittest.TestCase): + """Unit tests for InstrumentationPowerTest.""" + def setUp(self): + self.instrumentation_power_test = MockInstrumentationPowerTest() + + def test_validate_power_results_lower_and_upper_limit_accept(self): + """Test that validate_power_results accept passing measurements + given a lower and upper limit. + """ + criteria_accept = { + 'instrTest1': { + 'avg_current': { + 'unit_type': 'current', + 'unit': 'A', + 'lower_limit': 1.5, + 'upper_limit': 2.5 + }, + 'max_current': { + 'unit_type': 'current', + 'unit': 'mA', + 'upper_limit': 5000 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_accept) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_lower_and_upper_limit_reject(self): + """Test that validate_power_results reject failing measurements + given a lower and upper limit. + """ + criteria_reject = { + 'instrTest1': { + 'avg_current': { + 'unit_type': 'current', + 'unit': 'A', + 'lower_limit': 1.5, + 'upper_limit': 2 + }, + 'max_current': { + 'unit_type': 'current', + 'unit': 'mA', + 'upper_limit': 4000 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_reject) + with self.assertRaises(signals.TestFailure): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_expected_value_and_deviation_accept(self): + """Test that validate_power_results accept passing measurements + given an expected value and percent deviation. + """ + criteria_accept = { + 'instrTest1': { + 'stdev_current': { + 'unit_type': 'current', + 'unit': 'A', + 'expected_value': 1.5, + 'percent_deviation': 20 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_accept) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_expected_value_and_deviation_reject(self): + """Test that validate_power_results reject failing measurements + given an expected value and percent deviation. + """ + criteria_reject = { + 'instrTest1': { + 'min_current': { + 'unit_type': 'current', + 'unit': 'mA', + 'expected_value': 500, + 'percent_deviation': 10 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_reject) + with self.assertRaises(signals.TestFailure): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_no_such_test(self): + """Test that validate_power_results skip validation if there are no + criteria matching the specified instrumentation test name. + """ + criteria_wrong_test = { + 'instrTest2': { + 'min_current': { + 'unit_type': 'current', + 'unit': 'A', + 'expected_value': 2, + 'percent_deviation': 20 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_wrong_test) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_no_such_metric(self): + """Test that validate_power_results skip validation if the specified + metric is invalid. + """ + criteria_invalid_metric = { + 'instrTest1': { + 'no_such_metric': { + 'unit_type': 'current', + 'unit': 'A', + 'lower_limit': 5, + 'upper_limit': 7 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_invalid_metric) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_criteria_missing_params(self): + """Test that validate_power_results skip validation if the specified + metric has missing parameters. + """ + criteria_missing_params = { + 'instrTest1': { + 'avg_current': { + 'unit': 'A', + 'lower_limit': 1, + 'upper_limit': 2 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_missing_params) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results('instrTest1') + + def test_validate_power_results_pass_if_all_tests_accept(self): + """Test that validate_power_results succeeds if it accepts the results + of all instrumentation tests. + """ + criteria_multi_test_accept = { + 'instrTest1': { + 'avg_current': { + 'unit_type': 'current', + 'unit': 'A', + 'lower_limit': 2 + }, + 'stdev_current': { + 'unit_type': 'current', + 'unit': 'mA', + 'expected_value': 1250, + 'percent_deviation': 30 + } + }, + 'instrTest2': { + 'max_current': { + 'unit_type': 'current', + 'unit': 'A', + 'upper_limit': 5 + }, + 'avg_power': { + 'unit_type': 'power', + 'unit': 'W', + 'upper_limit': 10 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_multi_test_accept) + with self.assertRaises(signals.TestPass): + self.instrumentation_power_test.validate_power_results( + 'instrTest1', 'instrTest2') + + def test_validate_power_results_fail_if_at_least_one_test_rejects(self): + """Test that validate_power_results fails if it rejects the results + of at least one instrumentation test. + """ + criteria_multi_test_reject = { + 'instrTest1': { + 'avg_current': { + 'unit_type': 'current', + 'unit': 'A', + 'lower_limit': 2 + }, + 'stdev_current': { + 'unit_type': 'current', + 'unit': 'mA', + 'expected_value': 1250, + 'percent_deviation': 30 + } + }, + 'instrTest2': { + 'max_current': { + 'unit_type': 'current', + 'unit': 'A', + 'upper_limit': 5 + }, + 'avg_power': { + 'unit_type': 'power', + 'unit': 'W', + 'upper_limit': 8 + } + } + } + self.instrumentation_power_test.set_criteria(criteria_multi_test_reject) + with self.assertRaises(signals.TestFailure): + self.instrumentation_power_test.validate_power_results( + 'instrTest1', 'instrTest2') + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/power/power_metrics_test.py b/acts/framework/tests/test_utils/instrumentation/power/power_metrics_test.py new file mode 100644 index 0000000000..38441d136d --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/power/power_metrics_test.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the 'License'); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an 'AS IS' BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import statistics +import unittest + +from acts.test_utils.instrumentation import instrumentation_proto_parser \ + as parser +from acts.test_utils.instrumentation.power.power_metrics import CURRENT +from acts.test_utils.instrumentation.power.power_metrics import HOUR +from acts.test_utils.instrumentation.power.power_metrics import MILLIAMP +from acts.test_utils.instrumentation.power.power_metrics import MINUTE +from acts.test_utils.instrumentation.power.power_metrics import Measurement +from acts.test_utils.instrumentation.power.power_metrics import PowerMetrics +from acts.test_utils.instrumentation.power.power_metrics import TIME +from acts.test_utils.instrumentation.power.power_metrics import WATT + +FAKE_UNIT_TYPE = 'fake_unit' +FAKE_UNIT = 'F' + + +class MeasurementTest(unittest.TestCase): + """Unit tests for the Measurement class.""" + + def test_init_with_valid_unit_type(self): + """Test that a Measurement is properly initialized given a valid unit + type. + """ + measurement = Measurement(2, CURRENT, MILLIAMP) + self.assertEqual(measurement.value, 2) + self.assertEqual(measurement._unit, MILLIAMP) + + def test_init_with_invalid_unit_type(self): + """Test that __init__ raises an error if given an invalid unit type.""" + with self.assertRaisesRegex(TypeError, 'valid unit type'): + measurement = Measurement(2, FAKE_UNIT_TYPE, FAKE_UNIT) + + def test_unit_conversion(self): + """Test that to_unit correctly converts value and unit.""" + ratio = 1000 + current_amps = Measurement.amps(15) + current_milliamps = current_amps.to_unit(MILLIAMP) + self.assertEqual(current_milliamps.value / current_amps.value, ratio) + + def test_unit_conversion_with_wrong_type(self): + """Test that to_unit raises and error if incompatible unit type is + specified. + """ + current_amps = Measurement.amps(3.4) + with self.assertRaisesRegex(TypeError, 'Incompatible units'): + power_watts = current_amps.to_unit(WATT) + + def test_comparison_operators(self): + """Test that the comparison operators work as intended.""" + # time_a == time_b < time_c + time_a = Measurement.seconds(120) + time_b = Measurement(2, TIME, MINUTE) + time_c = Measurement(0.1, TIME, HOUR) + + self.assertEqual(time_a, time_b) + self.assertEqual(time_b, time_a) + self.assertLessEqual(time_a, time_b) + self.assertGreaterEqual(time_a, time_b) + + self.assertNotEqual(time_a, time_c) + self.assertNotEqual(time_c, time_a) + self.assertLess(time_a, time_c) + self.assertLessEqual(time_a, time_c) + self.assertGreater(time_c, time_a) + self.assertGreaterEqual(time_c, time_a) + + def test_arithmetic_operators(self): + """Test that the addition and subtraction operators work as intended""" + time_a = Measurement(3, TIME, HOUR) + time_b = Measurement(90, TIME, MINUTE) + + sum_ = time_a + time_b + self.assertEqual(sum_.value, 4.5) + self.assertEqual(sum_._unit, HOUR) + + sum_reversed = time_b + time_a + self.assertEqual(sum_reversed.value, 270) + self.assertEqual(sum_reversed._unit, MINUTE) + + diff = time_a - time_b + self.assertEqual(diff.value, 1.5) + self.assertEqual(diff._unit, HOUR) + + diff_reversed = time_b - time_a + self.assertEqual(diff_reversed.value, -90) + self.assertEqual(diff_reversed._unit, MINUTE) + + +class PowerMetricsTest(unittest.TestCase): + """Unit tests for the PowerMetrics class.""" + + SAMPLES = [0.13, 0.95, 0.32, 4.84, 2.48, 4.11, 4.85, 4.88, 4.22, 2.2] + RAW_DATA = list(zip(range(10), SAMPLES)) + VOLTAGE = 4.2 + START_TIME = 5 + + def setUp(self): + self.power_metrics = PowerMetrics(self.VOLTAGE, self.START_TIME) + + def test_import_raw_data(self): + """Test that power metrics can be loaded from file. Simply ensure that + the number of samples is correct.""" + + imported_data = PowerMetrics.import_raw_data( + os.path.join(os.path.dirname(__file__), + '../data/sample_monsoon_data') + ) + self.power_metrics.generate_test_metrics(imported_data) + self.assertEqual(self.power_metrics._num_samples, 10) + + def test_split_by_test_with_timestamps(self): + """Test that given test timestamps, a power metric is generated from + a subset of samples corresponding to the test.""" + sample_test = 'sample_test' + test_start = 8500 + test_end = 13500 + test_timestamps = {sample_test: {parser.START_TIMESTAMP: test_start, + parser.END_TIMESTAMP: test_end}} + self.power_metrics.generate_test_metrics(self.RAW_DATA, test_timestamps) + test_metrics = self.power_metrics.test_metrics[sample_test] + self.assertEqual(test_metrics._num_samples, 5) + + def test_numeric_metrics(self): + """Test that the numeric metrics have correct values.""" + self.power_metrics.generate_test_metrics(self.RAW_DATA) + self.assertAlmostEqual(self.power_metrics.avg_current.value, + statistics.mean(self.SAMPLES) * 1000) + self.assertAlmostEqual(self.power_metrics.max_current.value, + max(self.SAMPLES) * 1000) + self.assertAlmostEqual(self.power_metrics.min_current.value, + min(self.SAMPLES) * 1000) + self.assertAlmostEqual(self.power_metrics.stdev_current.value, + statistics.stdev(self.SAMPLES) * 1000) + self.assertAlmostEqual( + self.power_metrics.avg_power.value, + self.power_metrics.avg_current.value * self.VOLTAGE) + + +if __name__ == '__main__': + unittest.main() diff --git a/acts/framework/tests/test_utils/instrumentation/unit_test_suite.py b/acts/framework/tests/test_utils/instrumentation/unit_test_suite.py new file mode 100755 index 0000000000..d253cb33ad --- /dev/null +++ b/acts/framework/tests/test_utils/instrumentation/unit_test_suite.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys +import unittest + + +def main(): + suite = unittest.TestLoader().discover( + start_dir=os.path.dirname(__file__), pattern='*_test.py') + return suite + + +if __name__ == '__main__': + test_suite = main() + runner = unittest.TextTestRunner() + test_run = runner.run(test_suite) + sys.exit(not test_run.wasSuccessful()) diff --git a/acts/framework/tests/test_utils/power/tel/lab/init_simulation_test.py b/acts/framework/tests/test_utils/power/tel/lab/init_simulation_test.py index 1bd2f074fc..24fe91a457 100644 --- a/acts/framework/tests/test_utils/power/tel/lab/init_simulation_test.py +++ b/acts/framework/tests/test_utils/power/tel/lab/init_simulation_test.py @@ -17,8 +17,8 @@ import unittest import mobly.config_parser as mobly_config_parser import mock_bokeh -from acts.test_utils.power.tel_simulations.LteSimulation import LteSimulation -from acts.test_utils.power.tel_simulations.UmtsSimulation import UmtsSimulation +from acts.controllers.cellular_lib.LteSimulation import LteSimulation +from acts.controllers.cellular_lib.UmtsSimulation import UmtsSimulation from unittest import mock diff --git a/acts/framework/tests/test_utils/power/tel/lab/power_tel_traffic_e2e_test.py b/acts/framework/tests/test_utils/power/tel/lab/power_tel_traffic_e2e_test.py index ff9599665f..065543ff1e 100644 --- a/acts/framework/tests/test_utils/power/tel/lab/power_tel_traffic_e2e_test.py +++ b/acts/framework/tests/test_utils/power/tel/lab/power_tel_traffic_e2e_test.py @@ -18,7 +18,7 @@ import unittest import mock_bokeh import acts.test_utils.power.cellular.cellular_traffic_power_test as ctpt import mobly.config_parser as mobly_config_parser -from acts.test_utils.power.tel_simulations.LteSimulation import LteSimulation +from acts.controllers.cellular_lib.LteSimulation import LteSimulation from acts.controllers.rohdeschwarz_lib import cmw500_cellular_simulator as cmw from unittest import mock diff --git a/acts/framework/tests/test_utils/power/tel/lab/save_summary_to_file_test.py b/acts/framework/tests/test_utils/power/tel/lab/save_summary_to_file_test.py index 1e1554a0dc..900c3a74da 100644 --- a/acts/framework/tests/test_utils/power/tel/lab/save_summary_to_file_test.py +++ b/acts/framework/tests/test_utils/power/tel/lab/save_summary_to_file_test.py @@ -17,7 +17,7 @@ import unittest import mobly.config_parser as mobly_config_parser import mock_bokeh -from acts.test_utils.power.tel_simulations.LteSimulation import LteSimulation +from acts.controllers.cellular_lib.LteSimulation import LteSimulation from unittest import mock from unittest.mock import mock_open diff --git a/acts/tests/google/ble/api/BleAdvertiseApiTest.py b/acts/tests/google/ble/api/BleAdvertiseApiTest.py new file mode 100644 index 0000000000..26c459f70a --- /dev/null +++ b/acts/tests/google/ble/api/BleAdvertiseApiTest.py @@ -0,0 +1,1273 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See thea +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to exercise Ble Advertisement Api's. This exercises all getters and +setters. This is important since there is a builder object that is immutable +after you set all attributes of each object. If this test suite doesn't pass, +then other test suites utilising Ble Advertisements will also fail. +""" + +from acts.controllers.sl4a_lib import rpc_client +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import adv_fail +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers +from acts.test_utils.bt.bt_constants import java_integer + + +class BleAdvertiseVerificationError(Exception): + """Error in fetsching BleScanner Advertise result.""" + + +class BleAdvertiseApiTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.ad_dut = self.android_devices[0] + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d6d8d0a6-7b3e-4e4b-a5d0-bcfd6e207474') + def test_adv_settings_defaults(self): + """Tests the default advertisement settings. + + This builder object should have a proper "get" expectation for each + attribute of the builder object once it's built. + + Steps: + 1. Build a new advertise settings object. + 2. Get the attributes of the advertise settings object. + 3. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 0 + """ + test_result = True + droid = self.ad_dut.droid + adv_settings = droid.bleBuildAdvertiseSettings() + adv_mode = droid.bleGetAdvertiseSettingsMode(adv_settings) + tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel( + adv_settings) + is_connectable = droid.bleGetAdvertiseSettingsIsConnectable( + adv_settings) + + exp_adv_mode = ble_advertise_settings_modes['low_power'] + exp_tx_power_level = ble_advertise_settings_tx_powers['medium'] + exp_is_connectable = True + if adv_mode != exp_adv_mode: + test_result = False + self.log.debug("exp filtering mode: {}," + " found filtering mode: {}".format( + exp_adv_mode, adv_mode)) + if tx_power_level != exp_tx_power_level: + test_result = False + self.log.debug("exp tx power level: {}," + " found filtering tx power level: {}".format( + exp_tx_power_level, tx_power_level)) + if exp_is_connectable != is_connectable: + test_result = False + self.log.debug("exp is connectable: {}," + " found filtering is connectable: {}".format( + exp_is_connectable, is_connectable)) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f2a276ae-1436-43e4-aba7-1ede787200ee') + def test_adv_data_defaults(self): + """Tests the default advertisement data. + + This builder object should have a proper "get" expectation for each + attribute of the builder object once it's built. + + Steps: + 1. Build a new AdvertiseData object. + 2. Get the attributes of the advertise settings object. + 3. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 0 + """ + test_result = True + droid = self.ad_dut.droid + adv_data = droid.bleBuildAdvertiseData() + service_uuids = droid.bleGetAdvertiseDataServiceUuids(adv_data) + include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel( + adv_data) + include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName( + adv_data) + + exp_service_uuids = [] + exp_include_tx_power_level = False + exp_include_device_name = False + self.log.debug("Step 4: Verify all defaults match exp values.") + if service_uuids != exp_service_uuids: + test_result = False + self.log.debug("exp filtering service uuids: {}," + " found filtering service uuids: {}".format( + exp_service_uuids, service_uuids)) + if include_tx_power_level != exp_include_tx_power_level: + test_result = False + self.log.debug( + "exp filtering include tx power level:: {}," + " found filtering include tx power level: {}".format( + exp_include_tx_power_level, include_tx_power_level)) + if include_device_name != exp_include_device_name: + test_result = False + self.log.debug( + "exp filtering include tx power level: {}," + " found filtering include tx power level: {}".format( + exp_include_device_name, include_device_name)) + if not test_result: + self.log.debug("Some values didn't match the defaults.") + else: + self.log.debug("All default values passed.") + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8d462e60-6b4e-49f3-9ef4-5a8b612d285d') + def test_adv_settings_set_adv_mode_balanced(self): + """Tests advertise settings balanced mode. + + This advertisement settings from "set" advertisement mode should match + the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to balanced. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_mode = ble_advertise_settings_modes['balanced'] + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_adv_mode)) + return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='334fefeb-365f-4ee3-9be0-42b1fabe3178') + def test_adv_settings_set_adv_mode_low_power(self): + """Tests advertise settings low power mode. + + This advertisement settings from "set" advertisement mode should match + the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to low power mode. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_mode = ble_advertise_settings_modes['low_power'] + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_adv_mode)) + return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ce087782-1535-4694-944a-e962c22638ed') + def test_adv_settings_set_adv_mode_low_latency(self): + """Tests advertise settings low latency mode. + + This advertisement settings from "set" advertisement mode should match + the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to low latency mode. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_mode = ble_advertise_settings_modes['low_latency'] + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_adv_mode)) + return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='59b52be9-d38b-4814-af08-c68aa8910a16') + def test_adv_settings_set_invalid_adv_mode(self): + """Tests advertise settings invalid advertising mode. + + This advertisement settings from "set" advertisement mode should fail + when setting an invalid advertisement. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to -1. + + Expected Result: + Building the advertise settings should fail. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 2 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_mode = -1 + self.log.debug("Step 2: Set the filtering mode to -1") + return self.verify_invalid_adv_settings_adv_mode(droid, exp_adv_mode) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d8292633-831f-41c4-974a-ad267e9795e9') + def test_adv_settings_set_adv_tx_power_level_high(self): + """Tests advertise settings tx power level high. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to tx power level high. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_tx_power = ble_advertise_settings_tx_powers['high'] + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_adv_tx_power)) + return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d577de1f-4fd9-43d5-beff-c0696c5e0ea1') + def test_adv_settings_set_adv_tx_power_level_medium(self): + """Tests advertise settings tx power level medium. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to tx power level medium. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + test_result = True + droid = self.ad_dut.droid + exp_adv_tx_power = ble_advertise_settings_tx_powers['medium'] + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_adv_tx_power)) + return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') + def test_adv_settings_set_adv_tx_power_level_low(self): + """Tests advertise settings tx power level low. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to tx power level low. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_tx_power = (ble_advertise_settings_tx_powers['low']) + self.log.debug( + "Step 2: Set the filtering settings object's value to ".format( + exp_adv_tx_power)) + return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') + def test_adv_settings_set_adv_tx_power_level_ultra_low(self): + """Tests advertise settings tx power level ultra low. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise mode attribute to tx power level ultra low. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_tx_power = ble_advertise_settings_tx_powers['ultra_low'] + self.log.debug( + "Step 2: Set the filtering settings object's value to ".format( + exp_adv_tx_power)) + return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') + def test_adv_settings_set_invalid_adv_tx_power_level(self): + """Tests advertise settings invalid advertising tx power level. + + This advertisement settings from "set" advertisement mode should fail + when setting an invalid advertisement. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise tx power level attribute to -1. + + Expected Result: + Building the advertise settings should fail. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_adv_tx_power = -1 + self.log.debug("Step 2: Set the filtering mode to -1") + return self.verify_invalid_adv_settings_tx_power_level( + droid, exp_adv_tx_power) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1be71f77-64af-42b7-84cb-e06df0836966') + def test_adv_settings_set_is_connectable_true(self): + """Tests advertise settings is connectable true. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise is connectable to true. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_is_connectable = True + self.log.debug( + "Step 2: Set the filtering settings object's value to {}".format( + exp_is_connectable)) + return self.verify_adv_settings_is_connectable(droid, + exp_is_connectable) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f9865333-9198-4385-938d-5fc641ee9968') + def test_adv_settings_set_is_connectable_false(self): + """Tests advertise settings is connectable false. + + This advertisement settings from "set" advertisement tx power level + should match the corresponding "get" function. + + Steps: + 1. Build a new advertise settings object. + 2. Set the advertise is connectable to false. + 3. Get the attributes of the advertise settings object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_is_connectable = False + self.log.debug("Step 2: Set the filtering settings object's value to " + + str(exp_is_connectable)) + return self.verify_adv_settings_is_connectable(droid, + exp_is_connectable) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a770ed7e-c6cd-4533-8876-e42e68f8b4fb') + def test_adv_data_set_service_uuids_empty(self): + """Tests advertisement data's service uuids to empty. + + This advertisement data from "set" advertisement service uuid + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service uuid to empty. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_uuids = [] + self.log.debug("Step 2: Set the filtering data object's value to " + + str(exp_service_uuids)) + return self.verify_adv_data_service_uuids(droid, exp_service_uuids) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3da511db-d024-45c8-be3c-fe8e123129fa') + def test_adv_data_set_service_uuids_single(self): + """Tests advertisement data's service uuids to empty. + + This advertisement data from "set" advertisement service uuid + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service uuid to empty. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_uuids = ["00000000-0000-1000-8000-00805f9b34fb"] + self.log.debug("Step 2: Set the filtering data object's value to " + + str(exp_service_uuids)) + return self.verify_adv_data_service_uuids(droid, exp_service_uuids) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='15073359-d607-4a76-b60a-00a4b34f9a85') + def test_adv_data_set_service_uuids_multiple(self): + """Tests advertisement data's service uuids to multiple uuids. + + This advertisement data from "set" advertisement service uuid + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service uuid to multiple uuids. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_uuids = [ + "00000000-0000-1000-8000-00805f9b34fb", + "00000000-0000-1000-8000-00805f9b34fb" + ] + self.log.debug("Step 2: Set the filtering data object's value to " + + str(exp_service_uuids)) + return self.verify_adv_data_service_uuids(droid, exp_service_uuids) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='af783a71-ef80-4974-a077-16a4ed8f0114') + def test_adv_data_set_service_uuids_invalid_uuid(self): + """Tests advertisement data's service uuids to an invalid uuid. + + This advertisement data from "set" advertisement service uuid + should fail when there is an invalid service uuid. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service uuid to an invalid uuid. + + Expected Result: + Building the AdvertiseData should fail. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_uuids = ["0"] + self.log.debug("Step 2: Set the filtering data service uuids to " + + str(exp_service_uuids)) + return self.verify_invalid_adv_data_service_uuids( + droid, exp_service_uuids) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='51d634e7-6271-4cc0-a57b-3c1b632a7db6') + def test_adv_data_set_service_data(self): + """Tests advertisement data's service data. + + This advertisement data from "set" advertisement service data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service data. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb" + exp_service_data = [1, 2, 3] + self.log.debug( + "Step 2: Set the filtering data object's service data uuid to: {}, " + "service data: {}".format(exp_service_data_uuid, exp_service_data)) + return self.verify_adv_data_service_data(droid, exp_service_data_uuid, + exp_service_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='aa18b0af-2a41-4b2a-af64-ea639961d561') + def test_adv_data_set_service_data_invalid_service_data(self): + """Tests advertisement data's invalid service data. + + This advertisement data from "set" advertisement service data + should fail on an invalid value. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service data to an invalid value. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb" + exp_service_data = "helloworld" + self.log.debug( + "Step 2: Set the filtering data object's service data uuid to: {}, " + "service data: {}".format(exp_service_data_uuid, exp_service_data)) + return self.verify_invalid_adv_data_service_data( + droid, exp_service_data_uuid, exp_service_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='13a75a47-eff4-429f-a436-d244bbfe4496') + def test_adv_data_set_service_data_invalid_service_data_uuid(self): + """Tests advertisement data's invalid service data and uuid. + + This advertisement data from "set" advertisement service data + should fail on an invalid value. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's service data and uuid to an invalid value. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_service_data_uuid = "0" + exp_service_data = "1,2,3" + self.log.debug( + "Step 2: Set the filtering data object's service data uuid to: {}, " + "service data: {}".format(exp_service_data_uuid, exp_service_data)) + return self.verify_invalid_adv_data_service_data( + droid, exp_service_data_uuid, exp_service_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='386024e2-212e-4eed-8ef3-43d0c0239ea5') + def test_adv_data_set_manu_id(self): + """Tests advertisement data's manufacturers data and id. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's manufacturers data and id. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_manu_id = 0 + exp_manu_specific_data = [1, 2, 3] + self.log.debug( + "Step 2: Set the filtering data object's service data manu id: {}" + ", manu specific data: {}".format(exp_manu_id, + exp_manu_specific_data)) + return self.verify_adv_data_manu_id(droid, exp_manu_id, + exp_manu_specific_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='650ceff2-2760-4a34-90fb-e637a2c5ebb5') + def test_adv_data_set_manu_id_invalid_manu_id(self): + """Tests advertisement data's manufacturers invalid id. + + This advertisement data from "set" advertisement manufacturers data + should not be successful on an invalid id. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's manufacturers id to -1. + 3. Build the advertisement data. + + Expected Result: + Building the advertisement data should fail. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_manu_id = -1 + exp_manu_specific_data = [1, 2, 3] + self.log.debug( + "Step 2: Set the filtering data object's service data manu id: {}" + ", manu specific data: {}".format(exp_manu_id, + exp_manu_specific_data)) + return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id, + exp_manu_specific_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='27ccd7d7-9cd2-4e95-8198-ef6ca746d1cc') + def test_adv_data_set_manu_id_invalid_manu_specific_data(self): + """Tests advertisement data's manufacturers invalid specific data. + + This advertisement data from "set" advertisement manufacturers data + should not be successful on an invalid specific data. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's manufacturers specific data to helloworld. + 3. Build the advertisement data. + + Expected Result: + Building the advertisement data should fail. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_manu_id = 0 + exp_manu_specific_data = ['helloworld'] + self.log.debug( + "Step 2: Set the filtering data object's service data manu id: {}" + ", manu specific data: {}".format(exp_manu_id, + exp_manu_specific_data)) + return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id, + exp_manu_specific_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8e78d444-cd25-4c17-9532-53972a6f0ffe') + def test_adv_data_set_manu_id_max(self): + """Tests advertisement data's manufacturers id to the max size. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's manufacturers id to JavaInterger.MAX value. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 3 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_manu_id = java_integer['max'] + exp_manu_specific_data = [1, 2, 3] + self.log.debug( + "Step 2: Set the filtering data object's service data manu id: {}" + ", manu specific data: {}".format(exp_manu_id, + exp_manu_specific_data)) + return self.verify_adv_data_manu_id(droid, exp_manu_id, + exp_manu_specific_data) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6c4866b7-ddf5-44ef-a231-0af683c6db80') + def test_adv_data_set_include_tx_power_level_true(self): + """Tests advertisement data's include tx power level to True. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's include tx power level to True. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_include_tx_power_level = True + self.log.debug( + "Step 2: Set the filtering data object's include tx power level: " + "{}".format(exp_include_tx_power_level)) + return self.verify_adv_data_include_tx_power_level( + droid, exp_include_tx_power_level) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='db06cc5f-60cf-4f04-b0fe-0c354f987541') + def test_adv_data_set_include_tx_power_level_false(self): + """Tests advertisement data's include tx power level to False. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's include tx power level to False. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_include_tx_power_level = False + self.log.debug( + "Step 2: Set the filtering data object's include tx power level: {}" + .format(exp_include_tx_power_level)) + return self.verify_adv_data_include_tx_power_level( + droid, exp_include_tx_power_level) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e99480c4-fd37-4791-a8d0-7eb8f8f72d62') + def test_adv_data_set_include_device_name_true(self): + """Tests advertisement data's include device name to True. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's include device name to True. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + droid = self.ad_dut.droid + exp_include_device_name = True + self.log.debug( + "Step 2: Set the filtering data object's include device name: {}" + .format(exp_include_device_name)) + return self.verify_adv_data_include_device_name( + droid, exp_include_device_name) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b89ed642-c426-4777-8217-7bb8c2058592') + def test_adv_data_set_include_device_name_false(self): + """Tests advertisement data's include device name to False. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's include device name to False. + 3. Get the attributes of the AdvertiseData object. + 4. Compare the attributes found against the attributes exp. + + Expected Result: + Found attributes should match expected attributes. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + self.log.debug("Step 1: Setup environment.") + test_result = True + droid = self.ad_dut.droid + exp_include_device_name = False + self.log.debug( + "Step 2: Set the filtering data object's include device name: {}". + format(exp_include_device_name)) + return self.verify_adv_data_include_device_name( + droid, exp_include_device_name) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5033bcf5-a841-4b8b-af35-92c7237c7b36') + def test_advertisement_greater_than_31_bytes(self): + """Tests advertisement data's size to be greater than 31 bytes. + + This advertisement data from "set" advertisement manufacturers data + should match the corresponding "get" function. + + Steps: + 1. Build a new AdvertiseData object. + 2. Set the AdvertiseData's size to be greater than 31 bytes + 3. Build the advertisement data. + + Expected Result: + Api fails to build the AdvertiseData. + + Returns: + True is pass + False if fail + + TAGS: LE, Advertising + Priority: 1 + """ + test_result = True + droid = self.ad_dut.droid + ed = self.android_devices[0].ed + service_data = [] + for i in range(25): + service_data.append(i) + droid.bleAddAdvertiseDataServiceData( + "0000110D-0000-1000-8000-00805F9B34FB", service_data) + advcallback, adv_data, adv_settings = generate_ble_advertise_objects( + droid) + droid.bleStartBleAdvertising(advcallback, adv_data, adv_settings) + try: + ed.pop_event(adv_fail.format(advcallback)) + except rpc_client.Sl4aApiError: + self.log.info("{} event was not found.".format( + adv_fail.format(advcallback))) + return False + return test_result + + def verify_adv_settings_adv_mode(self, droid, exp_adv_mode): + try: + droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering settings object's index.") + settings_index = droid.bleBuildAdvertiseSettings() + self.log.debug("Step 4: Get the filtering setting's filtering mode.") + adv_mode = droid.bleGetAdvertiseSettingsMode(settings_index) + if exp_adv_mode is not adv_mode: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_adv_mode, adv_mode)) + return False + self.log.debug("Advertise Setting's filtering mode {} value " + "test Passed.".format(exp_adv_mode)) + return True + + def verify_adv_settings_tx_power_level(self, droid, exp_adv_tx_power): + try: + droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering settings object's index.") + settings_index = droid.bleBuildAdvertiseSettings() + self.log.debug("Step 4: Get the filtering setting's tx power level.") + adv_tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel( + settings_index) + if exp_adv_tx_power is not adv_tx_power_level: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_adv_tx_power, adv_tx_power_level)) + return False + self.log.debug("Advertise Setting's tx power level {}" + " value test Passed.".format(exp_adv_tx_power)) + return True + + def verify_adv_settings_is_connectable(self, droid, exp_is_connectable): + try: + droid.bleSetAdvertiseSettingsIsConnectable(exp_is_connectable) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering settings object's index.") + settings_index = droid.bleBuildAdvertiseSettings() + self.log.debug( + "Step 4: Get the filtering setting's is connectable value.") + is_connectable = droid.bleGetAdvertiseSettingsIsConnectable( + settings_index) + if exp_is_connectable is not is_connectable: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_is_connectable, is_connectable)) + return False + self.log.debug("Advertise Setting's is connectable {}" + " value test Passed.".format(exp_is_connectable)) + return True + + def verify_adv_data_service_uuids(self, droid, exp_service_uuids): + try: + droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering data object's index.") + data_index = droid.bleBuildAdvertiseData() + self.log.debug("Step 4: Get the filtering data's service uuids.") + service_uuids = droid.bleGetAdvertiseDataServiceUuids(data_index) + if exp_service_uuids != service_uuids: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_service_uuids, service_uuids)) + return False + self.log.debug( + "Advertise Data's service uuids {}, value test Passed.".format( + exp_service_uuids)) + return True + + def verify_adv_data_service_data(self, droid, exp_service_data_uuid, + exp_service_data): + try: + droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid, + exp_service_data) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering data object's index.") + data_index = droid.bleBuildAdvertiseData() + self.log.debug("Step 4: Get the filtering data's service data.") + service_data = droid.bleGetAdvertiseDataServiceData( + data_index, exp_service_data_uuid) + if exp_service_data != service_data: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_service_data, service_data)) + return False + self.log.debug("Advertise Data's service data uuid: {}, service data: " + "{}, value test Passed.".format(exp_service_data_uuid, + exp_service_data)) + return True + + def verify_adv_data_manu_id(self, droid, exp_manu_id, + exp_manu_specific_data): + try: + droid.bleAddAdvertiseDataManufacturerId(exp_manu_id, + exp_manu_specific_data) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering data object's index.") + data_index = droid.bleBuildAdvertiseData() + self.log.debug("Step 5: Get the filtering data's manu specific data.") + manu_specific_data = droid.bleGetAdvertiseDataManufacturerSpecificData( + data_index, exp_manu_id) + if exp_manu_specific_data != manu_specific_data: + self.log.debug("exp value: " + str(exp_manu_specific_data) + + ", Actual value: " + str(manu_specific_data)) + return False + self.log.debug("Advertise Data's manu id: " + str(exp_manu_id) + + ", manu's specific data: " + + str(exp_manu_specific_data) + " value test Passed.") + return True + + def verify_adv_data_include_tx_power_level(self, droid, + exp_include_tx_power_level): + try: + droid.bleSetAdvertiseDataIncludeTxPowerLevel( + exp_include_tx_power_level) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering settings object's index.") + data_index = droid.bleBuildAdvertiseData() + self.log.debug( + "Step 4: Get the filtering data's include tx power level.") + include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel( + data_index) + if exp_include_tx_power_level is not include_tx_power_level: + self.log.debug("exp value: " + str(exp_include_tx_power_level) + + ", Actual value: " + str(include_tx_power_level)) + return False + self.log.debug("Advertise Setting's include tx power level " + str( + exp_include_tx_power_level) + " value test Passed.") + return True + + def verify_adv_data_include_device_name(self, droid, + exp_include_device_name): + try: + droid.bleSetAdvertiseDataIncludeDeviceName(exp_include_device_name) + except BleAdvertiseVerificationError as error: + self.log.debug(str(error)) + return False + self.log.debug("Step 3: Get a filtering settings object's index.") + data_index = droid.bleBuildAdvertiseData() + self.log.debug("Step 4: Get the filtering data's include device name.") + include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName( + data_index) + if exp_include_device_name is not include_device_name: + self.log.debug("exp value: {}, Actual value: {}".format( + exp_include_device_name, include_device_name)) + return False + self.log.debug("Advertise Setting's include device name {}" + " value test Passed.".format(exp_include_device_name)) + return True + + def verify_invalid_adv_settings_adv_mode(self, droid, exp_adv_mode): + try: + droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode) + droid.bleBuildAdvertiseSettings() + self.log.debug("Set Advertise settings invalid filtering mode " + "passed with input as {}".format(exp_adv_mode)) + return False + except rpc_client.Sl4aApiError: + self.log.debug( + "Set Advertise settings invalid filtering mode " + "failed successfully with input as {}".format(exp_adv_mode)) + return True + + def verify_invalid_adv_settings_tx_power_level(self, droid, + exp_adv_tx_power): + try: + droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power) + droid.bleBuildAdvertiseSettings() + self.log.debug("Set Advertise settings invalid tx power level " + + " with input as {}".format(exp_adv_tx_power)) + return False + except rpc_client.Sl4aApiError: + self.log.debug( + "Set Advertise settings invalid tx power level " + "failed successfullywith input as {}".format(exp_adv_tx_power)) + return True + + def verify_invalid_adv_data_service_uuids(self, droid, exp_service_uuids): + try: + droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids) + droid.bleBuildAdvertiseData() + self.log.debug("Set Advertise Data service uuids " + + " with input as {}".format(exp_service_uuids)) + return False + except rpc_client.Sl4aApiError: + self.log.debug( + "Set Advertise Data invalid service uuids failed " + "successfully with input as {}".format(exp_service_uuids)) + return True + + def verify_invalid_adv_data_service_data( + self, droid, exp_service_data_uuid, exp_service_data): + try: + droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid, + exp_service_data) + droid.bleBuildAdvertiseData() + self.log.debug("Set Advertise Data service data uuid: {}," + ", service data: {}".format(exp_service_data_uuid, + exp_service_data)) + return False + except rpc_client.Sl4aApiError: + self.log.debug("Set Advertise Data service data uuid: " + + str(exp_service_data_uuid) + ", service data: " + + str(exp_service_data) + " failed successfully.") + return True + + def verify_invalid_adv_data_manu_id(self, droid, exp_manu_id, + exp_manu_specific_data): + try: + droid.bleAddAdvertiseDataManufacturerId(exp_manu_id, + exp_manu_specific_data) + droid.bleBuildAdvertiseData() + self.log.debug( + "Set Advertise Data manu id: " + str(exp_manu_id) + + ", manu specific data: " + str(exp_manu_specific_data)) + return False + except rpc_client.Sl4aApiError: + self.log.debug("Set Advertise Data manu id: {}," + " manu specific data: {},".format( + exp_manu_id, exp_manu_specific_data)) + return True diff --git a/acts/tests/google/ble/api/BleScanApiTest.py b/acts/tests/google/ble/api/BleScanApiTest.py new file mode 100644 index 0000000000..06f2362079 --- /dev/null +++ b/acts/tests/google/ble/api/BleScanApiTest.py @@ -0,0 +1,1296 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to exercise Ble Scan Api's. This exercises all getters and +setters. This is important since there is a builder object that is immutable +after you set all attributes of each object. If this test suite doesn't pass, +then other test suites utilising Ble Scanner will also fail. +""" + +from acts.controllers.sl4a_lib import rpc_client +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_result_types +from acts.test_utils.bt.bt_constants import ble_scan_settings_report_delay_milli_seconds +from acts.test_utils.bt.bt_constants import ble_uuids + + +class BleScanResultsError(Exception): + """Error in getting scan results""" + + +class BleScanVerificationError(Exception): + """Error in comparing BleScan results""" + + +class BleSetScanSettingsError(Exception): + """Error in setting Ble Scan Settings""" + + +class BleSetScanFilterError(Exception): + """Error in setting Ble Scan Settings""" + + +class BleScanApiTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.ad_dut = self.android_devices[0] + + def _format_defaults(self, input): + """ + Creates a dictionary of default ScanSetting and ScanFilter Values. + :return: input: dict + """ + if 'ScanSettings' not in input.keys(): + input['ScanSettings'] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + if 'ScanFilterManufacturerDataId' not in input.keys(): + input['ScanFilterManufacturerDataId'] = -1 + if 'ScanFilterDeviceName' not in input.keys(): + input['ScanFilterDeviceName'] = None + if 'ScanFilterDeviceAddress' not in input.keys(): + input['ScanFilterDeviceAddress'] = None + if 'ScanFilterManufacturerData' not in input.keys(): + input['ScanFilterManufacturerData'] = None + return input + + def validate_scan_settings_helper(self, input, droid): + """ + Validates each input of the scan settings object that is matches what + was set or not set such that it matches the defaults. + :return: False at any point something doesn't match. True if everything + matches. + """ + filter_list = droid.bleGenFilterList() + if 'ScanSettings' in input.keys(): + try: + droid.bleSetScanSettingsCallbackType(input['ScanSettings'][0]) + droid.bleSetScanSettingsReportDelayMillis( + input['ScanSettings'][1]) + droid.bleSetScanSettingsScanMode(input['ScanSettings'][2]) + droid.bleSetScanSettingsResultType(input['ScanSettings'][3]) + except rpc_client.Sl4aApiError as error: + self.log.debug("Set Scan Settings failed with: ".format(error)) + return False + if 'ScanFilterDeviceName' in input.keys(): + try: + droid.bleSetScanFilterDeviceName(input['ScanFilterDeviceName']) + except rpc_client.Sl4aApiError as error: + self.log.debug("Set Scan Filter Device Name failed with: {}" + .format(error)) + return False + if 'ScanFilterDeviceAddress' in input.keys(): + try: + droid.bleSetScanFilterDeviceAddress( + input['ScanFilterDeviceAddress']) + except rpc_client.Sl4aApiError as error: + self.log.debug("Set Scan Filter Device Address failed with: {}" + .format(error)) + return False + if ('ScanFilterManufacturerDataId' in input.keys() + and 'ScanFilterManufacturerDataMask' in input.keys()): + try: + droid.bleSetScanFilterManufacturerData( + input['ScanFilterManufacturerDataId'], + input['ScanFilterManufacturerData'], + input['ScanFilterManufacturerDataMask']) + except rpc_client.Sl4aApiError as error: + self.log.debug("Set Scan Filter Manufacturer info with data " + "mask failed with: {}".format(error)) + return False + if ('ScanFilterManufacturerDataId' in input.keys() + and 'ScanFilterManufacturerData' in input.keys() + and 'ScanFilterManufacturerDataMask' not in input.keys()): + try: + droid.bleSetScanFilterManufacturerData( + input['ScanFilterManufacturerDataId'], + input['ScanFilterManufacturerData']) + except rpc_client.Sl4aApiError as error: + self.log.debug( + "Set Scan Filter Manufacturer info failed with: " + "{}".format(error)) + return False + if ('ScanFilterServiceUuid' in input.keys() + and 'ScanFilterServiceMask' in input.keys()): + + droid.bleSetScanFilterServiceUuid(input['ScanFilterServiceUuid'], + input['ScanFilterServiceMask']) + + input = self._format_defaults(input) + scan_settings_index = droid.bleBuildScanSetting() + scan_settings = ( + droid.bleGetScanSettingsCallbackType(scan_settings_index), + droid.bleGetScanSettingsReportDelayMillis(scan_settings_index), + droid.bleGetScanSettingsScanMode(scan_settings_index), + droid.bleGetScanSettingsScanResultType(scan_settings_index)) + + scan_filter_index = droid.bleBuildScanFilter(filter_list) + device_name_filter = droid.bleGetScanFilterDeviceName( + filter_list, scan_filter_index) + device_address_filter = droid.bleGetScanFilterDeviceAddress( + filter_list, scan_filter_index) + manufacturer_id = droid.bleGetScanFilterManufacturerId( + filter_list, scan_filter_index) + manufacturer_data = droid.bleGetScanFilterManufacturerData( + filter_list, scan_filter_index) + + if scan_settings != input['ScanSettings']: + self.log.debug("Scan Settings did not match. expected: {}, found: " + "{}".format(input['ScanSettings'], scan_settings)) + return False + if device_name_filter != input['ScanFilterDeviceName']: + self.log.debug("Scan Filter device name did not match. expected: " + "{}, found {}".format(input['ScanFilterDeviceName'], + device_name_filter)) + return False + if device_address_filter != input['ScanFilterDeviceAddress']: + self.log.debug( + "Scan Filter address name did not match. expected: " + "{}, found: {}".format(input['ScanFilterDeviceAddress'], + device_address_filter)) + return False + if manufacturer_id != input['ScanFilterManufacturerDataId']: + self.log.debug("Scan Filter manufacturer data id did not match. " + "expected: {}, found: {}".format( + input['ScanFilterManufacturerDataId'], + manufacturer_id)) + return False + if manufacturer_data != input['ScanFilterManufacturerData']: + self.log.debug("Scan Filter manufacturer data did not match. " + "expected: {}, found: {}".format( + input['ScanFilterManufacturerData'], + manufacturer_data)) + return False + if 'ScanFilterManufacturerDataMask' in input.keys(): + manufacturer_data_mask = droid.bleGetScanFilterManufacturerDataMask( + filter_list, scan_filter_index) + if manufacturer_data_mask != input['ScanFilterManufacturerDataMask']: + self.log.debug( + "Manufacturer data mask did not match. expected:" + " {}, found: {}".format( + input['ScanFilterManufacturerDataMask'], + manufacturer_data_mask)) + + return False + if ('ScanFilterServiceUuid' in input.keys() + and 'ScanFilterServiceMask' in input.keys()): + + expected_service_uuid = input['ScanFilterServiceUuid'] + expected_service_mask = input['ScanFilterServiceMask'] + service_uuid = droid.bleGetScanFilterServiceUuid( + filter_list, scan_filter_index) + service_mask = droid.bleGetScanFilterServiceUuidMask( + filter_list, scan_filter_index) + if service_uuid != expected_service_uuid.lower(): + self.log.debug("Service uuid did not match. expected: {}, " + "found {}".format(expected_service_uuid, + service_uuid)) + return False + if service_mask != expected_service_mask.lower(): + self.log.debug("Service mask did not match. expected: {}, " + "found {}".format(expected_service_mask, + service_mask)) + return False + self.scan_settings_index = scan_settings_index + self.filter_list = filter_list + self.scan_callback = droid.bleGenScanCallback() + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5ffc9f7b-c261-4bf0-9a6b-7fda182b6c97') + def test_start_ble_scan_with_default_settings(self): + """Test LE scan with default settings. + + Test to validate all default scan settings values. + + Steps: + 1. Create LE scan objects. + 2. Start LE scan. + + Expected Result: + Scan starts successfully and matches expected settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='88c3b0cb-b4d4-45d1-be25-9855290a6d03') + def test_stop_ble_scan_default_settings(self): + """Test stopping an LE scan. + + Test default scan settings on an actual scan. Verify it can also stop + the scan. + + Steps: + 1. Validate default scan settings. + 2. Start ble scan. + 3. Stop ble scan. + + Expected Result: + LE scan is stopped successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 0 + """ + input = {} + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + if not test_result: + self.log.error("Could not setup ble scanner.") + return test_result + self.ad_dut.droid.bleStartBleScan( + self.filter_list, self.scan_settings_index, self.scan_callback) + try: + self.ad_dut.droid.bleStopBleScan(self.scan_callback) + except BleScanResultsError as error: + self.log.error(str(error)) + test_result = False + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5aa7a4c2-0b7d-4000-a980-f00c9329a7b9') + def test_scan_settings_callback_type_all_matches(self): + """Test LE scan settings callback type all matches. + + Test scan settings callback type all matches. + + Steps: + 1. Validate the scan settings callback type with all other settings set + to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='fd764861-aa76-480e-b2d2-5d55a888d123') + def test_scan_settings_set_callback_type_first_match(self): + """Test LE scan settings callback type first match + + Test scan settings callback type first match. + + Steps: + 1. Validate the scan settings callback type with all other settings set + to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['first_match'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='52e4626e-199c-4755-b9f1-8b38ecb30896') + def test_scan_settings_set_callback_type_match_lost(self): + """Test LE scan settings callback type match lost. + + Test scan settings callback type match lost. + + Steps: + 1. Validate the scan settings callback type with all other settings set + to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['match_lost'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='57476b3c-ba7a-4342-86f6-1b56b2c00181') + def test_scan_settings_set_invalid_callback_type(self): + """Test LE scan settings invalid callback type. + + Test scan settings invalid callback type -1. + + Steps: + 1. Build a LE ScanSettings object with an invalid callback type. + + Expected Result: + Api should fail to build object. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input["ScanSettings"] = (-1, 0, ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + return not test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='52c80f0c-4f26-4cda-8a6b-291ac52f673a') + def test_scan_settings_set_scan_mode_low_power(self): + """Test LE scan settings scan mode low power mode. + + Test scan settings scan mode low power. + + Steps: + 1. Validate the scan settings scan mode with all other settings set to + their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='20f4513c-44a7-435d-be4e-03420093297a') + def test_scan_settings_set_scan_mode_balanced(self): + """Test LE scan settings scan mode balanced. + + Test scan settings scan mode balanced. + + Steps: + 1. Validate the scan settings scan mode with all other settings set to + their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['balanced'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='bf14e7fd-853b-4833-8fef-8c4bd629374b') + def test_scan_settings_set_scan_mode_low_latency(self): + """Test LE scan settings scan mode low latency. + + Test scan settings scan mode low latency. + + Steps: + 1. Validate the scan settings scan mode with all other settings set to + their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_latency'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9f3b2e10-98f8-4d6a-b6b6-e8dee87063f0') + def test_scan_settings_set_invalid_scan_mode(self): + """Test LE scan settings scan mode as an invalid value. + Test scan settings invalid scan mode -2. + Steps: + 1. Set the scan settings scan mode to -2. + + Expected Result: + Building the ScanSettings object should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, -2, + ble_scan_settings_result_types['full']) + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cb246be7-4fef-4313-964d-5fb6dbe558c8') + def test_scan_settings_set_report_delay_millis_min(self): + """Test scan settings report delay millis as min value + + Test scan settings report delay millis min acceptable value. + + Steps: + 1. Validate the scan settings report delay millis with all other + settings set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], + ble_scan_settings_report_delay_milli_seconds['min'], + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='db1ea8f6-503d-4e9a-b61a-01210508c5a2') + def test_scan_settings_set_report_delay_millis_min_plus_one(self): + """Test scan settings report delay millis as min value plus one. + + Test scan settings report delay millis as min value plus one. + + Steps: + 1. Validate the scan settings report delay millis with all other + settings set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 4 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], + ble_scan_settings_report_delay_milli_seconds['min'] + 1, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='54e83ff8-92b0-473e-839a-1ff1c7dcea83') + def test_scan_settings_set_report_delay_millis_max(self): + """Test scan settings report delay millis as max value. + + Test scan settings report delay millis max value. + + Steps: + 1. Validate the scan settings report delay millis with all other + settings set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 3 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], + ble_scan_settings_report_delay_milli_seconds['max'], + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='45d918ec-7e43-463b-8f07-f009f8808903') + def test_scan_settings_set_report_delay_millis_max_minus_one(self): + """Test scan settings report delay millis as max value minus one. + + Test scan settings report delay millis max value - 1. + + Steps: + 1. Validate the scan settings report delay millis with all other + settings set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 3 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], + ble_scan_settings_report_delay_milli_seconds['max'] - 1, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='eb94b5ee-f2e7-4322-b3df-7bdd3a250262') + def test_scan_settings_set_invalid_report_delay_millis_min_minus_one(self): + """Test scan settings report delay millis as an invalid value. + + Test scan settings invalid report delay millis min value - 1. + + Steps: + 1. Set scan settings report delay millis to min value -1. + 2. Build scan settings object. + + Expected Result: + Building scan settings object should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + droid = self.ad_dut.droid + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], + ble_scan_settings_report_delay_milli_seconds['min'] - 1, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return not self.validate_scan_settings_helper(input, droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8f5a2bd0-6037-4ac6-a962-f11e7fc13920') + def test_scan_settings_set_scan_result_type_full(self): + """Test scan settings result type full. + + Test scan settings result type full. + + Steps: + 1. Validate the scan settings result type with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['full']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='610fe301-600e-443e-a28b-cd722cc8a4c1') + def test_scan_settings_set_scan_result_type_abbreviated(self): + """Test scan settings result type abbreviated. + + Test scan settings result type abbreviated. + + Steps: + 1. Validate the scan settings result type with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], + ble_scan_settings_result_types['abbreviated']) + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ed58430b-8180-472f-a118-64f5fce5e84c') + def test_scan_settings_set_invalid_scan_result_type(self): + """Test scan settings result type as an invalid value. + + Test scan settings invalid result type -1. + + Steps: + 1. Set scan settings result type as an invalid value. + 2. Build scan settings object. + + Expected Result: + Expected Scan settings should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input["ScanSettings"] = ( + ble_scan_settings_callback_types['all_matches'], 0, + ble_scan_settings_modes['low_power'], -1) + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6489665f-313d-4b1b-bd7f-f0fdeeaad335') + def test_scan_filter_set_device_name(self): + """Test scan filter set valid device name. + + Test scan filter device name sl4atest. + + Steps: + 1. Validate the scan filter device name with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan settings. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input['ScanFilterDeviceName'] = "sl4atest" + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='76021a9a-14ca-4a2f-a908-96ab90db39ce') + def test_scan_filter_set_device_name_blank(self): + """Test scan filter set blank device name. + + Test scan filter device name blank. + + Steps: + 1. Validate the scan filter device name with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + droid = self.ad_dut.droid + input = {} + input['ScanFilterDeviceName'] = "" + return self.validate_scan_settings_helper(input, droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d77c3d81-43a9-4572-a99b-87969117ede5') + def test_scan_filter_set_device_name_special_chars(self): + """Test scan filter set device name as special chars. + + Test scan filter device name special characters. + + Steps: + 1. Validate the scan filter device name with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input['ScanFilterDeviceName'] = "!@#$%^&*()\":<>/" + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1697004e-76ab-444b-9419-0437e30444ad') + def test_scan_filter_set_device_address(self): + """Test scan filter set valid device address. + + Test scan filter device address valid. + + Steps: + 1. Validate the scan filter device address with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input['ScanFilterDeviceAddress'] = "01:02:03:AB:CD:EF" + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='eab0409c-7fc5-4d1f-8fbe-5ee2bb743f7e') + def test_scan_filter_set_invalid_device_address_lower_case(self): + """Test scan filter set invalid device address. + + Test scan filter device address lower case. + + Steps: + 1. Set the scan filter address to an invalid, lowercase mac address + + Expected Result: + Api to build scan filter should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input['ScanFilterDeviceAddress'] = "01:02:03:ab:cd:ef" + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0ec491ac-d273-468e-bbfe-e36a290aeb2a') + def test_scan_filter_set_invalid_device_address_blank(self): + """Test scan filter set invalid device address. + + Test scan filter invalid device address blank. + + Steps: + 1. Set the scan filter address to an invalid, blank mac address + + Expected Result: + Api to build scan filter should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input['ScanFilterDeviceAddress'] = "" + test_result = self.validate_scan_settings_helper( + input, self.ad_dut.droid) + return not test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5cebc454-091c-4e46-b200-1e52c8dffbec') + def test_scan_filter_set_invalid_device_address_bad_format(self): + """Test scan filter set badly formatted device address. + + Test scan filter badly formatted device address. + + Steps: + 1. Set the scan filter address to an invalid, blank mac address + + Expected Result: + Api to build scan filter should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + input = {} + input['ScanFilterDeviceAddress'] = "10.10.10.10.10" + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d5249d10-1486-4c38-a22d-1f1b077926db') + def test_scan_filter_set_invalid_device_address_bad_address(self): + """Test scan filter device address as an invalid value. + + Test scan filter invalid device address invalid characters. + + Steps: + 1. Set a scan filter's device address as ZZ:ZZ:ZZ:ZZ:ZZ:ZZ + + Expected Result: + Api to build the scan filter should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + input = {} + input['ScanFilterDeviceAddress'] = "ZZ:ZZ:ZZ:ZZ:ZZ:ZZ" + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='65c62d50-69f6-4a0b-bd74-2340e0ce32ca') + def test_scan_filter_set_manufacturer_id_data(self): + """Test scan filter manufacturer data. + + Test scan filter manufacturer data with a valid input. + + Steps: + 1. Validate the scan filter manufacturer id with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + expected_manufacturer_id = 0 + expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12807021-9f66-4784-b34a-80859cf4a32f') + def test_scan_filter_set_manufacturer_id_data_mask(self): + """Test scan filter manufacturer data mask. + + Test scan filter manufacturer data with a valid data mask. + + Steps: + 1. Validate the scan filter manufacturer id with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + expected_manufacturer_id = 1 + expected_manufacturer_data = [1] + expected_manufacturer_data_mask = [1, 2, 1, 3, 4, 5, 6] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + input[ + 'ScanFilterManufacturerDataMask'] = expected_manufacturer_data_mask + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='980e5ab6-5381-4471-8e5b-0b716665a9b8') + def test_scan_filter_set_manufacturer_max_id(self): + """Test scan filter manufacturer data id. + + Test scan filter manufacturer data max id. + + Steps: + 1. Validate the scan filter manufacturer id with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + expected_manufacturer_id = 2147483647 + expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cf0efe38-8621-4288-be26-742719da2f6c') + def test_scan_filter_set_manufacturer_data_empty(self): + """Test scan filter empty manufacturer data. + + Test scan filter manufacturer data as empty but valid manufacturer data. + + Steps: + 1. Validate the scan filter manufacturer id with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + expected_manufacturer_id = 1 + expected_manufacturer_data = [] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7ea0e82e-e92a-469c-8432-8f21978508cb') + def test_scan_filter_set_manufacturer_data_mask_empty(self): + """Test scan filter empty manufacturer data mask. + + Test scan filter manufacturer mask empty. + + Steps: + 1. Validate the scan filter manufacturer id with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + expected_manufacturer_id = 1 + expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] + expected_manufacturer_data_mask = [] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + input[ + 'ScanFilterManufacturerDataMask'] = expected_manufacturer_data_mask + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='88e4a9b8-afae-48cb-873a-fd6b4ef84116') + def test_scan_filter_set_invalid_manufacturer_min_id_minus_one(self): + """Test scan filter invalid manufacturer data. + + Test scan filter invalid manufacturer id min value - 1. + + Steps: + 1. Set the scan filters manufacturer id to -1. + 2. Build the scan filter. + + Expected Result: + Api to build the scan filter should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + expected_manufacturer_id = -1 + expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] + input = {} + input['ScanFilterManufacturerDataId'] = expected_manufacturer_id + input['ScanFilterManufacturerData'] = expected_manufacturer_data + return not self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2e8438dc-29cd-4f72-8747-4a161974d4d3') + def test_scan_filter_set_service_uuid(self): + """Test scan filter set valid service uuid. + + Test scan filter service uuid. + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + expected_service_uuid = "00000000-0000-1000-8000-00805F9B34FB" + expected_service_mask = "00000000-0000-1000-8000-00805F9B34FB" + input = {} + input['ScanFilterServiceUuid'] = expected_service_uuid + input['ScanFilterServiceMask'] = expected_service_mask + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e07b9985-44b6-4dc4-b570-0833b5d2893c') + def test_scan_filter_service_uuid_p_service(self): + """Test scan filter service uuid. + + Test scan filter service uuid p service + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 2 + """ + expected_service_uuid = ble_uuids['p_service'] + expected_service_mask = "00000000-0000-1000-8000-00805F9B34FB" + self.log.debug("Step 1: Setup environment.") + + input = {} + input['ScanFilterServiceUuid'] = expected_service_uuid + input['ScanFilterServiceMask'] = expected_service_mask + return self.validate_scan_settings_helper(input, self.ad_dut.droid) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0467af19-6e9a-4cfe-9e10-878b0c224df2') + def test_classic_ble_scan_with_service_uuids_p(self): + """Test classic LE scan with valid service uuid. + + Test classic ble scan with scan filter service uuid p service uuids. + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + 2. Start classic ble scan. + 3. Stop classic ble scan + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + + droid = self.ad_dut.droid + service_uuid_list = [ble_uuids['p_service']] + scan_callback = droid.bleGenLeScanCallback() + return self.verify_classic_ble_scan_with_service_uuids( + droid, scan_callback, service_uuid_list) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='516c295f-a2df-44f6-b2ad-54451af43ce8') + def test_classic_ble_scan_with_service_uuids_hr(self): + """Test classic LE scan with valid service uuid. + + Test classic ble scan with scan filter service uuid hr service + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + 2. Start classic ble scan. + 3. Stop classic ble scan + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + droid = self.ad_dut.droid + service_uuid_list = [ble_uuids['hr_service']] + scan_callback = droid.bleGenLeScanCallback() + return self.verify_classic_ble_scan_with_service_uuids( + droid, scan_callback, service_uuid_list) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0458b5e0-bb0b-4d6e-ab79-e21169d3256b') + def test_classic_ble_scan_with_service_uuids_empty_uuid_list(self): + """Test classic LE scan with empty but valid uuid list. + + Test classic ble scan with service uuids as empty list. + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + 2. Start classic ble scan. + 3. Stop classic ble scan + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + droid = self.ad_dut.droid + service_uuid_list = [] + scan_callback = droid.bleGenLeScanCallback() + return self.verify_classic_ble_scan_with_service_uuids( + droid, scan_callback, service_uuid_list) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c0d84a37-c86c-43c4-9dc7-d16959fdbc2a') + def test_classic_ble_scan_with_service_uuids_hr_and_p(self): + """Test classic LE scan with multiple service uuids. + + Test classic ble scan with service uuids a list of hr and p service. + + Steps: + 1. Validate the scan filter service uuid with all other settings + set to their respective defaults. + 2. Start classic ble scan. + 3. Stop classic ble scan + + Expected Result: + Expected Scan filter should match found scan filter. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 1 + """ + droid = self.ad_dut.droid + service_uuid_list = [ble_uuids['hr_service'], ble_uuids['p_service']] + scan_callback = droid.bleGenLeScanCallback() + return self.verify_classic_ble_scan_with_service_uuids( + droid, scan_callback, service_uuid_list) + + def verify_classic_ble_scan_with_service_uuids(self, droid, scan_callback, + service_uuid_list): + + test_result = True + try: + test_result = droid.bleStartClassicBleScanWithServiceUuids( + scan_callback, service_uuid_list) + except BleScanResultsError as error: + self.log.error(str(error)) + return False + droid.bleStopClassicBleScan(scan_callback) + if not test_result: + self.log.error( + "Start classic ble scan with service uuids return false " + "boolean value.") + return False + return True diff --git a/acts/tests/google/ble/api/GattApiTest.py b/acts/tests/google/ble/api/GattApiTest.py new file mode 100644 index 0000000000..cc87979a73 --- /dev/null +++ b/acts/tests/google/ble/api/GattApiTest.py @@ -0,0 +1,119 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to exercise Gatt Apis. +""" + +from acts.controllers.sl4a_lib import rpc_client +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test + + +class GattApiTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.ad = self.android_devices[0] + + return setup_multiple_devices_for_bt_test(self.android_devices) + + def setup_test(self): + for a in self.android_devices: + a.ed.clear_all_events() + return True + + def teardown_test(self): + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='fffe5c46-eb97-477b-ac3e-3f70700bb84e') + def test_open_gatt_server(self): + """Test a gatt server. + + Test opening a gatt server. + + Steps: + 1. Create a gatt server callback. + 2. Open the gatt server. + + Expected Result: + Api to open gatt server should not fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 1 + """ + gatt_server_cb = self.ad.droid.gattServerCreateGattServerCallback() + self.ad.droid.gattServerOpenGattServer(gatt_server_cb) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12828c2c-b6ae-4670-a829-9867e75fb711') + def test_open_gatt_server_on_same_callback(self): + """Test repetitive opening of a gatt server. + + Test opening a gatt server on the same callback twice in a row. + + Steps: + 1. Create a gatt server callback. + 2. Open the gatt server. + 3. Open the gatt server on the same callback as step 2. + + Expected Result: + Api to open gatt server should not fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 2 + """ + gatt_server_cb = self.ad.droid.gattServerCreateGattServerCallback() + self.ad.droid.gattServerOpenGattServer(gatt_server_cb) + self.ad.droid.gattServerOpenGattServer(gatt_server_cb) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='63fc684d-6c1d-455e-afdb-1887123b4d2f') + def test_open_gatt_server_on_invalid_callback(self): + """Test gatt server an an invalid callback. + + Test opening a gatt server with an invalid callback. + + Steps: + 1. Open a gatt server with the gall callback set to -1. + + Expected Result: + Api should fail to open a gatt server. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 2 + """ + invalid_callback_index = -1 + try: + self.ad.droid.gattServerOpenGattServer(invalid_callback_index) + except rpc_client.Sl4aApiError as e: + self.log.info("Failed successfully with exception: {}.".format(e)) + return True + return False diff --git a/acts/tests/google/ble/beacon_tests/BeaconSwarmTest.py b/acts/tests/google/ble/beacon_tests/BeaconSwarmTest.py new file mode 100644 index 0000000000..0df9a7b2be --- /dev/null +++ b/acts/tests/google/ble/beacon_tests/BeaconSwarmTest.py @@ -0,0 +1,341 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different testcases with a lot of ble beacon traffic. + +This test script was designed with this setup in mind: +Shield box one: Android Device as DUT. 7x Sprout devices acting as 192 beacons +""" + +import threading + +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode +from acts.test_utils.bt.BleEnum import ScanSettingsScanMode +from acts.test_utils.bt.bt_test_utils import adv_succ +from acts.test_utils.bt.bt_test_utils import batch_scan_result +from acts.test_utils.bt.bt_test_utils import scan_result +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs + + +class BeaconSwarmTest(BluetoothBaseTest): + default_timeout = 10 + beacon_swarm_count = 0 + advertising_device_name_list = [] + discovered_mac_address_list = [] + + def setup_test(self): + self.discovered_mac_address_list = [] + for a in self.android_devices: + a.ed.clear_all_events() + return True + + def teardown_test(self): + reset_bluetooth([self.android_devices[0]]) + return True + + def setup_class(self): + self.scn_ad = self.android_devices[0] + if not setup_multiple_devices_for_bt_test(self.android_devices): + return False + return self._start_special_advertisements() + + def cleanup_class(self): + return reset_bluetooth(self.android_devices) + + def on_fail(self, test_name, begin_time): + take_btsnoop_logs(self.android_devices, self, test_name) + reset_bluetooth([self.scn_ad]) + + def _start_advertisements_thread(self, ad, beacon_count, restart=False): + d, e = ad.droid, ad.ed + if restart: + try: + reset_bluetooth([ad]) + except Exception: + self.log.debug("Failed resetting Bluetooth, continuing...") + return + try: + for _ in range(beacon_count): + d.bleSetAdvertiseDataIncludeDeviceName(True) + d.bleSetAdvertiseSettingsAdvertiseMode( + AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY. + value) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(d)) + d.bleStartBleAdvertising(advertise_callback, advertise_data, + advertise_settings) + try: + e.pop_event( + adv_succ.format(advertise_callback), + self.default_timeout) + self.beacon_swarm_count += 1 + local_bt_name = d.bluetoothGetLocalName() + if local_bt_name not in self.advertising_device_name_list: + self.advertising_device_name_list.append( + d.bluetoothGetLocalName()) + except Exception as e: + self.log.info("Advertising failed due to " + str(e)) + self.log.info("Beacons active: {}".format( + self.beacon_swarm_count)) + except Exception: + self.log.debug( + "Something went wrong in starting advertisements, continuing.") + return + + def _start_special_advertisements(self): + self.log.info("Setting up advertisements.") + beacon_serials = [] + beacon_count = 0 + try: + beacon_serials = self.user_params['beacon_devices'] + beacon_count = self.user_params['beacon_count'] + except AttributeError: + self.log.info( + "No controllable devices connected to create beacons with." + " Continuing...") + threads = [] + for a in self.android_devices: + d, e = a.droid, a.ed + serial_no = a.serial + if serial_no not in beacon_serials: + continue + thread = threading.Thread(target=self._start_advertisements_thread, + args=(d, e, beacon_count)) + threads.append(thread) + thread.start() + for t in threads: + t.join() + if self.beacon_swarm_count < (beacon_count * len(beacon_serials)): + self.log.error("Not enough beacons advertising: {}".format( + self.beacon_swarm_count)) + return False + return True + + def _restart_special_advertisements_thread(self): + beacon_serials = [] + beacon_count = 0 + try: + beacon_serials = self.user_params['beacon_devices'] + beacon_count = self.user_params['beacon_count'] + except AttributeError: + self.log.info("No controllable devices connected to create beacons" + " with. Continuing...") + threads = [] + while True: + self.log.info("Restarting advertisements.") + for a in self.android_devices: + d, e = a.droid, a.ed + serial_no = a.serial + if serial_no not in beacon_serials: + continue + thread = threading.Thread( + target=self._start_advertisements_thread, + args=(d, e, beacon_count, True)) + threads.append(thread) + thread.start() + for t in threads: + t.join() + return True + + def test_swarm_1000_on_scan_result(self): + """Test LE scanning in a mass beacon deployment. + + Test finding 1000 LE scan results in a mass beacon deployment. + + Steps: + 1. Assume that mass beacon deployment is setup. + 2. Set LE scanning mode to low latency. + 3. Start LE scan. + 4. Pop scan results off the event dispatcher 1000 times. + 5. Stop LE scanning. + + Expected Result: + 1000 scan results should be found without any exceptions. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Beacon + Priority: 1 + """ + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + for _ in range(1000000): + event_info = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + mac_address = event_info['data']['Result']['deviceInfo']['address'] + if mac_address not in self.discovered_mac_address_list: + self.discovered_mac_address_list.append(mac_address) + self.log.info("Discovered {} different devices.".format(len( + self.discovered_mac_address_list))) + self.log.debug("Discovered {} different devices.".format(len( + self.discovered_mac_address_list))) + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True + + def test_swarm_10000_on_batch_scan_result(self): + """Test LE batch scanning in a mass beacon deployment. + + Test finding 10000 LE batch scan results in a mass beacon deployment. + + Steps: + 1. Assume that mass beacon deployment is setup. + 2. Set LE scanning mode to low latency and report delay millis to 1 + second. + 3. Start LE scan. + 4. Pop batch scan results off the event dispatcher 10000 times. + 5. Stop LE scanning. + + Expected Result: + 1000 scan results should be found without any exceptions. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Beacon + Priority: 1 + """ + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis(1000) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + for _ in range(10000): + event_info = self.scn_ad.ed.pop_event( + batch_scan_result.format(scan_callback), self.default_timeout) + for result in event_info['data']['Results']: + mac_address = result['deviceInfo']['address'] + if mac_address not in self.discovered_mac_address_list: + self.discovered_mac_address_list.append(mac_address) + self.log.info("Discovered {} different devices.".format(len( + self.discovered_mac_address_list))) + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True + + def test_swarm_scan_result_filter_each_device_name(self): + """Test basic LE scan filtering in a mass beacon deployment. + + Test finding LE scan results in a mass beacon deployment. This + test specifically tests scan filtering of different device names and + that each device name is found. + + Steps: + 1. Assume that mass beacon deployment is setup with device names + advertising. + 2. Set LE scanning mode to low latency. + 3. Filter device name from one of the known advertising device names + 4. Start LE scan. + 5. Pop scan results matching the scan filter. + 6. Stop LE scanning. + 7. Repeat steps 2-6 until all advertising device names are found. + + Expected Result: + All advertising beacons are found by their device name. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Beacon, Filtering + Priority: 1 + """ + for filter_name in self.advertising_device_name_list: + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) + filter_list, scan_settings, scan_callback = ( + generate_ble_scan_objects(self.scn_ad.droid)) + try: + self.scn_ad.droid.bleSetScanFilterDeviceName(filter_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.log.debug(self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout)) + except Exception: + self.log.info("Couldn't find advertiser name {}.".format( + filter_name)) + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True + + def test_swarm_rotate_addresses(self): + """Test basic LE scan filtering in a mass beacon deployment. + + Test finding LE scan results in a mass beacon deployment. This test + rotates the mac address of the advertising devices at a consistent + interval in order to make the scanning device think there are + thousands of devices nearby. + + Steps: + 1. Assume that mass beacon deployment is setup with device names + advertising. + 2. Set LE scanning mode to low latency on 28 scan instances. + 3. Start LE scan on each of the scan instances. + 5. Continuously Pop scan results matching the scan filter. + 6. Rotate mac address of each advertising device sequentially. + 7. 5-6 10,000 times. + 8. Stop LE scanning + + Expected Result: + The Bluetooth stack doesn't crash. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Beacon + Priority: 1 + """ + scan_callback_list = [] + for _ in range(28): + self.scn_ad.droid.bleSetScanSettingsScanMode( + ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + scan_callback_list.append(scan_callback) + thread = threading.Thread( + target=self._restart_special_advertisements_thread, + args=()) + thread.start() + n = 0 + while n < 10000: + for cb in scan_callback_list: + event_info = self.scn_ad.ed.pop_event( + scan_result.format(cb), self.default_timeout) + mac_address = event_info['data']['Result']['deviceInfo'][ + 'address'] + if mac_address not in self.discovered_mac_address_list: + self.discovered_mac_address_list.append(mac_address) + self.log.info("Discovered {} different devices.".format(len( + self.discovered_mac_address_list))) + n += 1 + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True diff --git a/acts/tests/google/ble/bt5/AdvertisingSetTest.py b/acts/tests/google/ble/bt5/AdvertisingSetTest.py new file mode 100644 index 0000000000..de4192f125 --- /dev/null +++ b/acts/tests/google/ble/bt5/AdvertisingSetTest.py @@ -0,0 +1,197 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different Bluetooth 5 specific scan scenarios. +It is expected that the second AndroidDevice is able to advertise. + +This test script was designed with this setup in mind: +Shield box one: Android Device, Android Device +""" + +from queue import Empty + +from acts.asserts import assert_equal +from acts.asserts import assert_true +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import advertising_set_started +from acts.test_utils.bt.bt_constants import advertising_set_stopped +from acts.test_utils.bt.bt_constants import advertising_set_enabled +from acts.test_utils.bt.bt_constants import advertising_set_data_set +from acts.test_utils.bt.bt_constants import advertising_set_scan_response_set +from acts.test_utils.bt.bt_constants import advertising_set_parameters_update +from acts.test_utils.bt.bt_constants import advertising_set_periodic_parameters_updated +from acts.test_utils.bt.bt_constants import advertising_set_periodic_data_set +from acts.test_utils.bt.bt_constants import advertising_set_periodic_enable +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts import signals + + +class AdvertisingSetTest(BluetoothBaseTest): + default_timeout = 10 + report_delay = 2000 + scan_callbacks = [] + adv_callbacks = [] + active_scan_callback_list = [] + big_adv_data = { + "includeDeviceName": True, + "manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"], + "manufacturerData2": + [0x2540, [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF]], + "serviceData": [ + "b19d42dc-58ba-4b20-b6c1-6628e7d21de4", + "00112233445566778899AABBCCDDEE" + ], + "serviceData2": [ + "000042dc-58ba-4b20-b6c1-6628e7d21de4", + [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF] + ] + } + + def setup_class(self): + super(AdvertisingSetTest, self).setup_class() + self.adv_ad = self.android_devices[0] + + if not self.adv_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): + raise signals.TestAbortClass( + "Advertiser does not support LE Extended Advertising") + + def teardown_test(self): + self.active_scan_callback_list = [] + + def on_exception(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='58182f7e-443f-47fb-b718-1be3ac850287') + def test_reenabling(self): + """Test re-enabling an Advertising Set + + Test GATT notify characteristic value. + + Steps: + 1. Start an advertising set that only lasts for a few seconds + 2. Restart advertising set + 3. Repeat steps 1-2 + + Expected Result: + Verify that advertising set re-enables + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + duration = 0 + max_ext_adv_events = 0 + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": False, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_1M", + "interval": 320 + }, self.big_adv_data, None, None, None, duration, max_ext_adv_events, + adv_callback) + + set_started_evt = self.adv_ad.ed.pop_event( + advertising_set_started.format(adv_callback), self.default_timeout) + set_id = set_started_evt['data']['setId'] + assert_equal(0, set_started_evt['data']['status']) + assert_equal(0, set_started_evt['data']['status']) + + self.log.info("Successfully started set " + str(set_id)) + + self.adv_ad.droid.bleAdvSetEnableAdvertising(set_id, False, duration, + max_ext_adv_events) + enable_evt = self.adv_ad.ed.pop_event( + advertising_set_enabled.format(adv_callback), self.default_timeout) + assert_equal(set_id, enable_evt['data']['setId']) + assert_equal(False, enable_evt['data']['enable']) + assert_equal(0, enable_evt['data']['status']) + self.log.info("Successfully disabled advertising set " + str(set_id)) + + self.log.info("Enabling advertising for 2 seconds... ") + duration_200 = 200 + self.adv_ad.droid.bleAdvSetEnableAdvertising( + set_id, True, duration_200, max_ext_adv_events) + enable_evt = self.adv_ad.ed.pop_event( + advertising_set_enabled.format(adv_callback), self.default_timeout) + assert_equal(set_id, enable_evt['data']['setId']) + assert_equal(True, enable_evt['data']['enable']) + assert_equal(0, enable_evt['data']['status']) + self.log.info("Enabled. Waiting for disable event ~2s ...") + + enable_evt = self.adv_ad.ed.pop_event( + advertising_set_enabled.format(adv_callback), self.default_timeout) + assert_equal(set_id, enable_evt['data']['setId']) + assert_equal(False, enable_evt['data']['enable']) + assert_equal(0, enable_evt['data']['status']) + self.log.info("Disable event received. Now trying to set data...") + + self.adv_ad.droid.bleAdvSetSetAdvertisingData( + set_id, + {"manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"]}) + data_set_evt = self.adv_ad.ed.pop_event( + advertising_set_data_set.format(adv_callback), + self.default_timeout) + assert_equal(set_id, data_set_evt['data']['setId']) + assert_equal(0, data_set_evt['data']['status']) + self.log.info("Data changed successfully.") + + max_len = self.adv_ad.droid.bluetoothGetLeMaximumAdvertisingDataLength( + ) + + self.log.info("Will try to set data to maximum possible length") + data_len = max_len - 4 + test_fill = '01' * data_len + self.adv_ad.droid.bleAdvSetSetAdvertisingData( + set_id, {"manufacturerData": [0x0123, test_fill]}) + data_set_evt = self.adv_ad.ed.pop_event( + advertising_set_data_set.format(adv_callback), + self.default_timeout) + assert_equal(set_id, data_set_evt['data']['setId']) + assert_equal(0, data_set_evt['data']['status']) + self.log.info("Data changed successfully.") + + if max_len < 1650: + self.log.info("Will try to set data to more than maximum length") + data_len = max_len - 4 + 1 + test_fill = '01' * data_len + self.adv_ad.droid.bleAdvSetSetAdvertisingData( + set_id, {"manufacturerData": [0x0123, test_fill]}) + data_set_evt = self.adv_ad.ed.pop_event( + advertising_set_data_set.format(adv_callback), + self.default_timeout) + assert_equal(set_id, data_set_evt['data']['setId']) + #TODO(jpawlowski): make nicer error fot this case + assert_true(data_set_evt['data']['status'] != 0, + "Setting data should fail because data too long.") + + self.log.info("Data change failed as expected.") + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + try: + self.adv_ad.ed.pop_event( + advertising_set_stopped.format(adv_callback), + self.default_timeout) + except Empty: + self.log.error("Failed to find advertising set stopped event.") + return False + return True diff --git a/acts/tests/google/ble/bt5/Bt5ScanTest.py b/acts/tests/google/ble/bt5/Bt5ScanTest.py new file mode 100644 index 0000000000..e2c9c83cc3 --- /dev/null +++ b/acts/tests/google/ble/bt5/Bt5ScanTest.py @@ -0,0 +1,480 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different Bluetooth 5 specific scan scenarios. +It is expected that the second AndroidDevice is able to advertise. + +This test script was designed with this setup in mind: +Shield box one: Android Device, Android Device +""" + +from queue import Empty + +from acts import asserts +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_phys +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import batch_scan_result +from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_constants import advertising_set_on_own_address_read +from acts.test_utils.bt.bt_constants import advertising_set_started +from acts import signals + + +class Bt5ScanTest(BluetoothBaseTest): + default_timeout = 10 + report_delay = 2000 + scan_callbacks = [] + adv_callbacks = [] + active_scan_callback_list = [] + big_adv_data = { + "includeDeviceName": True, + "manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"], + "manufacturerData2": + [0x2540, [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF]], + "serviceData": [ + "b19d42dc-58ba-4b20-b6c1-6628e7d21de4", + "00112233445566778899AABBCCDDEE" + ], + "serviceData2": [ + "000042dc-58ba-4b20-b6c1-6628e7d21de4", + [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF] + ] + } + + def setup_class(self): + super(Bt5ScanTest, self).setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + if not self.scn_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): + raise signals.TestAbortClass( + "Scanner does not support LE Extended Advertising") + + if not self.adv_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): + raise signals.TestAbortClass( + "Advertiser does not support LE Extended Advertising") + + def teardown_test(self): + cleanup_scanners_and_advertisers( + self.scn_ad, self.active_scan_callback_list, self.adv_ad, []) + self.active_scan_callback_list = [] + + def on_exception(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + # This one does not relly test anything, but display very helpful + # information that might help with debugging. + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='787e0877-269f-4b9b-acb0-b98a8bb3770a') + def test_capabilities(self): + """Test capabilities + + Test BT 5.0 scan scapabilities + + Steps: + 1. Test various vapabilities. + + Expected Result: + Pass + + Returns: + Pass if True + Fail if False + + TAGS: BT5.0, Scanning + Priority: 2 + """ + d = self.scn_ad.droid + sup2M = d.bluetoothIsLe2MPhySupported() + supCoded = d.bluetoothIsLeCodedPhySupported() + supExt = d.bluetoothIsLeExtendedAdvertisingSupported() + supPeriodic = d.bluetoothIsLePeriodicAdvertisingSupported() + maxDataLen = d.bluetoothGetLeMaximumAdvertisingDataLength() + self.log.info("Scanner capabilities:") + self.log.info("LE 2M: " + str(sup2M) + ", LE Coded: " + str( + supCoded) + ", LE Extended Advertising: " + str( + supExt) + ", LE Periodic Advertising: " + str(supPeriodic) + + ", maximum advertising data length: " + str(maxDataLen)) + d = self.adv_ad.droid + sup2M = d.bluetoothIsLe2MPhySupported() + supCoded = d.bluetoothIsLeCodedPhySupported() + supExt = d.bluetoothIsLeExtendedAdvertisingSupported() + supPeriodic = d.bluetoothIsLePeriodicAdvertisingSupported() + maxDataLen = d.bluetoothGetLeMaximumAdvertisingDataLength() + self.log.info("Advertiser capabilities:") + self.log.info("LE 2M: " + str(sup2M) + ", LE Coded: " + str( + supCoded) + ", LE Extended Advertising: " + str( + supExt) + ", LE Periodic Advertising: " + str(supPeriodic) + + ", maximum advertising data length: " + str(maxDataLen)) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='62d36679-bb91-465e-897f-2635433aac2f') + def test_1m_1m_extended_scan(self): + """Test scan on LE 1M PHY using LE 1M PHY as secondary. + + Tests test verify that device is able to receive extended advertising + on 1M PHY when secondary is 1M PHY. + + Steps: + 1. Start advertising set on dut1 + 2. Start scanning on dut0, scan filter set to advertiser's device name + 3. Try to find an event, expect found + 4. Stop advertising + + Expected Result: + Scan finds a advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": True, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_1M", + "interval": 320 + }, self.big_adv_data, None, None, None, 0, 0, adv_callback) + + self.scn_ad.droid.bleSetScanSettingsLegacy(False) + self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Scan result not found") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3e3c9757-f7b6-4d1d-a2d6-8e2330d1a18e') + def test_1m_2m_extended_scan(self): + """Test scan on LE 1M PHY using LE 2M PHY as secondary. + + Tests test verify that device is able to receive extended advertising + on 1M PHY when secondary is 2M PHY. + + Steps: + 1. Start advertising set on dut1 + 2. Start scanning on dut0, scan filter set to advertiser's device name + 3. Try to find an event, expect found + 4. Stop advertising + + Expected Result: + Scan finds a advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": True, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_2M", + "interval": 320 + }, self.big_adv_data, None, None, None, 0, 0, adv_callback) + + self.scn_ad.droid.bleSetScanSettingsLegacy(False) + self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Scan result not found") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='236e9e5b-3853-4762-81ae-e88db03d74f3') + def test_legacy_scan_result_raw_length(self): + """Test that raw scan record data in legacy scan is 62 bytes long. + + This is required for compability with older apps that make this + assumption. + + Steps: + 1. Start legacy advertising set on dut1 + 2. Start scanning on dut0, scan filter set to advertiser's device name + 3. Try to find an event, expect found, verify scan recurd data length + 4. Stop advertising + + Expected Result: + Scan finds a legacy advertisement of proper size + + Returns: + Pass if True + Fail if False + + TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": True, + "scannable": True, + "legacyMode": True, + "interval": 320 + }, {"includeDeviceName": True}, None, None, None, 0, 0, adv_callback) + + self.scn_ad.droid.bleSetScanSettingsLegacy(True) + self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + try: + evt = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + rawData = evt['data']['Result']['scanRecord'] + asserts.assert_true(62 == len(rawData.split(",")), + "Raw data should be 62 bytes long.") + except Empty: + self.log.error("Scan result not found") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='04632d8d-4303-476f-8f83-52c16be3713a') + def test_duration(self): + """Test scanning duration + + Tests BT5.0 scanning duration + + Steps: + 1. Start advertising set + 2. Start 5.0 scan + 3. Scan for advertisement event + + Expected Result: + Scan finds a legacy advertisement of proper size + + Returns: + Pass if True + Fail if False + + TAGS: BT5.0, LE, Advertising, Scanning + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": True, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_2M", + "interval": 320 + }, self.big_adv_data, None, None, None, 0, 0, adv_callback) + + self.scn_ad.droid.bleSetScanSettingsLegacy(False) + self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Scan result not found") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a3704083-0f5c-4a46-b979-32ebc594d6ee') + def test_anonymous_advertising(self): + """Test anonymous advertising. + + Tests test verify that device is able to receive anonymous advertising + on 1M PHY when secondary is 2M PHY. + + Steps: + 1. Start anonymous advertising set on dut1 + 2. Start scanning on dut0, scan filter set to advertiser's device name + 3. Try to find an event, expect found + 4. Stop advertising + + Expected Result: + Scan finds a advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": False, + "anonymous": True, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_2M", + "interval": 320 + }, self.big_adv_data, None, None, None, 0, 0, adv_callback) + + self.scn_ad.droid.bleSetScanSettingsLegacy(False) + self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) + + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + try: + evt = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + address = evt['data']['Result']['deviceInfo']['address'] + asserts.assert_true( + '00:00:00:00:00:00' == address, + "Anonymous address should be 00:00:00:00:00:00, but was " + + str(address)) + except Empty: + self.log.error("Scan result not found") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e3277355-eebf-4760-9502-e49a9289f6ab') + def test_get_own_address(self): + """Test obtaining own address for PTS. + + Test obtaining own address. + + Steps: + 1. Start advertising set dut1 + 2. Grab address + 3. Stop advertising + + Expected Result: + Callback with address is received. + + Returns: + Pass if True + Fail if False + + TAGS: LE Advertising Extension, BT5, LE, Advertising + Priority: 1 + """ + adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() + self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ + "connectable": False, + "anonymous": True, + "legacyMode": False, + "primaryPhy": "PHY_LE_1M", + "secondaryPhy": "PHY_LE_2M", + "interval": 320 + }, self.big_adv_data, None, None, None, 0, 0, adv_callback) + + set_id = -1 + + try: + evt = self.adv_ad.ed.pop_event( + advertising_set_started.format(adv_callback), + self.default_timeout) + self.log.info("data: " + str(evt['data'])) + set_id = evt['data']['setId'] + except Empty: + self.log.error("did not receive the set started event!") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetGetOwnAddress(set_id) + + try: + evt = self.adv_ad.ed.pop_event( + advertising_set_on_own_address_read.format(set_id), + self.default_timeout) + address = evt['data']['address'] + self.log.info("Advertiser address is: " + str(address)) + except Empty: + self.log.error("onOwnAddressRead not received.") + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return False + + self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) + return True diff --git a/acts/tests/google/ble/bt5/PhyTest.py b/acts/tests/google/ble/bt5/PhyTest.py new file mode 100644 index 0000000000..0b1ecfade8 --- /dev/null +++ b/acts/tests/google/ble/bt5/PhyTest.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises set PHY and read PHY procedures. +""" + +from queue import Empty + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest +from acts.test_utils.bt.bt_constants import gatt_connection_priority +from acts.test_utils.bt.bt_constants import gatt_event +from acts.test_utils.bt.bt_constants import gatt_phy +from acts import signals + +CONNECTION_PRIORITY_HIGH = gatt_connection_priority['high'] +PHY_LE_1M = gatt_phy['1m'] +PHY_LE_2M = gatt_phy['2m'] + + +def lfmt(txPhy, rxPhy): + return '(' + list(gatt_phy.keys())[list(gatt_phy.values()).index( + txPhy)] + ', ' + list(gatt_phy.keys())[list(gatt_phy.values()).index( + rxPhy)] + ')' + + +class PhyTest(GattConnectedBaseTest): + def setup_class(self): + super(PhyTest, self).setup_class() + if not self.cen_ad.droid.bluetoothIsLe2MPhySupported(): + raise signals.TestAbortClass( + "Central device does not support LE 2M PHY") + + if not self.per_ad.droid.bluetoothIsLe2MPhySupported(): + raise signals.TestAbortClass( + "Peripheral device does not support LE 2M PHY") + + # Some controllers auto-update PHY to 2M, and both client and server + # might receive PHY Update event right after connection, if the + # connection was established over 1M PHY. We will ignore this event, but + # must pop it from queue. + def pop_initial_phy_update(self): + try: + maybe_event = gatt_event['phy_update']['evt'].format( + self.gatt_callback) + self.cen_ad.ed.pop_event(maybe_event, 0) + except Empty: + pass + + try: + maybe_event = gatt_event['serv_phy_update']['evt'].format( + self.gatt_server_callback) + self.per_ad.ed.pop_event(maybe_event, 0) + except Empty: + pass + + # this helper method checks wether both client and server received PHY + # update event with proper txPhy and rxPhy + def ensure_both_updated_phy(self, clientTxPhy, clientRxPhy): + event = self._client_wait(gatt_event['phy_update']) + txPhy = event['data']['TxPhy'] + rxPhy = event['data']['RxPhy'] + self.log.info("\tClient PHY updated: " + lfmt(txPhy, rxPhy)) + self.assertEqual(0, event['data']['Status'], "Status should be 0") + self.assertEqual(clientTxPhy, event['data']['TxPhy']) + self.assertEqual(clientRxPhy, event['data']['RxPhy']) + + bt_device_id = 0 + event = self._server_wait(gatt_event['serv_phy_update']) + txPhy = event['data']['TxPhy'] + rxPhy = event['data']['RxPhy'] + self.log.info("\tServer PHY updated: " + lfmt(txPhy, rxPhy)) + self.assertEqual(0, event['data']['Status'], "Status should be 0") + self.assertEqual(clientRxPhy, event['data']['TxPhy']) + self.assertEqual(clientTxPhy, event['data']['RxPhy']) + + # read the client phy, return (txPhy, rxPhy) + def read_client_phy(self): + self.cen_ad.droid.gattClientReadPhy(self.bluetooth_gatt) + event = self._client_wait(gatt_event['phy_read']) + self.assertEqual(0, event['data']['Status'], "Status should be 0") + return (event['data']['TxPhy'], event['data']['RxPhy']) + + # read the server phy, return (txPhy, rxPhy) + def read_server_phy(self): + bt_device_id = 0 + self.per_ad.droid.gattServerReadPhy(self.gatt_server, bt_device_id) + event = self._server_wait(gatt_event['serv_phy_read']) + self.assertEqual(0, event['data']['Status'], "Status should be 0") + return (event['data']['TxPhy'], event['data']['RxPhy']) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='edb95ae1-97e5-4337-9a60-1e113aa43a4d') + def test_phy_read(self): + """Test LE read PHY. + + Test LE read PHY. + + Steps: + 1. Central, Peripheral : read PHY, make sure values are same. + 2. Central: update PHY. + 3. Ensure both Central and Peripheral received PHY update event. + 4. Central, Peripheral: read PHY, make sure values are same. + + Expected Result: + Verify that read PHY works properly. + + Returns: + Pass if True + Fail if False + + TAGS: LE, PHY + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) + self.pop_initial_phy_update() + + # read phy from client and server, make sure they're same + cTxPhy, cRxPhy = self.read_client_phy() + sTxPhy, sRxPhy = self.read_server_phy() + self.assertEqual(cTxPhy, sTxPhy) + self.assertEqual(cRxPhy, sRxPhy) + + self.log.info("Initial connection PHY was: " + lfmt(cTxPhy, cRxPhy)) + + nextTxPhy = (cTxPhy == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M + nextRxPhy = (cRxPhy == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M + + # try to update PHY from Client + self.log.info("Will try to set PHY to: " + lfmt(nextTxPhy, nextRxPhy)) + self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, + nextTxPhy, nextRxPhy, 0) + self.ensure_both_updated_phy(nextTxPhy, nextRxPhy) + + # read phy on client and server, make sure values are same and equal + # the newly set value + cTxPhy, cRxPhy = self.read_client_phy() + sTxPhy, sRxPhy = self.read_server_phy() + self.assertEqual(cTxPhy, sTxPhy) + self.assertEqual(cRxPhy, sRxPhy) + + self.assertEqual(nextTxPhy, cTxPhy) + self.assertEqual(nextRxPhy, cRxPhy) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6b66af0a-35eb-42af-acd5-9634684f275d') + def test_phy_change_20_times(self): + """Test PHY update. + + Test LE PHY update. + + Steps: + 1. Central: read PHY. + 2. Central: update PHY to 1M, 2M, 1M... 20 times, each time ensuring + both client and server received PHY update event. + + Expected Result: + Verify that read update PHY worked properly each time. + + Returns: + Pass if True + Fail if False + + TAGS: LE, PHY + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) + self.pop_initial_phy_update() + + txPhyB, rxPhyB = self.read_client_phy() + txPhyA = (txPhyB == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M + rxPhyA = (rxPhyB == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M + + self.log.info("Initial connection PHY was: " + lfmt(txPhyB, rxPhyB)) + + for i in range(20): + #swap values between iterations + txPhy = (i & 1) and txPhyB or txPhyA + rxPhy = (i & 1) and rxPhyB or rxPhyA + + self.log.info("Will try to set PHY to: " + lfmt(txPhy, rxPhy)) + self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, + txPhy, rxPhy, 0) + self.ensure_both_updated_phy(txPhy, rxPhy) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='13f28de4-07f4-458c-a3e5-3ba95318616f') + def test_phy_change_asym(self): + """Test PHY update with asymetric rx and tx PHY. + + Test PHY update with asymetric rx and tx PHY. + + Steps: + 1. Central: read PHY. + 2. Central: update PHY to tx: 1M, rx: 2M, ensure both devices received + the asymetric update. + 3. Central: update PHY to tx: 2M, rx: 1M, ensure both devices received + the asymetric update. + + Expected Result: + Verify that read update PHY worked properly each time. + + Returns: + Pass if True + Fail if False + + TAGS: LE, PHY + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) + self.pop_initial_phy_update() + + txPhy, rxPhy = self.read_client_phy() + + self.log.info("Initial connection PHY was: " + lfmt(txPhy, rxPhy)) + self.log.info("will try to set PHY to: PHY_LE_1M, PHY_LE_2M") + + #try to update PHY to tx 1M, rx 2M from Client + self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, + PHY_LE_1M, PHY_LE_2M, 0) + self.ensure_both_updated_phy(PHY_LE_1M, PHY_LE_2M) + + #try to update PHY to TX 2M, RX 1M from Client + self.log.info("will try to set PHY to: PHY_LE_2M, PHY_LE_1M") + self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, + PHY_LE_2M, PHY_LE_1M, 0) + self.ensure_both_updated_phy(PHY_LE_2M, PHY_LE_1M) + + return True diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py new file mode 100644 index 0000000000..c38fc935de --- /dev/null +++ b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisementDiscoveryTest.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to test the integrity of LE scan results upon resetting the +Bluetooth stack. +""" + +import concurrent +import os +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import BtTestUtilsError +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_n_advertisements +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs +from acts.test_utils.bt.bt_test_utils import teardown_n_advertisements +from acts.test_utils.bt.bt_test_utils import scan_and_verify_n_advertisements + + +class ConcurrentBleAdvertisementDiscoveryTest(BluetoothBaseTest): + default_timeout = 10 + droid_list = [] + max_advertisements = -1 + advertise_callback_list = [] + + def setup_class(self): + super().setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + self.droid_list = get_advanced_droid_list(self.android_devices) + self.max_advertisements = self.droid_list[1]['max_advertisements'] + + def setup_test(self): + super().setup_test() + self.log.info("Setting up advertisements") + reset_bluetooth(self.android_devices) + try: + self.advertise_callback_list = setup_n_advertisements( + self.adv_ad, self.max_advertisements) + except BtTestUtilsError: + return False + return True + + def teardown_test(self): + super(BluetoothBaseTest, self).teardown_test() + self.log.info("Tearing down advertisements") + teardown_n_advertisements(self.adv_ad, + len(self.advertise_callback_list), + self.advertise_callback_list) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e02d6ca6-4db3-4a1d-adaf-98db7c7c2c7a') + def test_max_advertisements_defaults(self): + """Test scan integrity after BT state is reset + + This test is to verify that LE devices are found + successfully after the Bluetooth stack is + reset. This is repeated multiple times in order + to verify that LE devices are not lost in scanning + when the stack is brought back up. + + Steps: + 1. Pre-Condition: Max advertisements are active + 2. With the DUT android device, scan for all advertisements + and verify that all expected advertisements are found. + 3. Reset Bluetooth on DUT. + 4. Repeat steps 2-3 for defined iterations + + Expected Result: + All expected advertisements should be found on all iterations. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency, Scanning + Priority: 2 + """ + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['all_matches']) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + iterations = 20 + for _ in range(iterations): + self.log.info("Verify all advertisements found") + try: + if not scan_and_verify_n_advertisements( + self.scn_ad, self.max_advertisements): + self.log.error("Failed to find all advertisements") + return False + except BtTestUtilsError: + return False + if not reset_bluetooth([self.scn_ad]): + self.log.error("Failed to reset Bluetooth state") + return False + return True diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py new file mode 100644 index 0000000000..09c6cd3a5e --- /dev/null +++ b/acts/tests/google/ble/concurrency/ConcurrentBleAdvertisingTest.py @@ -0,0 +1,632 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to exercises different ways Ble Advertisements can run in +concurrency. This test was designed to be run in a shield box. +""" + +import concurrent +import os +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import BtTestUtilsError +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import scan_and_verify_n_advertisements +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import setup_n_advertisements +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs +from acts.test_utils.bt.bt_test_utils import teardown_n_advertisements + + +class ConcurrentBleAdvertisingTest(BluetoothBaseTest): + default_timeout = 10 + droid_list = [] + max_advertisements = -1 + + def setup_class(self): + super().setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + self.droid_list = get_advanced_droid_list(self.android_devices) + self.max_advertisements = self.droid_list[1]['max_advertisements'] + + def setup_test(self): + super().setup_test() + return reset_bluetooth(self.android_devices) + + def _verify_n_advertisements(self, num_advertisements): + try: + advertise_callback_list = setup_n_advertisements( + self.adv_ad, num_advertisements) + except BtTestUtilsError: + return False + try: + scan_and_verify_n_advertisements(self.scn_ad, num_advertisements) + except BtTestUtilsError: + return False + teardown_n_advertisements(self.adv_ad, + len(advertise_callback_list), + advertise_callback_list) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='abc03874-6d7a-4b5d-9f29-18731a102793') + def test_max_advertisements_defaults(self): + """Testing max advertisements. + + Test that a single device can have the max advertisements + concurrently advertising. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Start scanning on the max_advertisements as defined in the script. + 4. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 0 + """ + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='50ee137e-eb71-40ef-b72f-a5fd646190d2') + def test_max_advertisements_include_device_name_and_filter_device_name( + self): + """Testing max advertisement variant. + + Test that a single device can have the max advertisements + concurrently advertising. Include the device name as a part of the filter + and advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include device name in each advertisement. + 4. Include device name filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f7e9ba2b-6286-4510-a8a0-f1df831056c0') + def test_max_advertisements_exclude_device_name_and_filter_device_name( + self): + """Test max advertisement variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the device name as a part of the filter but not the + advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include device name filter in the scanner. + 4. Start scanning on the max_advertisements as defined in the script. + 5. Verify that no advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(False) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + return not self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6ce102d7-61e1-4ca0-bcfb-767437b86c2b') + def test_max_advertisements_with_manufacturer_data(self): + """Test max advertisement variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the manufacturer data as a part of the filter and + advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include manufacturer data in each advertisement. + 4. Include manufacturer data filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.scn_ad.droid.bleSetScanFilterManufacturerData(1, [1]) + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(1, [1]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2fc7d5e8-1539-42a8-8681-ce0b8bfc0924') + def test_max_advertisements_with_manufacturer_data_mask(self): + """Test max advertisements variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the manufacturer data mask as a part of the filter + and advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include manufacturer data in each advertisement. + 4. Include manufacturer data mask filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.scn_ad.droid.bleSetScanFilterManufacturerData(1, [1], [1]) + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(1, [1]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ef615ed-1705-44ae-ab5b-f7e8fb4bb770') + def test_max_advertisements_with_service_data(self): + """Test max advertisement variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the service data as a part of the filter and + advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include service data in each advertisement. + 4. Include service data filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + test_result = True + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterServiceData( + "0000110A-0000-1000-8000-00805F9B34FB", [11, 17, 80]) + self.adv_ad.droid.bleAddAdvertiseDataServiceData( + "0000110A-0000-1000-8000-00805F9B34FB", [11, 17, 80]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ef615ed-1705-44ae-ab5b-f7e8fb4bb770') + def test_max_advertisements_with_manufacturer_data_mask_and_include_device_name( + self): + """Test max advertisement variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the device name and manufacturer data as a part of + the filter and advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include device name and manufacturer data in each advertisement. + 4. Include device name and manufacturer data filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleSetScanFilterManufacturerData(1, [1], [1]) + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(1, [1]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c2ca85fb-6663-431d-aa30-5286a85dbbe0') + def test_max_advertisements_with_service_uuids(self): + """Test max advertisement variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the service uuid as a part of the filter and + advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include service uuid in each advertisement. + 4. Include service uuid filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 1 + """ + self.scn_ad.droid.bleSetScanFilterServiceUuid( + "00000000-0000-1000-8000-00805f9b34fb") + self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( + ["00000000-0000-1000-8000-00805f9b34fb"]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='756e026f-64d7-4a2f-935a-3790c0ac4503') + def test_max_advertisements_with_service_uuid_and_service_mask(self): + """Test max advertisements variant. + + Test that a single device can have the max advertisements concurrently + advertising. Include the service mask as a part of the filter and + advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Include service uuid in each advertisement. + 4. Include service mask filter in the scanner. + 5. Start scanning on the max_advertisements as defined in the script. + 6. Verify that all advertisements are found. + + Expected Result: + All advertisements should start without errors. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + self.scn_ad.droid.bleSetScanFilterServiceUuid( + "00000000-0000-1000-8000-00805f9b34fb", + "00000000-0000-1000-8000-00805f9b34fb") + self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( + ["00000000-0000-1000-8000-00805f9b34fb"]) + return self._verify_n_advertisements(self.max_advertisements) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='79c4b6cd-9f07-49a9-829f-69b29ea8d322') + def test_max_advertisements_plus_one(self): + """Test max advertisements plus one. + + Test that a single device can have the max advertisements concurrently + advertising but fail on starting the max advertisements plus one. + filter and advertisement data. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Start max_advertisements + 1. + + Expected Result: + The last advertisement should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 0 + """ + return not self._verify_n_advertisements(self.max_advertisements + 1) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0bd6e490-a501-4fe1-88e5-9b77970c0b95') + def test_start_two_advertisements_on_same_callback(self): + """Test invalid advertisement scenario. + + Test that a single device cannot have two advertisements start on the + same callback. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Call start ble advertising on the same callback. + + Expected Result: + The second call of start advertising on the same callback should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 1 + """ + test_result = True + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with Empty error: {}".format(error)) + return False + except concurrent.futures._base.TimeoutError as error: + self.log.debug( + "Test failed, filtering callback onSuccess never occurred: {}" + .format(error)) + try: + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + test_result = False + except Empty as error: + self.log.debug("Test passed with Empty error: {}".format(error)) + except concurrent.futures._base.TimeoutError as error: + self.log.debug( + "Test passed, filtering callback onSuccess never occurred: {}" + .format(error)) + + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12632b31-22b9-4121-80b6-1263b9d90909') + def test_toggle_advertiser_bt_state(self): + """Test forcing stopping advertisements. + + Test that a single device resets its callbacks when the bluetooth state is + reset. There should be no advertisements. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Call start ble advertising. + 4. Toggle bluetooth on and off. + 5. Scan for any advertisements. + + Expected Result: + No advertisements should be found after toggling Bluetooth on the + advertising device. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 2 + """ + test_result = True + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with Empty error: {}".format(error)) + return False + except concurrent.futures._base.TimeoutError as error: + self.log.error( + "Test failed, filtering callback onSuccess never occurred: {}". + format(error)) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with: {}".format(error)) + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + test_result = reset_bluetooth([self.android_devices[1]]) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + if not test_result: + return False + try: + expected_event = scan_result.format(scan_callback) + event = self.scn_ad.ed.pop_event(expected_event, + self.default_timeout) + self.log.error("Event {} not expected. Found: {}".format( + expected_event, event)) + return False + except Empty as error: + self.log.debug("Test passed with: {}".format(error)) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='785c5c77-d5d4-4d0f-8b7b-3eb1f1646d2c') + def test_restart_advertise_callback_after_bt_toggle(self): + """Test starting an advertisement on a cleared out callback. + + Test that a single device resets its callbacks when the bluetooth state + is reset. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android device. + 3. Call start ble advertising. + 4. Toggle bluetooth on and off. + 5. Call start ble advertising on the same callback. + + Expected Result: + Starting an advertisement on a callback id after toggling bluetooth + should fail. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 1 + """ + test_result = True + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with Empty error: {}".format(error)) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug( + "Test failed, filtering callback onSuccess never occurred: {}". + format(error)) + test_result = reset_bluetooth([self.android_devices[1]]) + if not test_result: + return test_result + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with Empty error: {}".format(error)) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug( + "Test failed, filtering callback onSuccess never occurred: {}". + format(error)) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='dd5529b7-6774-4580-8b29-d84568c15442') + def test_timeout(self): + """Test starting advertiser with timeout. + + Test that when a timeout is used, the advertiser is cleaned properly, + and next one can be started. + + Steps: + 1. Setup the advertiser android device with 4 second timeout. + 2. Call start ble advertising. + 3. Wait 5 seconds, to make sure advertiser times out. + 4. Repeat steps 1-4 four times. + + Expected Result: + Starting the advertising should succeed each time. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Concurrency + Priority: 1 + """ + advertise_timeout_s = 4 + num_iterations = 4 + test_result = True + + for i in range(0, num_iterations): + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + + self.adv_ad.droid.bleSetAdvertiseSettingsTimeout( + advertise_timeout_s * 1000) + + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.error("Test failed with Empty error: {}".format( + error)) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug( + "Test failed, filtering callback onSuccess never occurred: {}". + format(error)) + + if not test_result: + return test_result + + time.sleep(advertise_timeout_s + 1) + + return test_result diff --git a/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py b/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py new file mode 100644 index 0000000000..512aed8f16 --- /dev/null +++ b/acts/tests/google/ble/concurrency/ConcurrentBleScanningTest.py @@ -0,0 +1,352 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to exercises Ble Scans can run in concurrency. +This test was designed to be run in a shield box. +""" + +import concurrent +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_failed +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs + + +class ConcurrentBleScanningTest(BluetoothBaseTest): + default_timeout = 20 + max_concurrent_scans = 27 + + def setup_class(self): + super().setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + def on_fail(self, test_name, begin_time): + self.log.debug("Test {} failed. Gathering bugreport and btsnoop logs." + .format(test_name)) + take_btsnoop_logs(self.android_devices, self, test_name) + reset_bluetooth(self.android_devices) + + def setup_test(self): + return reset_bluetooth(self.android_devices) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e7f68b9b-fb3f-48e9-a272-e41c2a32b4bd') + def test_max_concurrent_ble_scans(self): + """Test max LE scans. + + Test that a single device can have max scans concurrently scanning. + + Steps: + 1. Initialize scanner + 2. Initialize advertiser + 3. Start advertising on the device from step 2 + 4. Create max ble scan callbacks + 5. Start ble scan on each callback + 6. Verify that each callback triggers + 7. Stop all scans and advertisements + + Expected Result: + All scanning instances should start without errors and the advertisement + should be found on each scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Concurrency + Priority: 0 + """ + test_result = True + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['all_matches']) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleSetAdvertiseSettingsIsConnectable(False) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.exception("Test failed with Empty error: {}".format( + error)) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.exception( + "Test failed callback onSuccess never occurred: " + "{}".format(error)) + test_result = False + if not test_result: + return test_result + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback_list = [] + for i in range(self.max_concurrent_scans): + self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + scan_callback_list.append(scan_callback) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + self.log.info("Found scan event successfully. Iteration {} " + "successful.".format(i)) + except Exception: + self.log.info("Failed to find a scan result for callback {}" + .format(scan_callback)) + test_result = False + break + for callback in scan_callback_list: + self.scn_ad.droid.bleStopBleScan(callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + if not test_result: + return test_result + self.log.info("Waiting for scan callbacks to stop completely.") + # Wait for all scan callbacks to stop. There is no confirmation + # otherwise. + time.sleep(10) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='58b0c45e-1cbc-420a-9e89-901518ffe3d1') + def test_max_concurrent_ble_scans_then_discover_advertisement(self): + """Test max LE scans variant. + + Test that a single device can have max scans concurrently scanning. + + Steps: + 1. Initialize scanner + 2. Initialize advertiser + 3. Create max ble scan callbacks + 4. Start ble scan on each callback + 5. Start advertising on the device from step 2 + 6. Verify that each callback triggers + 7. Stop all scans and advertisements + + Expected Result: + All scanning instances should start without errors and the advertisement + should be found on each scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Concurrency + Priority: 1 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['all_matches']) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback_list = [] + for i in range(self.max_concurrent_scans): + self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + scan_callback_list.append(scan_callback) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.exception("Test failed with Empty error: {}".format( + error)) + return False + except concurrent.futures._base.TimeoutError as error: + self.log.exception("Test failed, filtering callback onSuccess " + "never occurred: {}".format(error)) + return False + i = 0 + for callback in scan_callback_list: + try: + self.scn_ad.ed.pop_event( + scan_result.format(callback), self.default_timeout) + self.log.info( + "Found scan event successfully. Iteration {} successful." + .format(i)) + except Exception: + self.log.info("Failed to find a scan result for callback {}" + .format(callback)) + return False + i += 1 + for callback in scan_callback_list: + self.scn_ad.droid.bleStopBleScan(callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7a45e45c-faf3-4e89-abb7-a52f63e53208') + def test_max_concurrent_ble_scans_plus_one(self): + """Test mac LE scans variant. + + Test that a single device can have max scans concurrently scanning. + + Steps: + 1. Initialize scanner + 3. Create max ble scan callbacks plus one + 5. Start ble scan on each callback + 6. Verify that the n+1th scan fails. + 7. Stop all scans + + Expected Result: + The n+1th scan should fail to start. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Concurrency + Priority: 1 + """ + test_result = True + filter_list = self.scn_ad.droid.bleGenFilterList() + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback_list = [] + for i in range(self.max_concurrent_scans): + self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + scan_callback_list.append(scan_callback) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + try: + self.scn_ad.ed.pop_event( + scan_failed.format(scan_callback), self.default_timeout) + self.log.info( + "Found scan event successfully. Iteration {} successful." + .format(self.max_concurrent_scans + 1)) + except Exception: + self.log.error("Failed to find a onScanFailed event for callback {}" + .format(scan_callback)) + test_result = False + for callback in scan_callback_list: + self.scn_ad.droid.bleStopBleScan(callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5a91f612-69e5-490f-b9d0-50d58a3db736') + def test_max_concurrent_ble_scans_verify_scans_stop_independently(self): + """Test max LE scans variant. + + Test that a single device can have max scans concurrently scanning. + + Steps: + 1. Initialize scanner + 2. Initialize advertiser + 3. Create max ble scan callbacks + 4. Start ble scan on each callback + 5. Start advertising on the device from step 2 + 6. Verify that the first callback triggers + 7. Stop the scan and repeat steps 6 and 7 until all scans stopped + + Expected Result: + All scanning instances should start without errors and the advertisement + should be found on each scan instance. All scanning instances should + stop successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Concurrency + Priority: 1 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['all_matches']) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback_list = [] + for i in range(self.max_concurrent_scans): + self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + scan_callback_list.append(scan_callback) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + except Empty as error: + self.log.exception("Test failed with Empty error: {}".format( + error)) + return False + except concurrent.futures._base.TimeoutError as error: + self.log.exception( + "Test failed, filtering callback onSuccess never" + " occurred: {}".format(error)) + return False + i = 0 + for callback in scan_callback_list: + expected_scan_event_name = scan_result.format(scan_callback) + try: + self.scn_ad.ed.pop_event(expected_scan_event_name, + self.default_timeout) + self.log.info( + "Found scan event successfully. Iteration {} successful.". + format(i)) + i += 1 + except Exception: + self.log.info("Failed to find a scan result for callback {}". + format(scan_callback)) + return False + self.scn_ad.droid.bleStopBleScan(callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return True diff --git a/acts/tests/google/ble/concurrency/ConcurrentGattConnectTest.py b/acts/tests/google/ble/concurrency/ConcurrentGattConnectTest.py new file mode 100644 index 0000000000..ec5e09cae8 --- /dev/null +++ b/acts/tests/google/ble/concurrency/ConcurrentGattConnectTest.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script for concurrent Gatt connections. +Testbed assumes 6 Android devices. One will be the central and the rest +peripherals. +""" + +from queue import Empty +import concurrent.futures +import threading +import time +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import bt_profile_constants +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format +from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_service_types +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_gatt_utils import run_continuous_write_descriptor +from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection +from acts.test_utils.bt.gatts_lib import GattServerLib +from acts.test_decorators import test_tracker_info + +service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb' +characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630' +descriptor_uuid = "00000003-0000-1000-8000-00805f9b34fb" + +gatt_server_read_descriptor_sample = { + 'services': [{ + 'uuid': + service_uuid, + 'type': + gatt_service_types['primary'], + 'characteristics': [{ + 'uuid': + characteristic_uuid, + 'properties': + gatt_characteristic['property_write'], + 'permissions': + gatt_characteristic['permission_write'], + 'instance_id': + 0x002a, + 'value_type': + gatt_characteristic_value_format['string'], + 'value': + 'Test Database', + 'descriptors': [{ + 'uuid': descriptor_uuid, + 'permissions': gatt_descriptor['permission_write'], + }] + }] + }] +} + + +class ConcurrentGattConnectTest(BluetoothBaseTest): + bt_default_timeout = 10 + max_connections = 5 + # List of tuples (android_device, advertise_callback) + advertise_callbacks = [] + # List of tuples (android_device, advertisement_name) + advertisement_names = [] + list_of_arguments_list = [] + + def setup_class(self): + super(BluetoothBaseTest, self).setup_class() + self.pri_dut = self.android_devices[0] + + + # Create 5 advertisements from different android devices + for i in range(1, self.max_connections + 1): + # Set device name + ad = self.android_devices[i] + name = "test_adv_{}".format(i) + self.advertisement_names.append((ad, name)) + ad.droid.bluetoothSetLocalName(name) + + # Setup and start advertisements + ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_data = ad.droid.bleBuildAdvertiseData() + advertise_settings = ad.droid.bleBuildAdvertiseSettings() + advertise_callback = ad.droid.bleGenBleAdvertiseCallback() + ad.droid.bleStartBleAdvertising(advertise_callback, advertise_data, + advertise_settings) + self.advertise_callbacks.append((ad, advertise_callback)) + + def obtain_address_list_from_scan(self): + """Returns the address list of all devices that match the scan filter. + + Returns: + A list if all devices are found; None is any devices are not found. + """ + # From central device, scan for all appropriate addresses by name. + filter_list = self.pri_dut.droid.bleGenFilterList() + self.pri_dut.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + scan_settings = self.pri_dut.droid.bleBuildScanSetting() + scan_callback = self.pri_dut.droid.bleGenScanCallback() + for android_device, name in self.advertisement_names: + self.pri_dut.droid.bleSetScanFilterDeviceName(name) + self.pri_dut.droid.bleBuildScanFilter(filter_list) + self.pri_dut.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + address_list = [] + devices_found = [] + # Set the scan time out to 20 sec to provide enough time to discover the + # devices in busy environment + scan_timeout = 20 + end_time = time.time() + scan_timeout + while time.time() < end_time and len(address_list) < len( + self.advertisement_names): + try: + event = self.pri_dut.ed.pop_event( + "BleScan{}onScanResults".format(scan_callback), + self.bt_default_timeout) + + adv_name = event['data']['Result']['deviceInfo']['name'] + mac_address = event['data']['Result']['deviceInfo']['address'] + # Look up the android device handle based on event name + device = [ + item for item in self.advertisement_names + if adv_name in item + ] + devices_found.append(device[0][0].serial) + if len(device) is not 0: + address_list_tuple = (device[0][0], mac_address) + else: + continue + result = [item for item in address_list if mac_address in item] + # if length of result is 0, it indicates that we have discovered + # new mac address. + if len(result) is 0: + self.log.info("Found new mac address: {}".format( + address_list_tuple[1])) + address_list.append(address_list_tuple) + except Empty as err: + self.log.error("Failed to find any scan results.") + return None + if len(address_list) < self.max_connections: + self.log.info("Only found these devices: {}".format(devices_found)) + self.log.error("Could not find all necessary advertisements.") + return None + return address_list + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6638282c-69b5-4237-9f0d-18e131424a9f') + def test_concurrent_gatt_connections(self): + """Test max concurrent GATT connections + + Connect to all peripherals. + + Steps: + 1. Scan + 2. Save addresses + 3. Connect all addresses of the peripherals + + Expected Result: + All connections successful. + + Returns: + Pass if True + Fail if False + + TAGS: Bluetooth, GATT + Priority: 2 + """ + + address_list = self.obtain_address_list_from_scan() + if address_list is None: + return False + + # Connect to all addresses + for address_tuple in address_list: + address = address_tuple[1] + try: + autoconnect = False + bluetooth_gatt, gatt_callback = setup_gatt_connection( + self.pri_dut, address, autoconnect) + self.log.info("Successfully connected to {}".format(address)) + except Exception as err: + self.log.error( + "Failed to establish connection to {}".format(address)) + return False + if (len( + self.pri_dut.droid.bluetoothGetConnectedLeDevices( + bt_profile_constants['gatt_server'])) != + self.max_connections): + self.log.error("Did not reach max connection count.") + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='660bf05e-a8e5-45f3-b42b-b66b4ac0d85f') + def test_data_transfer_to_concurrent_gatt_connections(self): + """Test writing GATT descriptors concurrently to many peripherals. + + Connect to all peripherals and write gatt descriptors concurrently. + + + Steps: + 1. Scan the addresses by names + 2. Save mac addresses of the peripherals + 3. Connect all addresses of the peripherals and write gatt descriptors + + + Expected Result: + All connections and data transfers are successful. + + Returns: + Pass if True + Fail if False + + TAGS: Bluetooth, GATT + Priority: 2 + """ + + address_list = self.obtain_address_list_from_scan() + if address_list is None: + return False + + # Connect to all addresses + executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) + + for address_tuple in address_list: + ad, address = address_tuple + + gatts = GattServerLib(log=self.log, dut=ad) + gatt_server, gatt_server_callback = gatts.setup_gatts_db( + database=gatt_server_read_descriptor_sample) + + try: + bluetooth_gatt, gatt_callback = setup_gatt_connection( + self.pri_dut, address, autoconnect=False) + self.log.info("Successfully connected to {}".format(address)) + + except Exception as err: + self.log.error( + "Failed to establish connection to {}".format(address)) + return False + + if self.pri_dut.droid.gattClientDiscoverServices(bluetooth_gatt): + event = self.pri_dut.ed.pop_event( + "GattConnect{}onServicesDiscovered".format(bluetooth_gatt), + self.bt_default_timeout) + discovered_services_index = event['data']['ServicesIndex'] + else: + self.log.info("Failed to discover services.") + return False + services_count = self.pri_dut.droid.gattClientGetDiscoveredServicesCount( + discovered_services_index) + + arguments_list = [ + self.pri_dut.droid, self.pri_dut.ed, ad.droid, ad.ed, + gatt_server, gatt_server_callback, bluetooth_gatt, + services_count, discovered_services_index, 100 + ] + self.list_of_arguments_list.append(arguments_list) + + for arguments_list in self.list_of_arguments_list: + executor.submit(run_continuous_write_descriptor, *arguments_list) + + executor.shutdown(wait=True) + + if (len( + self.pri_dut.droid.bluetoothGetConnectedLeDevices( + bt_profile_constants['gatt_server'])) != + self.max_connections): + self.log.error("Failed to write concurrently.") + return False + + return True diff --git a/acts/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py b/acts/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py new file mode 100644 index 0000000000..353f507088 --- /dev/null +++ b/acts/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py @@ -0,0 +1,510 @@ +#!/usr/bin/env python3 +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Test script to execute Bluetooth Connection-orient Channel (CoC) functionality for +2 connections test cases. This test was designed to be run in a shield box. +""" + +import threading +import time + +from acts import utils +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_coc_test_utils import orchestrate_coc_connection +from acts.test_utils.bt.bt_coc_test_utils import do_multi_connection_throughput +from acts.test_utils.bt.bt_constants import default_le_data_length +from acts.test_utils.bt.bt_constants import default_bluetooth_socket_timeout_ms +from acts.test_utils.bt.bt_constants import l2cap_coc_header_size +from acts.test_utils.bt.bt_constants import l2cap_max_inactivity_delay_after_disconnect +from acts.test_utils.bt.bt_constants import le_connection_event_time_step_ms +from acts.test_utils.bt.bt_test_utils import clear_bonded_devices +from acts.test_utils.bt.bt_test_utils import kill_bluetooth_process +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs +from acts.test_utils.bt.bt_test_utils import write_read_verify_data +from acts.test_utils.bt.bt_test_utils import verify_server_and_client_connected + + +class BleCoc2ConnTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.client_ad = self.android_devices[0] + # The client which is scanning will need location to be enabled in order to + # start scan and get scan results. + utils.set_location_service(self.client_ad, True) + self.server_ad = self.android_devices[1] + # Note that some tests required a third device. + if len(self.android_devices) > 2: + self.server2_ad = self.android_devices[2] + + return setup_multiple_devices_for_bt_test(self.android_devices) + + def teardown_test(self): + self.client_ad.droid.bluetoothSocketConnStop() + self.server_ad.droid.bluetoothSocketConnStop() + # Give sufficient time for the physical LE link to be disconnected. + time.sleep(l2cap_max_inactivity_delay_after_disconnect) + + # This utility function calculates the max and min connection event (ce) time. + # The formula is that the min/max ce time should be less than half the connection + # interval and must be multiples of the le_connection_event_time_step. + def _calc_min_max_ce_time(self, le_connection_interval): + conn_event_time_steps = int((le_connection_interval/2)/le_connection_event_time_step_ms) + conn_event_time_steps -= 1 + return (le_connection_event_time_step_ms * conn_event_time_steps) + + def _run_coc_connection_throughput_2_conn( + self, + is_secured, + buffer_size, + le_connection_interval=0, + le_tx_data_length=default_le_data_length, + min_ce_len=0, + max_ce_len=0): + + # The num_iterations is that number of repetitions of each + # set of buffers r/w. + # number_buffers is the total number of data buffers to transmit per + # set of buffers r/w. + # buffer_size is the number of bytes per L2CAP data buffer. + num_iterations = 10 + number_buffers = 100 + + # Make sure at least 3 phones are setup + if len(self.android_devices) <= 2: + self.log.info("test_coc_connection_throughput_2_conn: " + "Error: 3rd phone not configured in file") + return False + + self.log.info( + "_run_coc_connection_throughput_2_conn: is_secured={}, Interval={}, buffer_size={}, " + "le_tx_data_length={}, min_ce_len={}".format(is_secured, le_connection_interval, + buffer_size, le_tx_data_length, min_ce_len)) + status, client_conn_id1, server_conn_id1 = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured, + le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms, + min_ce_len, max_ce_len) + if not status: + return False + + status, client_conn_id2, server_conn_id2 = orchestrate_coc_connection( + self.client_ad, self.server2_ad, True, is_secured, + le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms, + min_ce_len, max_ce_len) + if not status: + return False + + list_server_ad = [self.server_ad, self.server2_ad] + list_client_conn_id = [client_conn_id1, client_conn_id2] + data_rate = do_multi_connection_throughput( + self.client_ad, list_server_ad, list_client_conn_id, + num_iterations, number_buffers, buffer_size) + if data_rate <= 0: + return False + + self.log.info( + "test_coc_connection_throughput_2_conn: throughput=%d bytes per " + "sec", data_rate) + + self.client_ad.droid.bluetoothSocketConnStop(client_conn_id1) + self.client_ad.droid.bluetoothSocketConnStop(client_conn_id2) + self.server_ad.droid.bluetoothSocketConnStop(server_conn_id1) + self.server2_ad.droid.bluetoothSocketConnStop(server_conn_id2) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='27226006-b725-4312-920e-6193cf0539d4') + def test_coc_insecured_connection_throughput_2_conn(self): + """Test LE CoC data throughput on two insecured connections + + Test Data Throughput of 2 L2CAP CoC insecured connections. + 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Verify that the L2CAP CoC connection is active from both the client + and server. + 4. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to both server#1 and server#2. + 7. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length + status = self._run_coc_connection_throughput_2_conn(False, 117) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1a5fb032-8a27-42f1-933f-3e39311c09a6') + def test_coc_secured_connection_throughput_2_conn(self): + """Test LE CoC data throughput on two secured connections + + Test Data Throughput of 2 L2CAP CoC secured connections. + 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is secured. + 3. Verify that the L2CAP CoC connection is active from both the client + and server. + 4. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is secured. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to both server#1 and server#2. + 7. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length + status = self._run_coc_connection_throughput_2_conn(True, 117) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b198f8cc-26af-44bd-bb4d-7dc8f8645617') + def test_coc_connection_throughput_2_conn_NOSEC_10CI_60SIZE(self): + """Test LE CoC data throughput with 10msec CI and 60bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval + and 60 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 20 msec and buffer size to 60 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 20 msec and buffer size to 60 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 60 + le_tx_data_length = buffer_size + l2cap_coc_header_size + + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12dc2a6c-8283-4617-a911-42335dd693a8') + def test_coc_connection_throughput_2_conn_NOSEC_10CI_80SIZE(self): + """Test LE CoC data throughput with 10msec CI and 80bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval + and 80 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 20 msec and buffer size to 80 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 20 msec and buffer size to 80 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 80 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4730df05-3909-4adf-a365-7f0c3258c402') + def test_coc_connection_throughput_2_conn_NOSEC_10CI_120SIZE(self): + """Test LE CoC data throughput with 10msec CI and 120bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval + and 120 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 20 msec and buffer size to 120 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 20 msec and buffer size to 120 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 120 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='471a8748-b0a5-4be5-9322-7c75e2b5d048') + def test_coc_connection_throughput_2_conn_NOSEC_15CI_120SIZE(self): + """Test LE CoC data throughput with 15msec CI and 120bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 15msec connection interval + and 120 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 15 msec and buffer size to 120 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 15 msec and buffer size to 120 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 15 + buffer_size = 120 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='053e59c2-f312-4bec-beaf-9e4efdce063a') + def test_coc_connection_throughput_2_conn_NOSEC_15CI_180SIZE(self): + """Test LE CoC data throughput with 15msec CI and 180bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 15msec connection interval + and 120 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 15 msec and buffer size to 180 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 15 msec and buffer size to 180 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 15 + buffer_size = 180 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2b43caa6-76b3-48c5-b342-32ebb31ac52c') + def test_coc_connection_throughput_2_conn_NOSEC_20CI_240SIZE(self): + """Test LE CoC data throughput with 20msec CI and 240bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval + and 240 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 20 msec and buffer size to 240 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 20 msec and buffer size to 240 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + le_connection_interval = 20 + buffer_size = 240 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f630df02-3fd6-4aa0-bc15-06837b705e97') + def test_coc_connection_throughput_2_conn_NOSEC_30CI_240SIZE(self): + """Test LE CoC data throughput with 30msec CI and 240bytes buffer size. + + Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval + and 240 bytes buffer size. 3 phones are required. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server#1 AD. + The connection is insecured. + 3. Set the connection interval to 30 msec and buffer size to 240 bytes. + 4. Verify that the L2CAP CoC connection is active from both the client + and server. + 5. Establish a L2CAP CoC connection from the client to the server#2 AD. + The connection is insecured. + 6. Set the connection interval to 30 msec and buffer size to 240 bytes. + 7. Verify that the L2CAP CoC connection is active from both the client + and server. + 8. Write data from the client to both server#1 and server#2. + 9. Verify data matches from client and server + + Expected Result: + L2CAP CoC connections are established and data written correctly to both servers. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 30 + buffer_size = 240 + le_tx_data_length = buffer_size + l2cap_coc_header_size + status = self._run_coc_connection_throughput_2_conn( + is_secured, buffer_size, le_connection_interval, le_tx_data_length, + self._calc_min_max_ce_time(le_connection_interval), + self._calc_min_max_ce_time(le_connection_interval)) + return status diff --git a/acts/tests/google/ble/conn_oriented_chan/BleCocTest.py b/acts/tests/google/ble/conn_oriented_chan/BleCocTest.py new file mode 100644 index 0000000000..166b848f26 --- /dev/null +++ b/acts/tests/google/ble/conn_oriented_chan/BleCocTest.py @@ -0,0 +1,587 @@ +#!/usr/bin/env python3 +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Test script to execute Bluetooth Connection-orient Channel (CoC) functionality +test cases. This test was designed to be run in a shield box. +""" + +import threading +import time + +from acts import utils +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_coc_test_utils import orchestrate_coc_connection +from acts.test_utils.bt.bt_coc_test_utils import do_multi_connection_throughput +from acts.test_utils.bt.bt_constants import default_le_data_length +from acts.test_utils.bt.bt_constants import l2cap_coc_header_size +from acts.test_utils.bt.bt_constants import l2cap_max_inactivity_delay_after_disconnect +from acts.test_utils.bt.bt_test_utils import clear_bonded_devices +from acts.test_utils.bt.bt_test_utils import kill_bluetooth_process +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs +from acts.test_utils.bt.bt_test_utils import write_read_verify_data +from acts.test_utils.bt.bt_test_utils import verify_server_and_client_connected + + +class BleCocTest(BluetoothBaseTest): + message = ( + "Space: the final frontier. These are the voyages of " + "the starship Enterprise. Its continuing mission: to explore " + "strange new worlds, to seek out new life and new civilizations," + " to boldly go where no man has gone before.") + + def setup_class(self): + super().setup_class() + self.client_ad = self.android_devices[0] + self.server_ad = self.android_devices[1] + # Note that some tests required a third device. + if len(self.android_devices) > 2: + self.server2_ad = self.android_devices[2] + + # The client which is scanning will need location to be enabled in order to + # start scan and get scan results. + utils.set_location_service(self.client_ad, True) + return setup_multiple_devices_for_bt_test(self.android_devices) + + def teardown_test(self): + self.client_ad.droid.bluetoothSocketConnStop() + self.server_ad.droid.bluetoothSocketConnStop() + # Give sufficient time for the physical LE link to be disconnected. + time.sleep(l2cap_max_inactivity_delay_after_disconnect) + + def _run_coc_connection_throughput( + self, + is_secured, + buffer_size, + le_connection_interval=0, + le_tx_data_length=default_le_data_length): + + # The num_iterations is that number of repetitions of each + # set of buffers r/w. + # number_buffers is the total number of data buffers to transmit per + # set of buffers r/w. + # buffer_size is the number of bytes per L2CAP data buffer. + number_buffers = 100 + num_iterations = 10 + + self.log.info( + "_run_coc_connection_throughput: calling " + "orchestrate_coc_connection. is_secured={}, Connection Interval={}msec, " + "buffer_size={}bytes".format(is_secured, le_connection_interval, + buffer_size)) + status, client_conn_id, server_conn_id = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured, + le_connection_interval, le_tx_data_length) + if not status: + return False + + list_server_ad = [self.server_ad] + list_client_conn_id = [client_conn_id] + data_rate = do_multi_connection_throughput( + self.client_ad, list_server_ad, list_client_conn_id, + num_iterations, number_buffers, buffer_size) + if data_rate <= 0: + return False + self.log.info( + "_run_coc_connection_throughput: throughput=%d bytes per sec", + data_rate) + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b6989966-c504-4934-bcd7-57fb4f7fde9c') + def test_coc_secured_connection(self): + """Test Bluetooth LE CoC secured connection + + Test LE CoC though establishing a basic connection with security. + + Steps: + 1. Get the mac address of the server device. + 2. Establish an LE CoC Secured connection from the client to the server AD. + 3. Verify that the LE CoC connection is active from both the client and + server. + Expected Result: + LE CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + is_secured = True + self.log.info( + "_test_coc_secured_connection: calling orchestrate_coc_connection but " + "isBle=1 and securedConn={}".format(is_secured)) + status, client_conn_id, server_conn_id = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured) + if not status: + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6587792c-78fb-469f-9084-772c249f97de') + def test_coc_insecured_connection(self): + """Test Bluetooth LE CoC insecured connection + + Test LE CoC though establishing a basic connection with no security. + + Steps: + 1. Get the mac address of the server device. + 2. Establish an LE CoC Secured connection from the client to the server AD. + 3. Verify that the LE CoC connection is active from both the client and + server. + Expected Result: + LE CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + is_secured = False + self.log.info( + "test_coc_insecured_connection: calling orchestrate_coc_connection but " + "isBle=1 and securedConn={}".format(is_secured)) + status, client_conn_id, server_conn_id = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured) + if not status: + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='32a7b02e-f2b5-4193-b414-36c8815ac407') + def test_coc_secured_connection_write_ascii(self): + """Test LE CoC secured connection writing and reading ascii data + + Test LE CoC though establishing a secured connection and reading and writing ascii data. + + Steps: + 1. Get the mac address of the server device. + 2. Establish an LE CoC connection from the client to the server AD. The security of + connection is TRUE. + 3. Verify that the LE CoC connection is active from both the client and + server. + 4. Write data from the client and read received data from the server. + 5. Verify data matches from client and server + 6. Disconnect the LE CoC connection. + + Expected Result: + LE CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + is_secured = True + self.log.info( + "test_coc_secured_connection_write_ascii: calling " + "orchestrate_coc_connection. is_secured={}".format(is_secured)) + status, client_conn_id, server_conn_id = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured) + if not status: + return False + if not write_read_verify_data(self.client_ad, self.server_ad, + self.message, False): + return False + if not verify_server_and_client_connected(self.client_ad, + self.server_ad): + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12537d27-79c9-40a0-8bdb-d023b0e36b58') + def test_coc_insecured_connection_write_ascii(self): + """Test LE CoC insecured connection writing and reading ascii data + + Test LE CoC though establishing a connection. + + Steps: + 1. Get the mac address of the server device. + 2. Establish an LE CoC connection from the client to the server AD. The security of + connection is FALSE. + 3. Verify that the LE CoC connection is active from both the client and + server. + 4. Write data from the client and read received data from the server. + 5. Verify data matches from client and server + 6. Disconnect the LE CoC connection. + + Expected Result: + LE CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + is_secured = False + self.log.info( + "test_coc_secured_connection_write_ascii: calling " + "orchestrate_coc_connection. is_secured={}".format(is_secured)) + status, client_conn_id, server_conn_id = orchestrate_coc_connection( + self.client_ad, self.server_ad, True, is_secured) + if not status: + return False + if not write_read_verify_data(self.client_ad, self.server_ad, + self.message, False): + return False + if not verify_server_and_client_connected(self.client_ad, + self.server_ad): + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='214037f4-f0d1-47db-86a7-5230c71bdcac') + def test_coc_secured_connection_throughput(self): + """Test LE CoC writing and measured data throughput with security + + Test CoC thoughput by establishing a secured connection and sending data. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server AD. + 3. Verify that the L2CAP CoC connection is active from both the client + and server. + 4. Write data from the client to server. + 5. Verify data matches from client and server + 6. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = True + # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length + return self._run_coc_connection_throughput(is_secured, 117) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6dc019bb-c3bf-4c98-978e-e2c5755058d7') + def test_coc_insecured_connection_throughput(self): + """Test LE CoC writing and measured data throughput without security. + + Test CoC thoughput by establishing an insecured connection and sending data. + + Steps: + 1. Get the mac address of the server device. + 2. Establish a L2CAP CoC connection from the client to the server AD. + 3. Verify that the L2CAP CoC connection is active from both the client + and server. + 4. Write data from the client to server. + 5. Verify data matches from client and server + 6. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 1 + """ + + is_secured = False + # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length + return self._run_coc_connection_throughput(is_secured, 117) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0af94805-1550-426c-bfdd-191b8b3a4c12') + def test_coc_connection_throughput_NOSEC_10CI_60SIZE(self): + """Test LE CoC data throughput with 10msec CI and 60bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 10msec + Connection Interval and 60 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 10msec. + 3. Change Payload Buffer Size to 60 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 60 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c32dac07-623a-4fdd-96c6-387a76afb2af') + def test_coc_connection_throughput_NOSEC_10CI_80SIZE(self): + """Test LE CoC data throughput with 10msec CI and 80bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 10msec + Connection Interval and 80 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 10msec. + 3. Change Payload Buffer Size to 80 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 80 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='45d1b0c1-73b6-483f-ac6b-c3cec805da32') + def test_coc_connection_throughput_NOSEC_10CI_120SIZE(self): + """Test LE CoC data throughput with 10msec CI and 120bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 10msec + Connection Interval and 120 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 10msec. + 3. Change Payload Buffer Size to 120 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 10 + buffer_size = 120 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='85f07f07-1017-42db-b38d-df0bf2fce804') + def test_coc_connection_throughput_NOSEC_15CI_120SIZE(self): + """Test LE CoC data throughput with 15msec CI and 120bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 15msec + Connection Interval and 120 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 15msec. + 3. Change Payload Buffer Size to 120 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 15 + buffer_size = 120 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4d3d4a06-7bbb-4a8c-9016-f326560cebb0') + def test_coc_connection_throughput_NOSEC_15CI_180SIZE(self): + """Test LE CoC data throughput with 15msec CI and 180bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 15msec + Connection Interval and 180 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 15msec. + 3. Change Payload Buffer Size to 180 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 15 + buffer_size = 180 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='124d85ba-41e6-4ab7-a017-99a88db7524a') + def test_coc_connection_throughput_NOSEC_20CI_240SIZE(self): + """Test LE CoC data throughput with 20msec CI and 240bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 20msec + Connection Interval and 240 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 20msec. + 3. Change Payload Buffer Size to 240 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 20 + buffer_size = 240 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='218932bc-ebb0-4c2b-96ad-220c600b50b1') + def test_coc_connection_throughput_NOSEC_30CI_240SIZE(self): + """Test LE CoC data throughput with 30msec CI and 240bytes buffer size. + + Test CoC thoughput by establishing a connection and sending data with 30msec + Connection Interval and 240 bytes data buffer size. + + Steps: + 1. Get the mac address of the server device. + 2. Change the Connection Interval to 30msec. + 3. Change Payload Buffer Size to 240 bytes. + 4. Establish a L2CAP CoC connection from the client to the server AD. + 5. Verify that the L2CAP CoC connection is active from both the client + and server. + 6. Write data from the client to server. + 7. Verify data matches from client and server + 8. Disconnect the L2CAP CoC connections. + + Expected Result: + CoC connection is established, check transmitted data contents, then disconnected + succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: BLE, CoC + Priority: 2 + """ + + is_secured = False + le_connection_interval = 30 + buffer_size = 240 + le_tx_data_length = buffer_size + l2cap_coc_header_size + return self._run_coc_connection_throughput( + is_secured, buffer_size, le_connection_interval, le_tx_data_length) diff --git a/acts/tests/google/ble/examples/BleExamplesTest.py b/acts/tests/google/ble/examples/BleExamplesTest.py new file mode 100644 index 0000000000..1ced2db965 --- /dev/null +++ b/acts/tests/google/ble/examples/BleExamplesTest.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This script shows simple examples of how to get started with bluetooth low energy testing in acts. +""" + +import pprint + +from acts.controllers import android_device +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers +from acts.test_utils.bt.bt_test_utils import reset_bluetooth + + +class BleExamplesTest(BluetoothBaseTest): + default_timeout = 10 + active_scan_callback_list = [] + active_adv_callback_list = [] + scn_droid = None + adv_droid = None + + def setup_class(self): + super().setup_class() + self.scn_droid, self.scn_ed = (self.android_devices[0].droid, + self.android_devices[0].ed) + self.adv_droid, self.adv_ed = (self.android_devices[1].droid, + self.android_devices[1].ed) + + def teardown_test(self): + cleanup_scanners_and_advertisers( + self.android_devices[0], self.active_adv_callback_list, + self.android_devices[1], self.active_adv_callback_list) + self.active_adv_callback_list = [] + self.active_scan_callback_list = [] + + # An optional function. This overrides the default + # on_exception in base_test. If the test throws an + # unexpected exception, you can customise it. + def on_exception(self, test_name, begin_time): + self.log.debug("Test {} failed. Gathering bugreport and btsnoop logs". + format(test_name)) + android_devices.take_bug_reports(self.android_devices, test_name, + begin_time) + + @BluetoothBaseTest.bt_test_wrap + def test_bt_toggle(self): + """ + Test that simply toggle bluetooth + :return: + """ + return reset_bluetooth([self.android_devices[0]]) + + ''' + Start: Examples of BLE Scanning + ''' + + @BluetoothBaseTest.bt_test_wrap + def test_start_ble_scan(self): + """Test to demonstrate how to start an LE scan + + Test that shows the steps to start a new ble scan. + + Steps: + 1. Create a scan filter object. + 2. Create a scan setting object. + 3. Create a scan callback object. + 4. Start an LE scan using the objects created in steps 1-3. + 5. Find an advertisement with the scanner's event dispatcher. + + Expected Result: + A generic advertisement is found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning + Priority: 4 + """ + filter_list = self.scn_droid.bleGenFilterList() + scan_settings = self.scn_droid.bleBuildScanSetting() + scan_callback = self.scn_droid.bleGenScanCallback() + self.scn_droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + event_name = scan_result.format(scan_callback) + try: + event = self.scn_ed.pop_event(event_name, self.default_timeout) + self.log.info("Found scan result: {}".format( + pprint.pformat(event))) + except Exception: + self.log.info("Didn't find any scan results.") + return True + + ''' + End: Examples of BLE Scanning + ''' + + @BluetoothBaseTest.bt_test_wrap + def test_start_ble_advertise(self): + """Test to demonstrate how to start an LE advertisement + + Test that shows the steps to start a new ble scan. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising + Priority: 4 + """ + advertise_data = self.adv_droid.bleBuildAdvertiseData() + advertise_settings = self.adv_droid.bleBuildAdvertiseSettings() + advertise_callback = self.adv_droid.bleGenBleAdvertiseCallback() + self.adv_droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.adv_ed.pop_event(adv_succ.format(advertise_callback)) + return True diff --git a/acts/tests/google/ble/examples/GattServerExampleTest.py b/acts/tests/google/ble/examples/GattServerExampleTest.py new file mode 100644 index 0000000000..e1f6476017 --- /dev/null +++ b/acts/tests/google/ble/examples/GattServerExampleTest.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_service_types +from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format +from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids +from acts.test_utils.bt.gatts_lib import GattServerLib + +service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb' +characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630' +descriptor_uuid = gatt_char_desc_uuids['client_char_cfg'] + +gatt_server_read_descriptor_sample = { + 'services': [{ + 'uuid': + service_uuid, + 'type': + gatt_service_types['primary'], + 'characteristics': [{ + 'uuid': + characteristic_uuid, + 'properties': + gatt_characteristic['property_read'], + 'permissions': + gatt_characteristic['permission_read'], + 'instance_id': + 0x002a, + 'value_type': + gatt_characteristic_value_format['string'], + 'value': + 'Test Database', + 'descriptors': [{ + 'uuid': descriptor_uuid, + 'permissions': gatt_descriptor['permission_read'], + }] + }] + }] +} + + +class GattServerExampleTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.dut = self.android_devices[0] + + @BluetoothBaseTest.bt_test_wrap + def test_create_gatt_server_db_example(self): + gatts = GattServerLib(log=self.log, dut=self.dut) + gatts.setup_gatts_db(database=gatt_server_read_descriptor_sample) + self.log.info(gatts.list_all_uuids()) + return True diff --git a/acts/tests/google/ble/filtering/FilteringTest.py b/acts/tests/google/ble/filtering/FilteringTest.py new file mode 100644 index 0000000000..d1bdc399c9 --- /dev/null +++ b/acts/tests/google/ble/filtering/FilteringTest.py @@ -0,0 +1,12100 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import itertools as it +import pprint +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers +from acts.test_utils.bt.bt_constants import java_integer +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import small_timeout +from acts.test_utils.bt.bt_constants import adv_fail +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_result + + +class FilteringTest(BluetoothBaseTest): + default_timeout = 30 + default_callback = 1 + default_is_connectable = True + default_advertise_mode = 0 + default_tx_power_level = 2 + + #Data constant variants + manu_sepecific_data_small = [1] + manu_sepecific_data_small_2 = [1, 2] + manu_specific_data_small_3 = [127] + manu_sepecific_data_large = [14, 0, 54, 0, 0, 0, 0, 0] + manu_sepecific_data_mask_small = [1] + manu_specific_data_id_1 = 1 + manu_specific_data_id_2 = 2 + manu_specific_data_id_3 = 65535 + + service_data_small = [13] + service_data_small_2 = [127] + service_data_medium = [11, 14, 50] + service_data_large = [ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 26, 17, 18, 19, 20, + 21, 22, 23, 24 + ] + + service_mask_1 = "00000000-0000-1000-8000-00805f9b34fb" + service_uuid_1 = "00000000-0000-1000-8000-00805f9b34fb" + service_uuid_2 = "FFFFFFFF-0000-1000-8000-00805f9b34fb" + service_uuid_3 = "3846D7A0-69C8-11E4-BA00-0002A5D5C51B" + + def setup_class(self): + super().setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + self.log.info("Scanner device model: {}".format( + self.scn_ad.droid.getBuildModel())) + self.log.info("Advertiser device model: {}".format( + self.adv_ad.droid.getBuildModel())) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='be72fc18-e7e9-41cf-80b5-e31babd763f6') + def test_filter_combo_0(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='92e11460-1877-4dd1-998b-8f78354dd776') + def test_filter_combo_1(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9cdb7ad3-9f1e-4cbc-ae3f-af27d9833ae3') + def test_filter_combo_2(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ae06ece8-28ae-4c2f-a768-d0e1e60cc253') + def test_filter_combo_3(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7a7c40fb-1398-4659-af46-ba01ca23ba7f') + def test_filter_combo_4(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='85cab0b7-4ba2-408c-b78b-c45d0cad1d1e') + def test_filter_combo_5(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='31e7a496-6626-4d73-8337-b250f7386ab6') + def test_filter_combo_6(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='465f5426-1157-4a6f-8c33-a266ee7439bc') + def test_filter_combo_7(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='77552584-74c7-4a1b-a98e-8863e91f4e74') + def test_filter_combo_8(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='fb2b5f08-53cd-400b-98a0-bbd96093e466') + def test_filter_combo_9(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='edacb609-9508-4394-9c94-9ed13a4205b5') + def test_filter_combo_10(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='73a86198-3213-43c5-b083-0a37089b8e44') + def test_filter_combo_11(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ca92075-d22b-4e82-9e7b-495060f3af45') + def test_filter_combo_12(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a0689f97-c616-49a5-b690-00b6193ac822') + def test_filter_combo_13(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='dbdf3a68-c79a-43a6-89a7-5269a1fad9a5') + def test_filter_combo_14(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='93e45b16-dff0-4067-9c14-7adf32a0f484') + def test_filter_combo_15(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='dace8a1c-e71a-4668-9e8f-b1cb19071087') + def test_filter_combo_16(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='192528e2-4a67-4984-9c68-f9d716470d5b') + def test_filter_combo_17(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2a9ffd92-f02d-45bc-81f5-f398e2572f14') + def test_filter_combo_18(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ab98e5e5-ac35-4ebe-8b37-780b0ab56b82') + def test_filter_combo_19(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0b4ca831-dbf6-44da-84b6-9425b7f50577') + def test_filter_combo_20(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f615206a-16bf-4481-be31-7b2a28d8009b') + def test_filter_combo_21(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e9a0e69e-bc5c-479e-a716-cbb88180e719') + def test_filter_combo_22(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='16c2949d-e7c8-4fa1-a781-3ced2c902c4c') + def test_filter_combo_23(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ffd7a3a8-b9b5-4bf0-84c1-ed3823b8a52c') + def test_filter_combo_24(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='457b5dee-1034-4973-88c1-bde0a6ef700c') + def test_filter_combo_25(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b848e90c-37ed-4ecb-8c49-601f3b66a4cc') + def test_filter_combo_26(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c03df405-b7aa-42cf-b282-adf5c228e513') + def test_filter_combo_27(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='83de681d-89fb-45e1-b8e0-0488e43b3248') + def test_filter_combo_28(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='712bf6b2-0cdc-4782-b593-17a846fd1c65') + def test_filter_combo_29(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='725c37e5-046b-4234-a7eb-ad8836531a74') + def test_filter_combo_30(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='665344f9-c246-4b08-aff6-73f7ff35431b') + def test_filter_combo_31(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6994ceff-fed8-42e4-a3cb-be6ed3a9a5c9') + def test_filter_combo_32(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2fb756c0-8b72-403a-a769-d22d31376037') + def test_filter_combo_33(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='146203bb-04cc-4b3d-b372-66e1b8da3e08') + def test_filter_combo_34(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1e123df5-db37-4e8d-ac1f-9399fe8487f9') + def test_filter_combo_35(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='886f0978-a2df-4005-810b-5e2cc0c2a5a4') + def test_filter_combo_36(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='94f61b07-e90a-42e3-b97b-07afc73755e6') + def test_filter_combo_37(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1dbb67ed-2f9e-464d-8ba8-dd7ac668d765') + def test_filter_combo_38(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3a3e5aa9-a5cc-4e99-aeb4-b32357186e1d') + def test_filter_combo_39(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2c51245a-7be3-4dfb-87c5-7c4530ab5908') + def test_filter_combo_40(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9d33bae5-0a5f-4d2c-96fc-fc1ec8107814') + def test_filter_combo_41(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='05b5ee9e-9a64-4bf8-91ab-a7762358d25e') + def test_filter_combo_42(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='589f4d3f-c644-4981-a0f8-cd9bcf4d5142') + def test_filter_combo_43(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='10ce4d36-081f-4353-a484-2c7988e7cda8') + def test_filter_combo_44(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6f52f24d-adda-4e2d-b52e-1b24b978c343') + def test_filter_combo_45(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5aacbec9-4a8b-4c76-9684-590a29f73854') + def test_filter_combo_46(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e1fa3728-9acb-47e9-bea4-3ac886c68a22') + def test_filter_combo_47(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ce98edd-5f94-456c-8083-3dd37eefe086') + def test_filter_combo_48(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cb93cdab-6443-4946-a7f6-9c34e0b21272') + def test_filter_combo_49(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d9069a4d-8635-4b91-9a0f-31a64586a216') + def test_filter_combo_50(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='559f4f49-bd6a-4490-b8b3-da13ef57eb83') + def test_filter_combo_51(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d769aa3c-c039-45f3-8ef7-f91ccbbcdfaf') + def test_filter_combo_52(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4c6adf11-7c79-4a97-b507-cc8044d2c7c6') + def test_filter_combo_53(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b99f7238-197b-4fb0-80a9-a51a20c00093') + def test_filter_combo_54(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f1e3e036-b611-4325-81e2-114ad777d00e') + def test_filter_combo_55(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9f786760-8a33-4076-b33e-38acc6689b5c') + def test_filter_combo_56(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9e6466c3-ce73-471e-8b4a-dce1a1c9d046') + def test_filter_combo_57(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b44f6d43-07cb-477d-bcc8-460cc2094475') + def test_filter_combo_58(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='38dcb64b-6564-4116-8abb-3a8e8ed530a9') + def test_filter_combo_59(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b0918c1a-1291-482c-9ecb-2df085ec036f') + def test_filter_combo_60(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6c317053-6fdc-45e1-9109-bd2726b2490f') + def test_filter_combo_61(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='af057157-3ef5-48af-918d-53ba6b2e8405') + def test_filter_combo_62(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4693bb43-a4b6-4595-a75b-ff18c4be50c7') + def test_filter_combo_63(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6e2037c1-5e99-4dc7-8950-5fd3df29fa08') + def test_filter_combo_64(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a85acfbb-e6d2-42f4-b917-6b0bac26e457') + def test_filter_combo_65(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d05f3aaa-833c-40a1-b3a0-c69756919218') + def test_filter_combo_66(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1dd2b27b-f9fe-41e3-b884-3500d6bf9a38') + def test_filter_combo_67(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e31e7d9d-878b-442e-9ae9-b07d5e903df3') + def test_filter_combo_68(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='05c05a71-27a4-4620-940b-ce3747d4e6c5') + def test_filter_combo_69(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c4bb2251-1246-466b-a6bb-76ae13089101') + def test_filter_combo_70(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b284008a-81be-42b6-8176-906a780f92a2') + def test_filter_combo_71(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='01bc025f-4696-4e80-a590-ec7b0eeea1a3') + def test_filter_combo_72(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ef674d1e-f3b1-43fc-a037-718ffe650d12') + def test_filter_combo_73(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cbc29a50-76fe-40b8-93fa-b274605660b2') + def test_filter_combo_74(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0674b703-2571-4bcf-91f2-a34a323e179b') + def test_filter_combo_75(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a65046b3-4aed-47f3-86cd-838155dfd309') + def test_filter_combo_76(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a379dfdd-8924-4e62-95ac-14fe3ae358da') + def test_filter_combo_77(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3ed6b73f-23fb-4ef2-8bd5-e59a34f362cd') + def test_filter_combo_78(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9d3fc46a-07b7-48ad-9a31-fcdba259c670') + def test_filter_combo_79(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ba5e905-634f-485b-829c-1ef79fa5f116') + def test_filter_combo_80(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b275ff76-eec5-467b-b12d-7440ff588cec') + def test_filter_combo_81(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='009ecb1c-2860-4a4e-867b-c712569ddfd1') + def test_filter_combo_82(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='61c7da36-6b19-49d2-9981-120bb0b76372') + def test_filter_combo_83(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4c22688a-4d03-4145-aa2f-f989832f8086') + def test_filter_combo_84(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cc159f43-5619-46fe-b8ad-209a446f10c0') + def test_filter_combo_85(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9a81d52e-cd46-4e2b-9ac1-ecebcc04d788') + def test_filter_combo_86(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='938c404f-8dd8-46a5-afe4-f87559bb2c9d') + def test_filter_combo_87(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4bc6a2db-e845-435d-8d8e-a990f4b1fcdc') + def test_filter_combo_88(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e245fb6a-35fc-488f-ada6-393fe4a09134') + def test_filter_combo_89(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4dd70ebf-ec85-4e95-a9f5-a10e1791293c') + def test_filter_combo_90(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b0085042-0fd6-4ff3-af69-156f270953b1') + def test_filter_combo_91(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6b9a539b-b6cc-46b1-a9a5-ef20808f5e74') + def test_filter_combo_92(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1f18a94c-a72e-4912-a91a-0be96e708be4') + def test_filter_combo_93(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9f2d3923-a932-40c8-b527-8baedcf3254c') + def test_filter_combo_94(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='edf61fa9-b51f-41fd-b3ca-0035ee7dbd65') + def test_filter_combo_95(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8b8adcf5-adb9-4a48-8570-4e1d2e6b47c6') + def test_filter_combo_96(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cc7857e0-5a5b-468f-bf5e-dc1478716715') + def test_filter_combo_97(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b4c9e01f-944c-4d8e-9a3f-49efaa22887c') + def test_filter_combo_98(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='951e19cf-c138-4d8e-92e6-b42410b8114f') + def test_filter_combo_99(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ad50f0c0-c19e-45b8-8fb2-95afe81f7620') + def test_filter_combo_100(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a7fd36d6-77ec-453e-a67c-0c2fc78e572a') + def test_filter_combo_101(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d661aafd-005d-4a31-88b0-a238e328b16d') + def test_filter_combo_102(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7fe951d2-28c5-43a9-af79-c0fbf3a3388f') + def test_filter_combo_103(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d802f38b-830f-4cd2-af2c-a44ba625a401') + def test_filter_combo_104(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e1a30f67-1577-4cfb-9a0d-c07493a341b2') + def test_filter_combo_105(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='774a6bf9-cfd6-40ef-8b91-3576f23eb01b') + def test_filter_combo_106(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b85d0c78-69bc-42e3-ac78-61ad8176a1d0') + def test_filter_combo_107(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='bd93c530-4ab0-4d9b-b202-ea6dd1c8a27d') + def test_filter_combo_108(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4590bfbb-006f-46be-bd03-5afe8b81ac52') + def test_filter_combo_109(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2626f60e-cb01-45a1-a23e-f1eaa85ac9ce') + def test_filter_combo_110(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='24cf16ac-10a6-4a02-9b72-84c280fa77a2') + def test_filter_combo_111(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6242aadb-028b-4932-9024-8b6d2148c458') + def test_filter_combo_112(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5918fef7-0578-4999-b331-d2948e62e720') + def test_filter_combo_113(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='63160fc2-306f-46a4-bf1f-b512642478c4') + def test_filter_combo_114(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='849749ae-e5f3-4029-be92-66a1353ba165') + def test_filter_combo_115(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5f150448-94f6-4f0b-a8da-0c4a78541a4f') + def test_filter_combo_116(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='39af4eca-990a-4b3b-bcf2-1a840e8a9308') + def test_filter_combo_117(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a59cb1fa-eb7d-4161-84a9-cda157b6b8c5') + def test_filter_combo_118(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cfaf02e5-76e4-4593-849c-b63de4907638') + def test_filter_combo_119(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9eb40c09-89ea-44e9-8514-e58cdce91779') + def test_filter_combo_120(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e2d2a8d5-0554-49cc-9cc9-66e97378d260') + def test_filter_combo_121(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cb72c86a-a7c6-4bf9-9eec-53f7d190a9f1') + def test_filter_combo_122(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cb75e56e-a029-478d-8031-8de12f5fbebf') + def test_filter_combo_123(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='277a98c4-4b1f-428d-8c10-8697a3fe1f0f') + def test_filter_combo_124(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2d884bf2-c678-429c-8aee-3be78b3176ff') + def test_filter_combo_125(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e6b5fcff-8a6e-4eb7-9070-74caf9e18349') + def test_filter_combo_126(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='682ffa88-2d13-4d21-878e-c2a8a510cf71') + def test_filter_combo_127(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a27d8f58-7523-404a-bf99-744afdb52aba') + def test_filter_combo_128(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f2c77cf7-dc52-471d-b66d-54e72f7f7ea0') + def test_filter_combo_129(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3e21ad66-88fc-48ee-a698-6c475f478a86') + def test_filter_combo_130(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='af046c81-524e-4016-b6a8-459538f320c2') + def test_filter_combo_131(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f3aad5f8-6214-4c67-9a84-2da7171fb111') + def test_filter_combo_132(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='16ab8d79-15ca-4ab3-b004-834edb4da37b') + def test_filter_combo_133(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cb37c6a3-496f-49a6-b02a-552b8260205e') + def test_filter_combo_134(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9e3ad4d0-4fab-4d85-9543-5e2c2fea79ec') + def test_filter_combo_135(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='37f93abf-237e-4917-91a6-afa2629b5f98') + def test_filter_combo_136(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1131c908-ddf2-4cdd-b1a2-9b73990e72c3') + def test_filter_combo_137(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1b283fa0-485b-4f45-a353-36f9cdd6c123') + def test_filter_combo_138(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e4bdc84e-413c-4a2b-9049-f5b04e32b5b7') + def test_filter_combo_139(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8791e036-3f30-4a44-b3a8-23371da893a6') + def test_filter_combo_140(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='27201535-9537-4e11-a1d7-1b1f5f01e213') + def test_filter_combo_141(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e40e7b8f-44f0-4f87-8206-fea14d0fef52') + def test_filter_combo_142(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0f369e78-c5ae-4cbc-8511-597cdc38b1ae') + def test_filter_combo_143(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='174418c1-6938-4319-9d8b-361df3fc28f3') + def test_filter_combo_144(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6bc94d17-b532-413b-86fc-185c194b430c') + def test_filter_combo_145(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3c47822e-5e74-4270-bcb4-72e3995bd5c5') + def test_filter_combo_146(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='19515def-b28d-4ef7-bae7-c4f64940879a') + def test_filter_combo_147(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a45abd7c-24ca-400c-b2d5-233431b07522') + def test_filter_combo_148(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4492a245-c91f-4df1-a55b-57541ce410c8') + def test_filter_combo_149(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e4c485af-66a0-413b-b70e-3396e130fffb') + def test_filter_combo_150(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='31369cd6-feb7-47f3-9022-2d619c961ba7') + def test_filter_combo_151(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5cf0da7f-a515-4f67-bae4-956d86275423') + def test_filter_combo_152(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a78293f0-aee5-40d1-9c97-3fdda3ddd43e') + def test_filter_combo_153(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3fd7d0cb-6d98-4ca8-9a14-8ca23b6dae07') + def test_filter_combo_154(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='19434f33-5bc5-427f-b332-36f85c997fe3') + def test_filter_combo_155(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4195c9e1-b87c-4fa1-8039-ec0f2652e216') + def test_filter_combo_156(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0536e50e-f33c-4772-b078-4f95231c3de6') + def test_filter_combo_157(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='116dcfef-caae-496f-abfa-0863f2968f6f') + def test_filter_combo_158(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='00f37533-9ca5-4c58-adb3-d3d709c7b215') + def test_filter_combo_159(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d86e57da-29b5-445e-bf75-3e2843b9b739') + def test_filter_combo_160(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='792736ce-8f43-4d21-b9b9-30d3bfd66b6a') + def test_filter_combo_161(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': False, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ec387a8a-e7b2-4df7-9580-b09362c3dc4d') + def test_filter_combo_162(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='93a8f3b0-0fb0-47bd-88fb-6dc847ac14e4') + def test_filter_combo_163(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='283356e9-58ac-4edc-bf08-0bc9c7313053') + def test_filter_combo_164(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ab4f0d84-58fd-4a2a-b3ed-128231f3e22f') + def test_filter_combo_165(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='02bbbdd0-3c57-41c5-ab32-28185f33802c') + def test_filter_combo_166(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f6c67a80-bede-4186-b7a1-09756b4c1a68') + def test_filter_combo_167(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4fc73f9c-4826-4ff2-bba0-bc64cc469f3a') + def test_filter_combo_168(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='58a6fafc-bbc5-466b-a586-310d9dfc14c1') + def test_filter_combo_169(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='38de3927-212c-4948-bd46-cca1d09ead90') + def test_filter_combo_170(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b03a34cf-c3e1-4954-9cb6-b5f1a59e94e9') + def test_filter_combo_171(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='455ead9d-1e50-46e4-907c-c5b9bbbdcc9c') + def test_filter_combo_172(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a7320afc-affb-4fa5-877d-7eb8bd1f8558') + def test_filter_combo_173(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='163c5c85-bef7-4da6-8e8a-89b0656b71d0') + def test_filter_combo_174(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='31147187-c5a9-4c2e-8be6-b79ff71cdaf3') + def test_filter_combo_175(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='783b5756-ca16-4a17-b1f0-8a16ddc009c4') + def test_filter_combo_176(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='924a107b-fe1c-4b9d-b29b-47c3b2df1de3') + def test_filter_combo_177(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='096a6596-fd8c-4d8c-88c6-45903047fe2c') + def test_filter_combo_178(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e37b2083-a9d0-4337-aa11-d9205c15f456') + def test_filter_combo_179(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3de8087b-7f25-4cda-8f07-fa9326524deb') + def test_filter_combo_180(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f218bf14-0a6e-4c5f-b151-3ac9719ca1a2') + def test_filter_combo_181(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1a13171d-b9a9-4b42-8cec-5c5841c4f3a5') + def test_filter_combo_182(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='53311ac1-239f-4033-aaa6-084523916fc6') + def test_filter_combo_183(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f8bb89b2-2dae-4d41-9d19-6c9af0fe6da8') + def test_filter_combo_184(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4747ab09-8d62-4866-80e6-c9b8e4cf5061') + def test_filter_combo_185(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='be6db894-57dd-452a-8f08-3ce462ac9417') + def test_filter_combo_186(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2070329b-b7c8-4958-af9c-2e1044b71564') + def test_filter_combo_187(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1a428d9e-46fd-4bd2-a12c-25c89ead74b1') + def test_filter_combo_188(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': True, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f07220c2-c0a9-471a-871d-a87931feb278') + def test_filter_combo_189(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b3af8fb0-cd93-4ab0-b8f3-4111969c7cbb') + def test_filter_combo_190(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b630cc10-4cda-487d-ab84-599963c172d7') + def test_filter_combo_191(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9cdbe1df-e3e1-45e4-b816-96b8a6efb90f') + def test_filter_combo_192(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='10cd2757-a182-419f-9512-8b536539a134') + def test_filter_combo_193(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5c7af5b2-8a2c-4c2d-911f-dad8216d849f') + def test_filter_combo_194(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0acb37c7-0ece-4f5b-9294-014dd7fcb3ed') + def test_filter_combo_195(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='14f07972-6403-49be-8eed-ce7294e33d32') + def test_filter_combo_196(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f2db7e80-d3ea-4beb-8e09-24ae33904716') + def test_filter_combo_197(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='30c1303f-956f-4b2d-af6a-3570aa4567fd') + def test_filter_combo_198(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8e210748-f842-4fa1-ac40-2bfd291f08a1') + def test_filter_combo_199(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='756c687d-8183-4bc9-90dc-4e46a5579fca') + def test_filter_combo_200(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8f904946-a9c7-4f7a-af96-0d22c5592709') + def test_filter_combo_201(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='abdfce9f-3529-435b-8fdc-9dd7bf0fc01c') + def test_filter_combo_202(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='71289aa2-f74d-44b7-ad18-515a3c438a15') + def test_filter_combo_203(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='223db6ca-7190-4f3f-89cc-92dcc2dcd109') + def test_filter_combo_204(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8a61a11e-fc25-4e28-928d-e2be2d95af63') + def test_filter_combo_205(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8c62bc17-6998-4ec8-923b-e29fe1693ae3') + def test_filter_combo_206(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': [1, 2], + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='85f168fa-a868-4940-aef1-de063a497083') + def test_filter_combo_207(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7697ca45-fc34-4f8c-9b61-58cc7d4f3321') + def test_filter_combo_208(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f5221c06-c006-4363-ab9c-90b9d8c31b43') + def test_filter_combo_209(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b7119a2d-6269-408c-ae69-39ebad1e4192') + def test_filter_combo_210(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2025037f-433b-4167-a0c9-3265a53fe6ba') + def test_filter_combo_211(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ecf2c84b-88b0-48d9-8a4f-3660f039cd97') + def test_filter_combo_212(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_2, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='844a6bcb-cd5a-4023-9af7-cab68ed2e847') + def test_filter_combo_213(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_medium + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b7e5ff94-93e0-45c9-a160-33628f5fcf9e') + def test_filter_combo_214(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b9781df2-59e4-44ba-9a98-1d35670a6f63') + def test_filter_combo_215(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_3, + 'service_data_uuid': self.service_uuid_1, + 'manufacturer_specific_data': self.manu_specific_data_small_3, + 'include_tx_power_level': False, + 'include_device_name': True, + 'service_data': self.service_data_small_2 + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4ad156f8-8d80-4635-b6d8-7bca07d8a899') + def test_filter_combo_216(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5b68c344-bfd1-44cb-9add-c81122d6b04f') + def test_filter_combo_217(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='355ca57c-998c-4e7e-b0d2-66854b5192bb') + def test_filter_combo_218(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a9ec0f76-6b8f-42e0-8310-07c02de49d9d') + def test_filter_combo_219(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='73f448ff-e9f6-4608-80ba-92131485234f') + def test_filter_combo_220(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='55ec509d-8cdd-4ab5-8e57-2ccadd5f8c0d') + def test_filter_combo_221(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1f6835fd-b33b-4be3-b133-b77f6c9872c8') + def test_filter_combo_222(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='62d483c0-7d08-4b7c-9b1f-3b0324006554') + def test_filter_combo_223(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='01bcb867-3f39-4aef-baf5-50b439768b43') + def test_filter_combo_224(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='faab6211-4408-4272-93d9-7b09b8c3b8cd') + def test_filter_combo_225(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a0f9ad8d-c00a-4420-9205-eeb081bf2b35') + def test_filter_combo_226(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7a2e8186-e8b0-4956-b8bc-fb2ba91b8f67') + def test_filter_combo_227(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='414b5464-b135-453b-acf3-aebc728d0366') + def test_filter_combo_228(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='580e3ff8-4648-402e-a531-ddb85bbf4c89') + def test_filter_combo_229(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7fe0c829-94b5-4e88-aa92-47159c1eb232') + def test_filter_combo_230(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='93c1747d-4b76-4faf-9efc-4ca40e751f08') + def test_filter_combo_231(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='96f7e662-6f74-407a-b1d8-e29ac3405ff4') + def test_filter_combo_232(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cde6415b-1138-4913-ab4f-542d4057542d') + def test_filter_combo_233(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4ca75288-0af8-462b-9146-022b9f915b1f') + def test_filter_combo_234(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4db5dae2-f974-4208-9c01-84ca050f8fc3') + def test_filter_combo_235(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c9f7abf0-b333-4500-9fd0-e4678574cf18') + def test_filter_combo_236(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b8176ca4-478c-49c6-a638-4f53d7d2720c') + def test_filter_combo_237(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7e84c371-f28e-4995-86a9-bb99a4a29d0c') + def test_filter_combo_238(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3b8eb500-6885-4273-9c53-f7930896e895') + def test_filter_combo_239(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f80ef69f-d71c-4c94-893d-363cf5a658f6') + def test_filter_combo_240(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='dca1ab9d-7923-4917-8a82-1917dbad4923') + def test_filter_combo_241(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='36faab09-d874-4f24-b7ea-8985d60dc4c3') + def test_filter_combo_242(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c94b7e3b-064c-4885-a4aa-899e83d0e754') + def test_filter_combo_243(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f6680820-8843-47e4-b4fb-0ee1b76d51f8') + def test_filter_combo_244(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4b1bf9a9-7761-435a-8c6c-511b20312c04') + def test_filter_combo_245(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5c5b0147-cacd-46f0-a6b7-ff8b37cf985b') + def test_filter_combo_246(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c31e26f2-2e82-40bc-a9a5-5ae059b702d8') + def test_filter_combo_247(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': True, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5a1a4438-6bb3-4acc-85ab-b48432c340db') + def test_filter_combo_248(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0dd54bff-d170-441f-81ae-bc11f7c8491b') + def test_filter_combo_249(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='98d878cf-1548-4e79-9527-8741e5b523d0') + def test_filter_combo_250(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ec0c9a9b-3df3-4cba-84fc-9a17a11b1be7') + def test_filter_combo_251(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='eabddddc-29c7-4804-93a8-c259957538ae') + def test_filter_combo_252(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ee0abe8f-254e-4802-b808-4aa8e0306203') + def test_filter_combo_253(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9482cda2-a6f5-4dff-8809-6dfabaaf9f71') + def test_filter_combo_254(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='279f54ee-975b-4edc-a6c8-f018e45846c3') + def test_filter_combo_255(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a3508588-ca01-4063-ae7e-c845ac4a595b') + def test_filter_combo_256(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8bde1746-dec8-4b17-93ba-90448addcb13') + def test_filter_combo_257(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9ae7e798-0981-4501-9302-54553c76a54c') + def test_filter_combo_258(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='28e1efdc-1c5f-44d8-8650-02720db32048') + def test_filter_combo_259(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a309d9d0-bf5e-4878-b6bb-89d3c388d5b2') + def test_filter_combo_260(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b0db2d76-8039-4257-bed0-e5e154a5874f') + def test_filter_combo_261(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='06ecd167-4dbc-4a8c-9c1c-2daea87f7a51') + def test_filter_combo_262(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12f6c002-8627-4477-8e5a-6d7b5335ed60') + def test_filter_combo_263(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['balanced'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ccd43a09-cb39-4d84-8ffc-99ad8449783b') + def test_filter_combo_264(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f9d9abad-e543-4996-b369-09fddd9c4965') + def test_filter_combo_265(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2a14e619-23a6-4a49-acd6-e712b026d75b') + def test_filter_combo_266(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='2ed25b96-54fd-4a81-b8d1-732b959aff8d') + def test_filter_combo_267(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0ef9198b-78ac-4fa6-afe2-cc87007c2c0d') + def test_filter_combo_268(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='43d97df2-07d7-4c45-bb83-908746e60923') + def test_filter_combo_269(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='55262e57-7b47-45a3-8926-18cea480c2b2') + def test_filter_combo_270(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5ece141d-43ad-448c-900c-500666cb0e1c') + def test_filter_combo_271(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['opportunistic'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='66d3c0de-7e3b-4108-9ab0-3e101c6a14cd') + def test_filter_combo_272(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9703d50a-8b23-4d42-8ed3-9b0704dac9d2') + def test_filter_combo_273(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a5739a21-0e1b-4ba7-b259-acb7b38a8e09') + def test_filter_combo_274(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c399011c-54c0-47a1-9e05-a52c2190f89d') + def test_filter_combo_275(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['balanced'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7854fdcc-5771-463a-91da-5b394484b065') + def test_filter_combo_276(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['high'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='fa0fe141-c99f-4228-b249-96232194e740') + def test_filter_combo_277(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d2143fe1-bbec-429a-8241-19f39361b490') + def test_filter_combo_278(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['ultra_low'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='21d025ef-2f89-49fd-bb31-2130dbe83c5c') + def test_filter_combo_279(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_tx_powers['medium'], + 'is_connectable': False, + 'scan_mode': ble_scan_settings_modes['low_power'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='19c5f91d-e10a-43af-8727-c66ee43187f2') + def test_filter_combo_280(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_tx_power_level': True} + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7bda5df3-2644-46ca-b6de-e3d5557395cf') + def test_filter_combo_281(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'filter_device_address': True} + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a80f6a40-9a60-4d68-b5e1-66d6e157cdd8') + def test_filter_combo_282(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='503bfb94-cfb8-4194-b451-23f19aff7b8e') + def test_filter_combo_283(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_large + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9bae0612-559b-460f-9723-fac896974835') + def test_filter_combo_284(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'manufacturer_specific_data_mask': [1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f1ad0e3a-17cd-4e06-a395-7e5dde2268b4') + def test_filter_combo_285(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110A-0000-1000-8000-00805F9B34FB', + 'service_data': self.service_data_large + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='84f29360-9219-4f39-8ead-b43779c65504') + def test_filter_combo_286(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110B-0000-1000-8000-00805F9B34FB', + 'service_data': [13] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='caece017-8379-46a3-913b-a21d3057e096') + def test_filter_combo_287(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110C-0000-1000-8000-00805F9B34FB', + 'service_data': [11, 14, 50] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='37d63f4e-ed0c-4003-8044-f7032238a449') + def test_filter_combo_288(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110D-0000-1000-8000-00805F9B34FB', + 'service_data': [16, 22, 11] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7a57c0d7-1b8d-44e7-b407-7a6c58095058') + def test_filter_combo_289(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110E-0000-1000-8000-00805F9B34FB', + 'service_data': [2, 9, 54] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='38f80b83-2aba-40f4-9238-7e108acea1e4') + def test_filter_combo_290(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110F-0000-1000-8000-00805F9B34FB', + 'service_data': [69, 11, 50] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='adec5d6d-c1f2-46d0-8b05-2c46c02435a6') + def test_filter_combo_291(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001101-0000-1000-8000-00805F9B34FB', + 'service_data': [12, 11, 21] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cd3cbc57-80a6-43d8-8042-9f163beda73a') + def test_filter_combo_292(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001102-0000-1000-8000-00805F9B34FB', + 'service_data': [12, 12, 44] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='35d9ab80-1ceb-4b45-ae9e-304c413f9273') + def test_filter_combo_293(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001103-0000-1000-8000-00805F9B34FB', + 'service_data': [4, 54, 1] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='07cecc9f-6e72-407e-a11d-c982f92c1834') + def test_filter_combo_294(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001104-0000-1000-8000-00805F9B34FB', + 'service_data': [33, 22, 44] + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8c0de318-4c57-47c3-8068-d1b0fde7f448') + def test_filter_combo_295(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': '00000000-0000-1000-8000-00805f9b34fb', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8fbd96a9-5844-4714-8f63-5b92432d23d1') + def test_filter_combo_296(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': 'FFFFFFFF-0000-1000-8000-00805f9b34fb', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d127b973-46ca-4a9f-a1e1-5cda6affaa53') + def test_filter_combo_297(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': '3846D7A0-69C8-11E4-BA00-0002A5D5C51B', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='efaad273-f953-43ca-b4f6-f9eba10d3ba5') + def test_filter_combo_298(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='373ba3e8-01e8-4c26-ad7f-7b7ba69d1a70') + def test_filter_combo_299(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_tx_power_level': True} + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e1848bba-b9a6-473b-bceb-101b14b4ccc1') + def test_filter_combo_300(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'filter_device_address': True} + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3a6068a5-0dd1-4503-b25a-79bc0f4a7006') + def test_filter_combo_301(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c54e14e7-c5f6-4c16-9900-2b8ac9ee96a5') + def test_filter_combo_302(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_large + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='bb188de9-8c63-4eba-96ab-b8577001412d') + def test_filter_combo_303(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'manufacturer_specific_data_id': self.manu_specific_data_id_1, + 'manufacturer_specific_data': self.manu_sepecific_data_small, + 'manufacturer_specific_data_mask': [1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4e42416b-fe86-41e7-99cd-3ea0ab61a027') + def test_filter_combo_304(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110A-0000-1000-8000-00805F9B34FB', + 'service_data': self.service_data_large + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a519609b-cd95-4017-adac-86954153669e') + def test_filter_combo_305(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110B-0000-1000-8000-00805F9B34FB', + 'service_data': [13] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ad1f5bdd-b532-482c-8f62-cc6804f0f8a2') + def test_filter_combo_306(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110C-0000-1000-8000-00805F9B34FB', + 'service_data': [11, 14, 50] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a44af1a3-f5ac-419b-a11b-a72734b57fa7') + def test_filter_combo_307(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110D-0000-1000-8000-00805F9B34FB', + 'service_data': [16, 22, 11] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1b2b17e7-5a1a-4795-974d-3a239c7fccc8') + def test_filter_combo_308(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110E-0000-1000-8000-00805F9B34FB', + 'service_data': [2, 9, 54] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9e9944cc-a85c-4077-9129-ca348a6c0286') + def test_filter_combo_309(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '0000110F-0000-1000-8000-00805F9B34FB', + 'service_data': [69, 11, 50] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e0bb52ea-ac8f-4951-bd00-5322d0e72fd2') + def test_filter_combo_310(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001101-0000-1000-8000-00805F9B34FB', + 'service_data': [12, 11, 21] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='719d258d-6556-47b6-92d6-224c691b5dfd') + def test_filter_combo_311(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001102-0000-1000-8000-00805F9B34FB', + 'service_data': [12, 12, 44] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1ab27561-6e2d-4da8-b2b1-dc4bd2c42f97') + def test_filter_combo_312(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001103-0000-1000-8000-00805F9B34FB', + 'service_data': [4, 54, 1] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5b460a48-f6d6-469c-9553-11817171dacb') + def test_filter_combo_313(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_data_uuid': '00001104-0000-1000-8000-00805F9B34FB', + 'service_data': [33, 22, 44] + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e0439501-b72d-43ac-a51f-c44b4d0c86d9') + def test_filter_combo_314(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': '00000000-0000-1000-8000-00805f9b34fb', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3a7f4527-2a77-4172-8402-78d90fbc5a8a') + def test_filter_combo_315(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': 'FFFFFFFF-0000-1000-8000-00805f9b34fb', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c6661021-33ad-4628-99f0-1a3b4b4a8263') + def test_filter_combo_316(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = { + 'service_uuid': '3846D7A0-69C8-11E4-BA00-0002A5D5C51B', + 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' + } + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='3a633941-1716-4bf6-a8d7-8a4ad0be24aa') + def test_filter_combo_317(self): + """Test a combination scan filter and advertisement + + Test that an advertisement is found and matches corresponding + settings. + + Steps: + 1. Create a advertise data object + 2. Create a advertise settings object. + 3. Create a advertise callback object. + 4. Start an LE advertising using the objects created in steps 1-3. + 5. Find the onSuccess advertisement event. + + Expected Result: + Advertisement is successfully advertising. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + filters = {'include_device_name': True} + settings_in_effect = { + 'scan_mode': ble_scan_settings_modes['low_latency'], + 'mode': ble_advertise_settings_modes['low_latency'] + } + return self._magic((filters, settings_in_effect)) + + def _blescan_verify_onscanresult_event(self, event, filters): + test_result = True + self.log.debug("Verifying onScanResult event: {}".format(event)) + callback_type = event['data']['CallbackType'] + if 'callback_type' in filters.keys(): + if filters['callback_type'] != callback_type: + self.log.error("Expected callback type: {}, Found callback " + "type: {}".format(filters['callback_type'], + callback_type)) + test_result = False + elif self.default_callback != callback_type: + self.log.error("Expected callback type: {}, Found callback type: " + "{}".format(self.default_callback, callback_type)) + test_result = False + if 'include_device_name' in filters.keys() and filters[ + 'include_device_name'] is not False: + if event['data']['Result']['deviceName'] != filters[ + 'include_device_name']: + self.log.error( + "Expected device name: {}, Found device name: {}" + .format(filters['include_device_name'], event['data'][ + 'Result']['deviceName'])) + + test_result = False + elif 'deviceName' in event['data']['Result'].keys(): + self.log.error( + "Device name was found when it wasn't meant to be included.") + test_result = False + if ('include_tx_power_level' in filters.keys() and + filters['include_tx_power_level'] is not False): + if not event['data']['Result']['txPowerLevel']: + self.log.error( + "Expected to find tx power level in event but found none.") + test_result = False + if not event['data']['Result']['rssi']: + self.log.error("Expected rssi in the advertisement, found none.") + test_result = False + if not event['data']['Result']['timestampNanos']: + self.log.error("Expected rssi in the advertisement, found none.") + test_result = False + return test_result + + def _bleadvertise_verify_onsuccess(self, event, settings_in_effect): + self.log.debug("Verifying {} event".format(adv_succ)) + test_result = True + if 'is_connectable' in settings_in_effect.keys(): + if (event['data']['SettingsInEffect']['isConnectable'] != + settings_in_effect['is_connectable']): + self.log.error("Expected is connectable value: {}, Actual is " + "connectable value:".format(settings_in_effect[ + 'is_connectable'], event['data'][ + 'SettingsInEffect']['isConnectable'])) + test_result = False + elif (event['data']['SettingsInEffect']['isConnectable'] != + self.default_is_connectable): + self.log.error( + "Default value for isConnectable did not match what was found.") + test_result = False + if 'mode' in settings_in_effect.keys(): + if (event['data']['SettingsInEffect']['mode'] != + settings_in_effect['mode']): + self.log.error("Expected mode value: {}, Actual mode value: {}" + .format(settings_in_effect['mode'], event[ + 'data']['SettingsInEffect']['mode'])) + test_result = False + elif (event['data']['SettingsInEffect']['mode'] != + self.default_advertise_mode): + self.log.error( + "Default value for filtering mode did not match what was " + "found.") + test_result = False + if 'tx_power_level' in settings_in_effect.keys(): + if (event['data']['SettingsInEffect']['txPowerLevel'] == + java_integer['min']): + self.log.error("Expected tx power level was not meant to be: " + "{}".format(java_integer['min'])) + test_result = False + elif (event['data']['SettingsInEffect']['txPowerLevel'] != + self.default_tx_power_level): + self.log.error( + "Default value for tx power level did not match what" + " was found.") + test_result = False + return test_result + + def _magic(self, params): + (filters, settings_in_effect) = params + test_result = True + + self.log.debug("Settings in effect: {}".format( + pprint.pformat(settings_in_effect))) + self.log.debug("Filters:".format(pprint.pformat(filters))) + if 'is_connectable' in settings_in_effect.keys(): + self.log.debug("Setting advertisement is_connectable to {}".format( + settings_in_effect['is_connectable'])) + self.adv_ad.droid.bleSetAdvertiseSettingsIsConnectable( + settings_in_effect['is_connectable']) + if 'mode' in settings_in_effect.keys(): + self.log.debug("Setting advertisement mode to {}" + .format(settings_in_effect['mode'])) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + settings_in_effect['mode']) + if 'tx_power_level' in settings_in_effect.keys(): + self.log.debug("Setting advertisement tx_power_level to {}".format( + settings_in_effect['tx_power_level'])) + self.adv_ad.droid.bleSetAdvertiseSettingsTxPowerLevel( + settings_in_effect['tx_power_level']) + filter_list = self.scn_ad.droid.bleGenFilterList() + if ('include_device_name' in filters.keys() and + filters['include_device_name'] is not False): + + self.log.debug("Setting advertisement include_device_name to {}" + .format(filters['include_device_name'])) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + filters['include_device_name'] = ( + self.adv_ad.droid.bluetoothGetLocalName()) + self.log.debug("Setting scanner include_device_name to {}".format( + filters['include_device_name'])) + self.scn_ad.droid.bleSetScanFilterDeviceName(filters[ + 'include_device_name']) + else: + self.log.debug( + "Setting advertisement include_device_name to False") + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(False) + if ('include_tx_power_level' in filters.keys() and + filters['include_tx_power_level'] is not False): + self.log.debug( + "Setting advertisement include_tx_power_level to True") + self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) + if 'manufacturer_specific_data_id' in filters.keys(): + if 'manufacturer_specific_data_mask' in filters.keys(): + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( + filters['manufacturer_specific_data_id'], + filters['manufacturer_specific_data']) + self.scn_ad.droid.bleSetScanFilterManufacturerData( + filters['manufacturer_specific_data_id'], + filters['manufacturer_specific_data'], + filters['manufacturer_specific_data_mask']) + else: + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( + filters['manufacturer_specific_data_id'], + filters['manufacturer_specific_data']) + self.scn_ad.droid.bleSetScanFilterManufacturerData( + filters['manufacturer_specific_data_id'], + filters['manufacturer_specific_data']) + if 'service_data' in filters.keys(): + self.adv_ad.droid.bleAddAdvertiseDataServiceData( + filters['service_data_uuid'], filters['service_data']) + self.scn_ad.droid.bleSetScanFilterServiceData( + filters['service_data_uuid'], filters['service_data']) + if 'manufacturer_specific_data_list' in filters.keys(): + for pair in filters['manufacturer_specific_data_list']: + (manu_id, manu_data) = pair + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(manu_id, + manu_data) + if 'service_mask' in filters.keys(): + self.scn_ad.droid.bleSetScanFilterServiceUuid( + filters['service_uuid'].upper(), filters['service_mask']) + self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( + [filters['service_uuid'].upper()]) + elif 'service_uuid' in filters.keys(): + self.scn_ad.droid.bleSetScanFilterServiceUuid(filters[ + 'service_uuid']) + self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( + [filters['service_uuid']]) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + if ('scan_mode' in settings_in_effect and + settings_in_effect['scan_mode'] != + ble_scan_settings_modes['opportunistic']): + self.scn_ad.droid.bleSetScanSettingsScanMode(settings_in_effect[ + 'scan_mode']) + else: + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + opportunistic = False + scan_settings2, scan_callback2 = None, None + if ('scan_mode' in settings_in_effect and + settings_in_effect['scan_mode'] == + ble_scan_settings_modes['opportunistic']): + opportunistic = True + scan_settings2 = self.scn_ad.droid.bleBuildScanSetting() + scan_callback2 = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings2, + scan_callback2) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['opportunistic']) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + regex = "(" + adv_succ.format( + advertise_callback) + "|" + adv_fail.format( + advertise_callback) + ")" + self.log.debug(regex) + try: + event = self.adv_ad.ed.pop_events(regex, self.default_timeout, + small_timeout) + except Empty: + self.adv_ad.log.error("Failed to get success or failed event.") + return False + if event[0]["name"] == adv_succ.format(advertise_callback): + if not self._bleadvertise_verify_onsuccess(event[0], + settings_in_effect): + return False + else: + self.adv_ad.log.info("Advertisement started successfully.") + else: + self.adv_ad.log.error("Failed to start advertisement: {}".format( + event[0]["data"]["Error"])) + expected_scan_event_name = scan_result.format(scan_callback) + try: + event = self.scn_ad.ed.pop_event(expected_scan_event_name, + self.default_timeout) + except Empty: + self.log.error("Scan event not found: {}".format( + expected_scan_event_name)) + return False + if not self._blescan_verify_onscanresult_event(event, filters): + return False + if opportunistic: + expected_scan_event_name = scan_result.format(scan_callback2) + try: + event = self.scn_ad.ed.pop_event(expected_scan_event_name, + self.default_timeout) + except Empty: + self.log.error("Opportunistic scan event not found: {}".format( + expected_scan_event_name)) + return False + if not self._blescan_verify_onscanresult_event(event, filters): + return False + self.scn_ad.droid.bleStopBleScan(scan_callback2) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + self.scn_ad.droid.bleStopBleScan(scan_callback) + return test_result diff --git a/acts/tests/google/ble/filtering/UniqueFilteringTest.py b/acts/tests/google/ble/filtering/UniqueFilteringTest.py new file mode 100644 index 0000000000..c2e837c567 --- /dev/null +++ b/acts/tests/google/ble/filtering/UniqueFilteringTest.py @@ -0,0 +1,650 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different filters and outcomes not exercised in +FilteringTest. +""" + +import concurrent +import json +import pprint +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_constants import batch_scan_result +from acts.test_utils.bt.bt_constants import scan_result + + +class UniqueFilteringTest(BluetoothBaseTest): + default_timeout = 10 + + def setup_class(self): + super().setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + def blescan_verify_onfailure_event_handler(self, event): + self.log.debug("Verifying onFailure event") + self.log.debug(pprint.pformat(event)) + return event + + def blescan_verify_onscanresult_event_handler(self, + event, + expected_callbacktype=None, + system_time_nanos=None): + test_result = True + self.log.debug("Verifying onScanResult event") + self.log.debug(pprint.pformat(event)) + callbacktype = event['data']['CallbackType'] + if callbacktype != expected_callbacktype: + self.log.debug( + "Expected callback type: {}, Found callback type: {}".format( + expected_callbacktype, callbacktype)) + test_result = False + return test_result + + def blescan_get_mac_address_event_handler(self, event): + return event['data']['Result']['deviceInfo']['address'] + + def blescan_verify_onbatchscanresult_event_handler( + self, event, system_time_nanos=None, report_delay_nanos=None): + test_result = True + self.log.debug("Verifying onBatchScanResult event") + self.log.debug(pprint.pformat(event)) + for result in event['data']['Results']: + timestamp_nanos = result['timestampNanos'] + length_of_time = timestamp_nanos - system_time_nanos + self.log.debug("Difference in time in between scan start and " + "onBatchScanResult: {}".format(length_of_time)) + buffer = 1000000000 # 1 second + if length_of_time > (report_delay_nanos + buffer): + self.log.debug( + "Difference was greater than the allowable difference.") + test_result = False + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c3764358-cd65-451c-9a2d-4bfb6cf98f48') + def test_scan_flush_pending_scan_results(self): + """Test LE scan api flush pending results. + + Test that flush pending scan results doesn't affect onScanResults from + triggering. + + Steps: + 1. Setup the scanning android device. + 2. Setup the advertiser android devices. + 3. Trigger bluetoothFlushPendingScanResults on the scanning droid. + 4. Verify that only one onScanResults callback was triggered. + + Expected Result: + After flushing pending scan results, make sure only one onScanResult + callback was triggered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 1 + """ + test_result = True + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + expected_event_name = scan_result.format(scan_callback) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.scn_ad.droid.bleFlushPendingScanResults(scan_callback) + worker = self.scn_ad.ed.handle_event( + self.blescan_verify_onscanresult_event_handler, + expected_event_name, ([1]), self.default_timeout) + try: + self.log.debug(worker.result(self.default_timeout)) + except Empty as error: + test_result = False + self.log.error("Test failed with Empty error: {}".format(error)) + except concurrent.futures._base.TimeoutError as error: + test_result = False + self.log.error("Test failed with TimeoutError: {}".format(error)) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4b358654-db69-4b51-98ec-7599aee2db10') + def test_scan_trigger_on_batch_scan_results(self): + """Test triggering batch scan results. + + Test that triggers onBatchScanResults and verifies the time to trigger + within one second leeway. + + Steps: + 1. Setup the scanning android device with report delay seconds set to + 5000. + 2. Setup the advertiser android devices. + 3. Verify that only one onBatchScanResult callback was triggered. + 4. Compare the system time that the scan was started with the elapsed + time that is in the callback. + + Expected Result: + The scan event dispatcher should find an onBatchScanResult event. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Batch Scanning + Priority: 2 + """ + test_result = True + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis(5000) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + expected_event_name = batch_scan_result.format(scan_callback) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + system_time_nanos = self.scn_ad.droid.getSystemElapsedRealtimeNanos() + self.log.debug("Current system time: {}".format(system_time_nanos)) + worker = self.scn_ad.ed.handle_event( + self.blescan_verify_onbatchscanresult_event_handler, + expected_event_name, ([system_time_nanos, 5000000000]), + self.default_timeout) + try: + self.log.debug(worker.result(self.default_timeout)) + except Empty as error: + test_result = False + self.log.debug("Test failed with: {}".format(error)) + except concurrent.futures._base.TimeoutError as error: + test_result = False + self.log.debug("Test failed with: {}".format(error)) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='94dbe8b2-9e7f-4da4-973e-5162b84a7ce0') + def test_scan_flush_results_without_on_batch_scan_results_triggered(self): + """Test that doesn't expect a batch scan result. + + Test flush pending scan results with a report delay seconds set to 0. + No onBatchScanResults callback should be triggered. + + Steps: + 1. Setup the scanning android device with report delay seconds set to 0 + (or just use default). + 2. Setup the advertiser android devices. + + Expected Result: + Verify that no onBatchScanResults were triggered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Batch Scanning + Priority: 2 + """ + test_result = True + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + expected_event_name = batch_scan_result.format(scan_callback) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + worker = self.scn_ad.ed.handle_event( + self.blescan_verify_onbatchscanresult_event_handler, + expected_event_name, ([]), self.default_timeout) + self.scn_ad.droid.bleFlushPendingScanResults(scan_callback) + try: + event_info = self.scn_ad.ed.pop_event(expected_event_name, 10) + self.log.debug( + "Unexpectedly found an advertiser: {}".format(event_info)) + test_result = False + except Empty: + self.log.debug("No {} events were found as expected.".format( + batch_scan_result)) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5856882e-3d82-4a6f-b110-389086b0ac41') + def test_scan_non_existent_name_filter(self): + """Test non-existent name filter. + + Test scan filter on non-existent device name. + + Steps: + 1. Setup the scanning android device with scan filter for device name + set to an unexpected value. + 2. Setup the advertiser android devices. + 3. Verify that no onScanResults were triggered. + + Expected Result: + No advertisements were found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + test_result = True + filter_name = "{}_probably_wont_find".format( + self.adv_ad.droid.bluetoothGetLocalName()) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.scn_ad.droid.bleSetScanFilterDeviceName(filter_name) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + expected_event_name = scan_result.format(scan_callback) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + try: + event_info = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + self.log.error( + "Unexpectedly found an advertiser: {}".format(event_info)) + test_result = False + except Empty: + self.log.debug("No events were found as expected.") + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0a54c50b-d4ef-4d8c-8328-775781aab2c7') + def test_scan_advertisement_with_device_service_uuid_filter_expect_no_events( + self): + """Test scan filtering against an advertisement with no data. + + Test that exercises a service uuid filter on the scanner but no server + uuid added to the advertisement. + + Steps: + 1. Setup the scanning android device with scan filter including a + service uuid and mask. + 2. Setup the advertiser android devices. + 3. Verify that no onScanResults were triggered. + + Expected Result: + Verify no advertisements found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 1 + """ + test_result = True + service_uuid = "00000000-0000-1000-8000-00805F9B34FB" + service_mask = "00000000-0000-1000-8000-00805F9B34FA" + self.scn_ad.droid.bleSetScanFilterServiceUuid(service_uuid, + service_mask) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + expected_event_name = scan_result.format(scan_callback) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + worker = self.scn_ad.ed.handle_event( + self.blescan_verify_onscanresult_event_handler, + expected_event_name, ([1]), self.default_timeout) + try: + event_info = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + self.log.error( + "Unexpectedly found an advertiser: {}".format(event_info)) + test_result = False + except Empty as error: + self.log.debug("No events were found as expected.") + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='aefbc70c-ea46-4a63-a627-6fcceb72ac9e') + def test_scan_filtering_multiple_advertisements_manufacturer_data(self): + """Test scan filtering against multiple varying advertisements. + + Test scan filtering against multiple varying advertisements. The first + advertisement will have partial manufacturer data that matches the + the full manufacturer data in the second advertisement. + + Steps: + 1. Setup up an advertisement with manufacturer data [1,2,3]. + 2. Setup a second advertisement with manufacturer data + [1,2,3,4,5,6,7,8]. + 3. Start advertising on each advertisement. + 4. Create a scan filter that includes manufacturer data [1,2,3]. + + Expected Result: + TBD. Right now Shamu finds only the first advertisement with + manufacturer data [1,2,3]. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 2 + """ + test_result = True + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(117, [1, 2, 3]) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( + 117, [1, 2, 3, 4, 5, 6, 7, 8]) + advertise_callback1, advertise_data1, advertise_settings1 = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback1, advertise_data1, advertise_settings1) + + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleSetScanFilterManufacturerData( + 117, [1, 2, 3], [127, 127, 127]) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cdbeeb8e-895e-4d11-9e42-7b89ff6917ce') + def test_scan_filter_device_address(self): + """Test scan filtering of a device address. + + This test will have to create two scanning instances. The first will + have no filters and will find the generic advertisement's mac address. + The second will have a filter of the found mac address. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a new scanner with scan filter with a mac address filter of + what was found in step 3. + 6. Start the scanner. + + Expected Result: + Verify that the advertisement was found in the second scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 1 + """ + test_result = True + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + expected_event_name = scan_result.format(scan_callback) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + try: + event_info = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + except Empty as error: + self.log.error("Could not find initial advertisement.") + return False + mac_address = event_info['data']['Result']['deviceInfo']['address'] + self.log.info( + "Filter advertisement with address {}".format(mac_address)) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + self.scn_ad.droid.bleSetScanFilterDeviceAddress(mac_address) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + + self.scn_ad.droid.bleBuildScanFilter(filter_list2) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + expected_event_name = scan_result.format(scan_callback2) + found_event = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + if (found_event['data']['Result']['deviceInfo']['address'] != + mac_address): + test_result = False + self.scn_ad.droid.bleStopBleScan(scan_callback2) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a4921d7b-cdd5-4d52-834c-f4bb85a9e2e8') + def test_filter_simulated_ibeacon(self): + """Test scan filtering of a simulated ibeacon. + + This test will setup one Android device as an ibeacon and + a second Android device will be used to test filtering of + the manufacturer data for 60 seconds. + + Steps: + 1. Start an advertisement with manufacturer id set to 0x004c + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a new scanner with scan filter with a mac address filter of + what was found in step 3. + 6. Start the scanner. + + Expected Result: + Verify that the advertisement was found in the second scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 1 + """ + manufacturer_id = 0x4c + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( + manufacturer_id, [0x01]) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + expected_event = adv_succ.format(advertise_callback) + try: + self.adv_ad.ed.pop_event(expected_event) + except Empty: + self.log.info("Failed to start advertisement.") + return False + + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + self.scn_ad.droid.bleSetScanFilterManufacturerData( + manufacturer_id, [0x01]) + filter_list = self.scn_ad.droid.bleGenFilterList() + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_filter = self.scn_ad.droid.bleBuildScanFilter(filter_list) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + # continuously scan for 60 seconds + scan_time = 60 + end_time = time.time() + scan_time + expected_event_name = scan_result.format(scan_callback) + event = None + while time.time() < end_time: + try: + event = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + found_manufacturer_id = json.loads( + event['data']['Result']['manufacturerIdList']) + if found_manufacturer_id[0] != manufacturer_id: + self.log.error( + "Manufacturer id mismatch. Found {}, Expected {}". + format(found_manufacturer_id, manufacturer_id)) + return False + except Empty: + self.log.error("Unable to find ibeacon advertisement.") + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a70a276d-7990-4754-8899-792b586ecce6') + def test_filter_manufacturer_id_bounds(self): + """Test scan filtering of lower and upper bounds of allowed manu data + + This test will setup one Android device as an advertiser and the + second as the scanner and test the upper and lower bounds of + manufacturer data filtering + + Steps: + 1. Start an advertisement with manufacturer id set to 0x004c + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a new scanner with scan filter with a mac address filter of + what was found in step 3. + 6. Start the scanner. + + Expected Result: + Verify that the advertisement was found in the second scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning + Priority: 1 + """ + manufacturer_id_list = [0, 1, 65534, 65535] + for manufacturer_id in manufacturer_id_list: + self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( + manufacturer_id, [0x01]) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + expected_event = adv_succ.format(advertise_callback) + try: + self.adv_ad.ed.pop_event(expected_event) + except Empty: + self.log.info("Failed to start advertisement.") + return False + + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + self.scn_ad.droid.bleSetScanFilterManufacturerData( + manufacturer_id, [0x01]) + filter_list = self.scn_ad.droid.bleGenFilterList() + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_filter = self.scn_ad.droid.bleBuildScanFilter(filter_list) + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + expected_event_name = scan_result.format(scan_callback) + event = None + try: + event = self.scn_ad.ed.pop_event(expected_event_name, + self.default_timeout) + except Empty: + self.log.error("Unable to find beacon advertisement.") + return False + found_manufacturer_id = json.loads( + event['data']['Result']['manufacturerIdList']) + if found_manufacturer_id[0] != manufacturer_id: + self.log.error( + "Manufacturer id mismatch. Found {}, Expected {}".format( + found_manufacturer_id, manufacturer_id)) + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return True diff --git a/acts/tests/google/ble/gatt/GattConnectTest.py b/acts/tests/google/ble/gatt/GattConnectTest.py new file mode 100644 index 0000000000..52f3601cd0 --- /dev/null +++ b/acts/tests/google/ble/gatt/GattConnectTest.py @@ -0,0 +1,1184 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different GATT connection tests. +""" + +import pprint +from queue import Empty +import time + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_match_nums +from acts.test_utils.bt.bt_constants import bt_profile_constants +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_service_types +from acts.test_utils.bt.bt_constants import gatt_cb_err +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.bt_constants import gatt_connection_state +from acts.test_utils.bt.bt_constants import gatt_mtu_size +from acts.test_utils.bt.bt_constants import gatt_phy_mask +from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError +from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection +from acts.test_utils.bt.bt_gatt_utils import wait_for_gatt_disconnect_event +from acts.test_utils.bt.bt_gatt_utils import close_gatt_client +from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids +from acts.test_utils.bt.bt_gatt_utils import orchestrate_gatt_connection +from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection +from acts.test_utils.bt.bt_gatt_utils import setup_multiple_services +from acts.test_utils.bt.bt_test_utils import get_mac_address_of_generic_advertisement +from acts.test_utils.bt.bt_test_utils import clear_bonded_devices + +PHYSICAL_DISCONNECT_TIMEOUT = 5 + + +class GattConnectTest(BluetoothBaseTest): + adv_instances = [] + bluetooth_gatt_list = [] + gatt_server_list = [] + default_timeout = 10 + default_discovery_timeout = 3 + + def setup_class(self): + super().setup_class() + self.cen_ad = self.android_devices[0] + self.per_ad = self.android_devices[1] + + def setup_test(self): + super(BluetoothBaseTest, self).setup_test() + bluetooth_gatt_list = [] + self.gatt_server_list = [] + self.adv_instances = [] + # Ensure there is ample time for a physical disconnect in between + # testcases. + self.log.info( + "Waiting for {} seconds for physical GATT disconnections".format( + PHYSICAL_DISCONNECT_TIMEOUT)) + time.sleep(PHYSICAL_DISCONNECT_TIMEOUT) + + def teardown_test(self): + for bluetooth_gatt in self.bluetooth_gatt_list: + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + for gatt_server in self.gatt_server_list: + self.per_ad.droid.gattServerClose(gatt_server) + for adv in self.adv_instances: + self.per_ad.droid.bleStopBleAdvertising(adv) + return True + + def _orchestrate_gatt_disconnection(self, bluetooth_gatt, gatt_callback): + self.log.info("Disconnecting from peripheral device.") + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, + gatt_callback) + close_gatt_client(self.cen_ad, bluetooth_gatt) + if bluetooth_gatt in self.bluetooth_gatt_list: + self.bluetooth_gatt_list.remove(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + return True + + def _find_service_added_event(self, gatt_server_cb, uuid): + expected_event = gatt_cb_strings['serv_added'].format(gatt_server_cb) + try: + event = self.per_ad.ed.pop_event(expected_event, + self.default_timeout) + except Empty: + self.log.error( + gatt_cb_strings['serv_added_err'].format(expected_event)) + return False + if event['data']['serviceUuid'].lower() != uuid.lower(): + self.log.error("Uuid mismatch. Found: {}, Expected {}.".format( + event['data']['serviceUuid'], uuid)) + return False + return True + + def _verify_mtu_changed_on_client_and_server( + self, expected_mtu, gatt_callback, gatt_server_callback): + expected_event = gatt_cb_strings['mtu_changed'].format(gatt_callback) + try: + mtu_event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + mtu_size_found = mtu_event['data']['MTU'] + if mtu_size_found != expected_mtu: + self.log.error("MTU size found: {}, expected: {}".format( + mtu_size_found, expected_mtu)) + return False + except Empty: + self.log.error( + gatt_cb_err['mtu_changed_err'].format(expected_event)) + return False + + expected_event = gatt_cb_strings['mtu_serv_changed'].format( + gatt_server_callback) + try: + mtu_event = self.per_ad.ed.pop_event(expected_event, + self.default_timeout) + mtu_size_found = mtu_event['data']['MTU'] + if mtu_size_found != expected_mtu: + self.log.error("MTU size found: {}, expected: {}".format( + mtu_size_found, expected_mtu)) + return False + except Empty: + self.log.error( + gatt_cb_err['mtu_serv_changed_err'].format(expected_event)) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8a3530a3-c8bb-466b-9710-99e694c38618') + def test_gatt_connect(self): + """Test GATT connection over LE. + + Test establishing a gatt connection between a GATT server and GATT + client. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and then disconnected + successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a839b505-03ac-4783-be7e-1d43129a1948') + def test_gatt_connect_stop_advertising(self): + """Test GATT connection over LE then stop advertising + + A test case that verifies the GATT connection doesn't + disconnect when LE advertisement is stopped. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. Stop the advertiser. + 7. Verify no connection state changed happened. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and not disconnected + when advertisement stops. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.per_ad.droid.bleStopBleAdvertising(adv_callback) + try: + event = self.cen_ad.ed.pop_event( + gatt_cb_strings['gatt_conn_change'].format( + gatt_callback, self.default_timeout)) + self.log.error( + "Connection event found when not expected: {}".format(event)) + return False + except Empty: + self.log.info("No connection state change as expected") + try: + self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) + except Exception as err: + self.log.info("Failed to orchestrate disconnect: {}".format(err)) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b82f91a8-54bb-4779-a117-73dc7fdb28cc') + def test_gatt_connect_autoconnect(self): + """Test GATT connection over LE. + + Test re-establishing a gatt connection using autoconnect + set to True in order to test connection whitelist. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. Disconnect the GATT connection. + 7. Create a GATT connection with autoconnect set to True + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was re-established and then disconnected + successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + autoconnect = False + mac_address, adv_callback, scan_callback = ( + get_mac_address_of_generic_advertisement(self.cen_ad, self.per_ad)) + self.adv_instances.append(adv_callback) + try: + bluetooth_gatt, gatt_callback = setup_gatt_connection( + self.cen_ad, mac_address, autoconnect) + self.cen_ad.droid.bleStopBleScan(scan_callback) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, + gatt_callback) + close_gatt_client(self.cen_ad, bluetooth_gatt) + if bluetooth_gatt in self.bluetooth_gatt_list: + self.bluetooth_gatt_list.remove(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + autoconnect = True + bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( + gatt_callback, mac_address, autoconnect, gatt_transport['auto'], + False, gatt_phy_mask['1m_mask']) + self.bluetooth_gatt_list.append(bluetooth_gatt) + expected_event = gatt_cb_strings['gatt_conn_change'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + except Empty: + self.log.error( + gatt_cb_err['gatt_conn_changed_err'].format(expected_event)) + test_result = False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e506fa50-7cd9-4bd8-938a-6b85dcfe6bc6') + def test_gatt_connect_opportunistic(self): + """Test opportunistic GATT connection over LE. + + Test establishing a gatt connection between a GATT server and GATT + client in opportunistic mode. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create GATT connection 1 between the scanner and advertiser normally + 6. Create GATT connection 2 between the scanner and advertiser using + opportunistic mode + 7. Disconnect GATT connection 1 + + Expected Result: + Verify GATT connection 2 automatically disconnects when GATT connection + 1 disconnect + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + mac_address, adv_callback, scan_callback = ( + get_mac_address_of_generic_advertisement(self.cen_ad, self.per_ad)) + # Make GATT connection 1 + try: + bluetooth_gatt_1, gatt_callback_1 = setup_gatt_connection( + self.cen_ad, + mac_address, + False, + transport=gatt_transport['auto'], + opportunistic=False) + self.cen_ad.droid.bleStopBleScan(scan_callback) + self.adv_instances.append(adv_callback) + self.bluetooth_gatt_list.append(bluetooth_gatt_1) + except GattTestUtilsError as err: + self.log.error(err) + return False + # Make GATT connection 2 + try: + bluetooth_gatt_2, gatt_callback_2 = setup_gatt_connection( + self.cen_ad, + mac_address, + False, + transport=gatt_transport['auto'], + opportunistic=True) + self.bluetooth_gatt_list.append(bluetooth_gatt_2) + except GattTestUtilsError as err: + self.log.error(err) + return False + # Disconnect GATT connection 1 + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt_1, + gatt_callback_1) + close_gatt_client(self.cen_ad, bluetooth_gatt_1) + if bluetooth_gatt_1 in self.bluetooth_gatt_list: + self.bluetooth_gatt_list.remove(bluetooth_gatt_1) + except GattTestUtilsError as err: + self.log.error(err) + return False + # Confirm that GATT connection 2 also disconnects + wait_for_gatt_disconnect_event(self.cen_ad, gatt_callback_2) + close_gatt_client(self.cen_ad, bluetooth_gatt_2) + if bluetooth_gatt_2 in self.bluetooth_gatt_list: + self.bluetooth_gatt_list.remove(bluetooth_gatt_2) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='1e01838e-c4de-4720-9adf-9e0419378226') + def test_gatt_request_min_mtu(self): + """Test GATT connection over LE and exercise MTU sizes. + + Test establishing a gatt connection between a GATT server and GATT + client. Request an MTU size that matches the correct minimum size. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (client) request MTU size change to the + minimum value. + 7. Find the MTU changed event on the client. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and the MTU value found + matches the expected MTU value. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + expected_mtu = gatt_mtu_size['min'] + self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) + if not self._verify_mtu_changed_on_client_and_server( + expected_mtu, gatt_callback, gatt_server_cb): + return False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c1fa3a2d-fb47-47db-bdd1-458928cd6a5f') + def test_gatt_request_max_mtu(self): + """Test GATT connection over LE and exercise MTU sizes. + + Test establishing a gatt connection between a GATT server and GATT + client. Request an MTU size that matches the correct maximum size. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (client) request MTU size change to the + maximum value. + 7. Find the MTU changed event on the client. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and the MTU value found + matches the expected MTU value. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + expected_mtu = gatt_mtu_size['max'] + self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) + if not self._verify_mtu_changed_on_client_and_server( + expected_mtu, gatt_callback, gatt_server_cb): + return False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4416d483-dec3-46cb-8038-4d82620f873a') + def test_gatt_request_out_of_bounds_mtu(self): + """Test GATT connection over LE and exercise an out of bound MTU size. + + Test establishing a gatt connection between a GATT server and GATT + client. Request an MTU size that is the MIN value minus 1. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (client) request MTU size change to the + minimum value minus one. + 7. Find the MTU changed event on the client. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that an MTU changed event was not discovered and that + it didn't cause an exception when requesting an out of bounds + MTU. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU + Priority: 0 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + unexpected_mtu = gatt_mtu_size['min'] - 1 + self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, unexpected_mtu) + if self._verify_mtu_changed_on_client_and_server( + unexpected_mtu, gatt_callback, gatt_server_cb): + return False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='31ffb9ca-cc75-43fb-9802-c19f1c5856b6') + def test_gatt_connect_trigger_on_read_rssi(self): + """Test GATT connection over LE read RSSI. + + Test establishing a gatt connection between a GATT server and GATT + client then read the RSSI. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner, request to read the RSSI of the advertiser. + 7. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and then disconnected + successfully. Verify that the RSSI was ready correctly. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, RSSI + Priority: 1 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + expected_event = gatt_cb_strings['rd_remote_rssi'].format( + gatt_callback) + if self.cen_ad.droid.gattClientReadRSSI(bluetooth_gatt): + try: + self.cen_ad.ed.pop_event(expected_event, self.default_timeout) + except Empty: + self.log.error( + gatt_cb_err['rd_remote_rssi_err'].format(expected_event)) + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='dee9ef28-b872-428a-821b-cc62f27ba936') + def test_gatt_connect_trigger_on_services_discovered(self): + """Test GATT connection and discover services of peripheral. + + Test establishing a gatt connection between a GATT server and GATT + client the discover all services from the connected device. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (central device), discover services. + 7. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and then disconnected + successfully. Verify that the service were discovered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, Services + Priority: 1 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='01883bdd-0cf8-48fb-bf15-467bbd4f065b') + def test_gatt_connect_trigger_on_services_discovered_iterate_attributes( + self): + """Test GATT connection and iterate peripherals attributes. + + Test establishing a gatt connection between a GATT server and GATT + client and iterate over all the characteristics and descriptors of the + discovered services. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (central device), discover services. + 7. Iterate over all the characteristics and descriptors of the + discovered features. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and then disconnected + successfully. Verify that the services, characteristics, and descriptors + were discovered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, Services + Characteristics, Descriptors + Priority: 1 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + discovered_services_index = event['data']['ServicesIndex'] + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + log_gatt_server_uuids(self.cen_ad, discovered_services_index) + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='d4277bee-da99-4f48-8a4d-f81b5389da18') + def test_gatt_connect_with_service_uuid_variations(self): + """Test GATT connection with multiple service uuids. + + Test establishing a gatt connection between a GATT server and GATT + client with multiple service uuid variations. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. From the scanner (central device), discover services. + 7. Verify that all the service uuid variations are found. + 8. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established and then disconnected + successfully. Verify that the service uuid variations are found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, Services + Priority: 2 + """ + try: + gatt_server_cb, gatt_server = setup_multiple_services(self.per_ad) + self.gatt_server_list.append(gatt_server) + except GattTestUtilsError as err: + self.log.error(err) + return False + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.adv_instances.append(adv_callback) + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + discovered_services_index = event['data']['ServicesIndex'] + log_gatt_server_uuids(self.cen_ad, discovered_services_index) + + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7d3442c5-f71f-44ae-bd35-f2569f01b3b8') + def test_gatt_connect_in_quick_succession(self): + """Test GATT connections multiple times. + + Test establishing a gatt connection between a GATT server and GATT + client with multiple iterations. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 6. Disconnect the GATT connection. + 7. Repeat steps 5 and 6 twenty times. + + Expected Result: + Verify that a connection was established and then disconnected + successfully twenty times. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, Stress + Priority: 1 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + mac_address, adv_callback, scan_callback = get_mac_address_of_generic_advertisement( + self.cen_ad, self.per_ad) + autoconnect = False + for i in range(1000): + self.log.info("Starting connection iteration {}".format(i + 1)) + try: + bluetooth_gatt, gatt_callback = setup_gatt_connection( + self.cen_ad, mac_address, autoconnect) + self.cen_ad.droid.bleStopBleScan(scan_callback) + except GattTestUtilsError as err: + self.log.error(err) + return False + test_result = self._orchestrate_gatt_disconnection( + bluetooth_gatt, gatt_callback) + if not test_result: + self.log.info("Failed to disconnect from peripheral device.") + return False + self.adv_instances.append(adv_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='148469d9-7ab0-4c08-b2e9-7e49e88da1fc') + def test_gatt_connect_mitm_attack(self): + """Test GATT connection with permission write encrypted mitm. + + Test establishing a gatt connection between a GATT server and GATT + client while the GATT server's characteristic includes the property + write value and the permission write encrypted mitm value. This will + prompt LE pairing and then the devices will create a bond. + + Steps: + 1. Create a GATT server and server callback on the peripheral device. + 2. Create a unique service and characteristic uuid on the peripheral. + 3. Create a characteristic on the peripheral with these properties: + gatt_characteristic['property_write'], + gatt_characteristic['permission_write_encrypted_mitm'] + 4. Create a GATT service on the peripheral. + 5. Add the characteristic to the GATT service. + 6. Create a GATT connection between your central and peripheral device. + 7. From the central device, discover the peripheral's services. + 8. Iterate the services found until you find the unique characteristic + created in step 3. + 9. Once found, write a random but valid value to the characteristic. + 10. Start pairing helpers on both devices immediately after attempting + to write to the characteristic. + 11. Within 10 seconds of writing the characteristic, there should be + a prompt to bond the device from the peripheral. The helpers will + handle the UI interaction automatically. (see + BluetoothConnectionFacade.java bluetoothStartPairingHelper). + 12. Verify that the two devices are bonded. + + Expected Result: + Verify that a connection was established and the devices are bonded. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, GATT, Characteristic, MITM + Priority: 1 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + service_uuid = "3846D7A0-69C8-11E4-BA00-0002A5D5C51B" + test_uuid = "aa7edd5a-4d1d-4f0e-883a-d145616a1630" + bonded = False + characteristic = self.per_ad.droid.gattServerCreateBluetoothGattCharacteristic( + test_uuid, gatt_characteristic['property_write'], + gatt_characteristic['permission_write_encrypted_mitm']) + gatt_service = self.per_ad.droid.gattServerCreateService( + service_uuid, gatt_service_types['primary']) + self.per_ad.droid.gattServerAddCharacteristicToService( + gatt_service, characteristic) + self.per_ad.droid.gattServerAddService(gatt_server, gatt_service) + result = self._find_service_added_event(gatt_server_cb, service_uuid) + if not result: + return False + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + self.adv_instances.append(adv_callback) + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + discovered_services_index = event['data']['ServicesIndex'] + else: + self.log.info("Failed to discover services.") + return False + test_value = [1, 2, 3, 4, 5, 6, 7] + services_count = self.cen_ad.droid.gattClientGetDiscoveredServicesCount( + discovered_services_index) + for i in range(services_count): + characteristic_uuids = ( + self.cen_ad.droid.gattClientGetDiscoveredCharacteristicUuids( + discovered_services_index, i)) + for characteristic_uuid in characteristic_uuids: + if characteristic_uuid == test_uuid: + self.cen_ad.droid.bluetoothStartPairingHelper() + self.per_ad.droid.bluetoothStartPairingHelper() + self.cen_ad.droid.gattClientCharacteristicSetValue( + bluetooth_gatt, discovered_services_index, i, + characteristic_uuid, test_value) + self.cen_ad.droid.gattClientWriteCharacteristic( + bluetooth_gatt, discovered_services_index, i, + characteristic_uuid) + start_time = time.time() + self.default_timeout + target_name = self.per_ad.droid.bluetoothGetLocalName() + while time.time() < start_time and bonded == False: + bonded_devices = \ + self.cen_ad.droid.bluetoothGetBondedDevices() + for device in bonded_devices: + if ('name' in device.keys() + and device['name'] == target_name): + bonded = True + break + bonded = False + target_name = self.cen_ad.droid.bluetoothGetLocalName() + while time.time() < start_time and bonded == False: + bonded_devices = \ + self.per_ad.droid.bluetoothGetBondedDevices() + for device in bonded_devices: + if ('name' in device.keys() + and device['name'] == target_name): + bonded = True + break + + # Dual mode devices will establish connection over the classic transport, + # in order to establish bond over both transports, and do SDP. Starting + # disconnection before all this is finished is not safe, might lead to + # race conditions, i.e. bond over classic tranport shows up after LE + # bond is already removed. + time.sleep(4) + + for ad in [self.cen_ad, self.per_ad]: + if not clear_bonded_devices(ad): + return False + + # Necessary sleep time for entries to update unbonded state + time.sleep(2) + + for ad in [self.cen_ad, self.per_ad]: + bonded_devices = ad.droid.bluetoothGetBondedDevices() + if len(bonded_devices) > 0: + self.log.error( + "Failed to unbond devices: {}".format(bonded_devices)) + return False + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cc3fc361-7bf1-4ee2-9e46-4a27c88ce6a8') + def test_gatt_connect_get_connected_devices(self): + """Test GATT connections show up in getConnectedDevices + + Test establishing a gatt connection between a GATT server and GATT + client. Verify that active connections show up using + BluetoothManager.getConnectedDevices API. + + Steps: + 1. Start a generic advertisement. + 2. Start a generic scanner. + 3. Find the advertisement and extract the mac address. + 4. Stop the first scanner. + 5. Create a GATT connection between the scanner and advertiser. + 7. Verify the GATT Client has an open connection to the GATT Server. + 8. Verify the GATT Server has an open connection to the GATT Client. + 9. Disconnect the GATT connection. + + Expected Result: + Verify that a connection was established, connected devices are found + on both the central and peripheral devices, and then disconnected + successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, GATT + Priority: 2 + """ + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + self.gatt_server_list.append(gatt_server) + try: + bluetooth_gatt, gatt_callback, adv_callback = ( + orchestrate_gatt_connection(self.cen_ad, self.per_ad)) + self.bluetooth_gatt_list.append(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + conn_cen_devices = self.cen_ad.droid.bluetoothGetConnectedLeDevices( + bt_profile_constants['gatt']) + conn_per_devices = self.per_ad.droid.bluetoothGetConnectedLeDevices( + bt_profile_constants['gatt_server']) + target_name = self.per_ad.droid.bluetoothGetLocalName() + error_message = ("Connected device {} not found in list of connected " + "devices {}") + if not any(d['name'] == target_name for d in conn_cen_devices): + self.log.error(error_message.format(target_name, conn_cen_devices)) + return False + # For the GATT server only check the size of the list since + # it may or may not include the device name. + target_name = self.cen_ad.droid.bluetoothGetLocalName() + if not conn_per_devices: + self.log.error(error_message.format(target_name, conn_per_devices)) + return False + self.adv_instances.append(adv_callback) + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='a0a37ca6-9fa8-4d35-9fdb-0e25b4b8a363') + def test_gatt_connect_second_adv_after_canceling_first_adv(self): + """Test GATT connection to peripherals second advertising address. + + The the ability of cancelling GATT connections and trying to reconnect + to the same device via a different address. + + Steps: + 1. A starts advertising + 2. B starts scanning and finds A's mac address + 3. Stop advertisement from step 1. Start a new advertisement on A and + find the new new mac address, B knows of both old and new address. + 4. B1 sends connect request to old address of A + 5. B1 cancel connect attempt after 10 seconds + 6. B1 sends connect request to new address of A + 7. Verify B1 establish connection to A in less than 10 seconds + + Expected Result: + Verify that a connection was established only on the second + advertisement's mac address. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, GATT + Priority: 3 + """ + autoconnect = False + transport = gatt_transport['auto'] + opportunistic = False + # Setup a basic Gatt server on the peripheral + gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() + gatt_server = self.per_ad.droid.gattServerOpenGattServer( + gatt_server_cb) + + # Set advertisement settings to include local name in advertisement + # and set the advertising mode to low_latency. + self.per_ad.droid.bleSetAdvertiseSettingsIsConnectable(True) + self.per_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.per_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + + # Setup necessary advertisement objects. + advertise_data = self.per_ad.droid.bleBuildAdvertiseData() + advertise_settings = self.per_ad.droid.bleBuildAdvertiseSettings() + advertise_callback = self.per_ad.droid.bleGenBleAdvertiseCallback() + + # Step 1: Start advertisement + self.per_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + + # Setup scan settings for low_latency scanning and to include the local name + # of the advertisement started in step 1. + filter_list = self.cen_ad.droid.bleGenFilterList() + self.cen_ad.droid.bleSetScanSettingsNumOfMatches( + ble_scan_settings_match_nums['one']) + self.cen_ad.droid.bleSetScanFilterDeviceName( + self.per_ad.droid.bluetoothGetLocalName()) + self.cen_ad.droid.bleBuildScanFilter(filter_list) + self.cen_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + + # Setup necessary scan objects. + scan_settings = self.cen_ad.droid.bleBuildScanSetting() + scan_callback = self.cen_ad.droid.bleGenScanCallback() + + # Step 2: Start scanning on central Android device and find peripheral + # address. + self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + expected_event_name = scan_result.format(scan_callback) + try: + mac_address_pre_restart = self.cen_ad.ed.pop_event( + expected_event_name, self.default_timeout)['data']['Result'][ + 'deviceInfo']['address'] + self.log.info( + "Peripheral advertisement found with mac address: {}".format( + mac_address_pre_restart)) + except Empty: + self.log.info("Peripheral advertisement not found") + test_result = False + + # Step 3: Restart peripheral advertising such that a new mac address is + # created. + self.per_ad.droid.bleStopBleAdvertising(advertise_callback) + self.per_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + + mac_address_post_restart = mac_address_pre_restart + + while True: + try: + mac_address_post_restart = self.cen_ad.ed.pop_event( + expected_event_name, self.default_timeout)['data']['Result'][ + 'deviceInfo']['address'] + self.log.info( + "Peripheral advertisement found with mac address: {}".format( + mac_address_post_restart)) + except Empty: + self.log.info("Peripheral advertisement not found") + test_result = False + + if mac_address_pre_restart != mac_address_post_restart: + break + + self.cen_ad.droid.bleStopBleScan(scan_callback) + + # Steps 4: Try to connect to the first mac address + gatt_callback = self.cen_ad.droid.gattCreateGattCallback() + self.log.info( + "Gatt Connect to mac address {}.".format(mac_address_pre_restart)) + bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( + gatt_callback, mac_address_pre_restart, autoconnect, transport, + opportunistic, gatt_phy_mask['1m_mask']) + self.bluetooth_gatt_list.append(bluetooth_gatt) + expected_event = gatt_cb_strings['gatt_conn_change'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + self.log.error( + "Connection callback updated unexpectedly: {}".format(event)) + return False + except Empty: + self.log.info("No connection update as expected.") + + # Step 5: Cancel connection request. + self.cen_ad.droid.gattClientDisconnect(bluetooth_gatt) + close_gatt_client(self.cen_ad, bluetooth_gatt) + if bluetooth_gatt in self.bluetooth_gatt_list: + self.bluetooth_gatt_list.remove(bluetooth_gatt) + + # Step 6: Connect to second mac address. + gatt_callback = self.cen_ad.droid.gattCreateGattCallback() + self.log.info( + "Gatt Connect to mac address {}.".format(mac_address_post_restart)) + bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( + gatt_callback, mac_address_post_restart, autoconnect, transport, + opportunistic, gatt_phy_mask['1m_mask']) + self.bluetooth_gatt_list.append(bluetooth_gatt) + expected_event = gatt_cb_strings['gatt_conn_change'].format( + gatt_callback) + + # Step 7: Verify connection was setup successfully. + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.default_timeout) + self.log.info( + "Connection callback updated successfully: {}".format(event)) + if event['data']['State'] != gatt_connection_state['connected']: + self.log.error( + "Could not establish a connection to the peripheral.") + return False + except Empty: + self.log.error("No connection update was found.") + return False + + self.per_ad.droid.bleStopBleAdvertising(advertise_callback) + + return self._orchestrate_gatt_disconnection(bluetooth_gatt, + gatt_callback) diff --git a/acts/tests/google/ble/gatt/GattNotifyTest.py b/acts/tests/google/ble/gatt/GattNotifyTest.py new file mode 100644 index 0000000000..7d62d65349 --- /dev/null +++ b/acts/tests/google/ble/gatt/GattNotifyTest.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises GATT notify/indicate procedures. +""" + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_event +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids +from math import ceil + + +class GattNotifyTest(GattConnectedBaseTest): + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='e0ba60af-c1f2-4516-a5d5-89e2def0c757') + def test_notify_char(self): + """Test notify characteristic value. + + Test GATT notify characteristic value. + + Steps: + 1. Central: write CCC - register for notifications. + 2. Peripheral: receive CCC modification. + 3. Peripheral: send characteristic notification. + 4. Central: receive notification, verify it's conent matches what was + sent + + Expected Result: + Verify that notification registration and delivery works. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + #write CCC descriptor to enable notifications + self.cen_ad.droid.gattClientDescriptorSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.NOTIFIABLE_CHAR_UUID, + gatt_char_desc_uuids['client_char_cfg'], + gatt_descriptor['enable_notification_value']) + + self.cen_ad.droid.gattClientWriteDescriptor( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.NOTIFIABLE_CHAR_UUID, + gatt_char_desc_uuids['client_char_cfg']) + + #enable notifications in app + self.cen_ad.droid.gattClientSetCharacteristicNotification( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.NOTIFIABLE_CHAR_UUID, True) + + event = self._server_wait(gatt_event['desc_write_req']) + + request_id = event['data']['requestId'] + bt_device_id = 0 + status = 0 + #confirm notification registration was successful + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, 0, []) + #wait for client to get response + event = self._client_wait(gatt_event['desc_write']) + + #set notified value + notified_value = [1, 5, 9, 7, 5, 3, 6, 4, 8, 2] + self.per_ad.droid.gattServerCharacteristicSetValue( + self.notifiable_char_index, notified_value) + + #send notification + self.per_ad.droid.gattServerNotifyCharacteristicChanged( + self.gatt_server, bt_device_id, self.notifiable_char_index, False) + + #wait for client to receive the notification + event = self._client_wait(gatt_event['char_change']) + self.assertEqual(notified_value, event["data"]["CharacteristicValue"]) + + return True diff --git a/acts/tests/google/ble/gatt/GattReadTest.py b/acts/tests/google/ble/gatt/GattReadTest.py new file mode 100644 index 0000000000..e880757586 --- /dev/null +++ b/acts/tests/google/ble/gatt/GattReadTest.py @@ -0,0 +1,198 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different GATT read procedures. +""" + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_event +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from math import ceil + + +class GattReadTest(GattConnectedBaseTest): + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ed8523f4-0eb8-4d14-b558-d3c28902f8bb') + def test_read_char(self): + """Test read characteristic value. + + Test GATT read characteristic value. + + Steps: + 1. Central: send read request. + 2. Peripheral: receive read request . + 3. Peripheral: send read response with status 0 (success), and + characteristic value. + 4. Central: receive read response, verify it's conent matches what was + sent + + Expected Result: + Verify that read request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + self.cen_ad.droid.gattClientReadCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.READABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_read_req']) + + request_id = event['data']['requestId'] + self.assertEqual(0, event['data']['offset'], "offset should be 0") + + bt_device_id = 0 + status = 0 + char_value = [1, 2, 3, 4, 5, 6, 7, 20] + offset = 0 + self.per_ad.droid.gattServerSendResponse(self.gatt_server, + bt_device_id, request_id, + status, offset, char_value) + + event = self._client_wait(gatt_event['char_read']) + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + self.assertEqual(char_value, event["data"]["CharacteristicValue"], + "Read value shall be equal to value sent from server") + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5916a78d-3db8-4df2-9b96-b25e99096e0d') + def test_read_long_char(self): + """Test read long characteristic value. + + Test GATT read long characteristic value. + + Steps: + 1. Central: send read request. + 2. Peripheral: receive read request . + 3. Peripheral: send read response with status 0 (success), and + characteristic content. + 5. Central: stack receives read response that was full, so stack sends + read blob request with increased offset. + 6. Peripheral: receive read blob request, send read blob response with + next piece of characteristic value. + 7. Central: stack receives read blob response, so stack sends read blob + request with increased offset. No Java callbacks are called here + 8. Repeat steps 6 and 7 until whole characteristic is read. + 9. Central: verify onCharacteristicRead callback is called with whole + characteristic content. + + Expected Result: + Verify that read request/response is properly delivered, and that read + blob reqest/response is properly sent internally by the stack. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + char_value = [] + for i in range(512): + char_value.append(i % 256) + + self.cen_ad.droid.gattClientReadCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.READABLE_CHAR_UUID) + + # characteristic value is divided into packets, each contains MTU-1 + # bytes. Compute number of packets we expect to receive. + num_packets = ceil((len(char_value) + 1) / (self.mtu - 1)) + + for i in range(num_packets): + startOffset = i * (self.mtu - 1) + + event = self._server_wait(gatt_event['char_read_req']) + + request_id = event['data']['requestId'] + self.assertEqual(startOffset, event['data']['offset'], + "offset should be 0") + + bt_device_id = 0 + status = 0 + offset = 0 + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, offset, + char_value[startOffset:startOffset + self.mtu - 1]) + + event = self._client_wait(gatt_event['char_read']) + + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + self.assertEqual(char_value, event["data"]["CharacteristicValue"], + "Read value shall be equal to value sent from server") + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='12498522-cac5-478b-a0cd-faa542832fa8') + def test_read_using_char_uuid(self): + """Test read using characteristic UUID. + + Test GATT read value using characteristic UUID. + + Steps: + 1. Central: send read by UUID request. + 2. Peripheral: receive read request . + 3. Peripheral: send read response with status 0 (success), and + characteristic value. + 4. Central: receive read response, verify it's conent matches what was + sent + + Expected Result: + Verify that read request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + self.cen_ad.droid.gattClientReadUsingCharacteristicUuid( + self.bluetooth_gatt, self.READABLE_CHAR_UUID, 0x0001, 0xFFFF) + + event = self._server_wait(gatt_event['char_read_req']) + + request_id = event['data']['requestId'] + self.assertEqual(0, event['data']['offset'], "offset should be 0") + + bt_device_id = 0 + status = 0 + char_value = [1, 2, 3, 4, 5, 6, 7, 20] + offset = 0 + self.per_ad.droid.gattServerSendResponse(self.gatt_server, + bt_device_id, request_id, + status, offset, char_value) + + event = self._client_wait(gatt_event['char_read']) + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + self.assertEqual(char_value, event["data"]["CharacteristicValue"], + "Read value shall be equal to value sent from server") + + return True diff --git a/acts/tests/google/ble/gatt/GattToolTest.py b/acts/tests/google/ble/gatt/GattToolTest.py new file mode 100644 index 0000000000..8e7a9f0182 --- /dev/null +++ b/acts/tests/google/ble/gatt/GattToolTest.py @@ -0,0 +1,445 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script is for partial automation of LE devices + +This script requires these custom parameters in the config file: + +"ble_mac_address" +"service_uuid" +"notifiable_char_uuid" +""" + +import pprint +from queue import Empty +import time + +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import gatt_cb_err +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_transport +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError +from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection +from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids +from acts.test_utils.bt.bt_test_utils import reset_bluetooth + + +class GattToolTest(BluetoothBaseTest): + AUTOCONNECT = False + DEFAULT_TIMEOUT = 10 + PAIRING_TIMEOUT = 20 + adv_instances = [] + timer_list = [] + + def setup_class(self): + super().setup_class() + # Central role Android device + self.cen_ad = self.android_devices[0] + self.ble_mac_address = self.user_params['ble_mac_address'] + self.SERVICE_UUID = self.user_params['service_uuid'] + self.NOTIFIABLE_CHAR_UUID = self.user_params['notifiable_char_uuid'] + # CCC == Client Characteristic Configuration + self.CCC_DESC_UUID = "00002902-0000-1000-8000-00805f9b34fb" + + def setup_test(self): + super(BluetoothBaseTest, self).setup_test() + if not self._is_peripheral_advertising(): + input("Press enter when peripheral is advertising...") + return True + + def teardown_test(self): + super(BluetoothBaseTest, self).teardown_test() + self.log_stats() + self.timer_list = [] + return True + + def _pair_with_peripheral(self): + self.cen_ad.droid.bluetoothDiscoverAndBond(self.ble_mac_address) + end_time = time.time() + self.PAIRING_TIMEOUT + self.log.info("Verifying devices are bonded") + while time.time() < end_time: + bonded_devices = self.cen_ad.droid.bluetoothGetBondedDevices() + if self.ble_mac_address in {d['address'] for d in bonded_devices}: + self.log.info("Successfully bonded to device") + return True + return False + + def _is_peripheral_advertising(self): + self.cen_ad.droid.bleSetScanFilterDeviceAddress(self.ble_mac_address) + self.cen_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.cen_ad.droid) + self.cen_ad.droid.bleBuildScanFilter(filter_list) + + self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + expected_event_name = scan_result.format(scan_callback) + test_result = True + try: + self.cen_ad.ed.pop_event(expected_event_name, self.DEFAULT_TIMEOUT) + self.log.info( + "Peripheral found with event: {}".format(expected_event_name)) + except Empty: + self.log.info("Peripheral not advertising or not found: {}".format( + self.ble_mac_address)) + test_result = False + self.cen_ad.droid.bleStopBleScan(scan_callback) + return test_result + + def _unbond_device(self): + self.cen_ad.droid.bluetoothUnbond(self.ble_mac_address) + time.sleep(2) #Grace timeout for unbonding to finish + bonded_devices = self.cen_ad.droid.bluetoothGetBondedDevices() + if bonded_devices: + self.log.error( + "Failed to unbond device... found: {}".format(bonded_devices)) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + def test_gatt_connect_without_scanning(self): + """Test the round trip speed of connecting to a peripheral + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script will measure the amount + of time it takes to establish a GATT connection to the + peripheral. The test will then disconnect + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Start timer + 3. Perform GATT connection to peripheral + 4. Upon successful connection, stop timer + 5. Disconnect from peripheral + + Expected Result: + Device should be connected successfully + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 1 + """ + self.AUTOCONNECT = False + start_time = self._get_time_in_milliseconds() + try: + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + gatt_transport['le'])) + except GattTestUtilsError as err: + self.log.error(err) + return False + end_time = self._get_time_in_milliseconds() + self.log.info("Total time (ms): {}".format(end_time - start_time)) + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, + gatt_callback) + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + + @BluetoothBaseTest.bt_test_wrap + def test_gatt_connect_stress(self): + """Test the round trip speed of connecting to a peripheral many times + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script will measure the amount + of time it takes to establish a GATT connection to the + peripheral. The test will then disconnect. It will attempt to + repeat this process multiple times. + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Start timer + 3. Perform GATT connection to peripheral + 4. Upon successful connection, stop timer + 5. Disconnect from peripheral + 6. Repeat steps 2-5 1000 times. + + Expected Result: + Test should measure 1000 iterations of connect/disconnect cycles. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 2 + """ + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.cen_ad.droid) + self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.AUTOCONNECT = False + iterations = 1000 + n = 0 + while n < iterations: + self.start_timer() + try: + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + gatt_transport['le'])) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.log.info("Total time (ms): {}".format(self.end_timer())) + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, + gatt_callback) + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + n += 1 + return True + + @BluetoothBaseTest.bt_test_wrap + def test_gatt_connect_iterate_uuids(self): + """Test the discovery of uuids of a peripheral + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script connects an Android device + to the periphal and attempt to discover all services, + characteristics, and descriptors. + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Perform GATT connection to peripheral + 3. Upon successful connection, iterate through all services, + characteristics, and descriptors. + 5. Disconnect from peripheral + + Expected Result: + Device services, characteristics, and descriptors should all + be read. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 2 + """ + try: + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + gatt_transport['le'])) + except GattTestUtilsError as err: + self.log.error(err) + return False + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.DEFAULT_TIMEOUT) + discovered_services_index = event['data']['ServicesIndex'] + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + log_gatt_server_uuids(self.cen_ad, discovered_services_index) + try: + disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, + gatt_callback) + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + except GattTestUtilsError as err: + self.log.error(err) + return False + self.cen_ad.droid.gattClientClose(bluetooth_gatt) + return True + + @BluetoothBaseTest.bt_test_wrap + def test_pairing(self): + """Test pairing to a GATT mac address + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script will bond the Android device + to the peripheral. + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Perform Bluetooth pairing to GATT mac address + 3. Upon successful bonding. + 4. Unbond from device + + Expected Result: + Device services, characteristics, and descriptors should all + be read. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 1 + """ + if not self._pair_with_peripheral(): + return False + self.cen_ad.droid.bluetoothUnbond(self.ble_mac_address) + return self._unbond_device() + + @BluetoothBaseTest.bt_test_wrap + def test_pairing_stress(self): + """Test the round trip speed of pairing to a peripheral many times + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script will measure the amount + of time it takes to establish a pairing with a BLE device. + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Start timer + 3. Perform Bluetooth pairing to GATT mac address + 4. Upon successful bonding, stop timer. + 5. Unbond from device + 6. Repeat steps 2-5 100 times. + + Expected Result: + Test should measure 100 iterations of bonding. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 3 + """ + iterations = 100 + for _ in range(iterations): + start_time = self.start_timer() + if not self._pair_with_peripheral(): + return False + self.log.info("Total time (ms): {}".format(self.end_timer())) + if not self._unbond_device(): + return False + return True + + @BluetoothBaseTest.bt_test_wrap + def test_gatt_notification_longev(self): + """Test GATT characterisitic notifications for long periods of time + + This test will prompt the user to press "Enter" when the + peripheral is in a connecable advertisement state. Once + the user presses enter, this script aims to set characteristic + notification to true on the config file's SERVICE_UUID, + NOTIFIABLE_CHAR_UUID, and CCC_DESC_UUID. This test assumes + the peripheral will constantly write data to a notifiable + characteristic. + + Steps: + 1. Wait for user input to confirm peripheral is advertising. + 2. Perform Bluetooth pairing to GATT mac address + 3. Perform a GATT connection to the periheral + 4. Get the discovered service uuid that matches the user's input + in the config file + 4. Write to the CCC descriptor to enable notifications + 5. Enable notifications on the user's input Characteristic UUID + 6. Continuously wait for Characteristic Changed events which + equate to recieving notifications for 15 minutes. + + Expected Result: + There should be no disconnects and we should constantly receive + Characteristic Changed information. Values should vary upon user + interaction with the peripheral. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT + Priority: 1 + """ + #pair devices + if not self._pair_with_peripheral(): + return False + try: + bluetooth_gatt, gatt_callback = (setup_gatt_connection( + self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, + gatt_transport['le'])) + except GattTestUtilsError as err: + self.log.error(err) + return False + if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): + expected_event = gatt_cb_strings['gatt_serv_disc'].format( + gatt_callback) + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.DEFAULT_TIMEOUT) + discovered_services_index = event['data']['ServicesIndex'] + except Empty: + self.log.error( + gatt_cb_err['gatt_serv_disc'].format(expected_event)) + return False + # TODO: in setup save service_cound and discovered_services_index + # programatically + services_count = self.cen_ad.droid.gattClientGetDiscoveredServicesCount( + discovered_services_index) + test_service_index = None + for i in range(services_count): + disc_service_uuid = ( + self.cen_ad.droid.gattClientGetDiscoveredServiceUuid( + discovered_services_index, i)) + if disc_service_uuid == self.SERVICE_UUID: + test_service_index = i + break + if not test_service_index: + self.log.error("Service not found.") + return False + + self.cen_ad.droid.gattClientDescriptorSetValue( + bluetooth_gatt, discovered_services_index, test_service_index, + self.NOTIFIABLE_CHAR_UUID, self.CCC_DESC_UUID, + gatt_descriptor['enable_notification_value']) + + self.cen_ad.droid.gattClientWriteDescriptor( + bluetooth_gatt, discovered_services_index, test_service_index, + self.NOTIFIABLE_CHAR_UUID, self.CCC_DESC_UUID) + + self.cen_ad.droid.gattClientSetCharacteristicNotification( + bluetooth_gatt, discovered_services_index, test_service_index, + self.NOTIFIABLE_CHAR_UUID, True) + + # set 15 minute notification test time + notification_test_time = 900 + end_time = time.time() + notification_test_time + expected_event = gatt_cb_strings['char_change'].format(gatt_callback) + while time.time() < end_time: + try: + event = self.cen_ad.ed.pop_event(expected_event, + self.DEFAULT_TIMEOUT) + self.log.info(event) + except Empty as err: + print(err) + self.log.error( + gatt_cb_err['char_change_err'].format(expected_event)) + return False + return True diff --git a/acts/tests/google/ble/gatt/GattWriteTest.py b/acts/tests/google/ble/gatt/GattWriteTest.py new file mode 100644 index 0000000000..d245e9e36e --- /dev/null +++ b/acts/tests/google/ble/gatt/GattWriteTest.py @@ -0,0 +1,572 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different GATT write procedures. +""" + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_event +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.bt_constants import gatt_connection_priority +from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length +from acts.test_utils.bt.bt_constants import gatt_mtu_size +from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu + + +class GattWriteTest(GattConnectedBaseTest): + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='513f4cef-489e-4bb6-96cc-c298c589225c') + def test_write_char(self): + """Test write characteristic value + + Test write characteristic value using Write Request + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write request. + 2. Peripheral: receive the written data. + 3. Peripheral: send response with status 0 (success). + 4. Central: make sure write callback is called. + + Expected Result: + Verify that write request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + char_value = [1, 2, 3, 4, 5, 6, 7] + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_default']) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_write_req']) + + request_id = event['data']['requestId'] + self.assertEqual(True, event['data']['responseNeeded'], + "Should need response") + self.assertEqual(char_value, event['data']['value']) + self.assertEqual(0, event['data']['offset']) + + bt_device_id = 0 + status = 0 + #both offset and return value don't matter, just the status + offset = 0 + self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, offset, []) + + event = self._client_wait(gatt_event['char_write']) + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + # Write response doesn't carry any data expcept status + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='329dbef8-1b54-47e2-a388-b33ef9384464') + def test_write_descr(self): + """Test write descriptor value + + Test write descriptor value + + 1. Central: write WRITABLE_DESC_UUID descriptor with desc_value. + 2. Peripheral: receive the written data. + 3. Peripheral: send response with status 0 (success). + 4. Central: make sure write callback is called. + + Expected Result: + Verify that write request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Descriptor + Priority: 0 + """ + desc_value = [1, 2, 3, 4, 5, 6, 7] + self.cen_ad.droid.gattClientDescriptorSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + self.WRITABLE_DESC_UUID, desc_value) + + self.cen_ad.droid.gattClientWriteDescriptor( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + self.WRITABLE_DESC_UUID) + + event = self._server_wait(gatt_event['desc_write_req']) + + request_id = event['data']['requestId'] + self.assertEqual(True, event['data']['responseNeeded'], + "Should need response") + self.assertEqual(desc_value, event['data']['value']) + self.assertEqual(0, event['data']['offset']) + + bt_device_id = 0 + status = 0 + #both offset and return value don't matter, just the status + offset = 0 + self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, offset, []) + + event = self._client_wait(gatt_event['desc_write']) + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + # Write response doesn't carry any data except status + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='85757307-5bb1-43e5-9331-f1d7bdcbd6a0') + def test_write_char_no_resp(self): + """Test write characteristic value + + Test write characteristic value using Write Command + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write command. + 2. Central: make sure write callback is called. + 3. Peripheral: receive the written data. + + Expected Result: + Verify that write command is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + char_value = [1, 2, 3, 4, 5, 6, 7] + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_no_response']) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._client_wait(gatt_event['char_write']) + if event["data"]["Status"] != 0: + self.log.error("Write status should be 0") + return False + + event = self._server_wait(gatt_event['char_write_req']) + + request_id = event['data']['requestId'] + self.assertEqual(False, event['data']['responseNeeded'], + "Should not need response") + self.assertEqual(0, event['data']['offset']) + self.assertEqual(char_value, event['data']['value']) + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0bf0182a-c315-4160-81be-9ce09f93608b') + def test_write_characteristic_long_no_resp(self): + """Test write characteristic value + + Test write characteristic value using Write Command + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write command. + 2. Central: make sure write callback is called. + 3. Peripheral: receive the written data. Check it was properly trimmed. + + Expected Result: + Verify that write command is properly trimmed and delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + char_value = [] + for i in range(512): + char_value.append(i % 256) + + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_no_response']) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_write_req']) + + request_id = event['data']['requestId'] + self.assertEqual(False, event['data']['responseNeeded']) + + # value shall be trimmed to MTU-3 + trimmed_value = char_value[0:self.mtu - 3] + self.assertEqual( + trimmed_value, event['data']['value'], + "Received value should be sent value trimmed to MTU-3") + + event = self._client_wait(gatt_event['char_write']) + if event["data"]["Status"] != 0: + self.log.error("Write status should be 0") + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b80f1b5a-a223-441e-a6ed-d3c284c83cc7') + def test_write_characteristic_value_longer_than_mtu_request(self): + """Test writing characteristic value longer than what mtu limts + + Test establishing a gatt connection between a GATT Peripheral and GATT + Client. Request mtu size equal to the max MTU. + The max number of bytes can be sent within a characteristic is + (MTU - gatt_characteristic_attr_length['attr_2']) since + the gatt_characteristic_attr_length['attr_2'] (3 bytes) are + used for its attribute of the command code and its handle. + Then reduce mtu by 1 and re-send the same characteristic. + Make sure the characteristic value received by the remote side is + also reduced properly. + + Steps: + 1. Create a GATT connection between the scanner(Client) and + advertiser(Peripheral). + 2. Client: request new mtu size change to max MTU. + 3. Client: write a characteristic with char_value of max MTU bytes. + 4. Peripheral: receive the written data. Check it was properly + truncated to (max MTU - gatt_characteristic_attr_length['attr_2']). + 5. Client: request mtu size change to (max MTU - 1). + 6. Client: write the same characteristic again. + 7. Peripheral: receive the written data. Check it was properly + truncated to (max MTU - 1 - gatt_characteristic_attr_length['attr_2']) + 8. Client: return mtu size. + + Expected Result: + Verify that data received by the Peripheral side is properly truncated + when mtu is set. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic, MTU + Priority: 2 + """ + self.mtu = gatt_mtu_size['max'] + self.log.info("Set mtu to max MTU: {}".format(self.mtu)) + # set new MTU to the middle point of min and max of MTU + if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, + self.gatt_callback, self.mtu): + return False + + # create a characteristic with max MTU (217) bytes + char_value = [] + for i in range(gatt_mtu_size['max']): + char_value.append(i) + + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_no_response']) + + # write data to the characteristic of the Peripheral + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_write_req']) + self.log.info("Received value with mtu = max MTU: {}".format(event[ + 'data']['value'])) + + # check the data received by Peripheral shall be truncated to + # (mtu - gatt_characteristic_attr_length['attr_2']) bytes + data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] + expected_value = char_value[:data_length] + self.assertEqual( + expected_value, event['data']['value'], + "Received value should have {} bytes".format(data_length)) + + # set the mtu to max MTU-1 + self.mtu = gatt_mtu_size['max'] - 1 + self.log.info("Set mtu to max MTU - 1 : {}".format(self.mtu)) + data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] + if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, + self.gatt_callback, self.mtu): + return False + + # write the same characteric to Peripheral again + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_write_req']) + self.log.info("Data received when mtu = max MTU - 1: {}".format(event[ + 'data']['value'])) + + # check the data received by Peripheral shall be truncated to + # (mtu - gatt_characteristic_attr_length['attr_2']) bytes + # when mtu is reduced + expected_value = char_value[:data_length] + self.assertEqual( + expected_value, event['data']['value'], + "Received value should have {} bytes".format(data_length)) + + # return the mtu to default + self.mtu = gatt_mtu_size['min'] + self.log.info("Set mtu to min : {}".format(self.mtu)) + if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, + self.gatt_callback, self.mtu): + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='319eee6d-22d9-4498-bb15-21d0018e45e6') + def test_write_characteristic_stress(self): + """Stress test write characteristic value + + Test write characteristic value using Write Request + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write request. + 2. Peripheral: receive the written data. + 3. Peripheral: send response with status 0 (success). + 4. Central: make sure write callback is called. + 5. Repeat steps 1-4 100 times. + + Expected Result: + Verify that write request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, gatt_connection_priority['high']) + + bt_device_id = 0 + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_default']) + + for i in range(100): + + char_value = [] + for j in range(i, i + self.mtu - 3): + char_value.append(j % 256) + + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + event = self._server_wait(gatt_event['char_write_req']) + + self.log.info("{} event found: {}".format(gatt_cb_strings[ + 'char_write_req'].format(self.gatt_server_callback), event[ + 'data']['value'])) + request_id = event['data']['requestId'] + found_value = event['data']['value'] + if found_value != char_value: + self.log.info("Values didn't match. Found: {}, " + "Expected: {}".format(found_value, char_value)) + return False + + # only status is sent + status = 0 + offset = 0 + char_value_return = [] + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, offset, + char_value_return) + + event = self._client_wait(gatt_event['char_write']) + if event["data"]["Status"] != status: + self.log.error("Write status should be 0") + return False + + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='b19d42dc-58ba-4b20-b6c1-6628e7d21de4') + def test_write_descriptor_stress(self): + """Stress test write descriptor value + + Stress test write descriptor value + + 1. Central: write WRITABLE_DESC_UUID descriptor with desc_value. + 2. Peripheral: receive the written data. + 3. Peripheral: send response with status 0 (success). + 4. Central: make sure write callback is called. + 5. Repeat 1-4 100 times + + Expected Result: + Verify that write request/response is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Descriptor + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, gatt_connection_priority['high']) + + for i in range(100): + + desc_value = [] + for j in range(i, i + self.mtu - 3): + desc_value.append(j % 256) + + self.cen_ad.droid.gattClientDescriptorSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + self.WRITABLE_DESC_UUID, desc_value) + + self.cen_ad.droid.gattClientWriteDescriptor( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + self.WRITABLE_DESC_UUID) + + event = self._server_wait(gatt_event['desc_write_req']) + + self.log.info("{} event found: {}".format(gatt_cb_strings[ + 'char_write_req'].format(self.gatt_server_callback), event[ + 'data']['value'])) + + request_id = event['data']['requestId'] + self.assertEqual(True, event['data']['responseNeeded'], + "Should need response") + self.assertEqual(desc_value, event['data']['value']) + self.assertEqual(0, event['data']['offset']) + + bt_device_id = 0 + status = 0 + #both offset and return value don't matter, just the status + offset = 0 + self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) + self.per_ad.droid.gattServerSendResponse( + self.gatt_server, bt_device_id, request_id, status, offset, []) + + event = self._client_wait(gatt_event['desc_write']) + self.assertEqual(status, event["data"]["Status"], + "Write status should be 0") + # Write response doesn't carry any data except status + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='74c147eb-2702-4cd8-be1f-efff3e9eaa6c') + def test_write_characteristic_no_resp_stress(self): + """Stress test write characteristic value + + Stress test write characteristic value using Write Command + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write command. + 2. Central: make sure write callback is called. + 3. Peripheral: receive the written data. + 4. Repeat steps 1-3 100 times. + + Expected Result: + Verify that write command is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, gatt_connection_priority['high']) + + bt_device_id = 0 + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_no_response']) + + for i in range(100): + char_value = [] + for j in range(i, i + self.mtu - 3): + char_value.append(j % 256) + + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + # client shall not wait for server, get complete event right away + event = self._client_wait(gatt_event['char_write']) + if event["data"]["Status"] != 0: + self.log.error("Write status should be 0") + return False + + event = self._server_wait(gatt_event['char_write_req']) + + self.log.info("{} event found: {}".format(gatt_cb_strings[ + 'char_write_req'].format(self.gatt_server_callback), event[ + 'data']['value'])) + request_id = event['data']['requestId'] + found_value = event['data']['value'] + if found_value != char_value: + self.log.info("Values didn't match. Found: {}, " + "Expected: {}".format(found_value, char_value)) + return False + + return True diff --git a/acts/tests/google/ble/scan/BleBackgroundScanTest.py b/acts/tests/google/ble/scan/BleBackgroundScanTest.py new file mode 100644 index 0000000000..68396023b4 --- /dev/null +++ b/acts/tests/google/ble/scan/BleBackgroundScanTest.py @@ -0,0 +1,277 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises background scan test scenarios. +""" + +from queue import Empty + +from acts import utils +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import bluetooth_off +from acts.test_utils.bt.bt_test_utils import bluetooth_on +from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers +from acts.test_utils.bt.bt_test_utils import enable_bluetooth +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_constants import bluetooth_le_off +from acts.test_utils.bt.bt_constants import bluetooth_le_on +from acts.test_utils.bt.bt_constants import bt_adapter_states +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import scan_result + +import time + + +class BleBackgroundScanTest(BluetoothBaseTest): + default_timeout = 10 + report_delay = 2000 + scan_callbacks = [] + adv_callbacks = [] + active_scan_callback_list = [] + active_adv_callback_list = [] + + def setup_class(self): + super(BluetoothBaseTest, self).setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + utils.set_location_service(self.scn_ad, True) + utils.set_location_service(self.adv_ad, True) + return True + + def setup_test(self): + # Always start tests with Bluetooth enabled and BLE disabled. + enable_bluetooth(self.scn_ad.droid, self.scn_ad.ed) + self.scn_ad.droid.bluetoothDisableBLE() + for a in self.android_devices: + a.ed.clear_all_events() + return True + + def teardown_test(self): + cleanup_scanners_and_advertisers( + self.scn_ad, self.active_adv_callback_list, self.adv_ad, + self.active_adv_callback_list) + self.active_adv_callback_list = [] + self.active_scan_callback_list = [] + + def _setup_generic_advertisement(self): + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( + self.adv_ad.droid) + self.adv_ad.droid.bleStartBleAdvertising(adv_callback, adv_data, + adv_settings) + self.active_adv_callback_list.append(adv_callback) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4d13c3a8-1805-44ef-a92a-e385540767f1') + def test_background_scan(self): + """Test generic background scan. + + Tests LE background scan. The goal is to find scan results even though + Bluetooth is turned off. + + Steps: + 1. Setup an advertisement on dut1 + 2. Enable LE on the Bluetooth Adapter on dut0 + 3. Toggle BT off on dut1 + 4. Start a LE scan on dut0 + 5. Find the advertisement from dut1 + + Expected Result: + Find a advertisement from the scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Background Scanning + Priority: 0 + """ + self.scn_ad.droid.bluetoothEnableBLE() + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bluetoothToggleState(False) + try: + self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) + except Empty: + self.log.error("Bluetooth Off event not found. Expected {}".format( + bluetooth_off)) + return False + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + expected_event = scan_result.format(scan_callback) + try: + self.scn_ad.ed.pop_event(expected_event, self.default_timeout) + except Empty: + self.log.error("Scan Result event not found. Expected {}".format( + expected_event)) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9c4577f8-5e06-4034-b977-285956734974') + def test_background_scan_ble_disabled(self): + """Test background LE scanning with LE disabled. + + Tests LE background scan. The goal is to find scan results even though + Bluetooth is turned off. + + Steps: + 1. Setup an advertisement on dut1 + 2. Enable LE on the Bluetooth Adapter on dut0 + 3. Toggle BT off on dut1 + 4. Start a LE scan on dut0 + 5. Find the advertisement from dut1 + + Expected Result: + Find a advertisement from the scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Background Scanning + Priority: 0 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bluetoothEnableBLE() + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['low_latency']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bluetoothToggleState(False) + try: + self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) + except Empty: + self.log.info(self.scn_ad.droid.bluetoothCheckState()) + self.log.error("Bluetooth Off event not found. Expected {}".format( + bluetooth_off)) + return False + try: + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + expected_event = scan_result.format(scan_callback) + try: + self.scn_ad.ed.pop_event(expected_event, self.default_timeout) + except Empty: + self.log.error( + "Scan Result event not found. Expected {}".format( + expected_event)) + return False + except Exception: + self.log.info( + "Was not able to start a background scan as expected.") + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='0bdd1764-3dc6-4a82-b041-76e48ed0f424') + def test_airplane_mode_disables_ble(self): + """Try to start LE mode in Airplane Mode. + + This test will enable airplane mode, then attempt to start LE scanning + mode. This should result in bluetooth still being turned off, LE + not enabled. + + Steps: + 1. Start LE only mode. + 2. Bluetooth should be in LE ONLY mode + 2. Turn on airplane mode. + 3. Bluetooth should be OFF + 4. Try to start LE only mode. + 5. Bluetooth should stay in OFF mode (LE only start should fail) + 6. Turn off airplane mode. + 7. Bluetooth should be OFF. + + Expected Result: + No unexpected bluetooth state changes. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Airplane + Priority: 1 + """ + ble_state_error_msg = "Bluetooth LE State not OK {}. Expected {} got {}" + # Enable BLE always available (effectively enabling BT in location) + self.scn_ad.shell.enable_ble_scanning() + self.scn_ad.droid.bluetoothEnableBLE() + self.scn_ad.droid.bluetoothToggleState(False) + try: + self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) + except Empty: + self.log.error("Bluetooth Off event not found. Expected {}".format( + bluetooth_off)) + self.log.info(self.scn_ad.droid.bluetoothCheckState()) + return False + + # Sleep because LE turns off after the bluetooth off event fires + time.sleep(self.default_timeout) + state = self.scn_ad.droid.bluetoothGetLeState() + if state != bt_adapter_states['ble_on']: + self.log.error( + ble_state_error_msg.format("after BT Disable", + bt_adapter_states['ble_on'], state)) + return False + + self.scn_ad.droid.bluetoothListenForBleStateChange() + self.scn_ad.droid.connectivityToggleAirplaneMode(True) + try: + self.scn_ad.ed.pop_event(bluetooth_le_off, self.default_timeout) + except Empty: + self.log.error( + "Bluetooth LE Off event not found. Expected {}".format( + bluetooth_le_off)) + return False + state = self.scn_ad.droid.bluetoothGetLeState() + if state != bt_adapter_states['off']: + self.log.error( + ble_state_error_msg.format("after Airplane Mode ON", + bt_adapter_states['off'], state)) + return False + result = self.scn_ad.droid.bluetoothEnableBLE() + if result: + self.log.error( + "Bluetooth Enable command succeded when it should have failed (in airplane mode)" + ) + return False + state = self.scn_ad.droid.bluetoothGetLeState() + if state != bt_adapter_states['off']: + self.log.error( + "Bluetooth LE State not OK after attempted enable. Expected {} got {}". + format(bt_adapter_states['off'], state)) + return False + self.scn_ad.droid.connectivityToggleAirplaneMode(False) + # Sleep to let Airplane Mode disable propogate through the system + time.sleep(self.default_timeout) + state = self.scn_ad.droid.bluetoothGetLeState() + if state != bt_adapter_states['off']: + self.log.error( + ble_state_error_msg.format("after Airplane Mode OFF", + bt_adapter_states['off'], state)) + return False + return True diff --git a/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py b/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py new file mode 100644 index 0000000000..01f7976db4 --- /dev/null +++ b/acts/tests/google/ble/scan/BleOnLostOnFoundTest.py @@ -0,0 +1,292 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different onLost/onFound scenarios. +""" + +from queue import Empty +from acts import utils +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types +from acts.test_utils.bt.BleEnum import ScanSettingsMatchMode +from acts.test_utils.bt.BleEnum import ScanSettingsMatchNum +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_match_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_match_nums +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_result + + +class BleOnLostOnFoundTest(BluetoothBaseTest): + default_timeout = 10 + active_scan_callback_list = [] + active_adv_callback_list = [] + + def setup_class(self): + super(BluetoothBaseTest, self).setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + utils.set_location_service(self.scn_ad, True) + utils.set_location_service(self.adv_ad, True) + return True + + def teardown_test(self): + cleanup_scanners_and_advertisers( + self.scn_ad, self.active_adv_callback_list, self.adv_ad, + self.active_adv_callback_list) + self.active_adv_callback_list = [] + self.active_scan_callback_list = [] + + def on_exception(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + def _start_generic_advertisement_include_device_name(self): + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + advertise_data = self.adv_ad.droid.bleBuildAdvertiseData() + advertise_settings = self.adv_ad.droid.bleBuildAdvertiseSettings() + advertise_callback = self.adv_ad.droid.bleGenBleAdvertiseCallback() + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + self.adv_ad.ed.pop_event( + adv_succ.format(advertise_callback), self.default_timeout) + self.active_adv_callback_list.append(advertise_callback) + return advertise_callback + + def _verify_no_events_found(self, event_name): + try: + self.scn_ad.ed.pop_event(event_name, self.default_timeout) + self.log.error("Found an event when none was expected.") + return False + except Empty: + self.log.info("No scan result found as expected.") + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9bd7fd09-71c9-4623-90f0-9a895eb37409') + def test_onlost_onfound_defaults(self): + """Test generic onlost/onfound defaults. + + Tests basic onFound/onLost functionality. + + Steps: + 1. Setup dut0 scanner and start scan with this setup: + Scan Mode: SCAN_MODE_LOW_LATENCY + Callback Type: CALLBACK_TYPE_FOUND_AND_LOST + Match Mode: AGGRESSIVE + Num of Matches: MATCH_NUM_ONE_ADVERTISEMENT + Filter: Device name of dut1 + 2. Start an advertisement on dut1, include device name + 3. Find an onFound event + 4. Stop the advertisement on dut1 + 5. Find an onLost event + + Expected Result: + Find an onLost and an onFound event successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, onLost, onFound + Priority: 0 + """ + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['found_and_lost']) + self.scn_ad.droid.bleSetScanSettingsMatchMode( + ble_scan_settings_match_modes['aggresive']) + self.scn_ad.droid.bleSetScanSettingsNumOfMatches( + ble_scan_settings_match_nums['one']) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + adv_callback = self._start_generic_advertisement_include_device_name() + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 3) + found_callback_type = event['data']['CallbackType'] + if event['data']['CallbackType'] != ble_scan_settings_callback_types[ + 'first_match']: + self.log.info( + "Found Callbacreset_bluetoothkType:{}, Expected CallbackType:{}". + format(found_callback_type, ble_scan_settings_callback_types[ + 'first_match'])) + return False + self.adv_ad.droid.bleStopBleAdvertising(adv_callback) + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 4) + found_callback_type = event['data']['CallbackType'] + if found_callback_type != ble_scan_settings_callback_types[ + 'match_lost']: + self.log.info( + "Found CallbackType:{}, Expected CallbackType:{}".format( + found_callback_type, ble_scan_settings_callback_types[ + 'match_lost'])) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='10b48dc9-0c2a-46a3-8890-5cde3004a996') + def test_onlost_onfound_match_mode_sticky(self): + """Test generic onlost/onfound in sticky mode. + + Tests basic onFound/onLost functionality. + + Steps: + 1. Setup dut0 scanner and start scan with this setup: + Scan Mode: SCAN_MODE_LOW_LATENCY + Callback Type: CALLBACK_TYPE_FOUND_AND_LOST + Match Mode: STICKY + Num of Matches: MATCH_NUM_ONE_ADVERTISEMENT + Filter: Device name of dut1 + 2. Start an advertisement on dut1, include device name + 3. Find an onFound event + 4. Stop the advertisement on dut1 + 5. Find an onLost event + + Expected Result: + Find an onLost and an onFound event successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, onLost, onFound + Priority: 1 + """ + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['found_and_lost']) + self.scn_ad.droid.bleSetScanSettingsMatchMode( + ble_scan_settings_match_modes['sticky']) + self.scn_ad.droid.bleSetScanSettingsNumOfMatches( + ble_scan_settings_match_nums['one']) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + adv_callback = self._start_generic_advertisement_include_device_name() + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 3) + found_callback_type = event['data']['CallbackType'] + if event['data']['CallbackType'] != ble_scan_settings_callback_types[ + 'first_match']: + self.log.info( + "Found CallbackType:{}, Expected CallbackType:{}".format( + found_callback_type, ble_scan_settings_callback_types[ + 'first_match'])) + return False + self.adv_ad.droid.bleStopBleAdvertising(adv_callback) + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 4) + found_callback_type = event['data']['CallbackType'] + if found_callback_type != ble_scan_settings_callback_types[ + 'match_lost']: + self.log.info( + "Found CallbackType:{}, Expected CallbackType:{}".format( + found_callback_type, ble_scan_settings_callback_types[ + 'match_lost'])) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4fefed82-7800-41be-8272-aac076640fed') + def test_onlost_onfound_match_num_few(self): + """Test generic onlost/onfound num few. + + Tests basic onFound/onLost functionality. + + Steps: + 1. Setup dut0 scanner and start scan with this setup: + Scan Mode: SCAN_MODE_LOW_LATENCY + Callback Type: CALLBACK_TYPE_FOUND_AND_LOST + Match Mode: AGGRESSIVE + Num of Matches: MATCH_NUM_FEW_ADVERTISEMENT + Filter: Device name of dut1 + 2. Start an advertisement on dut1, include device name + 3. Find an onFound event + 4. Stop the advertisement on dut1 + 5. Find an onLost event + + Expected Result: + Find an onLost and an onFound event successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, onLost, onFound + Priority: 1 + """ + filter_list = self.scn_ad.droid.bleGenFilterList() + self.scn_ad.droid.bleSetScanFilterDeviceName( + self.adv_ad.droid.bluetoothGetLocalName()) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsCallbackType( + ble_scan_settings_callback_types['found_and_lost']) + self.scn_ad.droid.bleSetScanSettingsMatchMode( + ble_scan_settings_match_modes['aggresive']) + self.scn_ad.droid.bleSetScanSettingsNumOfMatches( + ble_scan_settings_match_nums['few']) + scan_settings = self.scn_ad.droid.bleBuildScanSetting() + scan_callback = self.scn_ad.droid.bleGenScanCallback() + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + adv_callback = self._start_generic_advertisement_include_device_name() + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 3) + found_callback_type = event['data']['CallbackType'] + if event['data']['CallbackType'] != ble_scan_settings_callback_types[ + 'first_match']: + self.log.info( + "Found CallbackType:{}, Expected CallbackType:{}".format( + found_callback_type, ble_scan_settings_callback_types[ + 'first_match'])) + return False + self.adv_ad.droid.bleStopBleAdvertising(adv_callback) + event = self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout * 4) + found_callback_type = event['data']['CallbackType'] + if found_callback_type != ble_scan_settings_callback_types[ + 'match_lost']: + self.log.info( + "Found CallbackType:{}, Expected CallbackType:{}".format( + found_callback_type, ble_scan_settings_callback_types[ + 'match_lost'])) + return False + return True diff --git a/acts/tests/google/ble/scan/BleOpportunisticScanTest.py b/acts/tests/google/ble/scan/BleOpportunisticScanTest.py new file mode 100644 index 0000000000..9e591281b1 --- /dev/null +++ b/acts/tests/google/ble/scan/BleOpportunisticScanTest.py @@ -0,0 +1,702 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different opportunistic scan scenarios. +It is expected that the second AndroidDevice is able to advertise. + +This test script was designed with this setup in mind: +Shield box one: Android Device, Android Device +""" + +from queue import Empty + +from acts import utils +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import batch_scan_result +from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_result + + +class BleOpportunisticScanTest(BluetoothBaseTest): + default_timeout = 10 + max_scan_instances = 25 + report_delay = 2000 + scan_callbacks = [] + adv_callbacks = [] + active_scan_callback_list = [] + active_adv_callback_list = [] + + def setup_class(self): + super(BluetoothBaseTest, self).setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + utils.set_location_service(self.scn_ad, True) + utils.set_location_service(self.adv_ad, True) + return True + + def teardown_test(self): + cleanup_scanners_and_advertisers( + self.scn_ad, self.active_scan_callback_list, self.adv_ad, + self.active_adv_callback_list) + self.active_adv_callback_list = [] + self.active_scan_callback_list = [] + + def on_exception(self, test_name, begin_time): + reset_bluetooth(self.android_devices) + + def _setup_generic_advertisement(self): + adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( + self.adv_ad.droid) + self.adv_ad.droid.bleStartBleAdvertising(adv_callback, adv_data, + adv_settings) + self.active_adv_callback_list.append(adv_callback) + + def _verify_no_events_found(self, event_name): + try: + event = self.scn_ad.ed.pop_event(event_name, self.default_timeout) + self.log.error("Found an event when none was expected: {}".format( + event)) + return False + except Empty: + self.log.info("No scan result found as expected.") + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6bccfbea-3734-4504-8ea9-3511ad17a3e0') + def test_scan_result_no_advertisement(self): + """Test opportunistic scan with no advertisement. + + Tests opportunistic scan where there are no advertisements. This should + not find any onScanResults. + + Steps: + 1. Initialize scanner with scan mode set to opportunistic mode. + 2. Start scanning on dut 0 + 3. Pop onScanResults event on the scanner + + Expected Result: + Find no advertisements with the opportunistic scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='8430bc57-925c-4b70-a62e-cd34df264ca1') + def test_batch_scan_result_no_advertisement(self): + """Test batch opportunistic scan without an advertisement. + + Tests opportunistic scan where there are no advertisements. This should + not find any onBatchScanResult. + + Steps: + 1. Initialize scanner with scan mode set to opportunistic mode. + 2. Set report delay seconds such that onBatchScanResult events are + expected + 2. Start scanning on dut 0 + 3. Pop onBatchScanResult event on the scanner + + Expected Result: + Find no advertisements with the opportunistic scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning + Priority: 1 + """ + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found( + batch_scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleStopBleScan(scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='4613cb67-0f54-494e-8a56-2e8ce56fad41') + def test_scan_result(self): + """Test opportunistic scan with an advertisement. + + Tests opportunistic scan where it will only report scan results when + other registered scanners find results. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Initialize scanner with scan mode set to opportunistic mode on dut0 + and start scanning + 3. Try to find an event, expect none. + 4. Start a second scanner on dut0, with any other mode set + 5. Pop onScanResults event on the second scanner + 6. Pop onScanResults event on the first scanner + + Expected Result: + Scan result is found on the opportunistic scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Opportunistic scan found no scan results.") + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5b46fefc-70ef-48a0-acf4-35077cd72202') + def test_batch_scan_result(self): + """Test batch opportunistic scan with advertisement. + + Tests opportunistic scan where it will only report scan results when + other registered scanners find results. Set the report delay millis such + that an onBatchScanResult is expected. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Initialize scanner with scan mode set to opportunistic mode and + set scan settings report delay seconds such that a batch scan is + expected + 3. Start scanning on dut 0 + 4. Try to find an event, expect none. + 5. Start a second scanner on dut0, with any other mode set and set scan + settings report delay millis such that an onBatchScanResult is expected + 6. Pop onBatchScanResult event on the second scanner + 7. Pop onBatchScanResult event on the first scanner + + Expected Result: + Find a batch scan result on both opportunistic scan instances. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found( + batch_scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + batch_scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + try: + self.scn_ad.ed.pop_event( + batch_scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Opportunistic scan found no scan results.") + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='fd85d95e-dc8c-48c1-8d8a-83c3475755ff') + def test_batch_scan_result_not_expected(self): + """Test opportunistic batch scan without expecting an event. + + Tests opportunistic scan where it will only report scan results when + other registered scanners find results. Set the report delay millis such + that a batch scan is not expected. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Initialize scanner with scan mode set to opportunistic mode and + set scan settings report delay seconds such that a batch scan is + expected. + 3. Start scanning on dut 0 + 4. Try to find an event, expect none. + 5. Start a second scanner on dut0, with any other mode set and set scan + settings report delay millis to 0 such that an onBatchScanResult is not + expected. + 6. Pop onScanResults event on the second scanner + 7. Pop onBatchScanResult event on the first scanner + + Expected Result: + Batch scan result is not expected on opportunistic scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found( + batch_scan_result.format(scan_callback)): + + return False + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + return self._verify_no_events_found( + batch_scan_result.format(scan_callback)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6138592e-8fd5-444f-9a7c-25cd9695644a') + def test_scan_result_not_expected(self): + """Test opportunistic scan without expecting an event. + + Tests opportunistic scan where it will only report batch scan results + when other registered scanners find results. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Initialize scanner with scan mode set to opportunistic mode. + 3. Start scanning on dut 0 + 4. Try to find an event, expect none. + 5. Start a second scanner on dut0, with any other mode set and set scan + settings + report delay millis such that an onBatchScanResult is expected + 6. Pop onBatchScanResult event on the second scanner + 7. Pop onScanResults event on the first scanner + + Expected Result: + Scan result is not expected on opportunistic scan instance. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + batch_scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + return self._verify_no_events_found(scan_result.format(scan_callback)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='f7aba3d9-d3f7-4b2f-976e-441772705613') + def test_max_opportunistic_scan_instances(self): + """Test max number of opportunistic scan instances. + + Tests max instances of opportunistic scans. Each instances should + find an onScanResults event. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Set scan settings to opportunistic scan on dut0 scan instance + 3. Start scan scan from step 2 + 4. Repeat step two and three until there are max_scan_instances-1 scan + instances + 5. Start a regular ble scan on dut0 with the last available scan + instance + 6. Pop onScanResults event on all scan instances + + Expected Result: + Each opportunistic scan instance finds a advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self._setup_generic_advertisement() + for _ in range(self.max_scan_instances - 1): + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + + for callback in self.active_scan_callback_list: + try: + self.scn_ad.ed.pop_event( + scan_result.format(callback), self.default_timeout) + except Empty: + self.log.error("No scan results found for callback {}".format( + callback)) + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='cf971f08-4d92-4046-bba6-b86a75aa773c') + def test_max_opportunistic_batch_scan_instances(self): + """Test max opportunistic batch scan instances. + + Tests max instances of opportunistic batch scans. Each instances should + find an onBatchScanResult event. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. Set scan settings to opportunistic scan on dut0 scan instance and + set report delay seconds such that an onBatchScanResult is expected + 3. Start scan scan from step 2 + 4. Repeat step two and three until there are max_scan_instances-1 scan + instances + 5. Start a regular ble scan on dut0 with the last available scan + instance + 6. Pop onBatchScanResult event on all scan instances + + Expected Result: + Each opportunistic scan instance finds an advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning + Priority: 1 + """ + self._setup_generic_advertisement() + for _ in range(self.max_scan_instances - 1): + self.scn_ad.droid.bleSetScanSettingsScanMode( + ble_scan_settings_modes['opportunistic']) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( + self.report_delay) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + + for callback in self.active_scan_callback_list: + try: + self.scn_ad.ed.pop_event( + batch_scan_result.format(callback), self.default_timeout) + except Empty: + self.log.error("No scan results found for callback {}".format( + callback)) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='965d84ef-11a7-418a-97e9-2a441c6de776') + def test_discover_opportunistic_scan_result_off_secondary_scan_filter( + self): + """Test opportunistic scan result from secondary scan filter. + + Tests opportunistic scan where the filtered scan instance does not find + an advertisement and the scan instance with scan mode set to + opportunistic scan will also not find an advertisement. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 (make sure the + advertisement is not advertising the device name) + 2. Set scan settings to opportunistic scan on dut0 scan instance + 3. Start scan scan from step 2 + 4. Try to find an event, expect none + 5. Start a second scanner on dut0, with any other mode set and set the + scan filter device name to "opp_test" + 6. Pop onScanResults from the second scanner + 7. Expect no events + 8. Pop onScanResults from the first scanner + 9. Expect no events + + Expected Result: + Opportunistic scan instance finds an advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleBuildScanFilter(filter_list2) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + if not self._verify_no_events_found( + scan_result.format(scan_callback2)): + return False + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='13b0a83f-e96e-4d64-84ef-66351ec5054c') + def test_negative_opportunistic_scan_filter_result_off_secondary_scan_result( + self): + """Test opportunistic scan not found scenario. + + Tests opportunistic scan where the secondary scan instance does find an + advertisement but the scan instance with scan mode set to opportunistic + scan does not find an advertisement due to mismatched scan filters. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 (make sure the + advertisement is not advertising the device name) + 2. Set scan settings to opportunistic scan on dut0 scan instance and set + the scan filter device name to "opp_test" + 3. Start scan scan from step 2 + 4. Try to find an event, expect none + 5. Start a second scanner on dut0, with any other mode set + 6. Pop onScanResults from the second scanner + 7. Pop onScanResults from the first scanner + 8. Expect no events + + Expected Result: + Opportunistic scan instance doesn't find any advertisements. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self._setup_generic_advertisement() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + return self._verify_no_events_found(scan_result.format(scan_callback)) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='087f60b2-f6a1-4919-b4c5-cdf3debcfeff') + def test_opportunistic_scan_filter_result_off_secondary_scan_result(self): + """Test opportunistic scan from a secondary scan result. + + Tests opportunistic scan where the scan filters are the same between the + first scan instance with opportunistic scan set and the second instance + with any other mode set. + + Steps: + 1. Initialize advertiser and start advertisement on dut1 + 2. On dut0, set the scan settings mode to opportunistic scan and set + the scan filter device name to the advertiser's device name + 3. Start scan scan from step 2 + 4. Try to find an event, expect none + 5. Start a second scanner on dut0, with any other mode set and set the + scan filter device name to the advertiser's device name + 6. Pop onScanResults from the second scanner + 7. Pop onScanResults from the first scanner + + Expected Result: + Opportunistic scan instance finds a advertisement. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Scanning, Opportunistic Scan + Priority: 1 + """ + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + self._setup_generic_advertisement() + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.active_scan_callback_list.append(scan_callback) + if not self._verify_no_events_found(scan_result.format(scan_callback)): + return False + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'low_latency']) + filter_list2, scan_settings2, scan_callback2 = ( + generate_ble_scan_objects(self.scn_ad.droid)) + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + self.scn_ad.droid.bleBuildScanFilter(filter_list2) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + self.active_scan_callback_list.append(scan_callback2) + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.default_timeout) + except Empty: + self.log.error("Opportunistic scan found no scan results.") + return False + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.default_timeout) + except Empty: + self.log.error("Non-Opportunistic scan found no scan results.") + return False + return True diff --git a/acts/tests/google/ble/scan/BleScanScreenStateTest.py b/acts/tests/google/ble/scan/BleScanScreenStateTest.py new file mode 100644 index 0000000000..07ae898fbf --- /dev/null +++ b/acts/tests/google/ble/scan/BleScanScreenStateTest.py @@ -0,0 +1,559 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script exercises different scan filters with different screen states. +""" + +import concurrent +import json +import pprint +import time + +from queue import Empty +from acts import utils +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_constants import adv_succ +from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes +from acts.test_utils.bt.bt_constants import ble_scan_settings_modes +from acts.test_utils.bt.bt_constants import bt_default_timeout +from acts.test_utils.bt.bt_constants import scan_result +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import reset_bluetooth + + +class BleScanScreenStateTest(BluetoothBaseTest): + advertise_callback = -1 + max_concurrent_scans = 27 + scan_callback = -1 + shorter_scan_timeout = 4 + + def setup_class(self): + super(BluetoothBaseTest, self).setup_class() + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + utils.set_location_service(self.scn_ad, True) + utils.set_location_service(self.adv_ad, True) + return True + + def _setup_generic_advertisement(self): + self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( + ble_advertise_settings_modes['low_latency']) + self.advertise_callback, advertise_data, advertise_settings = ( + generate_ble_advertise_objects(self.adv_ad.droid)) + self.adv_ad.droid.bleStartBleAdvertising( + self.advertise_callback, advertise_data, advertise_settings) + try: + self.adv_ad.ed.pop_event(adv_succ.format(self.advertise_callback)) + except Empty: + self.log.error("Failed to start advertisement.") + return False + return True + + def _setup_scan_with_no_filters(self): + filter_list, scan_settings, self.scan_callback = \ + generate_ble_scan_objects(self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + self.scan_callback) + + def _scan_found_results(self): + try: + self.scn_ad.ed.pop_event( + scan_result.format(self.scan_callback), bt_default_timeout) + self.log.info("Found an advertisement.") + except Empty: + self.log.info("Did not find an advertisement.") + return False + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='9b695819-e5a8-48b3-87a0-f90422998bf9') + def test_scan_no_filters_screen_on(self): + """Test LE scanning is successful with no filters and screen on. + + Test LE scanning is successful with no filters and screen on. Scan + results should be found. + + Steps: + 1. Setup advertisement + 2. Turn on screen + 3. Start scanner without filters + 4. Verify scan results are found + 5. Teardown advertisement and scanner + + Expected Result: + Scan results should be found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 2 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.wakeUpNow() + + # Step 3 + self._setup_scan_with_no_filters() + + # Step 4 + if not self._scan_found_results(): + return False + + # Step 5 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='38fb6959-f07b-4501-814b-81a498e3efc4') + def test_scan_no_filters_screen_off(self): + """Test LE scanning is successful with no filters and screen off. + + Test LE scanning is successful with no filters and screen off. No scan + results should be found. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner without filters + 4. Verify no scan results are found + 5. Teardown advertisement and scanner + + Expected Result: + No scan results should be found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 1 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + + # Step 3 + self._setup_scan_with_no_filters() + + # Step 4 + if self._scan_found_results(): + return False + + # Step 5 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7186ef2f-096a-462e-afde-b0e3d4ecdd83') + def test_scan_filters_works_with_screen_off(self): + """Test LE scanning is successful with filters and screen off. + + Test LE scanning is successful with no filters and screen off. No scan + results should be found. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner with filters + 4. Verify scan results are found + 5. Teardown advertisement and scanner + + Expected Result: + Scan results should be found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 1 + """ + # Step 1 + adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() + print(adv_device_name) + self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.goToSleepNow() + + # Step 3 + self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) + filter_list, scan_settings, self.scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleBuildScanFilter(filter_list) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + self.scan_callback) + + # Step 4 + if not self._scan_found_results(): + return False + + # Step 5 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='02cd6dca-149e-439b-8427-a2edc7864265') + def test_scan_no_filters_screen_off_then_turn_on(self): + """Test start LE scan with no filters while screen is off then turn on. + + Test that a scan without filters will not return results while the + screen is off but will return results when the screen turns on. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner without filters + 4. Verify no scan results are found + 5. Turn screen on + 6. Verify scan results are found + 7. Teardown advertisement and scanner + + Expected Result: + Scan results should only come in when the screen is on. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 2 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + + # Step 3 + self._setup_scan_with_no_filters() + + # Step 4 + if self._scan_found_results(): + return False + + # Step 5 + self.scn_ad.droid.wakeUpNow() + + # Step 6 + if not self._scan_found_results(): + return False + + # Step 7 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='eb9fc373-f5e8-4a55-9750-02b7a11893d1') + def test_scan_no_filters_screen_on_then_turn_off(self): + """Test start LE scan with no filters while screen is on then turn off. + + Test that a scan without filters will not return results while the + screen is off but will return results when the screen turns on. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner without filters + 4. Verify no scan results are found + 5. Turn screen on + 6. Verify scan results are found + 7. Teardown advertisement and scanner + + Expected Result: + Scan results should only come in when the screen is on. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 2 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.wakeUpNow() + + # Step 3 + self._setup_scan_with_no_filters() + + # Step 4 + if not self._scan_found_results(): + return False + + # Step 5 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + self.scn_ad.ed.clear_all_events() + + # Step 6 + if self._scan_found_results(): + return False + + # Step 7 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='41d90e11-b0a8-4eed-bff1-c19678920762') + def test_scan_no_filters_screen_toggling(self): + """Test start LE scan with no filters and test screen toggling. + + Test that a scan without filters will not return results while the + screen is off and return results while the screen is on. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner without filters + 4. Verify no scan results are found + 5. Turn screen on + 6. Verify scan results are found + 7. Repeat steps 1-6 10 times + 7. Teardown advertisement and scanner + + Expected Result: + Scan results should only come in when the screen is on. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 3 + """ + iterations = 10 + # Step 1 + if not self._setup_generic_advertisement(): + return False + + for i in range(iterations): + self.log.info("Starting iteration {}".format(i + 1)) + # Step 2 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + self.scn_ad.ed.clear_all_events() + + # Step 3 + self._setup_scan_with_no_filters() + + # Step 4 + if self._scan_found_results(): + return False + + # Step 5 + self.scn_ad.droid.wakeUpNow() + + # Step 6 + if not self._scan_found_results(): + return False + + # Step 7 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(self.scan_callback) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7a2fe7ef-b15f-4e93-a2f0-40e2f7d9cbcb') + def test_opportunistic_scan_no_filters_screen_off_then_on(self): + """Test opportunistic scanning does not find results with screen off. + + Test LE scanning is successful with no filters and screen off. No scan + results should be found. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start opportunistic scan without filters + 4. Start scan without filters + 5. Verify no scan results are found on either scan instance + 6. Wake up phone + 7. Verify scan results on each scan instance + 8. Teardown advertisement and scanner + + Expected Result: + No scan results should be found. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 1 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + + # Step 3 + self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ + 'opportunistic']) + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + + # Step 4 + filter_list2, scan_settings2, scan_callback2 = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, + scan_callback2) + + # Step 5 + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.shorter_scan_timeout) + self.log.error("Found an advertisement on opportunistic scan.") + return False + except Empty: + self.log.info("Did not find an advertisement.") + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.shorter_scan_timeout) + self.log.error("Found an advertisement on scan instance.") + return False + except Empty: + self.log.info("Did not find an advertisement.") + + # Step 6 + self.scn_ad.droid.wakeUpNow() + + # Step 7 + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback), self.shorter_scan_timeout) + self.log.info("Found an advertisement on opportunistic scan.") + except Empty: + self.log.error( + "Did not find an advertisement on opportunistic scan.") + return False + try: + self.scn_ad.ed.pop_event( + scan_result.format(scan_callback2), self.shorter_scan_timeout) + self.log.info("Found an advertisement on scan instance.") + except Empty: + self.log.info("Did not find an advertisement.") + return False + + # Step 8 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + self.scn_ad.droid.bleStopBleScan(scan_callback) + self.scn_ad.droid.bleStopBleScan(scan_callback2) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='406f1a2e-160f-4fb2-8a87-6403996df36e') + def test_max_scan_no_filters_screen_off_then_turn_on(self): + """Test start max scans with no filters while screen is off then turn on + + Test that max LE scan without filters will not return results while the + screen is off but will return results when the screen turns on. + + Steps: + 1. Setup advertisement + 2. Turn off screen + 3. Start scanner without filters and verify no scan results + 4. Turn screen on + 5. Verify scan results are found on each scan callback + 6. Teardown advertisement and all scanner + + Expected Result: + Scan results should only come in when the screen is on. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Filtering, Scanning, Screen + Priority: 2 + """ + # Step 1 + if not self._setup_generic_advertisement(): + return False + + # Step 2 + self.scn_ad.droid.goToSleepNow() + # Give the device time to go to sleep + time.sleep(2) + + # Step 3 + scan_callback_list = [] + for _ in range(self.max_concurrent_scans): + filter_list, scan_settings, scan_callback = \ + generate_ble_scan_objects(self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + scan_callback_list.append(scan_callback) + try: + self.scn_ad.ed.pop_event( + scan_result.format(self.scan_callback), + self.shorter_scan_timeout) + self.log.info("Found an advertisement.") + return False + except Empty: + self.log.info("Did not find an advertisement.") + + # Step 4 + self.scn_ad.droid.wakeUpNow() + + # Step 5 + for callback in scan_callback_list: + try: + self.scn_ad.ed.pop_event( + scan_result.format(callback), self.shorter_scan_timeout) + self.log.info("Found an advertisement.") + except Empty: + self.log.info("Did not find an advertisement.") + return False + + # Step 7 + self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) + for callback in scan_callback_list: + self.scn_ad.droid.bleStopBleScan(callback) + return True diff --git a/acts/tests/google/ble/system_tests/BleStressTest.py b/acts/tests/google/ble/system_tests/BleStressTest.py new file mode 100644 index 0000000000..afbb67a1cd --- /dev/null +++ b/acts/tests/google/ble/system_tests/BleStressTest.py @@ -0,0 +1,355 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Basic LE Stress tests. +""" + +import concurrent +import pprint +import time + +from queue import Empty +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import BtTestUtilsError +from acts.test_utils.bt.bt_test_utils import clear_bonded_devices +from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects +from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects +from acts.test_utils.bt.bt_test_utils import get_advanced_droid_list +from acts.test_utils.bt.bt_test_utils import get_mac_address_of_generic_advertisement +from acts.test_utils.bt.bt_test_utils import reset_bluetooth +from acts.test_utils.bt.bt_constants import scan_result + + +class BleStressTest(BluetoothBaseTest): + default_timeout = 10 + PAIRING_TIMEOUT = 20 + droid_list = [] + + def setup_class(self): + super().setup_class() + self.droid_list = get_advanced_droid_list(self.android_devices) + self.scn_ad = self.android_devices[0] + self.adv_ad = self.android_devices[1] + + def teardown_test(self): + super().teardown_test() + self.log_stats() + + def bleadvertise_verify_onsuccess_handler(self, event): + test_result = True + self.log.debug("Verifying onSuccess event") + self.log.debug(pprint.pformat(event)) + return test_result + + def _verify_successful_bond(self, target_address): + end_time = time.time() + self.PAIRING_TIMEOUT + self.log.info("Verifying devices are bonded") + while time.time() < end_time: + bonded_devices = self.scn_ad.droid.bluetoothGetBondedDevices() + if target_address in {d['address'] for d in bonded_devices}: + self.log.info("Successfully bonded to device") + return True + return False + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='22f98085-6ed8-4ad8-b62d-b8d1eae20b89') + def test_loop_scanning_1000(self): + """Stress start/stop scan instances. + + This test will start and stop scan instances as fast as possible. This + will guarantee that the scan instances are properly being cleaned up + when the scan is stopped. + + Steps: + 1. Start a scan instance. + 2. Stop the scan instance. + 3. Repeat steps 1-2 1000 times. + + Expected Result: + Neither starting or stopping scan instances causes any failures. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Stress + Priority: 1 + """ + test_result = True + for _ in range(1000): + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.scn_ad.droid.bleStopBleScan(scan_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='6caa84c2-50ac-46f2-a5e5-f942fd2cd6f6') + def test_loop_scanning_100_verify_no_hci_timeout(self): + """Stress start/stop scan instances variant. + + This test will start and stop scan instances with a one second timeout + in between each iteration. This testcase was added because the specific + timing combination caused hci timeouts. + + Steps: + 1. Start a scan instance. + 2. Stop the scan instance. + 3. Sleep for 1 second. + 4. Repeat steps 1-3 100 times. + + Expected Result: + Neither starting or stopping scan instances causes any failures. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Stress + Priority: 1 + """ + for _ in range(self.droid_list[1]['max_advertisements']): + adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( + self.adv_ad.droid) + self.adv_ad.droid.bleStartBleAdvertising(adv_callback, adv_data, + adv_settings) + for _ in range(100): + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + self.log.info( + self.scn_ad.ed.pop_event(scan_result.format(scan_callback))) + self.scn_ad.droid.bleStopBleScan(scan_callback) + time.sleep(1) + return True + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5e9e4c8d-b72e-4767-81e5-f907c1834430') + def test_loop_advertising_100(self): + """Stress start/stop advertising instances. + + This test will start and stop advertising instances as fast as possible. + + Steps: + 1. Start a advertising instance. + 2. Find that an onSuccess callback is triggered. + 3. Stop the advertising instance. + 4. Repeat steps 1-3 100 times. + + Expected Result: + Neither starting or stopping advertising instances causes any failures. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Stress + Priority: 1 + """ + test_result = True + for _ in range(100): + advertise_callback, advertise_data, advertise_settings = generate_ble_advertise_objects( + self.adv_ad.droid) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + expected_advertise_event_name = "".join( + ["BleAdvertise", + str(advertise_callback), "onSuccess"]) + worker = self.adv_ad.ed.handle_event( + self.bleadvertise_verify_onsuccess_handler, + expected_advertise_event_name, ([]), self.default_timeout) + try: + self.log.debug(worker.result(self.default_timeout)) + except Empty as error: + self.log.debug(" ".join( + ["Test failed with Empty error:", + str(error)])) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug(" ".join([ + "Test failed, filtering callback onSuccess never occurred:", + str(error) + ])) + test_result = False + self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='11a2f51b-7178-4c32-bb5c-7eddd100a50f') + def test_restart_advertise_callback_after_bt_toggle(self): + """Test to reuse an advertise callback. + + This will verify if advertising objects can be reused after a bluetooth + toggle. + + Steps: + 1. Start a advertising instance. + 2. Find that an onSuccess callback is triggered. + 3. Stop the advertising instance. + 4. Toggle bluetooth off and on. + 5. Start an advertising instance on the same objects used in step 1. + 6. Find that an onSuccess callback is triggered. + + Expected Result: + Advertisement should start successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Advertising, Stress + Priority: 1 + """ + test_result = True + advertise_callback, advertise_data, advertise_settings = generate_ble_advertise_objects( + self.adv_ad.droid) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + expected_advertise_event_name = "".join( + ["BleAdvertise", + str(advertise_callback), "onSuccess"]) + worker = self.adv_ad.ed.handle_event( + self.bleadvertise_verify_onsuccess_handler, + expected_advertise_event_name, ([]), self.default_timeout) + try: + self.log.debug(worker.result(self.default_timeout)) + except Empty as error: + self.log.debug(" ".join( + ["Test failed with Empty error:", + str(error)])) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug(" ".join([ + "Test failed, filtering callback onSuccess never occurred:", + str(error) + ])) + test_result = reset_bluetooth([self.scn_ad]) + if not test_result: + return test_result + time.sleep(5) + self.adv_ad.droid.bleStartBleAdvertising( + advertise_callback, advertise_data, advertise_settings) + worker = self.adv_ad.ed.handle_event( + self.bleadvertise_verify_onsuccess_handler, + expected_advertise_event_name, ([]), self.default_timeout) + try: + self.log.debug(worker.result(self.default_timeout)) + except Empty as error: + self.log.debug(" ".join( + ["Test failed with Empty error:", + str(error)])) + test_result = False + except concurrent.futures._base.TimeoutError as error: + self.log.debug(" ".join([ + "Test failed, filtering callback onSuccess never occurred:", + str(error) + ])) + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='88f3c068-41be-41df-920c-c0ecaae1a619') + def test_restart_scan_callback_after_bt_toggle(self): + """Test to reuse an scan callback. + + This will verify if scan objects can be reused after a bluetooth + toggle. + + Steps: + 1. Start a scanning instance. + 3. Stop the scanning instance. + 4. Toggle bluetooth off and on. + 5. Start an scanning instance on the same objects used in step 1. + + Expected Result: + Scanner should start successfully. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Stress + Priority: 1 + """ + test_result = True + filter_list, scan_settings, scan_callback = generate_ble_scan_objects( + self.scn_ad.droid) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + reset_bluetooth([self.scn_ad]) + self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, + scan_callback) + + return test_result + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='ce8adfc0-384f-4751-9438-13a76cada8da') + def test_le_pairing(self): + """Test LE pairing transport stress + + This will test LE pairing between two android devices. + + Steps: + 1. Start an LE advertisement on secondary device. + 2. Find address from primary device. + 3. Discover and bond to LE address. + 4. Stop LE advertisement on secondary device. + 5. Repeat steps 1-4 100 times + + Expected Result: + LE pairing should pass 100 times. + + Returns: + Pass if True + Fail if False + + TAGS: LE, Scanning, Stress, Pairing + Priority: 1 + """ + iterations = 100 + for i in range(iterations): + try: + target_address, adv_callback, scan_callback = get_mac_address_of_generic_advertisement( + self.scn_ad, self.adv_ad) + except BtTestUtilsError as err: + self.log.error(err) + return False + self.log.info("Begin interation {}/{}".format(i + 1, iterations)) + self.scn_ad.droid.bluetoothStartPairingHelper() + self.adv_ad.droid.bluetoothStartPairingHelper() + start_time = self.start_timer() + self.scn_ad.droid.bluetoothDiscoverAndBond(target_address) + if not self._verify_successful_bond(target_address): + self.log.error("Failed to bond devices.") + return False + self.log.info("Total time (ms): {}".format(self.end_timer())) + if not self._verify_successful_bond(self.adv_ad.droid.bluetoothGetLocalAddress()): + self.log.error("Failed to bond BREDR devices.") + return False + if not self.scn_ad.droid.bluetoothUnbond(target_address): + self.log.error("Failed to unbond device from scanner.") + return False + time.sleep(2) + if not self.adv_ad.droid.bluetoothUnbond(self.scn_ad.droid.bluetoothGetLocalAddress()): + self.log.error("Failed to unbond device from advertiser.") + return False + self.adv_ad.droid.bleStopBleAdvertising(adv_callback) + self.scn_ad.droid.bleStopBleScan(scan_callback) + # Magic sleep to let unbonding finish + time.sleep(2) + return True diff --git a/acts/tests/google/ble/system_tests/GattLongevityTest.py b/acts/tests/google/ble/system_tests/GattLongevityTest.py new file mode 100644 index 0000000000..bb13646625 --- /dev/null +++ b/acts/tests/google/ble/system_tests/GattLongevityTest.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +This test script for GATT longevity tests. +""" + +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest +from acts.test_utils.bt.bt_constants import gatt_characteristic +from acts.test_utils.bt.bt_constants import gatt_descriptor +from acts.test_utils.bt.bt_constants import gatt_event +from acts.test_utils.bt.bt_constants import gatt_cb_strings +from acts.test_utils.bt.bt_constants import gatt_connection_priority +from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length +from acts.test_utils.bt.GattEnum import MtuSize +from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu + + +class GattLongevityTest(GattConnectedBaseTest): + longevity_iterations = 1100000 + + @test_tracker_info(uuid='d7d378f4-89d8-4330-bb80-0054b92020bb') + def test_write_characteristic_no_resp_longevity(self): + """Longevity test write characteristic value + + Longevity test to write characteristic value for + self.longevity_iteration times. This is to test the + integrity of written data and the robustness of central + and peripheral mode of the Android devices under test. + + 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value + using write command. + 2. Central: make sure write callback is called. + 3. Peripheral: receive the written data. + 4. Verify data written matches data received. + 5. Repeat steps 1-4 self.longevity_iterations times. + + Expected Result: + Verify that write command is properly delivered. + + Returns: + Pass if True + Fail if False + + TAGS: LE, GATT, Characteristic, Longevity + Priority: 0 + """ + self.cen_ad.droid.gattClientRequestConnectionPriority( + self.bluetooth_gatt, gatt_connection_priority['high']) + + self.cen_ad.droid.gattClientCharacteristicSetWriteType( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, + gatt_characteristic['write_type_no_response']) + + for i in range(self.longevity_iterations): + self.log.debug("Iteration {} started.".format(i + 1)) + char_value = [] + for j in range(i, i + self.mtu - 3): + char_value.append(j % 256) + + self.cen_ad.droid.gattClientCharacteristicSetValue( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) + + self.cen_ad.droid.gattClientWriteCharacteristic( + self.bluetooth_gatt, self.discovered_services_index, + self.test_service_index, self.WRITABLE_CHAR_UUID) + + # client shall not wait for server, get complete event right away + event = self._client_wait(gatt_event['char_write']) + if event["data"]["Status"] != 0: + self.log.error("Write status should be 0") + return False + + event = self._server_wait(gatt_event['char_write_req']) + + self.log.info("{} event found: {}".format(gatt_cb_strings[ + 'char_write_req'].format(self.gatt_server_callback), event[ + 'data']['value'])) + request_id = event['data']['requestId'] + found_value = event['data']['value'] + if found_value != char_value: + self.log.info("Values didn't match. Found: {}, " + "Expected: {}".format(found_value, char_value)) + return False + + return True diff --git a/acts/tests/google/experimental/BluetoothLatencyTest.py b/acts/tests/google/experimental/BluetoothLatencyTest.py new file mode 100644 index 0000000000..ea6ed4a24d --- /dev/null +++ b/acts/tests/google/experimental/BluetoothLatencyTest.py @@ -0,0 +1,141 @@ +#/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import random +import statistics +import string +import time +from acts import asserts +from acts.base_test import BaseTestClass +from acts.signals import TestPass +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import orchestrate_rfcomm_connection +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.bt_test_utils import verify_server_and_client_connected +from acts.test_utils.bt.bt_test_utils import write_read_verify_data +from acts.test_utils.bt.loggers.bluetooth_metric_logger import BluetoothMetricLogger +from acts.test_utils.bt.loggers.protos import bluetooth_metric_pb2 as proto_module +from acts.utils import set_location_service + + +class BluetoothLatencyTest(BaseTestClass): + """Connects two Android phones and tests the RFCOMM latency. + + Attributes: + client_device: An Android device object that will be sending data + server_device: An Android device object that will be receiving data + bt_logger: The proxy logger instance for each test case + data_transfer_type: Data transfer protocol used for the test + """ + + def setup_class(self): + super().setup_class() + + # Sanity check of the devices under test + # TODO(b/119051823): Investigate using a config validator to replace this. + if len(self.android_devices) < 2: + raise ValueError( + 'Not enough android phones detected (need at least two)') + + # Data will be sent from the client_device to the server_device + self.client_device = self.android_devices[0] + self.server_device = self.android_devices[1] + self.bt_logger = BluetoothMetricLogger.for_test_case() + self.data_transfer_type = proto_module.BluetoothDataTestResult.RFCOMM + self.log.info('Successfully found required devices.') + + def setup_test(self): + setup_multiple_devices_for_bt_test(self.android_devices) + self._connect_rfcomm() + + def teardown_test(self): + if verify_server_and_client_connected( + self.client_device, self.server_device, log=False): + self.client_device.droid.bluetoothSocketConnStop() + self.server_device.droid.bluetoothSocketConnStop() + + def _connect_rfcomm(self): + """Establishes an RFCOMM connection between two phones. + + Connects the client device to the server device given the hardware + address of the server device. + """ + + set_location_service(self.client_device, True) + set_location_service(self.server_device, True) + server_address = self.server_device.droid.bluetoothGetLocalAddress() + self.log.info('Pairing and connecting devices') + asserts.assert_true(self.client_device.droid + .bluetoothDiscoverAndBond(server_address), + 'Failed to pair and connect devices') + + # Create RFCOMM connection + asserts.assert_true(orchestrate_rfcomm_connection + (self.client_device, self.server_device), + 'Failed to establish RFCOMM connection') + + def _measure_latency(self): + """Measures the latency of data transfer over RFCOMM. + + Sends data from the client device that is read by the server device. + Calculates the latency of the transfer. + + Returns: + The latency of the transfer milliseconds. + """ + + # Generates a random message to transfer + message = (''.join(random.choice(string.ascii_letters + string.digits) + for _ in range(6))) + + start_time = time.perf_counter() + write_read_successful = write_read_verify_data(self.client_device, + self.server_device, + message, + False) + end_time = time.perf_counter() + asserts.assert_true(write_read_successful, + 'Failed to send/receive message') + return (end_time - start_time) * 1000 + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='7748295d-204e-4ad0-adf5-7591380b940a') + def test_bluetooth_latency(self): + """Tests the latency for a data transfer over RFCOMM""" + + metrics = {} + latency_list = [] + + for _ in range(300): + latency_list.append(self._measure_latency()) + + metrics['data_transfer_protocol'] = self.data_transfer_type + metrics['data_latency_min_millis'] = int(min(latency_list)) + metrics['data_latency_max_millis'] = int(max(latency_list)) + metrics['data_latency_avg_millis'] = int(statistics.mean(latency_list)) + self.log.info('Latency: {}'.format(metrics)) + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.server_device, + self.client_device) + + asserts.assert_true(metrics['data_latency_min_millis'] > 0, + 'Minimum latency must be greater than 0!', + extras=proto) + + raise TestPass('Latency test completed successfully', extras=proto) diff --git a/acts/tests/google/experimental/BluetoothPairAndConnectTest.py b/acts/tests/google/experimental/BluetoothPairAndConnectTest.py new file mode 100644 index 0000000000..2402fb5444 --- /dev/null +++ b/acts/tests/google/experimental/BluetoothPairAndConnectTest.py @@ -0,0 +1,192 @@ +#/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +"""Bluetooth 1st time force pair and connect test implementation.""" +# Quick way to get the Apollo serial number: +# python3.5 -c "from acts.controllers.buds_lib.apollo_lib import get_devices; [print(d['serial_number']) for d in get_devices()]" + +import statistics +import time + +from acts import logger +from acts.base_test import BaseTestClass +from acts.controllers.buds_lib.test_actions.bt_utils import BTUtils +from acts.controllers.buds_lib.test_actions.bt_utils import BTUtilsError +from acts.controllers.buds_lib.test_actions.apollo_acts import ApolloTestActions +from acts.signals import TestFailure +from acts.signals import TestPass +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import factory_reset_bluetooth +from acts.test_utils.bt.bt_test_utils import enable_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.loggers.bluetooth_metric_logger import BluetoothMetricLogger +from acts.utils import set_location_service + + +# The number of pairing and connection attempts +PAIR_CONNECT_ATTEMPTS = 200 + + +class BluetoothPairConnectError(TestFailure): + pass + + +class BluetoothPairAndConnectTest(BaseTestClass): + """Pairs and connects a phone and an Apollo buds device. + + Attributes: + phone: An Android phone object + apollo: An Apollo earbuds object + apollo_act: An Apollo test action object + dut_bt_addr: The Bluetooth address of the Apollo earbuds + bt_utils: BTUtils test action object + """ + + def setup_class(self): + super().setup_class() + # Sanity check of the devices under test + # TODO(b/119051823): Investigate using a config validator to replace this. + if not self.android_devices: + raise ValueError( + 'Cannot find android phone (need at least one).') + self.phone = self.android_devices[0] + + if not self.buds_devices: + raise ValueError( + 'Cannot find apollo device (need at least one).') + self.apollo = self.buds_devices[0] + self.log.info('Successfully found needed devices.') + + # Staging the test, create result object, etc. + self.apollo_act = ApolloTestActions(self.apollo, self.log) + self.dut_bt_addr = self.apollo.bluetooth_address + self.bt_utils = BTUtils() + self.bt_logger = BluetoothMetricLogger.for_test_case() + + def setup_test(self): + setup_multiple_devices_for_bt_test(self.android_devices) + # Make sure Bluetooth is on + enable_bluetooth(self.phone.droid, self.phone.ed) + set_location_service(self.phone, True) + self.apollo_act.factory_reset() + self.log.info('===== START BLUETOOTH PAIR AND CONNECT TEST =====') + + def teardown_test(self): + self.log.info('Teardown test, shutting down all services...') + self.apollo_act.factory_reset() + self.apollo.close() + + def _get_device_pair_and_connect_times(self): + """Gets the pair and connect times of the phone and buds device. + + Pairs the phone with the buds device. Gets the pair and connect times. + Unpairs the devices. + + Returns: + pair_time: The time it takes to pair the devices in ms. + connection_time: The time it takes to connect the devices for the + first time after pairing. + + Raises: + BluetoothPairConnectError + """ + + try: + pair_time = self.bt_utils.bt_pair(self.phone, self.apollo) + except BTUtilsError: + raise BluetoothPairConnectError('Failed to pair devices') + + pair_time *= 1000 + connection_start_time = time.perf_counter() + if not self.apollo_act.wait_for_bluetooth_a2dp_hfp(30): + raise BluetoothPairConnectError('Failed to connect devices') + connection_end_time = time.perf_counter() + connection_time = (connection_end_time - + connection_start_time) * 1000 + + return pair_time, connection_time + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='c914fd08-350d-465a-96cf-970d40e71060') + def test_bluetooth_connect(self): + # Store metrics + metrics = {} + pair_connect_success = 0 + pair_connect_failures = [] + pair_times = [] + connect_times = [] + first_connection_failure = None + + for attempt in range(PAIR_CONNECT_ATTEMPTS): + self.log.info('Pair and connection attempt {}'.format(attempt + 1)) + pair_connect_timestamp = time.strftime(logger.log_line_time_format, + time.localtime()) + try: + pair_time, connect_time = (self. + _get_device_pair_and_connect_times()) + except BluetoothPairConnectError as err: + self.log.error(err) + failure_data = {'timestamp': pair_connect_timestamp, + 'error': str(err), + 'pair_and_connect_attempt': attempt + 1} + pair_connect_failures.append(failure_data) + if not first_connection_failure: + first_connection_failure = err + else: + connect_times.append(connect_time) + pair_times.append(pair_time) + pair_connect_success += 1 + + factory_reset_bluetooth([self.phone]) + self.log.info('Factory resetting Apollo device...') + self.apollo_act.factory_reset() + + # Buffer between pair and connect attempts + time.sleep(3) + + metrics['pair_attempt_count'] = PAIR_CONNECT_ATTEMPTS + metrics['pair_successful_count'] = pair_connect_success + metrics['pair_failed_count'] = (PAIR_CONNECT_ATTEMPTS - + pair_connect_success) + + if len(pair_times) > 0: + metrics['pair_max_time_millis'] = int(max(pair_times)) + metrics['pair_min_time_millis'] = int(min(pair_times)) + metrics['pair_avg_time_millis'] = int(statistics.mean(pair_times)) + + if len(connect_times) > 0: + metrics['first_connection_max_time_millis'] = int( + max(connect_times)) + metrics['first_connection_min_time_millis'] = int( + min(connect_times)) + metrics['first_connection_avg_time_millis'] = int( + (statistics.mean(connect_times))) + + if pair_connect_failures: + metrics['pair_conn_failure_info'] = pair_connect_failures + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.phone, + self.apollo) + + self.log.info('Metrics: {}'.format(metrics)) + + if PAIR_CONNECT_ATTEMPTS != pair_connect_success: + raise TestFailure(str(first_connection_failure), extras=proto) + else: + raise TestPass('Bluetooth pair and connect test passed', + extras=proto) diff --git a/acts/tests/google/experimental/BluetoothReconnectTest.py b/acts/tests/google/experimental/BluetoothReconnectTest.py new file mode 100644 index 0000000000..5339e517eb --- /dev/null +++ b/acts/tests/google/experimental/BluetoothReconnectTest.py @@ -0,0 +1,182 @@ +#/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +"""Bluetooth disconnect and reconnect verification.""" +# Quick way to get the Apollo serial number: +# python3.5 -c "from acts.controllers.buds_lib.apollo_lib import get_devices; [print(d['serial_number']) for d in get_devices()]" + +import statistics +import time +from acts import asserts +from acts.base_test import BaseTestClass +from acts.controllers.buds_lib.test_actions.apollo_acts import ApolloTestActions +from acts.signals import TestFailure +from acts.signals import TestPass +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import enable_bluetooth +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.loggers.bluetooth_metric_logger import BluetoothMetricLogger +from acts.utils import set_location_service + +# The number of reconnections to be attempted during the test +RECONNECTION_ATTEMPTS = 200 + + +class BluetoothReconnectError(TestFailure): + pass + + +class BluetoothReconnectTest(BaseTestClass): + """Connects a phone to Apollo earbuds to test Bluetooth reconnection. + + Attributes: + phone: An Android phone object + apollo: An Apollo earbuds object + apollo_act: An Apollo test action object + dut_bt_addr: The Bluetooth address of the Apollo earbuds + """ + + def setup_class(self): + super().setup_class() + # sanity check of the dut devices. + # TODO(b/119051823): Investigate using a config validator to replace this. + if not self.android_devices: + raise ValueError( + 'Cannot find android phone (need at least one).') + self.phone = self.android_devices[0] + + if not self.buds_devices: + raise ValueError( + 'Cannot find apollo device (need at least one).') + self.apollo = self.buds_devices[0] + self.log.info('Successfully found needed devices.') + + # Staging the test, create result object, etc. + self.apollo_act = ApolloTestActions(self.apollo, self.log) + self.dut_bt_addr = self.apollo.bluetooth_address + self.bt_logger = BluetoothMetricLogger.for_test_case() + + def setup_test(self): + setup_multiple_devices_for_bt_test(self.android_devices) + # Make sure Bluetooth is on + enable_bluetooth(self.phone.droid, self.phone.ed) + set_location_service(self.phone, True) + self.apollo_act.factory_reset() + + # Initial pairing and connection of devices + self.phone.droid.bluetoothDiscoverAndBond(self.dut_bt_addr) + paired_and_connected = self.apollo_act.wait_for_bluetooth_a2dp_hfp() + asserts.assert_true(paired_and_connected, + 'Failed to pair and connect devices') + time.sleep(20) + self.log.info('===== START BLUETOOTH RECONNECT TEST =====') + + def teardown_test(self): + self.log.info('Teardown test, shutting down all services...') + self.apollo_act.factory_reset() + self.apollo.close() + + def _reconnect_bluetooth_from_phone(self): + """Reconnects Bluetooth from the phone. + + Disables and then re-enables Bluetooth from the phone when Bluetooth + disconnection has been verified. Measures the reconnection time. + + Returns: + The time it takes to connect Bluetooth in milliseconds. + + Raises: + BluetoothReconnectError + """ + + # Disconnect Bluetooth from the phone side + self.log.info('Disconnecting Bluetooth from phone') + self.phone.droid.bluetoothDisconnectConnected(self.dut_bt_addr) + if not self.apollo_act.wait_for_bluetooth_disconnection(): + raise BluetoothReconnectError('Failed to disconnect Bluetooth') + self.log.info('Bluetooth disconnected successfully') + + # Buffer between disconnect and reconnect + time.sleep(3) + + # Reconnect Bluetooth from the phone side + self.log.info('Connecting Bluetooth from phone') + start_time = time.perf_counter() + self.phone.droid.bluetoothConnectBonded(self.dut_bt_addr) + self.log.info('Bluetooth connected successfully') + if not self.apollo_act.wait_for_bluetooth_a2dp_hfp(): + raise BluetoothReconnectError('Failed to connect Bluetooth') + end_time = time.perf_counter() + return (end_time - start_time) * 1000 + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='da921903-92d0-471d-ae01-456058cc1297') + def test_bluetooth_reconnect(self): + """Reconnects Bluetooth between a phone and Apollo device a specified + number of times and reports connection time statistics.""" + + # Store metrics + metrics = {} + connection_success = 0 + connection_times = [] + reconnection_failures = [] + first_connection_failure = None + + for attempt in range(RECONNECTION_ATTEMPTS): + self.log.info("Reconnection attempt {}".format(attempt + 1)) + reconnect_timestamp = time.strftime('%Y-%m-%d %H:%M:%S', + time.localtime()) + try: + connection_time = self._reconnect_bluetooth_from_phone() + except BluetoothReconnectError as err: + self.log.error(err) + failure_data = {'timestamp': reconnect_timestamp, + 'error': str(err), + 'reconnect_attempt': attempt + 1} + reconnection_failures.append(failure_data) + if not first_connection_failure: + first_connection_failure = err + else: + connection_times.append(connection_time) + connection_success += 1 + + # Buffer between reconnection attempts + time.sleep(3) + + metrics['connection_attempt_count'] = RECONNECTION_ATTEMPTS + metrics['connection_successful_count'] = connection_success + metrics['connection_failed_count'] = (RECONNECTION_ATTEMPTS + - connection_success) + if len(connection_times) > 0: + metrics['connection_max_time_millis'] = int(max(connection_times)) + metrics['connection_min_time_millis'] = int(min(connection_times)) + metrics['connection_avg_time_millis'] = int(statistics.mean( + connection_times)) + + if reconnection_failures: + metrics['connection_failure_info'] = reconnection_failures + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.phone, + self.apollo) + + self.log.info('Metrics: {}'.format(metrics)) + + if RECONNECTION_ATTEMPTS != connection_success: + raise TestFailure(str(first_connection_failure), extras=proto) + else: + raise TestPass('Bluetooth reconnect test passed', extras=proto) diff --git a/acts/tests/google/experimental/BluetoothThroughputTest.py b/acts/tests/google/experimental/BluetoothThroughputTest.py new file mode 100644 index 0000000000..1f53172d8e --- /dev/null +++ b/acts/tests/google/experimental/BluetoothThroughputTest.py @@ -0,0 +1,234 @@ +#/usr/bin/env python3 +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import statistics +from acts import asserts +from acts.base_test import BaseTestClass +from acts.signals import TestPass +from acts.test_decorators import test_tracker_info +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest +from acts.test_utils.bt.bt_test_utils import orchestrate_rfcomm_connection +from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test +from acts.test_utils.bt.bt_test_utils import verify_server_and_client_connected +from acts.test_utils.bt.loggers.bluetooth_metric_logger import BluetoothMetricLogger +from acts.test_utils.bt.loggers.protos import bluetooth_metric_pb2 as proto_module +from acts.utils import set_location_service + + +class BluetoothThroughputTest(BaseTestClass): + """Connects two Android phones and tests the throughput between them. + + Attributes: + client_device: An Android device object that will be sending data + server_device: An Android device object that will be receiving data + bt_logger: The proxy logger instance for each test case + data_transfer_type: Data transfer protocol used for the test + """ + + def setup_class(self): + super().setup_class() + + # Sanity check of the devices under test + # TODO(b/119051823): Investigate using a config validator to replace this. + if len(self.android_devices) < 2: + raise ValueError( + 'Not enough android phones detected (need at least two)') + + # Data will be sent from the client_device to the server_device + self.client_device = self.android_devices[0] + self.server_device = self.android_devices[1] + self.bt_logger = BluetoothMetricLogger.for_test_case() + self.data_transfer_type = proto_module.BluetoothDataTestResult.RFCOMM + self.log.info('Successfully found required devices.') + + def setup_test(self): + setup_multiple_devices_for_bt_test(self.android_devices) + self._connect_rfcomm() + + def teardown_test(self): + if verify_server_and_client_connected( + self.client_device, self.server_device, log=False): + self.client_device.droid.bluetoothSocketConnStop() + self.server_device.droid.bluetoothSocketConnStop() + + def _connect_rfcomm(self): + """Establishes an RFCOMM connection between two phones. + + Connects the client device to the server device given the hardware + address of the server device. + """ + + set_location_service(self.client_device, True) + set_location_service(self.server_device, True) + server_address = self.server_device.droid.bluetoothGetLocalAddress() + self.log.info('Pairing and connecting devices') + asserts.assert_true(self.client_device.droid + .bluetoothDiscoverAndBond(server_address), + 'Failed to pair and connect devices') + + # Create RFCOMM connection + asserts.assert_true(orchestrate_rfcomm_connection + (self.client_device, self.server_device), + 'Failed to establish RFCOMM connection') + + def _measure_throughput(self, num_of_buffers, buffer_size): + """Measures the throughput of a data transfer. + + Sends data from the client device that is read by the server device. + Calculates the throughput for the transfer. + + Args: + num_of_buffers: An integer value designating the number of buffers + to be sent. + buffer_size: An integer value designating the size of each buffer, + in bytes. + + Returns: + The throughput of the transfer in bytes per second. + """ + + # TODO(b/119638242): Need to fix throughput send/receive methods + (self.client_device.droid + .bluetoothConnectionThroughputSend(num_of_buffers, buffer_size)) + + throughput = (self.server_device.droid + .bluetoothConnectionThroughputRead(num_of_buffers, + buffer_size)) + return throughput + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='23afba5b-5801-42c2-8d7a-41510e91a605') + def test_bluetooth_throughput_large_buffer(self): + """Tests the throughput over a series of data transfers with large + buffer size. + """ + + metrics = {} + throughput_list = [] + + for transfer in range(300): + throughput = self._measure_throughput(1, 300) + self.log.info('Throughput: {} bytes-per-sec'.format(throughput)) + throughput_list.append(throughput) + + metrics['data_transfer_protocol'] = self.data_transfer_type + metrics['data_packet_size'] = 300 + metrics['data_throughput_min_bytes_per_second'] = int( + min(throughput_list)) + metrics['data_throughput_max_bytes_per_second'] = int( + max(throughput_list)) + metrics['data_throughput_avg_bytes_per_second'] = int(statistics.mean( + throughput_list)) + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.server_device, + self.client_device) + + asserts.assert_true(metrics['data_throughput_min_bytes_per_second'] > 0, + 'Minimum throughput must be greater than 0!', + extras=proto) + raise TestPass('Throughput test (large buffer) completed successfully', + extras=proto) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='5472fe33-891e-4fa1-ba84-78fc6f6a2327') + def test_bluetooth_throughput_medium_buffer(self): + """Tests the throughput over a series of data transfers with medium + buffer size. + """ + + metrics = {} + throughput_list = [] + + for transfer in range(300): + throughput = self._measure_throughput(1, 100) + self.log.info('Throughput: {} bytes-per-sec'.format(throughput)) + throughput_list.append(throughput) + + metrics['data_transfer_protocol'] = self.data_transfer_type + metrics['data_packet_size'] = 100 + metrics['data_throughput_min_bytes_per_second'] = int( + min(throughput_list)) + metrics['data_throughput_max_bytes_per_second'] = int( + max(throughput_list)) + metrics['data_throughput_avg_bytes_per_second'] = int(statistics.mean( + throughput_list)) + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.server_device, + self.client_device) + + asserts.assert_true(metrics['data_throughput_min_bytes_per_second'] > 0, + 'Minimum throughput must be greater than 0!', + extras=proto) + raise TestPass('Throughput test (medium buffer) completed successfully', + extras=proto) + + @BluetoothBaseTest.bt_test_wrap + @test_tracker_info(uuid='97589280-cefa-4ae4-b3fd-94ec9c1f4104') + def test_bluetooth_throughput_small_buffer(self): + """Tests the throughput over a series of data transfers with small + buffer size. + """ + + metrics = {} + throughput_list = [] + + for transfer in range(300): + throughput = self._measure_throughput(1, 10) + self.log.info('Throughput: {} bytes-per-sec'.format(throughput)) + throughput_list.append(throughput) + + metrics['data_transfer_protocol'] = self.data_transfer_type + metrics['data_packet_size'] = 10 + metrics['data_throughput_min_bytes_per_second'] = int( + min(throughput_list)) + metrics['data_throughput_max_bytes_per_second'] = int( + max(throughput_list)) + metrics['data_throughput_avg_bytes_per_second'] = int(statistics.mean( + throughput_list)) + + proto = self.bt_logger.get_results(metrics, + self.__class__.__name__, + self.server_device, + self.client_device) + + asserts.assert_true(metrics['data_throughput_min_bytes_per_second'] > 0, + 'Minimum throughput must be greater than 0!', + extras=proto) + raise TestPass('Throughput test (small buffer) completed successfully', + extras=proto) + + @BluetoothBaseTest.bt_test_wrap + def test_maximum_buffer_size(self): + """Calculates the maximum allowed buffer size for one packet.""" + + current_buffer_size = 1 + while True: + self.log.info('Trying buffer size {}'.format(current_buffer_size)) + try: + throughput = self._measure_throughput(1, current_buffer_size) + except Exception: + buffer_msg = ('Max buffer size: {} bytes'. + format(current_buffer_size - 1)) + throughput_msg = ('Max throughput: {} bytes-per-second'. + format(throughput)) + self.log.info(buffer_msg) + self.log.info(throughput_msg) + return True + current_buffer_size += 1 diff --git a/acts/tests/google/fugu/AndroidFuguRemotePairingTest.py b/acts/tests/google/fugu/AndroidFuguRemotePairingTest.py new file mode 100644 index 0000000000..a41f9fce79 --- /dev/null +++ b/acts/tests/google/fugu/AndroidFuguRemotePairingTest.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +""" +Test script to test pairing of an Android Device to a Fugu Remote +""" +import time + +from acts.controllers.relay_lib.relay import SynchronizeRelays +from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest + +class AndroidFuguRemotePairingTest(BluetoothBaseTest): + def setup_class(self): + super().setup_class() + self.dut = self.android_devices[0] + self.fugu_remote = self.relay_devices[0] + + def setup_test(self): + super(BluetoothBaseTest, self).setup_test() + self.fugu_remote.setup() + return True + + def teardown_test(self): + super(BluetoothBaseTest, self).teardown_test() + self.fugu_remote.clean_up() + return True + + @BluetoothBaseTest.bt_test_wrap + def test_pairing(self): + """Test pairing between a fugu device and a remote controller. + + Test the remote controller can be paired to fugu. + + Steps: + 1. Find the MAC address of remote controller from relay config file. + 2. Start the device paring process. + 3. Enable remote controller in pairing mode. + 4. Verify the remote is paired. + + Expected Result: + Remote controller is paired. + + Returns: + Pass if True + Fail if False + + TAGS: fugu + Priority: 1 + """ + + self.dut.droid.bluetoothStartPairingHelper(False) + self.fugu_remote.enter_pairing_mode() + self.dut.droid.bluetoothDiscoverAndBond(self.fugu_remote.mac_address) + + end_time = time.time() + 20 + self.dut.log.info("Verifying devices are bonded") + while time.time() < end_time: + bonded_devices = self.dut.droid.bluetoothGetBondedDevices() + + for d in bonded_devices: + if d['address'] == self.fugu_remote.mac_address: + self.dut.log.info("Successfully bonded to device.") + self.log.info("Fugu Bonded devices:\n{}".format( + bonded_devices)) + return True + # Timed out trying to bond. + self.dut.log.info("Failed to bond devices.") + + return False diff --git a/acts/tests/google/fugu/fugu_pairing_test.json b/acts/tests/google/fugu/fugu_pairing_test.json new file mode 100644 index 0000000000..59f45e35af --- /dev/null +++ b/acts/tests/google/fugu/fugu_pairing_test.json @@ -0,0 +1,39 @@ +{ + "_description": "Test configuration for Fugu pairing the remote controller", + "logpath": "/tmp/logs", + "testpaths": ["."], + "no_bug_report_on_fail": "True", + + "testbed": [ + { + "_description": "A testbed for RelayDevices", + "name": "7A18F48B", + "AndroidDevice": ["7A18F48B"], + "RelayDevice": "tests/google/fugu/relay.json" + }, + { + "_description": "A testbed for RelayDevices", + "name": "164FE498", + "AndroidDevice": ["164FE498"], + "RelayDevice": "tests/google/fugu/relay.json" + }, + { + "_description": "A testbed for RelayDevices", + "name": "B8B20856", + "AndroidDevice": ["B8B20856"], + "RelayDevice": "tests/google/fugu/relay.json" + }, + { + "_description": "A testbed for RelayDevices", + "name": "121A69F0", + "AndroidDevice": ["121A69F0"], + "RelayDevice": "tests/google/fugu/relay.json" + }, + { + "_description": "A testbed for RelayDevices", + "name": "BBDAC5ED", + "AndroidDevice": ["BBDAC5ED"], + "RelayDevice": "tests/google/fugu/relay.json" + } + ] +} diff --git a/acts/tests/google/fugu/relay.json b/acts/tests/google/fugu/relay.json new file mode 100644 index 0000000000..c3ab9db3d1 --- /dev/null +++ b/acts/tests/google/fugu/relay.json @@ -0,0 +1,21 @@ +{ + "boards": [ + { + "type": "SainSmartBoard", + "name": "ss0", + "base_url": "http://192.168.1.4/30000/" + } + ], + "devices": [ + { + "type": "FuguRemote", + "name": "Fugu0", + "mac_address" : "AC:9E:17:53:AC:3A", + "relays": { + "Play": "ss0/1", + "Home": "ss0/2", + "Back": "ss0/3" + } + } + ] +} diff --git a/acts/tests/google/instrumentation/power/camera/CapturePhotosTest.py b/acts/tests/google/instrumentation/power/camera/CapturePhotosTest.py new file mode 100644 index 0000000000..a99fd5d539 --- /dev/null +++ b/acts/tests/google/instrumentation/power/camera/CapturePhotosTest.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.power import instrumentation_power_test +from acts.test_utils.instrumentation.device.apps.dismiss_dialogs import \ + DialogDismissalUtil + + +class ImageCaptureTest(instrumentation_power_test.InstrumentationPowerTest): + """ + Test class for running instrumentation test CameraTests#testImageCapture. + """ + + def _prepare_device(self): + super()._prepare_device() + self.mode_airplane() + self.base_device_configuration() + self._dialog_util = DialogDismissalUtil( + self.ad_dut, + self.get_file_from_config('dismiss_dialogs_apk') + ) + self._dialog_util.dismiss_dialogs('GoogleCamera') + + def _cleanup_device(self): + self._dialog_util.close() + super()._cleanup_device() + + def test_capture_photos(self): + """Measures power during photo capture.""" + self.run_and_measure( + 'com.google.android.platform.powertests.CameraTests', + 'testImageCapture', req_params=['hdr_mode']) + self.validate_power_results() diff --git a/acts/tests/google/instrumentation/power/idle/DisplayAlwaysOnTest.py b/acts/tests/google/instrumentation/power/idle/DisplayAlwaysOnTest.py new file mode 100644 index 0000000000..b891b0cc45 --- /dev/null +++ b/acts/tests/google/instrumentation/power/idle/DisplayAlwaysOnTest.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.power import instrumentation_power_test +from acts.test_utils.instrumentation.device.command.adb_commands import common + + +class DisplayAlwaysOnTest(instrumentation_power_test.InstrumentationPowerTest): + """Test class for running instrumentation test DisplayAlwaysOn.""" + + def _prepare_device(self): + super()._prepare_device() + self.base_device_configuration() + self.adb_run(common.doze_mode.toggle(True)) + self.adb_run(common.doze_always_on.toggle(True)) + self.adb_run(common.disable_sensors) + + def test_display_always_on(self): + """Measures power when the device is rock bottom state plus display + always on (known as doze mode).""" + + self.run_and_measure( + 'com.google.android.platform.powertests.IdleTestCase', + 'testIdleScreenOff') + + self.validate_power_results() diff --git a/acts/tests/google/instrumentation/power/idle/PartialWakeLockTest.py b/acts/tests/google/instrumentation/power/idle/PartialWakeLockTest.py new file mode 100644 index 0000000000..973c0f9828 --- /dev/null +++ b/acts/tests/google/instrumentation/power/idle/PartialWakeLockTest.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.power import instrumentation_power_test + + +class PartialWakeLockTest(instrumentation_power_test.InstrumentationPowerTest): + """Test class for running instrumentation test PartialWakeLock.""" + + def _prepare_device(self): + super()._prepare_device() + self.base_device_configuration() + + def test_partial_wake_lock(self): + """Measures power when the device is idle with a partial wake lock.""" + self.run_and_measure( + 'com.google.android.platform.powertests.IdleTestCase', + 'testPartialWakelock') + self.validate_power_results() diff --git a/acts/tests/google/instrumentation/power/idle/RockBottomTest.py b/acts/tests/google/instrumentation/power/idle/RockBottomTest.py new file mode 100644 index 0000000000..43dd9f1a4c --- /dev/null +++ b/acts/tests/google/instrumentation/power/idle/RockBottomTest.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.power import instrumentation_power_test + + +class RockBottomTest(instrumentation_power_test.InstrumentationPowerTest): + """Test class for running instrumentation test RockBottom.""" + + def _prepare_device(self): + super()._prepare_device() + self.base_device_configuration() + + def test_rock_bottom(self): + """Measures power when the device is in a rock bottom state.""" + self.run_and_measure( + 'com.google.android.platform.powertests.IdleTestCase', + 'testIdleScreenOff') + self.validate_power_results() diff --git a/acts/tests/google/instrumentation/power/media/VideoPlaybackTest.py b/acts/tests/google/instrumentation/power/media/VideoPlaybackTest.py new file mode 100644 index 0000000000..9541f460d0 --- /dev/null +++ b/acts/tests/google/instrumentation/power/media/VideoPlaybackTest.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from acts.test_utils.instrumentation.power import instrumentation_power_test + +BIG_FILE_PUSH_TIMEOUT = 600 + + +class VideoPlaybackTest( + instrumentation_power_test.InstrumentationPowerTest): + """Test class for running instrumentation tests + VideoPlaybackHighBitRateTest.""" + + def _prepare_device(self): + super()._prepare_device() + self.base_device_configuration() + + def test_playback_high_bit_rate(self): + """Measures power when the device is in a rock bottom state.""" + video_location = self.push_to_external_storage( + self.get_file_from_config('high_bit_rate_video'), + timeout=BIG_FILE_PUSH_TIMEOUT) + self.trigger_scan_on_external_storage() + + self.run_and_measure( + 'com.google.android.platform.powertests.PhotosTests', + 'testVideoPlaybackThroughIntent', + extra_params=[('video_file_path', video_location)]) + + self.validate_power_results() diff --git a/acts/tests/google/native/NativeTest.py b/acts/tests/google/native/NativeTest.py new file mode 100644 index 0000000000..90ebceb28c --- /dev/null +++ b/acts/tests/google/native/NativeTest.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import time +from acts.base_test import BaseTestClass +from acts.test_utils.bt.native_bt_test_utils import setup_native_bluetooth +from acts.test_utils.bt.bt_test_utils import generate_id_by_size + +class NativeTest(BaseTestClass): + tests = None + + def __init__(self, controllers): + BaseTestClass.__init__(self, controllers) + self.tests = ( + "test_bool_return_true", + "test_bool_return_false", + "test_null_return", + "test_string_empty_return", + "test_max_param_size", + ) + + def setup_class(self): + super().setup_class() + self.droid = self.native_android_devices[0].droid + + def test_bool_return_true(self): + return self.droid.TestBoolTrueReturn() + + def test_bool_return_false(self): + return not self.droid.TestBoolFalseReturn() + + def test_null_return(self): + return not self.droid.TestNullReturn() + + def test_string_empty_return(self): + return self.droid.TestStringEmptyReturn() == "" + + def test_max_param_size(self): + json_buffer_size = 64 + max_sl4n_buffer_size = 4096 + test_string = "x" * (max_sl4n_buffer_size - json_buffer_size) + return test_string == self.droid.TestStringMaxReturn(test_string) + + def test_specific_param_naming(self): + a = [{"string_test":"test", "int_test":1}] + return self.droid.TestSpecificParamNaming(a) + diff --git a/acts/tests/google/native/bt/BtNativeTest.py b/acts/tests/google/native/bt/BtNativeTest.py new file mode 100644 index 0000000000..55674bcb42 --- /dev/null +++ b/acts/tests/google/native/bt/BtNativeTest.py @@ -0,0 +1,63 @@ +from acts.base_test import BaseTestClass +from acts.controllers import native_android_device +from acts.test_utils.bt.native_bt_test_utils import setup_native_bluetooth +from acts.test_utils.bt.bt_test_utils import generate_id_by_size + + +class BtNativeTest(BaseTestClass): + tests = None + + def __init__(self, controllers): + BaseTestClass.__init__(self, controllers) + self.tests = ( + "test_binder_get_name", + "test_binder_get_name_invalid_parameter", + "test_binder_set_name_get_name", + "test_binder_get_address", ) + + def setup_class(self): + setup_native_bluetooth(self.native_android_devices) + self.droid = self.native_android_devices[0].droid + if len(self.native_android_devices) > 1: + self.droid1 = self.native_android_devices[1].droid + self.tests = self.tests + ("test_two_devices_set_get_name", ) + + def test_binder_get_name(self): + result = self.droid.BtBinderGetName() + self.log.info("Bluetooth device name: {}".format(result)) + return True + + def test_binder_get_name_invalid_parameter(self): + try: + self.droid.BtBinderGetName("unexpected_parameter") + return False + except Exception: + return True + + def test_binder_set_name_get_name(self): + test_name = generate_id_by_size(4) + result = self.droid.BtBinderSetName(test_name) + if not result: + return False + name = self.droid.BtBinderGetName() + if test_name != name: + return False + return True + + def test_binder_get_address(self): + result = self.droid.BtBinderGetAddress() + self.log.info("Found BT address: {}".format(result)) + if not result: + return False + return True + + def test_two_devices_set_get_name(self): + test_name = generate_id_by_size(4) + for n in self.native_android_devices: + d = n.droid + d.BtBinderSetName(test_name) + name = d.BtBinderGetName() + if name != test_name: + return False + return True + diff --git a/acts/tests/google/nfc/NfcBasicFunctionalityTest.py b/acts/tests/google/nfc/NfcBasicFunctionalityTest.py new file mode 100644 index 0000000000..5d531d1931 --- /dev/null +++ b/acts/tests/google/nfc/NfcBasicFunctionalityTest.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python3.4 +# +# Copyright 2017 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import time + +from acts.base_test import BaseTestClass +from acts.test_decorators import test_tracker_info + + +class NfcBasicFunctionalityTest(BaseTestClass): + nfc_on_event = "NfcStateOn" + nfc_off_event = "NfcStateOff" + timeout = 5 + + def setup_class(self): + self.dut = self.android_devices[0] + self._ensure_nfc_enabled(self.dut) + self.dut.droid.nfcStartTrackingStateChange() + self.dut.adb.shell("setprop nfc.app_log_level 255") + self.dut.adb.shell("setprop nfc.enable_protocol_log 255") + self.dut.adb.shell("setprop nfc.nxp_log_level_global 5") + self.dut.adb.shell("setprop nfc.nxp_log_level_extns 5") + self.dut.adb.shell("setprop nfc.nxp_log_level_hal 5") + self.dut.adb.shell("setprop nfc.nxp_log_level_nci 5") + self.dut.adb.shell("setprop nfc.nxp_log_level_tml 5") + self.dut.adb.shell("setprop nfc.nxp_log_level_dnld 5") + self._ensure_nfc_disabled(self.dut) + return True + + def _ensure_nfc_enabled(self, dut): + end_time = time.time() + 10 + while end_time > time.time(): + try: + dut.ed.pop_event(self.nfc_on_event, self.timeout) + self.log.info("Event {} found".format(self.nfc_on_event)) + return True + except Exception as err: + self.log.debug( + "Event {} not yet found".format(self.nfc_on_event)) + return False + + def _ensure_nfc_disabled(self, dut): + end_time = time.time() + 10 + while end_time > time.time(): + try: + dut.ed.pop_event(self.nfc_off_event, self.timeout) + self.log.info("Event {} found".format(self.nfc_off_event)) + return True + except Exception as err: + self.log.debug( + "Event {} not yet found".format(self.nfc_off_event)) + return False + + def setup_test(self): + # Every test starts with the assumption that NFC is enabled + if not self.dut.droid.nfcIsEnabled(): + self.dut.droid.nfcEnable() + else: + return True + if not self._ensure_nfc_enabled(self.dut): + self.log.error("Failed to toggle NFC on") + return False + return True + + def on_fail(self, test_name, begin_time): + self.dut.take_bug_report(test_name, begin_time) + + @test_tracker_info(uuid='d57fcdd8-c56c-4ab0-81fb-e2218b100de9') + def test_nfc_toggle_state_100_iterations(self): + """Test toggling NFC state 100 times. + + Verify that NFC toggling works. Test assums NFC is on. + + Steps: + 1. Toggle NFC off + 2. Toggle NFC on + 3. Repeat steps 1-2 100 times. + + Expected Result: + RFCOMM connection is established then disconnected succcessfully. + + Returns: + Pass if True + Fail if False + + TAGS: NFC + Priority: 1 + """ + iterations = 100 + for i in range(iterations): + self.log.info("Starting iteration {}".format(i + 1)) + self.dut.droid.nfcDisable() + if not self._ensure_nfc_disabled(self.dut): + return False + self.dut.droid.nfcEnable() + if not self._ensure_nfc_enabled(self.dut): + return False + return True diff --git a/acts/tests/google/usb/UsbTetheringFunctionsTest.py b/acts/tests/google/usb/UsbTetheringFunctionsTest.py new file mode 100644 index 0000000000..3f0393ba01 --- /dev/null +++ b/acts/tests/google/usb/UsbTetheringFunctionsTest.py @@ -0,0 +1,419 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re +import time +from queue import Empty + +from acts import utils +from acts import base_test +from acts.libs.proc import job +from acts import signals +from acts.test_decorators import test_tracker_info +from acts.test_utils.wifi import wifi_test_utils as wutils +from acts.test_utils.tel import tel_test_utils as tutils +from acts.test_utils.tel import tel_defines +from acts.test_utils.tel.anritsu_utils import wait_for_sms_sent_success +from acts.test_utils.tel.tel_defines import EventMmsSentSuccess + +# Time it takes for the usb tethering IP to +# show up in ifconfig and function waiting. +DEFAULT_SETTLE_TIME = 5 +WifiEnums = wutils.WifiEnums +USB_CHARGE_MODE = 'svc usb setFunctions' +USB_TETHERING_MODE = 'svc usb setFunctions rndis' +USB_MTP_MODE = 'svc usb setFunctions mtp' +DEVICE_IP_ADDRESS = 'ip address' + + +class UsbTetheringFunctionsTest(base_test.BaseTestClass): + """Tests for usb tethering throughput test. + + Test Bed Requirement: + * One Android device. + * Wi-Fi networks visible to the device. + * Sim card with data call. + """ + + def setup_class(self): + self.dut = self.android_devices[0] + req_params = ['wifi_network', 'receiver_number', 'ping_count'] + self.unpack_userparams(req_param_names=req_params) + + self.ssid_map = {} + for network in self.wifi_network: + SSID = network['SSID'].replace('-', '_') + self.ssid_map[SSID] = network + self.dut.droid.setMobileDataEnabled() + if not tutils.verify_internet_connection( + self.dut.log, self.dut, retries=3): + tutils.abort_all_tests(self.dut.log, 'Internet connection Failed.') + + def setup_test(self): + self.dut.droid.wakeLockAcquireBright() + self.dut.droid.wakeUpNow() + self.dut.unlock_screen() + + def teardown_test(self): + wutils.wifi_toggle_state(self.dut, False) + self.dut.droid.wakeLockRelease() + self.dut.droid.goToSleepNow() + self.dut.droid.setMobileDataEnabled() + self.dut.droid.connectivityStopTethering(tel_defines.TETHERING_WIFI) + self.dut.stop_services() + # Set usb function back to charge mode. + self.dut.adb.shell(USB_CHARGE_MODE) + self.dut.adb.wait_for_device() + self.dut.start_services() + + def teardown_class(self): + wutils.reset_wifi(self.dut) + + def on_fail(self, test_name, begin_time): + self.dut.take_bug_report(test_name, begin_time) + self.dut.cat_adb_log(test_name, begin_time) + + def enable_usb_tethering(self, attempts=3): + """Stop SL4A service and enable usb tethering. + + Logic steps are + 1. Stop SL4A service. + 2. Enable usb tethering. + 3. Restart SL4A service. + 4. Check usb tethering enabled. + 5. Attempt if fail to enable usb tethering. + + Args: + attempts: number of times for enable usb tethering. + + Raises: + TestFailure when unable to find rndis string. + """ + for i in range(attempts): + self.dut.stop_services() + self.dut.adb.shell(USB_TETHERING_MODE, ignore_status=True) + self.dut.adb.wait_for_device() + self.dut.start_services() + if 'rndis' in self.dut.adb.shell(DEVICE_IP_ADDRESS): + self.log.info('Usb tethering is enabled.') + return + else: + self.log.info('Enable usb tethering - attempt %d' % (i + 1)) + raise signals.TestFailure('Unable to enable USB tethering.') + + def connect_to_wifi_network(self, network): + """Connection logic for wifi network. + + Args: + network: Dictionary with network info. + """ + SSID = network[WifiEnums.SSID_KEY] + self.dut.ed.clear_all_events() + wutils.start_wifi_connection_scan(self.dut) + scan_results = self.dut.droid.wifiGetScanResults() + wutils.assert_network_in_list({WifiEnums.SSID_KEY: SSID}, scan_results) + wutils.wifi_connect(self.dut, network, num_of_tries=3) + + def enable_wifi_hotspot(self): + """Enable wifi hotspot.""" + sap_config = wutils.create_softap_config() + wutils.start_wifi_tethering(self.dut, + sap_config[wutils.WifiEnums.SSID_KEY], + sap_config[wutils.WifiEnums.PWD_KEY], + wutils.WifiEnums.WIFI_CONFIG_APBAND_2G) + + def get_rndis_interface(self): + """Check rndis interface after usb tethering enable. + + Returns: + Usb tethering interface from Android device. + + Raises: + TestFailure when unable to find correct usb tethering interface. + """ + time.sleep(DEFAULT_SETTLE_TIME) + check_usb_tethering = job.run('ifconfig').stdout + # A regex that stores the tethering interface in group 1. + tethered_interface_regex = r'^(enp.*?):.*?broadcast 192.168.42.255' + match = re.search(tethered_interface_regex, check_usb_tethering, + re.DOTALL + re.MULTILINE) + if match: + return match.group(1) + else: + raise signals.TestFailure( + 'Unable to find tethering interface. The device may not be tethered.' + ) + + def can_ping(self, ip, extra_params='', count=10): + """Run ping test and check and check ping lost rate. + + Args: + ip: ip address for ping. + extra_params: params for ping test. + count: default ping count. + + Returns: + True: If no packet loss. + False: Otherwise. + """ + out = job.run( + 'ping -c {} {} {}'.format(count, extra_params, ip), + ignore_status=True).stdout + self.log.info(out) + return '0%' in out.split(' ') + + def can_ping_through_usb_interface(self): + """Run ping test and check result after usb tethering enabled. + + Raises: + TestFailure when unable to ping through usb tethering interface. + """ + ip = '8.8.8.8' + interface = self.get_rndis_interface() + if not self.can_ping( + ip, '-I {}'.format(interface), count=self.ping_count): + raise signals.TestFailure( + 'Fail to ping through usb tethering interface.') + + def enable_usb_mtp(self): + """Enable usb mtp mode. + + Raises: + TestFailure when unable to set mtp mode. + """ + try: + self.dut.stop_services() + self.dut.adb.shell(USB_MTP_MODE, ignore_status=True) + self.dut.adb.wait_for_device() + self.dut.start_services() + except: + raise signals.TestFailure('Device can not enable mtp mode.') + + def check_sms_send_status(self, message='usb_sms_test'): + """Send a SMS and check send status. + + Args: + message: SMS string. + + Raises: + Exception when unable to send SMS. + """ + self.dut.droid.smsSendTextMessage(self.receiver_number, message, False) + self.log.info('Waiting for SMS sent event') + test_status = wait_for_sms_sent_success(self.log, self.dut) + if not test_status: + raise Exception('Failed to send SMS') + + def check_mms_send_status(self, + subject='usb_subject', + message='usb_mms_test'): + """Send a MMS and check send status. + + Args: + subject: MMS subject. + message: MMS string. + + Raises: + Exception when unable to send MMS. + """ + # Permission require for send MMS. + self.dut.adb.shell('su root setenforce 0') + self.dut.droid.smsSendMultimediaMessage(self.receiver_number, subject, + message) + self.log.info('Waiting for MMS sent event') + test_status = self.wait_for_mms_sent_success() + if not test_status: + raise Exception('Failed to send MMS') + + def wait_for_mms_sent_success(self, time_to_wait=60): + """Check MMS send status. + + Args: + time_to_wait: Time out for check MMS. + + Returns: + status = MMS send status. + """ + mms_sent_event = EventMmsSentSuccess + try: + event = self.dut.ed.pop_event(mms_sent_event, time_to_wait) + self.log.info(event) + except Empty: + self.log.error('Timeout: Expected event is not received.') + return False + return True + + @test_tracker_info(uuid="7c2ae85e-32a2-416e-a65e-c15a15e76f86") + def test_usb_tethering_wifi_only(self): + """Enable usb tethering with wifi only then executing ping test. + + Steps: + 1. Stop SL4A services. + 2. Enable usb tethering. + 3. Restart SL4A services. + 4. Mobile data disable and wifi enable. + 5. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + self.log.info('Disable mobile data.') + self.dut.droid.setMobileDataEnabled(False) + self.log.info('Enable wifi.') + wutils.wifi_toggle_state(self.dut, True) + self.connect_to_wifi_network( + self.ssid_map[self.wifi_network[0]['SSID']]) + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="8910b07b-0beb-4d9d-b901-c4195b4e0930") + def test_usb_tethering_data_only(self): + """Enable usb tethering with data only then executing ping test. + + Steps: + 1. Stop SL4A services. + 2. Enable usb tethering. + 3. Restart SL4A services. + 4. Wifi disable and mobile data enable. + 5. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + wutils.wifi_toggle_state(self.dut, False) + self.dut.droid.setMobileDataEnabled() + time.sleep(DEFAULT_SETTLE_TIME) + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="f971806e-e003-430a-bc80-321f128d31cb") + def test_usb_tethering_after_airplane_mode(self): + """Enable usb tethering after airplane mode then executing ping test. + + Steps: + 1. Stop SL4A services. + 2. Enable usb tethering. + 3. Restart SL4A services. + 4. Wifi disable and mobile data enable. + 5. Enable/disable airplane mode. + 6. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + wutils.wifi_toggle_state(self.dut, False) + self.log.info('Enable airplane mode.') + utils.force_airplane_mode(self.dut, True) + self.log.info('Disable airplane mode.') + utils.force_airplane_mode(self.dut, False) + time.sleep(DEFAULT_SETTLE_TIME) + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="db1c561d-67bd-47d7-b65e-d882f0e2641e") + def test_usb_tethering_coexist_wifi_hotspot(self): + """Enable usb tethering with hotspot then executing ping test. + + Steps: + 1. Enable hotspot + 2. Stop SL4A services. + 3. Enable usb tethering. + 4. Restart SL4A services. + 5. Run ping test through tethering interface during hotspot enable. + 6. Run ping test through tethering interface during hotspot disable. + """ + self.log.info('Enable wifi hotspot.') + self.enable_wifi_hotspot() + self.enable_usb_tethering() + self.log.info('Ping test with hotspot enable.') + self.can_ping_through_usb_interface() + self.log.info('Disable wifi hotspot.') + self.dut.droid.connectivityStopTethering(tel_defines.TETHERING_WIFI) + self.log.info('Ping test with hotspot disable.') + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="7018abdb-049e-41aa-a4f9-e11012369d9b") + def test_usb_tethering_after_mtp(self): + """Enable usb tethering after mtp enable then executing ping test. + + Steps: + 1. Stop SL4A services. + 2. Enable usb tethering. + 3. Restart SL4A services. + 4. Enable usb mtp mode. + 5. Enable usb tethering and mtp will disable. + 6. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + self.log.info('Enable usb mtp mode.') + self.enable_usb_mtp() + # Turn on mtp mode for 5 sec. + time.sleep(DEFAULT_SETTLE_TIME) + self.enable_usb_tethering() + self.log.info('Usb tethering enable, usb mtp mode disabled.') + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="f1ba2cbc-1cb2-4b8a-92eb-9b366c3f4c37") + def test_usb_tethering_after_sms_mms(self): + """Enable usb tethering after send sms and mms then executing ping test. + + Steps: + 1. Stop SL4A services. + 2. Enable usb tethering. + 3. Restart SL4A services. + 4. Send a sms and mms. + 5. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + self.log.info('Start send SMS and check status.') + self.check_sms_send_status() + time.sleep(DEFAULT_SETTLE_TIME) + self.log.info('Start send MMS and check status.') + self.check_mms_send_status() + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="e6586b30-4886-4c3e-8225-633aa9333968") + def test_usb_tethering_after_reboot(self): + """Enable usb tethering after reboot then executing ping test. + + Steps: + 1. Reboot device. + 2. Stop SL4A services. + 3. Enable usb tethering. + 4. Restart SL4A services. + 5. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + self.log.info('Reboot device.') + self.dut.reboot() + self.dut.droid.setMobileDataEnabled() + self.log.info('Start usb tethering and ping test.') + self.enable_usb_tethering() + self.can_ping_through_usb_interface() + + @test_tracker_info(uuid="40093ab8-6db4-4af4-97ae-9467bf33bf23") + def test_usb_tethering_after_wipe(self): + """Enable usb tethering after wipe. + + Steps: + 1. Enable usb tethering. + 2. Wipe device. + 3. Wake up device and unlock screen. + 4. Enable usb tethering. + 5. Run ping test through usb tethering interface. + """ + self.enable_usb_tethering() + tutils.fastboot_wipe(self.dut) + time.sleep(DEFAULT_SETTLE_TIME) + # Skip setup wizard after wipe. + self.dut.adb.shell( + 'am start -a com.android.setupwizard.EXIT', ignore_status=True) + self.dut.droid.setMobileDataEnabled() + self.dut.droid.wakeUpNow() + self.dut.unlock_screen() + self.enable_usb_tethering() + self.can_ping_through_usb_interface()
\ No newline at end of file diff --git a/acts/tests/google/usb/UsbTetheringThroughputTest.py b/acts/tests/google/usb/UsbTetheringThroughputTest.py new file mode 100644 index 0000000000..ebe13b8529 --- /dev/null +++ b/acts/tests/google/usb/UsbTetheringThroughputTest.py @@ -0,0 +1,292 @@ +#!/usr/bin/env python3 +# +# Copyright 2019 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import re +import time + +from acts import base_test +from acts.libs.proc import job +from acts import signals +from acts.test_decorators import test_tracker_info + +# Time it takes for the usb tethering IP to show up in ifconfig. +IFCONFIG_SETTLE_TIME = 5 +USB_CHARGE_MODE = 'svc usb setFunctions' +USB_TETHERING_MODE = 'svc usb setFunctions rndis' +DEVICE_IP_ADDRESS = 'ip address' + + +class UsbTetheringThroughputTest(base_test.BaseTestClass): + """Tests for usb tethering throughput test. + + Test Bed Requirement: + * One Android device. + * Sim card with data call. + """ + + def setup_class(self): + """ Setup devices for usb tethering """ + self.dut = self.android_devices[0] + self.ip_server = self.iperf_servers[0] + self.port_num = self.ip_server.port + req_params = [ + 'iperf_usb_3_criteria', 'iperf_usb_2_criteria', 'controller_path', + 'iperf_test_sec' + ] + self.unpack_userparams(req_param_names=req_params) + if self.dut.model in self.user_params.get('legacy_projects', []): + self.usb_controller_path = self.user_params[ + 'legacy_controller_path'] + else: + self.usb_controller_path = self.controller_path + + def setup_test(self): + self.dut.adb.wait_for_device() + self.dut.droid.wakeLockAcquireBright() + self.dut.droid.wakeUpNow() + self.dut.unlock_screen() + + def teardown_test(self): + self.dut.droid.wakeLockRelease() + self.dut.droid.goToSleepNow() + # Reboot device to avoid the side effect that cause adb missing after echo usb speed. + self.dut.reboot() + + def on_fail(self, test_name, begin_time): + self.dut.take_bug_report(test_name, begin_time) + self.dut.cat_adb_log(test_name, begin_time) + + def enable_usb_tethering(self): + """Stop SL4A service and enable usb tethering. + + Logic steps are + 1. Stop SL4A service. + 2. Enable usb tethering. + 3. Restart SL4A service. + 4. Check usb tethering enabled. + + Raises: + Signals.TestFailure is raised by not find rndis string. + """ + self.dut.stop_services() + self.dut.adb.shell(USB_TETHERING_MODE, ignore_status=True) + self.dut.adb.wait_for_device() + self.dut.start_services() + if 'rndis' not in self.dut.adb.shell(DEVICE_IP_ADDRESS): + raise signals.TestFailure('Unable to enable USB tethering.') + + def get_pc_tethering_ip(self): + """Check usb tethering IP from PC. + + Returns: + Usb tethering IP from PC. + + Raises: + Signals.TestFailure is raised by not find usb tethering IP. + """ + time.sleep(IFCONFIG_SETTLE_TIME) + check_usb_tethering = job.run('ifconfig').stdout + matches = re.findall('inet (\d+.\d+.42.\d+)', check_usb_tethering) + if not matches: + raise signals.TestFailure( + 'Unable to find tethering IP. The device may not be tethered.') + else: + return matches[0] + + def get_dut_tethering_ip(self): + """Check usb tethering IP from Android device. + + Returns: + Usb tethering IP from Android device. + + Raises: + Signals.TestFailure is raised by not find usb tethering IP. + """ + time.sleep(IFCONFIG_SETTLE_TIME) + check_usb_tethering = self.dut.adb.shell('ifconfig') + matches = re.findall('addr:(\d+.\d+.42.\d+)', check_usb_tethering) + if not matches: + raise signals.TestFailure( + 'Unable to find tethering IP. The device may not be tethered.') + else: + return matches[0] + + def pc_can_ping(self, count=3): + """Run ping traffic from PC side. + + Logic steps are + 1. PC ping the usb server ip. + 2. Check the packet loss rate. + + Args: + count : count for ping test. + + Returns: + True: If no packet loss. + False: Otherwise. + """ + ip = self.get_dut_tethering_ip() + ping = job.run( + 'ping -c {} {}'.format(count, ip), ignore_status=True).stdout + self.log.info(ping) + return '0% packet loss' in ping + + def dut_can_ping(self, count=3): + """Run ping traffic from Android device side. + + Logic steps are + 1. Android device ping the 8.8.8.8. + 2. Check the packet loss rate. + + Args: + count : count for ping test. + + Returns: + True: If no packet loss. + False: Otherwise. + """ + ip = '8.8.8.8' + ping = self.dut.adb.shell( + 'ping -c {} {}'.format(count, ip), ignore_status=True) + self.log.info(ping) + return '0% packet loss' in ping + + def run_iperf_client(self, dut_ip, extra_params=''): + """Run iperf client command after iperf server enabled. + + Args: + dut_ip: string which contains the ip address. + extra_params: params to be added to the iperf client. + + Returns: + Success: True if the iperf execute. False otherwise. + Rate: throughput data. + """ + self.log.info('Run iperf process.') + cmd = "iperf3 -c {} {} -p {}".format(dut_ip, extra_params, + self.port_num) + self.log.info(cmd) + try: + result = self.dut.adb.shell(cmd, ignore_status=True) + self.log.info(result) + except: + self.log.error('Fail to execute iperf client.') + return False, 0 + rate = re.findall('(\d+.\d+) (.)bits/sec.*receiver', result) + return True, rate[0][0], rate[0][1] + + def run_iperf_tx_rx(self, usb_speed, criteria): + """Run iperf tx and rx. + + Args: + usb_speed: string which contains the speed info. + criteria: usb performance criteria. + + Raises: + Signals.TestFailure is raised by usb tethering under criteria. + """ + self.enable_usb_tethering() + self.dut.adb.wait_for_device() + self.ip_server.start() + pc_ip = self.get_pc_tethering_ip() + tx_success, tx_rate, tx_unit = self.run_iperf_client( + pc_ip, '-t{} -i1 -w2M'.format(self.iperf_test_sec)) + rx_success, rx_rate, rx_unit = self.run_iperf_client( + pc_ip, '-t{} -i1 -w2M -R'.format(self.iperf_test_sec)) + self.log.info('TestResult iperf_{}_rx'.format(usb_speed) + rx_rate + + ' ' + rx_unit + 'bits/sec') + self.log.info('TestResult iperf_{}_tx'.format(usb_speed) + tx_rate + + ' ' + tx_unit + 'bits/sec') + self.ip_server.stop() + if not tx_success or (float(tx_rate) < criteria and tx_unit != "G"): + raise signals.TestFailure('Iperf {}_tx test is {} {}bits/sec, ' + 'the throughput result failed.'.format( + usb_speed, tx_rate, tx_unit)) + if not rx_success or (float(rx_rate) < criteria and rx_unit != "G"): + raise signals.TestFailure('Iperf {}_rx test is {} {}bits/sec, ' + 'the throughput result failed.'.format( + usb_speed, rx_rate, rx_unit)) + + def get_usb_speed(self): + """Get current usb speed.""" + usb_controller_address = self.dut.adb.shell( + 'getprop sys.usb.controller', ignore_status=True) + usb_speed = self.dut.adb.shell( + 'cat sys/class/udc/{}/current_speed'.format( + usb_controller_address)) + return usb_speed, usb_controller_address + + @test_tracker_info(uuid="e7e0dfdc-3d1c-4642-a468-27326c49e4cb") + def test_tethering_ping(self): + """Enable usb tethering then executing ping test. + + Steps: + 1. Stop SL4A service. + 2. Enable usb tethering. + 3. Restart SL4A service. + 4. Execute ping test from PC and Android Device. + 5. Check the ping lost rate. + """ + self.enable_usb_tethering() + if self.pc_can_ping() and self.dut_can_ping(): + raise signals.TestPass( + 'Ping test is passed. Network is reachable.') + raise signals.TestFailure( + 'Ping test failed. Maybe network is unreachable.') + + @test_tracker_info(uuid="8263c880-8a7e-4a68-b47f-e7caba3e9968") + def test_usb_tethering_iperf_super_speed(self): + """Enable usb tethering then executing iperf test. + + Steps: + 1. Stop SL4A service. + 2. Enable usb tethering. + 3. Restart SL4A service. + 4. Skip test if device not support super-speed. + 5. Execute iperf test for usb tethering and get the throughput result. + 6. Check the iperf throughput result. + """ + if (self.get_usb_speed()[0] != 'super-speed'): + raise signals.TestSkip( + 'USB 3 not available for the device, skip super-speed performance test.' + ) + self.run_iperf_tx_rx('usb_3', self.iperf_usb_3_criteria) + + @test_tracker_info(uuid="5d8a22fd-1f9b-4758-a6b4-855d134b348a") + def test_usb_tethering_iperf_high_speed(self): + """Enable usb tethering then executing iperf test. + + Steps: + 1. Stop SL4A service. + 2. Enable usb tethering. + 3. Restart SL4A service. + 4. Force set usb speed to high-speed if default is super-speed. + 5. Execute iperf test for usb tethering and get the throughput result. + 6. Check the iperf throughput result. + """ + if (self.get_usb_speed()[0] != 'high-speed'): + self.log.info( + 'Default usb speed is USB 3,Force set usb to high-speed.') + self.dut.stop_services() + self.dut.adb.wait_for_device() + self.dut.adb.shell( + 'echo high > {}{}.ssusb/speed'.format( + self.usb_controller_path, + self.get_usb_speed()[1].strip('.dwc3')), + ignore_status=True) + self.dut.adb.wait_for_device() + self.dut.start_services() + self.run_iperf_tx_rx('usb_2', self.iperf_usb_2_criteria) diff --git a/acts/tests/google/wifi/p2p/functional/WifiP2pMultiPeersTest.py b/acts/tests/google/wifi/p2p/functional/WifiP2pMultiPeersTest.py new file mode 100644 index 0000000000..2951be6355 --- /dev/null +++ b/acts/tests/google/wifi/p2p/functional/WifiP2pMultiPeersTest.py @@ -0,0 +1,266 @@ +#!/usr/bin/env python3 +# +# Copyright 2020 - The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import acts.test_utils.wifi.wifi_test_utils as wutils +import acts.utils +import time + +from acts import asserts +from acts import utils + +from acts.test_decorators import test_tracker_info +from acts.test_utils.wifi import wifi_test_utils as wutils +from acts.test_utils.wifi.p2p.WifiP2pBaseTest import WifiP2pBaseTest +from acts.test_utils.wifi.p2p import wifi_p2p_test_utils as wp2putils +from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts + +WPS_PBC = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC +WPS_DISPLAY = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_DISPLAY +WPS_KEYPAD = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_KEYPAD + +WifiEnums = wutils.WifiEnums + + +class WifiP2pMultiPeersTest(WifiP2pBaseTest): + """Tests for multiple clients. + + Test Bed Requirement: + * 3 Android devices for each test in this class. + """ + def __init__(self, controllers): + WifiP2pBaseTest.__init__(self, controllers) + + def setup_test(self): + WifiP2pBaseTest.setup_test(self) + asserts.skip_if( + len(self.android_devices) < 3, + "No enough android devices. Skip this test") + + def form_group(self, dut1, dut2, isReconnect=False, wpsType=WPS_PBC): + # Request the connection to create a group + wp2putils.p2p_connect(dut1, dut2, isReconnect, wpsType) + + if wp2putils.is_go(dut1): + go_dut = dut1 + gc_dut = dut2 + elif wp2putils.is_go(dut2): + go_dut = dut2 + gc_dut = dut1 + return (go_dut, gc_dut) + + def verify_group_connection(self, group_clients): + for gc in group_clients: + go_ip = wp2putils.p2p_go_ip(gc) + wp2putils.p2p_connection_ping_test(gc, go_ip) + + def clear_all_events(self, duts): + for dut in duts: + dut.ed.clear_all_events() + + def check_disconnection(self, duts): + for dut in duts: + wp2putils.check_disconnect(dut) + + """Test Cases""" + @test_tracker_info(uuid="20cd4f4d-fe7d-4ee2-a832-33caa5b9700b") + def test_p2p_multi_clients_group_removal_behavior(self): + """Verify the p2p group removal behavior + + Steps: + 1. form a group between 3 peers + 2. verify their connection + 3. disconnect + 4. form a group between 3 peers + 5. trigger disconnect from GO + 6. check the group is removed + 7. form a group between 3 peers + 8. trigger disconnect from a GC + 9. check the group is still alive + 10. disconnect + """ + all_duts = [self.dut1, self.dut2, self.dut3] + + # the 1st round + (go_dut, gc_dut) = self.form_group(self.dut1, self.dut2) + gc2_dut = self.dut3 + wp2putils.p2p_connect(gc2_dut, + go_dut, + False, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_JOIN) + + self.verify_group_connection([gc_dut, gc2_dut]) + + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + self.check_disconnection([gc_dut, gc2_dut]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + # the 2nd round + self.log.info("Reconnect test, triggered by GO") + self.clear_all_events(all_duts) + + self.form_group(go_dut, gc_dut, isReconnect=True) + wp2putils.p2p_connect(gc2_dut, + go_dut, + True, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_JOIN) + + # trigger disconnect from GO, the group is destroyed and all + # client are disconnected. + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + self.check_disconnection([gc_dut, gc2_dut]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + # the 3rd round + self.log.info("Reconnect test, triggered by GC") + self.clear_all_events(all_duts) + + self.form_group(go_dut, gc_dut, isReconnect=True) + wp2putils.p2p_connect(gc2_dut, + go_dut, + True, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_JOIN) + + # trigger disconnect from GC, the group is still there. + gc_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(gc_dut) + self.verify_group_connection([ + gc2_dut, + ]) + + # all clients are disconnected, the group is removed. + wp2putils.p2p_disconnect(gc2_dut) + self.check_disconnection([ + go_dut, + ]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + @test_tracker_info(uuid="6ea6e802-df62-4ae2-aa15-44c3267fd99b") + def test_p2p_connect_with_p2p_and_join_go(self): + """Verify the invitation from GC + + Steps: + 1. form a group between 2 peers + 2. gc joins the group via go + 2. verify their connection + 3. disconnect + """ + all_duts = [self.dut1, self.dut2, self.dut3] + + (go_dut, gc_dut) = self.form_group(self.dut1, self.dut2) + gc2_dut = self.dut3 + wp2putils.p2p_connect(gc2_dut, + go_dut, + False, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_JOIN) + + self.verify_group_connection([gc_dut, gc2_dut]) + + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + self.check_disconnection([gc_dut, gc2_dut]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + @test_tracker_info(uuid="e00469a4-93b7-44dd-8a5e-5d317e0e9333") + def test_p2p_connect_with_p2p_and_legacy_client(self): + """Verify the invitation from GC + + Steps: + 1. form a group between 2 peers + 2. gc joins the group via go + 2. verify their connection + 3. disconnect + """ + all_duts = [self.dut1, self.dut2, self.dut3] + + (go_dut, gc_dut) = self.form_group(self.dut1, self.dut2) + gc2_dut = self.dut3 + + group = wp2putils.p2p_get_current_group(go_dut) + network = { + WifiEnums.SSID_KEY: group['NetworkName'], + WifiEnums.PWD_KEY: group['Passphrase'] + } + wutils.start_wifi_connection_scan_and_ensure_network_found( + gc2_dut, group['NetworkName']) + wutils.wifi_connect(gc2_dut, network, num_of_tries=3) + + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + @test_tracker_info(uuid="bd53cc18-bcc7-4e27-b78b-1506f5c098c5") + def test_p2p_connect_with_p2p_and_go_invite_peer(self): + """Verify the invitation from GC + + Steps: + 1. form a group between 2 peers + 2. gc joins the group via go + 2. verify their connection + 3. disconnect + """ + all_duts = [self.dut1, self.dut2, self.dut3] + + (go_dut, gc_dut) = self.form_group(self.dut1, self.dut2) + gc2_dut = self.dut3 + wp2putils.p2p_connect( + go_dut, + gc2_dut, + False, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_INVITATION, + go_ad=go_dut) + + self.verify_group_connection([gc_dut, gc2_dut]) + + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + self.check_disconnection([gc_dut, gc2_dut]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + @test_tracker_info(uuid="4d6e666d-dc48-4881-86c1-5d7cec5e2571") + def test_p2p_connect_with_p2p_and_gc_invite_peer(self): + """Verify the invitation from GC + + Steps: + 1. form a group between 2 peers + 2. gc joins the group via go + 2. verify their connection + 3. disconnect + """ + all_duts = [self.dut1, self.dut2, self.dut3] + + (go_dut, gc_dut) = self.form_group(self.dut1, self.dut2) + gc2_dut = self.dut3 + wp2putils.p2p_connect( + gc_dut, + gc2_dut, + False, + WPS_PBC, + p2p_connect_type=p2pconsts.P2P_CONNECT_INVITATION, + go_ad=go_dut) + + self.verify_group_connection([gc_dut, gc2_dut]) + + go_dut.log.info("Trigger disconnection") + wp2putils.p2p_disconnect(go_dut) + self.check_disconnection([gc_dut, gc2_dut]) + time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) diff --git a/acts_tests/tests/OWNERS b/acts_tests/tests/OWNERS index 4b455a459c..c07c1cff8d 100644 --- a/acts_tests/tests/OWNERS +++ b/acts_tests/tests/OWNERS @@ -10,6 +10,7 @@ dvj@google.com gmoturu@google.com mrtyler@google.com codycaldwell@google.com +chaoyangf@google.com # Pixel GTW jasonkmlu@google.com @@ -27,7 +28,7 @@ abhinavjadon@google.com djfernan@google.com iguarna@google.com jingliang@google.com -klug@google.com +yixiang@google.com oelayach@google.com qijiang@google.com sriramsundar@google.com diff --git a/acts_tests/tests/google/ble/api/BleAdvertiseApiTest.py b/acts_tests/tests/google/ble/api/BleAdvertiseApiTest.py index 26c459f70a..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/api/BleAdvertiseApiTest.py +++ b/acts_tests/tests/google/ble/api/BleAdvertiseApiTest.py @@ -1,1273 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See thea -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script to exercise Ble Advertisement Api's. This exercises all getters and -setters. This is important since there is a builder object that is immutable -after you set all attributes of each object. If this test suite doesn't pass, -then other test suites utilising Ble Advertisements will also fail. -""" - -from acts.controllers.sl4a_lib import rpc_client -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_test_utils import adv_fail -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import java_integer - - -class BleAdvertiseVerificationError(Exception): - """Error in fetsching BleScanner Advertise result.""" - - -class BleAdvertiseApiTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.ad_dut = self.android_devices[0] - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d6d8d0a6-7b3e-4e4b-a5d0-bcfd6e207474') - def test_adv_settings_defaults(self): - """Tests the default advertisement settings. - - This builder object should have a proper "get" expectation for each - attribute of the builder object once it's built. - - Steps: - 1. Build a new advertise settings object. - 2. Get the attributes of the advertise settings object. - 3. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 0 - """ - test_result = True - droid = self.ad_dut.droid - adv_settings = droid.bleBuildAdvertiseSettings() - adv_mode = droid.bleGetAdvertiseSettingsMode(adv_settings) - tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel( - adv_settings) - is_connectable = droid.bleGetAdvertiseSettingsIsConnectable( - adv_settings) - - exp_adv_mode = ble_advertise_settings_modes['low_power'] - exp_tx_power_level = ble_advertise_settings_tx_powers['medium'] - exp_is_connectable = True - if adv_mode != exp_adv_mode: - test_result = False - self.log.debug("exp filtering mode: {}," - " found filtering mode: {}".format( - exp_adv_mode, adv_mode)) - if tx_power_level != exp_tx_power_level: - test_result = False - self.log.debug("exp tx power level: {}," - " found filtering tx power level: {}".format( - exp_tx_power_level, tx_power_level)) - if exp_is_connectable != is_connectable: - test_result = False - self.log.debug("exp is connectable: {}," - " found filtering is connectable: {}".format( - exp_is_connectable, is_connectable)) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f2a276ae-1436-43e4-aba7-1ede787200ee') - def test_adv_data_defaults(self): - """Tests the default advertisement data. - - This builder object should have a proper "get" expectation for each - attribute of the builder object once it's built. - - Steps: - 1. Build a new AdvertiseData object. - 2. Get the attributes of the advertise settings object. - 3. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 0 - """ - test_result = True - droid = self.ad_dut.droid - adv_data = droid.bleBuildAdvertiseData() - service_uuids = droid.bleGetAdvertiseDataServiceUuids(adv_data) - include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel( - adv_data) - include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName( - adv_data) - - exp_service_uuids = [] - exp_include_tx_power_level = False - exp_include_device_name = False - self.log.debug("Step 4: Verify all defaults match exp values.") - if service_uuids != exp_service_uuids: - test_result = False - self.log.debug("exp filtering service uuids: {}," - " found filtering service uuids: {}".format( - exp_service_uuids, service_uuids)) - if include_tx_power_level != exp_include_tx_power_level: - test_result = False - self.log.debug( - "exp filtering include tx power level:: {}," - " found filtering include tx power level: {}".format( - exp_include_tx_power_level, include_tx_power_level)) - if include_device_name != exp_include_device_name: - test_result = False - self.log.debug( - "exp filtering include tx power level: {}," - " found filtering include tx power level: {}".format( - exp_include_device_name, include_device_name)) - if not test_result: - self.log.debug("Some values didn't match the defaults.") - else: - self.log.debug("All default values passed.") - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8d462e60-6b4e-49f3-9ef4-5a8b612d285d') - def test_adv_settings_set_adv_mode_balanced(self): - """Tests advertise settings balanced mode. - - This advertisement settings from "set" advertisement mode should match - the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to balanced. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['balanced'] - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_adv_mode)) - return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='334fefeb-365f-4ee3-9be0-42b1fabe3178') - def test_adv_settings_set_adv_mode_low_power(self): - """Tests advertise settings low power mode. - - This advertisement settings from "set" advertisement mode should match - the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to low power mode. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['low_power'] - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_adv_mode)) - return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ce087782-1535-4694-944a-e962c22638ed') - def test_adv_settings_set_adv_mode_low_latency(self): - """Tests advertise settings low latency mode. - - This advertisement settings from "set" advertisement mode should match - the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to low latency mode. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_mode = ble_advertise_settings_modes['low_latency'] - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_adv_mode)) - return self.verify_adv_settings_adv_mode(droid, exp_adv_mode) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='59b52be9-d38b-4814-af08-c68aa8910a16') - def test_adv_settings_set_invalid_adv_mode(self): - """Tests advertise settings invalid advertising mode. - - This advertisement settings from "set" advertisement mode should fail - when setting an invalid advertisement. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to -1. - - Expected Result: - Building the advertise settings should fail. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 2 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_mode = -1 - self.log.debug("Step 2: Set the filtering mode to -1") - return self.verify_invalid_adv_settings_adv_mode(droid, exp_adv_mode) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d8292633-831f-41c4-974a-ad267e9795e9') - def test_adv_settings_set_adv_tx_power_level_high(self): - """Tests advertise settings tx power level high. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to tx power level high. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['high'] - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_adv_tx_power)) - return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d577de1f-4fd9-43d5-beff-c0696c5e0ea1') - def test_adv_settings_set_adv_tx_power_level_medium(self): - """Tests advertise settings tx power level medium. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to tx power level medium. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - test_result = True - droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['medium'] - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_adv_tx_power)) - return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') - def test_adv_settings_set_adv_tx_power_level_low(self): - """Tests advertise settings tx power level low. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to tx power level low. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_tx_power = (ble_advertise_settings_tx_powers['low']) - self.log.debug( - "Step 2: Set the filtering settings object's value to ".format( - exp_adv_tx_power)) - return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') - def test_adv_settings_set_adv_tx_power_level_ultra_low(self): - """Tests advertise settings tx power level ultra low. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise mode attribute to tx power level ultra low. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_tx_power = ble_advertise_settings_tx_powers['ultra_low'] - self.log.debug( - "Step 2: Set the filtering settings object's value to ".format( - exp_adv_tx_power)) - return self.verify_adv_settings_tx_power_level(droid, exp_adv_tx_power) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e972f8b5-a3cf-4b3f-9223-a8a74c0fd855') - def test_adv_settings_set_invalid_adv_tx_power_level(self): - """Tests advertise settings invalid advertising tx power level. - - This advertisement settings from "set" advertisement mode should fail - when setting an invalid advertisement. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise tx power level attribute to -1. - - Expected Result: - Building the advertise settings should fail. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_adv_tx_power = -1 - self.log.debug("Step 2: Set the filtering mode to -1") - return self.verify_invalid_adv_settings_tx_power_level( - droid, exp_adv_tx_power) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1be71f77-64af-42b7-84cb-e06df0836966') - def test_adv_settings_set_is_connectable_true(self): - """Tests advertise settings is connectable true. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise is connectable to true. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_is_connectable = True - self.log.debug( - "Step 2: Set the filtering settings object's value to {}".format( - exp_is_connectable)) - return self.verify_adv_settings_is_connectable(droid, - exp_is_connectable) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f9865333-9198-4385-938d-5fc641ee9968') - def test_adv_settings_set_is_connectable_false(self): - """Tests advertise settings is connectable false. - - This advertisement settings from "set" advertisement tx power level - should match the corresponding "get" function. - - Steps: - 1. Build a new advertise settings object. - 2. Set the advertise is connectable to false. - 3. Get the attributes of the advertise settings object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_is_connectable = False - self.log.debug("Step 2: Set the filtering settings object's value to " - + str(exp_is_connectable)) - return self.verify_adv_settings_is_connectable(droid, - exp_is_connectable) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a770ed7e-c6cd-4533-8876-e42e68f8b4fb') - def test_adv_data_set_service_uuids_empty(self): - """Tests advertisement data's service uuids to empty. - - This advertisement data from "set" advertisement service uuid - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service uuid to empty. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_uuids = [] - self.log.debug("Step 2: Set the filtering data object's value to " + - str(exp_service_uuids)) - return self.verify_adv_data_service_uuids(droid, exp_service_uuids) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3da511db-d024-45c8-be3c-fe8e123129fa') - def test_adv_data_set_service_uuids_single(self): - """Tests advertisement data's service uuids to empty. - - This advertisement data from "set" advertisement service uuid - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service uuid to empty. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_uuids = ["00000000-0000-1000-8000-00805f9b34fb"] - self.log.debug("Step 2: Set the filtering data object's value to " + - str(exp_service_uuids)) - return self.verify_adv_data_service_uuids(droid, exp_service_uuids) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='15073359-d607-4a76-b60a-00a4b34f9a85') - def test_adv_data_set_service_uuids_multiple(self): - """Tests advertisement data's service uuids to multiple uuids. - - This advertisement data from "set" advertisement service uuid - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service uuid to multiple uuids. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_uuids = [ - "00000000-0000-1000-8000-00805f9b34fb", - "00000000-0000-1000-8000-00805f9b34fb" - ] - self.log.debug("Step 2: Set the filtering data object's value to " + - str(exp_service_uuids)) - return self.verify_adv_data_service_uuids(droid, exp_service_uuids) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='af783a71-ef80-4974-a077-16a4ed8f0114') - def test_adv_data_set_service_uuids_invalid_uuid(self): - """Tests advertisement data's service uuids to an invalid uuid. - - This advertisement data from "set" advertisement service uuid - should fail when there is an invalid service uuid. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service uuid to an invalid uuid. - - Expected Result: - Building the AdvertiseData should fail. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_uuids = ["0"] - self.log.debug("Step 2: Set the filtering data service uuids to " + - str(exp_service_uuids)) - return self.verify_invalid_adv_data_service_uuids( - droid, exp_service_uuids) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='51d634e7-6271-4cc0-a57b-3c1b632a7db6') - def test_adv_data_set_service_data(self): - """Tests advertisement data's service data. - - This advertisement data from "set" advertisement service data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service data. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb" - exp_service_data = [1, 2, 3] - self.log.debug( - "Step 2: Set the filtering data object's service data uuid to: {}, " - "service data: {}".format(exp_service_data_uuid, exp_service_data)) - return self.verify_adv_data_service_data(droid, exp_service_data_uuid, - exp_service_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='aa18b0af-2a41-4b2a-af64-ea639961d561') - def test_adv_data_set_service_data_invalid_service_data(self): - """Tests advertisement data's invalid service data. - - This advertisement data from "set" advertisement service data - should fail on an invalid value. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service data to an invalid value. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_data_uuid = "00000000-0000-1000-8000-00805f9b34fb" - exp_service_data = "helloworld" - self.log.debug( - "Step 2: Set the filtering data object's service data uuid to: {}, " - "service data: {}".format(exp_service_data_uuid, exp_service_data)) - return self.verify_invalid_adv_data_service_data( - droid, exp_service_data_uuid, exp_service_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='13a75a47-eff4-429f-a436-d244bbfe4496') - def test_adv_data_set_service_data_invalid_service_data_uuid(self): - """Tests advertisement data's invalid service data and uuid. - - This advertisement data from "set" advertisement service data - should fail on an invalid value. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's service data and uuid to an invalid value. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_service_data_uuid = "0" - exp_service_data = "1,2,3" - self.log.debug( - "Step 2: Set the filtering data object's service data uuid to: {}, " - "service data: {}".format(exp_service_data_uuid, exp_service_data)) - return self.verify_invalid_adv_data_service_data( - droid, exp_service_data_uuid, exp_service_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='386024e2-212e-4eed-8ef3-43d0c0239ea5') - def test_adv_data_set_manu_id(self): - """Tests advertisement data's manufacturers data and id. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's manufacturers data and id. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_manu_id = 0 - exp_manu_specific_data = [1, 2, 3] - self.log.debug( - "Step 2: Set the filtering data object's service data manu id: {}" - ", manu specific data: {}".format(exp_manu_id, - exp_manu_specific_data)) - return self.verify_adv_data_manu_id(droid, exp_manu_id, - exp_manu_specific_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='650ceff2-2760-4a34-90fb-e637a2c5ebb5') - def test_adv_data_set_manu_id_invalid_manu_id(self): - """Tests advertisement data's manufacturers invalid id. - - This advertisement data from "set" advertisement manufacturers data - should not be successful on an invalid id. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's manufacturers id to -1. - 3. Build the advertisement data. - - Expected Result: - Building the advertisement data should fail. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_manu_id = -1 - exp_manu_specific_data = [1, 2, 3] - self.log.debug( - "Step 2: Set the filtering data object's service data manu id: {}" - ", manu specific data: {}".format(exp_manu_id, - exp_manu_specific_data)) - return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id, - exp_manu_specific_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='27ccd7d7-9cd2-4e95-8198-ef6ca746d1cc') - def test_adv_data_set_manu_id_invalid_manu_specific_data(self): - """Tests advertisement data's manufacturers invalid specific data. - - This advertisement data from "set" advertisement manufacturers data - should not be successful on an invalid specific data. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's manufacturers specific data to helloworld. - 3. Build the advertisement data. - - Expected Result: - Building the advertisement data should fail. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_manu_id = 0 - exp_manu_specific_data = ['helloworld'] - self.log.debug( - "Step 2: Set the filtering data object's service data manu id: {}" - ", manu specific data: {}".format(exp_manu_id, - exp_manu_specific_data)) - return self.verify_invalid_adv_data_manu_id(droid, exp_manu_id, - exp_manu_specific_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8e78d444-cd25-4c17-9532-53972a6f0ffe') - def test_adv_data_set_manu_id_max(self): - """Tests advertisement data's manufacturers id to the max size. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's manufacturers id to JavaInterger.MAX value. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 3 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_manu_id = java_integer['max'] - exp_manu_specific_data = [1, 2, 3] - self.log.debug( - "Step 2: Set the filtering data object's service data manu id: {}" - ", manu specific data: {}".format(exp_manu_id, - exp_manu_specific_data)) - return self.verify_adv_data_manu_id(droid, exp_manu_id, - exp_manu_specific_data) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6c4866b7-ddf5-44ef-a231-0af683c6db80') - def test_adv_data_set_include_tx_power_level_true(self): - """Tests advertisement data's include tx power level to True. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's include tx power level to True. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_include_tx_power_level = True - self.log.debug( - "Step 2: Set the filtering data object's include tx power level: " - "{}".format(exp_include_tx_power_level)) - return self.verify_adv_data_include_tx_power_level( - droid, exp_include_tx_power_level) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='db06cc5f-60cf-4f04-b0fe-0c354f987541') - def test_adv_data_set_include_tx_power_level_false(self): - """Tests advertisement data's include tx power level to False. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's include tx power level to False. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_include_tx_power_level = False - self.log.debug( - "Step 2: Set the filtering data object's include tx power level: {}" - .format(exp_include_tx_power_level)) - return self.verify_adv_data_include_tx_power_level( - droid, exp_include_tx_power_level) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e99480c4-fd37-4791-a8d0-7eb8f8f72d62') - def test_adv_data_set_include_device_name_true(self): - """Tests advertisement data's include device name to True. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's include device name to True. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - droid = self.ad_dut.droid - exp_include_device_name = True - self.log.debug( - "Step 2: Set the filtering data object's include device name: {}" - .format(exp_include_device_name)) - return self.verify_adv_data_include_device_name( - droid, exp_include_device_name) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b89ed642-c426-4777-8217-7bb8c2058592') - def test_adv_data_set_include_device_name_false(self): - """Tests advertisement data's include device name to False. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's include device name to False. - 3. Get the attributes of the AdvertiseData object. - 4. Compare the attributes found against the attributes exp. - - Expected Result: - Found attributes should match expected attributes. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - self.log.debug("Step 1: Setup environment.") - test_result = True - droid = self.ad_dut.droid - exp_include_device_name = False - self.log.debug( - "Step 2: Set the filtering data object's include device name: {}". - format(exp_include_device_name)) - return self.verify_adv_data_include_device_name( - droid, exp_include_device_name) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5033bcf5-a841-4b8b-af35-92c7237c7b36') - def test_advertisement_greater_than_31_bytes(self): - """Tests advertisement data's size to be greater than 31 bytes. - - This advertisement data from "set" advertisement manufacturers data - should match the corresponding "get" function. - - Steps: - 1. Build a new AdvertiseData object. - 2. Set the AdvertiseData's size to be greater than 31 bytes - 3. Build the advertisement data. - - Expected Result: - Api fails to build the AdvertiseData. - - Returns: - True is pass - False if fail - - TAGS: LE, Advertising - Priority: 1 - """ - test_result = True - droid = self.ad_dut.droid - ed = self.android_devices[0].ed - service_data = [] - for i in range(25): - service_data.append(i) - droid.bleAddAdvertiseDataServiceData( - "0000110D-0000-1000-8000-00805F9B34FB", service_data) - advcallback, adv_data, adv_settings = generate_ble_advertise_objects( - droid) - droid.bleStartBleAdvertising(advcallback, adv_data, adv_settings) - try: - ed.pop_event(adv_fail.format(advcallback)) - except rpc_client.Sl4aApiError: - self.log.info("{} event was not found.".format( - adv_fail.format(advcallback))) - return False - return test_result - - def verify_adv_settings_adv_mode(self, droid, exp_adv_mode): - try: - droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering settings object's index.") - settings_index = droid.bleBuildAdvertiseSettings() - self.log.debug("Step 4: Get the filtering setting's filtering mode.") - adv_mode = droid.bleGetAdvertiseSettingsMode(settings_index) - if exp_adv_mode is not adv_mode: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_adv_mode, adv_mode)) - return False - self.log.debug("Advertise Setting's filtering mode {} value " - "test Passed.".format(exp_adv_mode)) - return True - - def verify_adv_settings_tx_power_level(self, droid, exp_adv_tx_power): - try: - droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering settings object's index.") - settings_index = droid.bleBuildAdvertiseSettings() - self.log.debug("Step 4: Get the filtering setting's tx power level.") - adv_tx_power_level = droid.bleGetAdvertiseSettingsTxPowerLevel( - settings_index) - if exp_adv_tx_power is not adv_tx_power_level: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_adv_tx_power, adv_tx_power_level)) - return False - self.log.debug("Advertise Setting's tx power level {}" - " value test Passed.".format(exp_adv_tx_power)) - return True - - def verify_adv_settings_is_connectable(self, droid, exp_is_connectable): - try: - droid.bleSetAdvertiseSettingsIsConnectable(exp_is_connectable) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering settings object's index.") - settings_index = droid.bleBuildAdvertiseSettings() - self.log.debug( - "Step 4: Get the filtering setting's is connectable value.") - is_connectable = droid.bleGetAdvertiseSettingsIsConnectable( - settings_index) - if exp_is_connectable is not is_connectable: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_is_connectable, is_connectable)) - return False - self.log.debug("Advertise Setting's is connectable {}" - " value test Passed.".format(exp_is_connectable)) - return True - - def verify_adv_data_service_uuids(self, droid, exp_service_uuids): - try: - droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering data object's index.") - data_index = droid.bleBuildAdvertiseData() - self.log.debug("Step 4: Get the filtering data's service uuids.") - service_uuids = droid.bleGetAdvertiseDataServiceUuids(data_index) - if exp_service_uuids != service_uuids: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_service_uuids, service_uuids)) - return False - self.log.debug( - "Advertise Data's service uuids {}, value test Passed.".format( - exp_service_uuids)) - return True - - def verify_adv_data_service_data(self, droid, exp_service_data_uuid, - exp_service_data): - try: - droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid, - exp_service_data) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering data object's index.") - data_index = droid.bleBuildAdvertiseData() - self.log.debug("Step 4: Get the filtering data's service data.") - service_data = droid.bleGetAdvertiseDataServiceData( - data_index, exp_service_data_uuid) - if exp_service_data != service_data: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_service_data, service_data)) - return False - self.log.debug("Advertise Data's service data uuid: {}, service data: " - "{}, value test Passed.".format(exp_service_data_uuid, - exp_service_data)) - return True - - def verify_adv_data_manu_id(self, droid, exp_manu_id, - exp_manu_specific_data): - try: - droid.bleAddAdvertiseDataManufacturerId(exp_manu_id, - exp_manu_specific_data) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering data object's index.") - data_index = droid.bleBuildAdvertiseData() - self.log.debug("Step 5: Get the filtering data's manu specific data.") - manu_specific_data = droid.bleGetAdvertiseDataManufacturerSpecificData( - data_index, exp_manu_id) - if exp_manu_specific_data != manu_specific_data: - self.log.debug("exp value: " + str(exp_manu_specific_data) + - ", Actual value: " + str(manu_specific_data)) - return False - self.log.debug("Advertise Data's manu id: " + str(exp_manu_id) + - ", manu's specific data: " + - str(exp_manu_specific_data) + " value test Passed.") - return True - - def verify_adv_data_include_tx_power_level(self, droid, - exp_include_tx_power_level): - try: - droid.bleSetAdvertiseDataIncludeTxPowerLevel( - exp_include_tx_power_level) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering settings object's index.") - data_index = droid.bleBuildAdvertiseData() - self.log.debug( - "Step 4: Get the filtering data's include tx power level.") - include_tx_power_level = droid.bleGetAdvertiseDataIncludeTxPowerLevel( - data_index) - if exp_include_tx_power_level is not include_tx_power_level: - self.log.debug("exp value: " + str(exp_include_tx_power_level) + - ", Actual value: " + str(include_tx_power_level)) - return False - self.log.debug("Advertise Setting's include tx power level " + str( - exp_include_tx_power_level) + " value test Passed.") - return True - - def verify_adv_data_include_device_name(self, droid, - exp_include_device_name): - try: - droid.bleSetAdvertiseDataIncludeDeviceName(exp_include_device_name) - except BleAdvertiseVerificationError as error: - self.log.debug(str(error)) - return False - self.log.debug("Step 3: Get a filtering settings object's index.") - data_index = droid.bleBuildAdvertiseData() - self.log.debug("Step 4: Get the filtering data's include device name.") - include_device_name = droid.bleGetAdvertiseDataIncludeDeviceName( - data_index) - if exp_include_device_name is not include_device_name: - self.log.debug("exp value: {}, Actual value: {}".format( - exp_include_device_name, include_device_name)) - return False - self.log.debug("Advertise Setting's include device name {}" - " value test Passed.".format(exp_include_device_name)) - return True - - def verify_invalid_adv_settings_adv_mode(self, droid, exp_adv_mode): - try: - droid.bleSetAdvertiseSettingsAdvertiseMode(exp_adv_mode) - droid.bleBuildAdvertiseSettings() - self.log.debug("Set Advertise settings invalid filtering mode " - "passed with input as {}".format(exp_adv_mode)) - return False - except rpc_client.Sl4aApiError: - self.log.debug( - "Set Advertise settings invalid filtering mode " - "failed successfully with input as {}".format(exp_adv_mode)) - return True - - def verify_invalid_adv_settings_tx_power_level(self, droid, - exp_adv_tx_power): - try: - droid.bleSetAdvertiseSettingsTxPowerLevel(exp_adv_tx_power) - droid.bleBuildAdvertiseSettings() - self.log.debug("Set Advertise settings invalid tx power level " + - " with input as {}".format(exp_adv_tx_power)) - return False - except rpc_client.Sl4aApiError: - self.log.debug( - "Set Advertise settings invalid tx power level " - "failed successfullywith input as {}".format(exp_adv_tx_power)) - return True - - def verify_invalid_adv_data_service_uuids(self, droid, exp_service_uuids): - try: - droid.bleSetAdvertiseDataSetServiceUuids(exp_service_uuids) - droid.bleBuildAdvertiseData() - self.log.debug("Set Advertise Data service uuids " + - " with input as {}".format(exp_service_uuids)) - return False - except rpc_client.Sl4aApiError: - self.log.debug( - "Set Advertise Data invalid service uuids failed " - "successfully with input as {}".format(exp_service_uuids)) - return True - - def verify_invalid_adv_data_service_data( - self, droid, exp_service_data_uuid, exp_service_data): - try: - droid.bleAddAdvertiseDataServiceData(exp_service_data_uuid, - exp_service_data) - droid.bleBuildAdvertiseData() - self.log.debug("Set Advertise Data service data uuid: {}," - ", service data: {}".format(exp_service_data_uuid, - exp_service_data)) - return False - except rpc_client.Sl4aApiError: - self.log.debug("Set Advertise Data service data uuid: " + - str(exp_service_data_uuid) + ", service data: " + - str(exp_service_data) + " failed successfully.") - return True - - def verify_invalid_adv_data_manu_id(self, droid, exp_manu_id, - exp_manu_specific_data): - try: - droid.bleAddAdvertiseDataManufacturerId(exp_manu_id, - exp_manu_specific_data) - droid.bleBuildAdvertiseData() - self.log.debug( - "Set Advertise Data manu id: " + str(exp_manu_id) + - ", manu specific data: " + str(exp_manu_specific_data)) - return False - except rpc_client.Sl4aApiError: - self.log.debug("Set Advertise Data manu id: {}," - " manu specific data: {},".format( - exp_manu_id, exp_manu_specific_data)) - return True diff --git a/acts_tests/tests/google/ble/api/BleScanApiTest.py b/acts_tests/tests/google/ble/api/BleScanApiTest.py index 06f2362079..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/api/BleScanApiTest.py +++ b/acts_tests/tests/google/ble/api/BleScanApiTest.py @@ -1,1296 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script to exercise Ble Scan Api's. This exercises all getters and -setters. This is important since there is a builder object that is immutable -after you set all attributes of each object. If this test suite doesn't pass, -then other test suites utilising Ble Scanner will also fail. -""" - -from acts.controllers.sl4a_lib import rpc_client -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_result_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_report_delay_milli_seconds -from acts.test_utils.bt.bt_constants import ble_uuids - - -class BleScanResultsError(Exception): - """Error in getting scan results""" - - -class BleScanVerificationError(Exception): - """Error in comparing BleScan results""" - - -class BleSetScanSettingsError(Exception): - """Error in setting Ble Scan Settings""" - - -class BleSetScanFilterError(Exception): - """Error in setting Ble Scan Settings""" - - -class BleScanApiTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.ad_dut = self.android_devices[0] - - def _format_defaults(self, input): - """ - Creates a dictionary of default ScanSetting and ScanFilter Values. - :return: input: dict - """ - if 'ScanSettings' not in input.keys(): - input['ScanSettings'] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - if 'ScanFilterManufacturerDataId' not in input.keys(): - input['ScanFilterManufacturerDataId'] = -1 - if 'ScanFilterDeviceName' not in input.keys(): - input['ScanFilterDeviceName'] = None - if 'ScanFilterDeviceAddress' not in input.keys(): - input['ScanFilterDeviceAddress'] = None - if 'ScanFilterManufacturerData' not in input.keys(): - input['ScanFilterManufacturerData'] = None - return input - - def validate_scan_settings_helper(self, input, droid): - """ - Validates each input of the scan settings object that is matches what - was set or not set such that it matches the defaults. - :return: False at any point something doesn't match. True if everything - matches. - """ - filter_list = droid.bleGenFilterList() - if 'ScanSettings' in input.keys(): - try: - droid.bleSetScanSettingsCallbackType(input['ScanSettings'][0]) - droid.bleSetScanSettingsReportDelayMillis( - input['ScanSettings'][1]) - droid.bleSetScanSettingsScanMode(input['ScanSettings'][2]) - droid.bleSetScanSettingsResultType(input['ScanSettings'][3]) - except rpc_client.Sl4aApiError as error: - self.log.debug("Set Scan Settings failed with: ".format(error)) - return False - if 'ScanFilterDeviceName' in input.keys(): - try: - droid.bleSetScanFilterDeviceName(input['ScanFilterDeviceName']) - except rpc_client.Sl4aApiError as error: - self.log.debug("Set Scan Filter Device Name failed with: {}" - .format(error)) - return False - if 'ScanFilterDeviceAddress' in input.keys(): - try: - droid.bleSetScanFilterDeviceAddress( - input['ScanFilterDeviceAddress']) - except rpc_client.Sl4aApiError as error: - self.log.debug("Set Scan Filter Device Address failed with: {}" - .format(error)) - return False - if ('ScanFilterManufacturerDataId' in input.keys() - and 'ScanFilterManufacturerDataMask' in input.keys()): - try: - droid.bleSetScanFilterManufacturerData( - input['ScanFilterManufacturerDataId'], - input['ScanFilterManufacturerData'], - input['ScanFilterManufacturerDataMask']) - except rpc_client.Sl4aApiError as error: - self.log.debug("Set Scan Filter Manufacturer info with data " - "mask failed with: {}".format(error)) - return False - if ('ScanFilterManufacturerDataId' in input.keys() - and 'ScanFilterManufacturerData' in input.keys() - and 'ScanFilterManufacturerDataMask' not in input.keys()): - try: - droid.bleSetScanFilterManufacturerData( - input['ScanFilterManufacturerDataId'], - input['ScanFilterManufacturerData']) - except rpc_client.Sl4aApiError as error: - self.log.debug( - "Set Scan Filter Manufacturer info failed with: " - "{}".format(error)) - return False - if ('ScanFilterServiceUuid' in input.keys() - and 'ScanFilterServiceMask' in input.keys()): - - droid.bleSetScanFilterServiceUuid(input['ScanFilterServiceUuid'], - input['ScanFilterServiceMask']) - - input = self._format_defaults(input) - scan_settings_index = droid.bleBuildScanSetting() - scan_settings = ( - droid.bleGetScanSettingsCallbackType(scan_settings_index), - droid.bleGetScanSettingsReportDelayMillis(scan_settings_index), - droid.bleGetScanSettingsScanMode(scan_settings_index), - droid.bleGetScanSettingsScanResultType(scan_settings_index)) - - scan_filter_index = droid.bleBuildScanFilter(filter_list) - device_name_filter = droid.bleGetScanFilterDeviceName( - filter_list, scan_filter_index) - device_address_filter = droid.bleGetScanFilterDeviceAddress( - filter_list, scan_filter_index) - manufacturer_id = droid.bleGetScanFilterManufacturerId( - filter_list, scan_filter_index) - manufacturer_data = droid.bleGetScanFilterManufacturerData( - filter_list, scan_filter_index) - - if scan_settings != input['ScanSettings']: - self.log.debug("Scan Settings did not match. expected: {}, found: " - "{}".format(input['ScanSettings'], scan_settings)) - return False - if device_name_filter != input['ScanFilterDeviceName']: - self.log.debug("Scan Filter device name did not match. expected: " - "{}, found {}".format(input['ScanFilterDeviceName'], - device_name_filter)) - return False - if device_address_filter != input['ScanFilterDeviceAddress']: - self.log.debug( - "Scan Filter address name did not match. expected: " - "{}, found: {}".format(input['ScanFilterDeviceAddress'], - device_address_filter)) - return False - if manufacturer_id != input['ScanFilterManufacturerDataId']: - self.log.debug("Scan Filter manufacturer data id did not match. " - "expected: {}, found: {}".format( - input['ScanFilterManufacturerDataId'], - manufacturer_id)) - return False - if manufacturer_data != input['ScanFilterManufacturerData']: - self.log.debug("Scan Filter manufacturer data did not match. " - "expected: {}, found: {}".format( - input['ScanFilterManufacturerData'], - manufacturer_data)) - return False - if 'ScanFilterManufacturerDataMask' in input.keys(): - manufacturer_data_mask = droid.bleGetScanFilterManufacturerDataMask( - filter_list, scan_filter_index) - if manufacturer_data_mask != input['ScanFilterManufacturerDataMask']: - self.log.debug( - "Manufacturer data mask did not match. expected:" - " {}, found: {}".format( - input['ScanFilterManufacturerDataMask'], - manufacturer_data_mask)) - - return False - if ('ScanFilterServiceUuid' in input.keys() - and 'ScanFilterServiceMask' in input.keys()): - - expected_service_uuid = input['ScanFilterServiceUuid'] - expected_service_mask = input['ScanFilterServiceMask'] - service_uuid = droid.bleGetScanFilterServiceUuid( - filter_list, scan_filter_index) - service_mask = droid.bleGetScanFilterServiceUuidMask( - filter_list, scan_filter_index) - if service_uuid != expected_service_uuid.lower(): - self.log.debug("Service uuid did not match. expected: {}, " - "found {}".format(expected_service_uuid, - service_uuid)) - return False - if service_mask != expected_service_mask.lower(): - self.log.debug("Service mask did not match. expected: {}, " - "found {}".format(expected_service_mask, - service_mask)) - return False - self.scan_settings_index = scan_settings_index - self.filter_list = filter_list - self.scan_callback = droid.bleGenScanCallback() - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5ffc9f7b-c261-4bf0-9a6b-7fda182b6c97') - def test_start_ble_scan_with_default_settings(self): - """Test LE scan with default settings. - - Test to validate all default scan settings values. - - Steps: - 1. Create LE scan objects. - 2. Start LE scan. - - Expected Result: - Scan starts successfully and matches expected settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='88c3b0cb-b4d4-45d1-be25-9855290a6d03') - def test_stop_ble_scan_default_settings(self): - """Test stopping an LE scan. - - Test default scan settings on an actual scan. Verify it can also stop - the scan. - - Steps: - 1. Validate default scan settings. - 2. Start ble scan. - 3. Stop ble scan. - - Expected Result: - LE scan is stopped successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 0 - """ - input = {} - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - if not test_result: - self.log.error("Could not setup ble scanner.") - return test_result - self.ad_dut.droid.bleStartBleScan( - self.filter_list, self.scan_settings_index, self.scan_callback) - try: - self.ad_dut.droid.bleStopBleScan(self.scan_callback) - except BleScanResultsError as error: - self.log.error(str(error)) - test_result = False - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5aa7a4c2-0b7d-4000-a980-f00c9329a7b9') - def test_scan_settings_callback_type_all_matches(self): - """Test LE scan settings callback type all matches. - - Test scan settings callback type all matches. - - Steps: - 1. Validate the scan settings callback type with all other settings set - to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fd764861-aa76-480e-b2d2-5d55a888d123') - def test_scan_settings_set_callback_type_first_match(self): - """Test LE scan settings callback type first match - - Test scan settings callback type first match. - - Steps: - 1. Validate the scan settings callback type with all other settings set - to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['first_match'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='52e4626e-199c-4755-b9f1-8b38ecb30896') - def test_scan_settings_set_callback_type_match_lost(self): - """Test LE scan settings callback type match lost. - - Test scan settings callback type match lost. - - Steps: - 1. Validate the scan settings callback type with all other settings set - to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['match_lost'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='57476b3c-ba7a-4342-86f6-1b56b2c00181') - def test_scan_settings_set_invalid_callback_type(self): - """Test LE scan settings invalid callback type. - - Test scan settings invalid callback type -1. - - Steps: - 1. Build a LE ScanSettings object with an invalid callback type. - - Expected Result: - Api should fail to build object. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input["ScanSettings"] = (-1, 0, ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - return not test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='52c80f0c-4f26-4cda-8a6b-291ac52f673a') - def test_scan_settings_set_scan_mode_low_power(self): - """Test LE scan settings scan mode low power mode. - - Test scan settings scan mode low power. - - Steps: - 1. Validate the scan settings scan mode with all other settings set to - their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='20f4513c-44a7-435d-be4e-03420093297a') - def test_scan_settings_set_scan_mode_balanced(self): - """Test LE scan settings scan mode balanced. - - Test scan settings scan mode balanced. - - Steps: - 1. Validate the scan settings scan mode with all other settings set to - their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['balanced'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='bf14e7fd-853b-4833-8fef-8c4bd629374b') - def test_scan_settings_set_scan_mode_low_latency(self): - """Test LE scan settings scan mode low latency. - - Test scan settings scan mode low latency. - - Steps: - 1. Validate the scan settings scan mode with all other settings set to - their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_latency'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9f3b2e10-98f8-4d6a-b6b6-e8dee87063f0') - def test_scan_settings_set_invalid_scan_mode(self): - """Test LE scan settings scan mode as an invalid value. - Test scan settings invalid scan mode -2. - Steps: - 1. Set the scan settings scan mode to -2. - - Expected Result: - Building the ScanSettings object should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, -2, - ble_scan_settings_result_types['full']) - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cb246be7-4fef-4313-964d-5fb6dbe558c8') - def test_scan_settings_set_report_delay_millis_min(self): - """Test scan settings report delay millis as min value - - Test scan settings report delay millis min acceptable value. - - Steps: - 1. Validate the scan settings report delay millis with all other - settings set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'], - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='db1ea8f6-503d-4e9a-b61a-01210508c5a2') - def test_scan_settings_set_report_delay_millis_min_plus_one(self): - """Test scan settings report delay millis as min value plus one. - - Test scan settings report delay millis as min value plus one. - - Steps: - 1. Validate the scan settings report delay millis with all other - settings set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 4 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'] + 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='54e83ff8-92b0-473e-839a-1ff1c7dcea83') - def test_scan_settings_set_report_delay_millis_max(self): - """Test scan settings report delay millis as max value. - - Test scan settings report delay millis max value. - - Steps: - 1. Validate the scan settings report delay millis with all other - settings set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 3 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['max'], - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='45d918ec-7e43-463b-8f07-f009f8808903') - def test_scan_settings_set_report_delay_millis_max_minus_one(self): - """Test scan settings report delay millis as max value minus one. - - Test scan settings report delay millis max value - 1. - - Steps: - 1. Validate the scan settings report delay millis with all other - settings set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 3 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['max'] - 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='eb94b5ee-f2e7-4322-b3df-7bdd3a250262') - def test_scan_settings_set_invalid_report_delay_millis_min_minus_one(self): - """Test scan settings report delay millis as an invalid value. - - Test scan settings invalid report delay millis min value - 1. - - Steps: - 1. Set scan settings report delay millis to min value -1. - 2. Build scan settings object. - - Expected Result: - Building scan settings object should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - droid = self.ad_dut.droid - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], - ble_scan_settings_report_delay_milli_seconds['min'] - 1, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return not self.validate_scan_settings_helper(input, droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8f5a2bd0-6037-4ac6-a962-f11e7fc13920') - def test_scan_settings_set_scan_result_type_full(self): - """Test scan settings result type full. - - Test scan settings result type full. - - Steps: - 1. Validate the scan settings result type with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['full']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='610fe301-600e-443e-a28b-cd722cc8a4c1') - def test_scan_settings_set_scan_result_type_abbreviated(self): - """Test scan settings result type abbreviated. - - Test scan settings result type abbreviated. - - Steps: - 1. Validate the scan settings result type with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], - ble_scan_settings_result_types['abbreviated']) - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ed58430b-8180-472f-a118-64f5fce5e84c') - def test_scan_settings_set_invalid_scan_result_type(self): - """Test scan settings result type as an invalid value. - - Test scan settings invalid result type -1. - - Steps: - 1. Set scan settings result type as an invalid value. - 2. Build scan settings object. - - Expected Result: - Expected Scan settings should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input["ScanSettings"] = ( - ble_scan_settings_callback_types['all_matches'], 0, - ble_scan_settings_modes['low_power'], -1) - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6489665f-313d-4b1b-bd7f-f0fdeeaad335') - def test_scan_filter_set_device_name(self): - """Test scan filter set valid device name. - - Test scan filter device name sl4atest. - - Steps: - 1. Validate the scan filter device name with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan settings. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input['ScanFilterDeviceName'] = "sl4atest" - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='76021a9a-14ca-4a2f-a908-96ab90db39ce') - def test_scan_filter_set_device_name_blank(self): - """Test scan filter set blank device name. - - Test scan filter device name blank. - - Steps: - 1. Validate the scan filter device name with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - droid = self.ad_dut.droid - input = {} - input['ScanFilterDeviceName'] = "" - return self.validate_scan_settings_helper(input, droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d77c3d81-43a9-4572-a99b-87969117ede5') - def test_scan_filter_set_device_name_special_chars(self): - """Test scan filter set device name as special chars. - - Test scan filter device name special characters. - - Steps: - 1. Validate the scan filter device name with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input['ScanFilterDeviceName'] = "!@#$%^&*()\":<>/" - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1697004e-76ab-444b-9419-0437e30444ad') - def test_scan_filter_set_device_address(self): - """Test scan filter set valid device address. - - Test scan filter device address valid. - - Steps: - 1. Validate the scan filter device address with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input['ScanFilterDeviceAddress'] = "01:02:03:AB:CD:EF" - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='eab0409c-7fc5-4d1f-8fbe-5ee2bb743f7e') - def test_scan_filter_set_invalid_device_address_lower_case(self): - """Test scan filter set invalid device address. - - Test scan filter device address lower case. - - Steps: - 1. Set the scan filter address to an invalid, lowercase mac address - - Expected Result: - Api to build scan filter should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input['ScanFilterDeviceAddress'] = "01:02:03:ab:cd:ef" - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0ec491ac-d273-468e-bbfe-e36a290aeb2a') - def test_scan_filter_set_invalid_device_address_blank(self): - """Test scan filter set invalid device address. - - Test scan filter invalid device address blank. - - Steps: - 1. Set the scan filter address to an invalid, blank mac address - - Expected Result: - Api to build scan filter should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input['ScanFilterDeviceAddress'] = "" - test_result = self.validate_scan_settings_helper( - input, self.ad_dut.droid) - return not test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5cebc454-091c-4e46-b200-1e52c8dffbec') - def test_scan_filter_set_invalid_device_address_bad_format(self): - """Test scan filter set badly formatted device address. - - Test scan filter badly formatted device address. - - Steps: - 1. Set the scan filter address to an invalid, blank mac address - - Expected Result: - Api to build scan filter should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - input = {} - input['ScanFilterDeviceAddress'] = "10.10.10.10.10" - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d5249d10-1486-4c38-a22d-1f1b077926db') - def test_scan_filter_set_invalid_device_address_bad_address(self): - """Test scan filter device address as an invalid value. - - Test scan filter invalid device address invalid characters. - - Steps: - 1. Set a scan filter's device address as ZZ:ZZ:ZZ:ZZ:ZZ:ZZ - - Expected Result: - Api to build the scan filter should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - input = {} - input['ScanFilterDeviceAddress'] = "ZZ:ZZ:ZZ:ZZ:ZZ:ZZ" - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='65c62d50-69f6-4a0b-bd74-2340e0ce32ca') - def test_scan_filter_set_manufacturer_id_data(self): - """Test scan filter manufacturer data. - - Test scan filter manufacturer data with a valid input. - - Steps: - 1. Validate the scan filter manufacturer id with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - expected_manufacturer_id = 0 - expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='12807021-9f66-4784-b34a-80859cf4a32f') - def test_scan_filter_set_manufacturer_id_data_mask(self): - """Test scan filter manufacturer data mask. - - Test scan filter manufacturer data with a valid data mask. - - Steps: - 1. Validate the scan filter manufacturer id with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - expected_manufacturer_id = 1 - expected_manufacturer_data = [1] - expected_manufacturer_data_mask = [1, 2, 1, 3, 4, 5, 6] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - input[ - 'ScanFilterManufacturerDataMask'] = expected_manufacturer_data_mask - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='980e5ab6-5381-4471-8e5b-0b716665a9b8') - def test_scan_filter_set_manufacturer_max_id(self): - """Test scan filter manufacturer data id. - - Test scan filter manufacturer data max id. - - Steps: - 1. Validate the scan filter manufacturer id with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - expected_manufacturer_id = 2147483647 - expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cf0efe38-8621-4288-be26-742719da2f6c') - def test_scan_filter_set_manufacturer_data_empty(self): - """Test scan filter empty manufacturer data. - - Test scan filter manufacturer data as empty but valid manufacturer data. - - Steps: - 1. Validate the scan filter manufacturer id with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - expected_manufacturer_id = 1 - expected_manufacturer_data = [] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7ea0e82e-e92a-469c-8432-8f21978508cb') - def test_scan_filter_set_manufacturer_data_mask_empty(self): - """Test scan filter empty manufacturer data mask. - - Test scan filter manufacturer mask empty. - - Steps: - 1. Validate the scan filter manufacturer id with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - expected_manufacturer_id = 1 - expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] - expected_manufacturer_data_mask = [] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - input[ - 'ScanFilterManufacturerDataMask'] = expected_manufacturer_data_mask - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='88e4a9b8-afae-48cb-873a-fd6b4ef84116') - def test_scan_filter_set_invalid_manufacturer_min_id_minus_one(self): - """Test scan filter invalid manufacturer data. - - Test scan filter invalid manufacturer id min value - 1. - - Steps: - 1. Set the scan filters manufacturer id to -1. - 2. Build the scan filter. - - Expected Result: - Api to build the scan filter should fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - expected_manufacturer_id = -1 - expected_manufacturer_data = [1, 2, 1, 3, 4, 5, 6] - input = {} - input['ScanFilterManufacturerDataId'] = expected_manufacturer_id - input['ScanFilterManufacturerData'] = expected_manufacturer_data - return not self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2e8438dc-29cd-4f72-8747-4a161974d4d3') - def test_scan_filter_set_service_uuid(self): - """Test scan filter set valid service uuid. - - Test scan filter service uuid. - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - expected_service_uuid = "00000000-0000-1000-8000-00805F9B34FB" - expected_service_mask = "00000000-0000-1000-8000-00805F9B34FB" - input = {} - input['ScanFilterServiceUuid'] = expected_service_uuid - input['ScanFilterServiceMask'] = expected_service_mask - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e07b9985-44b6-4dc4-b570-0833b5d2893c') - def test_scan_filter_service_uuid_p_service(self): - """Test scan filter service uuid. - - Test scan filter service uuid p service - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 2 - """ - expected_service_uuid = ble_uuids['p_service'] - expected_service_mask = "00000000-0000-1000-8000-00805F9B34FB" - self.log.debug("Step 1: Setup environment.") - - input = {} - input['ScanFilterServiceUuid'] = expected_service_uuid - input['ScanFilterServiceMask'] = expected_service_mask - return self.validate_scan_settings_helper(input, self.ad_dut.droid) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0467af19-6e9a-4cfe-9e10-878b0c224df2') - def test_classic_ble_scan_with_service_uuids_p(self): - """Test classic LE scan with valid service uuid. - - Test classic ble scan with scan filter service uuid p service uuids. - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - 2. Start classic ble scan. - 3. Stop classic ble scan - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - - droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['p_service']] - scan_callback = droid.bleGenLeScanCallback() - return self.verify_classic_ble_scan_with_service_uuids( - droid, scan_callback, service_uuid_list) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='516c295f-a2df-44f6-b2ad-54451af43ce8') - def test_classic_ble_scan_with_service_uuids_hr(self): - """Test classic LE scan with valid service uuid. - - Test classic ble scan with scan filter service uuid hr service - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - 2. Start classic ble scan. - 3. Stop classic ble scan - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['hr_service']] - scan_callback = droid.bleGenLeScanCallback() - return self.verify_classic_ble_scan_with_service_uuids( - droid, scan_callback, service_uuid_list) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0458b5e0-bb0b-4d6e-ab79-e21169d3256b') - def test_classic_ble_scan_with_service_uuids_empty_uuid_list(self): - """Test classic LE scan with empty but valid uuid list. - - Test classic ble scan with service uuids as empty list. - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - 2. Start classic ble scan. - 3. Stop classic ble scan - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - droid = self.ad_dut.droid - service_uuid_list = [] - scan_callback = droid.bleGenLeScanCallback() - return self.verify_classic_ble_scan_with_service_uuids( - droid, scan_callback, service_uuid_list) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c0d84a37-c86c-43c4-9dc7-d16959fdbc2a') - def test_classic_ble_scan_with_service_uuids_hr_and_p(self): - """Test classic LE scan with multiple service uuids. - - Test classic ble scan with service uuids a list of hr and p service. - - Steps: - 1. Validate the scan filter service uuid with all other settings - set to their respective defaults. - 2. Start classic ble scan. - 3. Stop classic ble scan - - Expected Result: - Expected Scan filter should match found scan filter. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 1 - """ - droid = self.ad_dut.droid - service_uuid_list = [ble_uuids['hr_service'], ble_uuids['p_service']] - scan_callback = droid.bleGenLeScanCallback() - return self.verify_classic_ble_scan_with_service_uuids( - droid, scan_callback, service_uuid_list) - - def verify_classic_ble_scan_with_service_uuids(self, droid, scan_callback, - service_uuid_list): - - test_result = True - try: - test_result = droid.bleStartClassicBleScanWithServiceUuids( - scan_callback, service_uuid_list) - except BleScanResultsError as error: - self.log.error(str(error)) - return False - droid.bleStopClassicBleScan(scan_callback) - if not test_result: - self.log.error( - "Start classic ble scan with service uuids return false " - "boolean value.") - return False - return True diff --git a/acts_tests/tests/google/ble/api/GattApiTest.py b/acts_tests/tests/google/ble/api/GattApiTest.py index cc87979a73..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/api/GattApiTest.py +++ b/acts_tests/tests/google/ble/api/GattApiTest.py @@ -1,119 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script to exercise Gatt Apis. -""" - -from acts.controllers.sl4a_lib import rpc_client -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test - - -class GattApiTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.ad = self.android_devices[0] - - return setup_multiple_devices_for_bt_test(self.android_devices) - - def setup_test(self): - for a in self.android_devices: - a.ed.clear_all_events() - return True - - def teardown_test(self): - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fffe5c46-eb97-477b-ac3e-3f70700bb84e') - def test_open_gatt_server(self): - """Test a gatt server. - - Test opening a gatt server. - - Steps: - 1. Create a gatt server callback. - 2. Open the gatt server. - - Expected Result: - Api to open gatt server should not fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 1 - """ - gatt_server_cb = self.ad.droid.gattServerCreateGattServerCallback() - self.ad.droid.gattServerOpenGattServer(gatt_server_cb) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='12828c2c-b6ae-4670-a829-9867e75fb711') - def test_open_gatt_server_on_same_callback(self): - """Test repetitive opening of a gatt server. - - Test opening a gatt server on the same callback twice in a row. - - Steps: - 1. Create a gatt server callback. - 2. Open the gatt server. - 3. Open the gatt server on the same callback as step 2. - - Expected Result: - Api to open gatt server should not fail. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 2 - """ - gatt_server_cb = self.ad.droid.gattServerCreateGattServerCallback() - self.ad.droid.gattServerOpenGattServer(gatt_server_cb) - self.ad.droid.gattServerOpenGattServer(gatt_server_cb) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='63fc684d-6c1d-455e-afdb-1887123b4d2f') - def test_open_gatt_server_on_invalid_callback(self): - """Test gatt server an an invalid callback. - - Test opening a gatt server with an invalid callback. - - Steps: - 1. Open a gatt server with the gall callback set to -1. - - Expected Result: - Api should fail to open a gatt server. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 2 - """ - invalid_callback_index = -1 - try: - self.ad.droid.gattServerOpenGattServer(invalid_callback_index) - except rpc_client.Sl4aApiError as e: - self.log.info("Failed successfully with exception: {}.".format(e)) - return True - return False diff --git a/acts_tests/tests/google/ble/beacon_tests/BeaconSwarmTest.py b/acts_tests/tests/google/ble/beacon_tests/BeaconSwarmTest.py index 0df9a7b2be..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/beacon_tests/BeaconSwarmTest.py +++ b/acts_tests/tests/google/ble/beacon_tests/BeaconSwarmTest.py @@ -1,341 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different testcases with a lot of ble beacon traffic. - -This test script was designed with this setup in mind: -Shield box one: Android Device as DUT. 7x Sprout devices acting as 192 beacons -""" - -import threading - -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.BleEnum import AdvertiseSettingsAdvertiseMode -from acts.test_utils.bt.BleEnum import ScanSettingsScanMode -from acts.test_utils.bt.bt_test_utils import adv_succ -from acts.test_utils.bt.bt_test_utils import batch_scan_result -from acts.test_utils.bt.bt_test_utils import scan_result -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test -from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs - - -class BeaconSwarmTest(BluetoothBaseTest): - default_timeout = 10 - beacon_swarm_count = 0 - advertising_device_name_list = [] - discovered_mac_address_list = [] - - def setup_test(self): - self.discovered_mac_address_list = [] - for a in self.android_devices: - a.ed.clear_all_events() - return True - - def teardown_test(self): - reset_bluetooth([self.android_devices[0]]) - return True - - def setup_class(self): - self.scn_ad = self.android_devices[0] - if not setup_multiple_devices_for_bt_test(self.android_devices): - return False - return self._start_special_advertisements() - - def cleanup_class(self): - return reset_bluetooth(self.android_devices) - - def on_fail(self, test_name, begin_time): - take_btsnoop_logs(self.android_devices, self, test_name) - reset_bluetooth([self.scn_ad]) - - def _start_advertisements_thread(self, ad, beacon_count, restart=False): - d, e = ad.droid, ad.ed - if restart: - try: - reset_bluetooth([ad]) - except Exception: - self.log.debug("Failed resetting Bluetooth, continuing...") - return - try: - for _ in range(beacon_count): - d.bleSetAdvertiseDataIncludeDeviceName(True) - d.bleSetAdvertiseSettingsAdvertiseMode( - AdvertiseSettingsAdvertiseMode.ADVERTISE_MODE_LOW_LATENCY. - value) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(d)) - d.bleStartBleAdvertising(advertise_callback, advertise_data, - advertise_settings) - try: - e.pop_event( - adv_succ.format(advertise_callback), - self.default_timeout) - self.beacon_swarm_count += 1 - local_bt_name = d.bluetoothGetLocalName() - if local_bt_name not in self.advertising_device_name_list: - self.advertising_device_name_list.append( - d.bluetoothGetLocalName()) - except Exception as e: - self.log.info("Advertising failed due to " + str(e)) - self.log.info("Beacons active: {}".format( - self.beacon_swarm_count)) - except Exception: - self.log.debug( - "Something went wrong in starting advertisements, continuing.") - return - - def _start_special_advertisements(self): - self.log.info("Setting up advertisements.") - beacon_serials = [] - beacon_count = 0 - try: - beacon_serials = self.user_params['beacon_devices'] - beacon_count = self.user_params['beacon_count'] - except AttributeError: - self.log.info( - "No controllable devices connected to create beacons with." - " Continuing...") - threads = [] - for a in self.android_devices: - d, e = a.droid, a.ed - serial_no = a.serial - if serial_no not in beacon_serials: - continue - thread = threading.Thread(target=self._start_advertisements_thread, - args=(d, e, beacon_count)) - threads.append(thread) - thread.start() - for t in threads: - t.join() - if self.beacon_swarm_count < (beacon_count * len(beacon_serials)): - self.log.error("Not enough beacons advertising: {}".format( - self.beacon_swarm_count)) - return False - return True - - def _restart_special_advertisements_thread(self): - beacon_serials = [] - beacon_count = 0 - try: - beacon_serials = self.user_params['beacon_devices'] - beacon_count = self.user_params['beacon_count'] - except AttributeError: - self.log.info("No controllable devices connected to create beacons" - " with. Continuing...") - threads = [] - while True: - self.log.info("Restarting advertisements.") - for a in self.android_devices: - d, e = a.droid, a.ed - serial_no = a.serial - if serial_no not in beacon_serials: - continue - thread = threading.Thread( - target=self._start_advertisements_thread, - args=(d, e, beacon_count, True)) - threads.append(thread) - thread.start() - for t in threads: - t.join() - return True - - def test_swarm_1000_on_scan_result(self): - """Test LE scanning in a mass beacon deployment. - - Test finding 1000 LE scan results in a mass beacon deployment. - - Steps: - 1. Assume that mass beacon deployment is setup. - 2. Set LE scanning mode to low latency. - 3. Start LE scan. - 4. Pop scan results off the event dispatcher 1000 times. - 5. Stop LE scanning. - - Expected Result: - 1000 scan results should be found without any exceptions. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Beacon - Priority: 1 - """ - self.scn_ad.droid.bleSetScanSettingsScanMode( - ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - for _ in range(1000000): - event_info = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - mac_address = event_info['data']['Result']['deviceInfo']['address'] - if mac_address not in self.discovered_mac_address_list: - self.discovered_mac_address_list.append(mac_address) - self.log.info("Discovered {} different devices.".format(len( - self.discovered_mac_address_list))) - self.log.debug("Discovered {} different devices.".format(len( - self.discovered_mac_address_list))) - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True - - def test_swarm_10000_on_batch_scan_result(self): - """Test LE batch scanning in a mass beacon deployment. - - Test finding 10000 LE batch scan results in a mass beacon deployment. - - Steps: - 1. Assume that mass beacon deployment is setup. - 2. Set LE scanning mode to low latency and report delay millis to 1 - second. - 3. Start LE scan. - 4. Pop batch scan results off the event dispatcher 10000 times. - 5. Stop LE scanning. - - Expected Result: - 1000 scan results should be found without any exceptions. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Beacon - Priority: 1 - """ - self.scn_ad.droid.bleSetScanSettingsScanMode( - ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis(1000) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - for _ in range(10000): - event_info = self.scn_ad.ed.pop_event( - batch_scan_result.format(scan_callback), self.default_timeout) - for result in event_info['data']['Results']: - mac_address = result['deviceInfo']['address'] - if mac_address not in self.discovered_mac_address_list: - self.discovered_mac_address_list.append(mac_address) - self.log.info("Discovered {} different devices.".format(len( - self.discovered_mac_address_list))) - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True - - def test_swarm_scan_result_filter_each_device_name(self): - """Test basic LE scan filtering in a mass beacon deployment. - - Test finding LE scan results in a mass beacon deployment. This - test specifically tests scan filtering of different device names and - that each device name is found. - - Steps: - 1. Assume that mass beacon deployment is setup with device names - advertising. - 2. Set LE scanning mode to low latency. - 3. Filter device name from one of the known advertising device names - 4. Start LE scan. - 5. Pop scan results matching the scan filter. - 6. Stop LE scanning. - 7. Repeat steps 2-6 until all advertising device names are found. - - Expected Result: - All advertising beacons are found by their device name. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Beacon, Filtering - Priority: 1 - """ - for filter_name in self.advertising_device_name_list: - self.scn_ad.droid.bleSetScanSettingsScanMode( - ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) - filter_list, scan_settings, scan_callback = ( - generate_ble_scan_objects(self.scn_ad.droid)) - try: - self.scn_ad.droid.bleSetScanFilterDeviceName(filter_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.log.debug(self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout)) - except Exception: - self.log.info("Couldn't find advertiser name {}.".format( - filter_name)) - return False - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True - - def test_swarm_rotate_addresses(self): - """Test basic LE scan filtering in a mass beacon deployment. - - Test finding LE scan results in a mass beacon deployment. This test - rotates the mac address of the advertising devices at a consistent - interval in order to make the scanning device think there are - thousands of devices nearby. - - Steps: - 1. Assume that mass beacon deployment is setup with device names - advertising. - 2. Set LE scanning mode to low latency on 28 scan instances. - 3. Start LE scan on each of the scan instances. - 5. Continuously Pop scan results matching the scan filter. - 6. Rotate mac address of each advertising device sequentially. - 7. 5-6 10,000 times. - 8. Stop LE scanning - - Expected Result: - The Bluetooth stack doesn't crash. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Beacon - Priority: 1 - """ - scan_callback_list = [] - for _ in range(28): - self.scn_ad.droid.bleSetScanSettingsScanMode( - ScanSettingsScanMode.SCAN_MODE_LOW_LATENCY.value) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - scan_callback_list.append(scan_callback) - thread = threading.Thread( - target=self._restart_special_advertisements_thread, - args=()) - thread.start() - n = 0 - while n < 10000: - for cb in scan_callback_list: - event_info = self.scn_ad.ed.pop_event( - scan_result.format(cb), self.default_timeout) - mac_address = event_info['data']['Result']['deviceInfo'][ - 'address'] - if mac_address not in self.discovered_mac_address_list: - self.discovered_mac_address_list.append(mac_address) - self.log.info("Discovered {} different devices.".format(len( - self.discovered_mac_address_list))) - n += 1 - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True diff --git a/acts_tests/tests/google/ble/bt5/AdvertisingSetTest.py b/acts_tests/tests/google/ble/bt5/AdvertisingSetTest.py index de4192f125..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/bt5/AdvertisingSetTest.py +++ b/acts_tests/tests/google/ble/bt5/AdvertisingSetTest.py @@ -1,197 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different Bluetooth 5 specific scan scenarios. -It is expected that the second AndroidDevice is able to advertise. - -This test script was designed with this setup in mind: -Shield box one: Android Device, Android Device -""" - -from queue import Empty - -from acts.asserts import assert_equal -from acts.asserts import assert_true -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import advertising_set_started -from acts.test_utils.bt.bt_constants import advertising_set_stopped -from acts.test_utils.bt.bt_constants import advertising_set_enabled -from acts.test_utils.bt.bt_constants import advertising_set_data_set -from acts.test_utils.bt.bt_constants import advertising_set_scan_response_set -from acts.test_utils.bt.bt_constants import advertising_set_parameters_update -from acts.test_utils.bt.bt_constants import advertising_set_periodic_parameters_updated -from acts.test_utils.bt.bt_constants import advertising_set_periodic_data_set -from acts.test_utils.bt.bt_constants import advertising_set_periodic_enable -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts import signals - - -class AdvertisingSetTest(BluetoothBaseTest): - default_timeout = 10 - report_delay = 2000 - scan_callbacks = [] - adv_callbacks = [] - active_scan_callback_list = [] - big_adv_data = { - "includeDeviceName": True, - "manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"], - "manufacturerData2": - [0x2540, [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF]], - "serviceData": [ - "b19d42dc-58ba-4b20-b6c1-6628e7d21de4", - "00112233445566778899AABBCCDDEE" - ], - "serviceData2": [ - "000042dc-58ba-4b20-b6c1-6628e7d21de4", - [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF] - ] - } - - def setup_class(self): - super(AdvertisingSetTest, self).setup_class() - self.adv_ad = self.android_devices[0] - - if not self.adv_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): - raise signals.TestAbortClass( - "Advertiser does not support LE Extended Advertising") - - def teardown_test(self): - self.active_scan_callback_list = [] - - def on_exception(self, test_name, begin_time): - reset_bluetooth(self.android_devices) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='58182f7e-443f-47fb-b718-1be3ac850287') - def test_reenabling(self): - """Test re-enabling an Advertising Set - - Test GATT notify characteristic value. - - Steps: - 1. Start an advertising set that only lasts for a few seconds - 2. Restart advertising set - 3. Repeat steps 1-2 - - Expected Result: - Verify that advertising set re-enables - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - duration = 0 - max_ext_adv_events = 0 - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": False, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_1M", - "interval": 320 - }, self.big_adv_data, None, None, None, duration, max_ext_adv_events, - adv_callback) - - set_started_evt = self.adv_ad.ed.pop_event( - advertising_set_started.format(adv_callback), self.default_timeout) - set_id = set_started_evt['data']['setId'] - assert_equal(0, set_started_evt['data']['status']) - assert_equal(0, set_started_evt['data']['status']) - - self.log.info("Successfully started set " + str(set_id)) - - self.adv_ad.droid.bleAdvSetEnableAdvertising(set_id, False, duration, - max_ext_adv_events) - enable_evt = self.adv_ad.ed.pop_event( - advertising_set_enabled.format(adv_callback), self.default_timeout) - assert_equal(set_id, enable_evt['data']['setId']) - assert_equal(False, enable_evt['data']['enable']) - assert_equal(0, enable_evt['data']['status']) - self.log.info("Successfully disabled advertising set " + str(set_id)) - - self.log.info("Enabling advertising for 2 seconds... ") - duration_200 = 200 - self.adv_ad.droid.bleAdvSetEnableAdvertising( - set_id, True, duration_200, max_ext_adv_events) - enable_evt = self.adv_ad.ed.pop_event( - advertising_set_enabled.format(adv_callback), self.default_timeout) - assert_equal(set_id, enable_evt['data']['setId']) - assert_equal(True, enable_evt['data']['enable']) - assert_equal(0, enable_evt['data']['status']) - self.log.info("Enabled. Waiting for disable event ~2s ...") - - enable_evt = self.adv_ad.ed.pop_event( - advertising_set_enabled.format(adv_callback), self.default_timeout) - assert_equal(set_id, enable_evt['data']['setId']) - assert_equal(False, enable_evt['data']['enable']) - assert_equal(0, enable_evt['data']['status']) - self.log.info("Disable event received. Now trying to set data...") - - self.adv_ad.droid.bleAdvSetSetAdvertisingData( - set_id, - {"manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"]}) - data_set_evt = self.adv_ad.ed.pop_event( - advertising_set_data_set.format(adv_callback), - self.default_timeout) - assert_equal(set_id, data_set_evt['data']['setId']) - assert_equal(0, data_set_evt['data']['status']) - self.log.info("Data changed successfully.") - - max_len = self.adv_ad.droid.bluetoothGetLeMaximumAdvertisingDataLength( - ) - - self.log.info("Will try to set data to maximum possible length") - data_len = max_len - 4 - test_fill = '01' * data_len - self.adv_ad.droid.bleAdvSetSetAdvertisingData( - set_id, {"manufacturerData": [0x0123, test_fill]}) - data_set_evt = self.adv_ad.ed.pop_event( - advertising_set_data_set.format(adv_callback), - self.default_timeout) - assert_equal(set_id, data_set_evt['data']['setId']) - assert_equal(0, data_set_evt['data']['status']) - self.log.info("Data changed successfully.") - - if max_len < 1650: - self.log.info("Will try to set data to more than maximum length") - data_len = max_len - 4 + 1 - test_fill = '01' * data_len - self.adv_ad.droid.bleAdvSetSetAdvertisingData( - set_id, {"manufacturerData": [0x0123, test_fill]}) - data_set_evt = self.adv_ad.ed.pop_event( - advertising_set_data_set.format(adv_callback), - self.default_timeout) - assert_equal(set_id, data_set_evt['data']['setId']) - #TODO(jpawlowski): make nicer error fot this case - assert_true(data_set_evt['data']['status'] != 0, - "Setting data should fail because data too long.") - - self.log.info("Data change failed as expected.") - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - try: - self.adv_ad.ed.pop_event( - advertising_set_stopped.format(adv_callback), - self.default_timeout) - except Empty: - self.log.error("Failed to find advertising set stopped event.") - return False - return True diff --git a/acts_tests/tests/google/ble/bt5/Bt5ScanTest.py b/acts_tests/tests/google/ble/bt5/Bt5ScanTest.py index e2c9c83cc3..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/bt5/Bt5ScanTest.py +++ b/acts_tests/tests/google/ble/bt5/Bt5ScanTest.py @@ -1,480 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different Bluetooth 5 specific scan scenarios. -It is expected that the second AndroidDevice is able to advertise. - -This test script was designed with this setup in mind: -Shield box one: Android Device, Android Device -""" - -from queue import Empty - -from acts import asserts -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_phys -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import batch_scan_result -from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_constants import advertising_set_on_own_address_read -from acts.test_utils.bt.bt_constants import advertising_set_started -from acts import signals - - -class Bt5ScanTest(BluetoothBaseTest): - default_timeout = 10 - report_delay = 2000 - scan_callbacks = [] - adv_callbacks = [] - active_scan_callback_list = [] - big_adv_data = { - "includeDeviceName": True, - "manufacturerData": [0x0123, "00112233445566778899AABBCCDDEE"], - "manufacturerData2": - [0x2540, [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF]], - "serviceData": [ - "b19d42dc-58ba-4b20-b6c1-6628e7d21de4", - "00112233445566778899AABBCCDDEE" - ], - "serviceData2": [ - "000042dc-58ba-4b20-b6c1-6628e7d21de4", - [0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0xFF] - ] - } - - def setup_class(self): - super(Bt5ScanTest, self).setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - if not self.scn_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): - raise signals.TestAbortClass( - "Scanner does not support LE Extended Advertising") - - if not self.adv_ad.droid.bluetoothIsLeExtendedAdvertisingSupported(): - raise signals.TestAbortClass( - "Advertiser does not support LE Extended Advertising") - - def teardown_test(self): - cleanup_scanners_and_advertisers( - self.scn_ad, self.active_scan_callback_list, self.adv_ad, []) - self.active_scan_callback_list = [] - - def on_exception(self, test_name, begin_time): - reset_bluetooth(self.android_devices) - - # This one does not relly test anything, but display very helpful - # information that might help with debugging. - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='787e0877-269f-4b9b-acb0-b98a8bb3770a') - def test_capabilities(self): - """Test capabilities - - Test BT 5.0 scan scapabilities - - Steps: - 1. Test various vapabilities. - - Expected Result: - Pass - - Returns: - Pass if True - Fail if False - - TAGS: BT5.0, Scanning - Priority: 2 - """ - d = self.scn_ad.droid - sup2M = d.bluetoothIsLe2MPhySupported() - supCoded = d.bluetoothIsLeCodedPhySupported() - supExt = d.bluetoothIsLeExtendedAdvertisingSupported() - supPeriodic = d.bluetoothIsLePeriodicAdvertisingSupported() - maxDataLen = d.bluetoothGetLeMaximumAdvertisingDataLength() - self.log.info("Scanner capabilities:") - self.log.info("LE 2M: " + str(sup2M) + ", LE Coded: " + str( - supCoded) + ", LE Extended Advertising: " + str( - supExt) + ", LE Periodic Advertising: " + str(supPeriodic) + - ", maximum advertising data length: " + str(maxDataLen)) - d = self.adv_ad.droid - sup2M = d.bluetoothIsLe2MPhySupported() - supCoded = d.bluetoothIsLeCodedPhySupported() - supExt = d.bluetoothIsLeExtendedAdvertisingSupported() - supPeriodic = d.bluetoothIsLePeriodicAdvertisingSupported() - maxDataLen = d.bluetoothGetLeMaximumAdvertisingDataLength() - self.log.info("Advertiser capabilities:") - self.log.info("LE 2M: " + str(sup2M) + ", LE Coded: " + str( - supCoded) + ", LE Extended Advertising: " + str( - supExt) + ", LE Periodic Advertising: " + str(supPeriodic) + - ", maximum advertising data length: " + str(maxDataLen)) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='62d36679-bb91-465e-897f-2635433aac2f') - def test_1m_1m_extended_scan(self): - """Test scan on LE 1M PHY using LE 1M PHY as secondary. - - Tests test verify that device is able to receive extended advertising - on 1M PHY when secondary is 1M PHY. - - Steps: - 1. Start advertising set on dut1 - 2. Start scanning on dut0, scan filter set to advertiser's device name - 3. Try to find an event, expect found - 4. Stop advertising - - Expected Result: - Scan finds a advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_1M", - "interval": 320 - }, self.big_adv_data, None, None, None, 0, 0, adv_callback) - - self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) - - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Scan result not found") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3e3c9757-f7b6-4d1d-a2d6-8e2330d1a18e') - def test_1m_2m_extended_scan(self): - """Test scan on LE 1M PHY using LE 2M PHY as secondary. - - Tests test verify that device is able to receive extended advertising - on 1M PHY when secondary is 2M PHY. - - Steps: - 1. Start advertising set on dut1 - 2. Start scanning on dut0, scan filter set to advertiser's device name - 3. Try to find an event, expect found - 4. Stop advertising - - Expected Result: - Scan finds a advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_2M", - "interval": 320 - }, self.big_adv_data, None, None, None, 0, 0, adv_callback) - - self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) - - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Scan result not found") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='236e9e5b-3853-4762-81ae-e88db03d74f3') - def test_legacy_scan_result_raw_length(self): - """Test that raw scan record data in legacy scan is 62 bytes long. - - This is required for compability with older apps that make this - assumption. - - Steps: - 1. Start legacy advertising set on dut1 - 2. Start scanning on dut0, scan filter set to advertiser's device name - 3. Try to find an event, expect found, verify scan recurd data length - 4. Stop advertising - - Expected Result: - Scan finds a legacy advertisement of proper size - - Returns: - Pass if True - Fail if False - - TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": True, - "scannable": True, - "legacyMode": True, - "interval": 320 - }, {"includeDeviceName": True}, None, None, None, 0, 0, adv_callback) - - self.scn_ad.droid.bleSetScanSettingsLegacy(True) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) - - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - try: - evt = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - rawData = evt['data']['Result']['scanRecord'] - asserts.assert_true(62 == len(rawData.split(",")), - "Raw data should be 62 bytes long.") - except Empty: - self.log.error("Scan result not found") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='04632d8d-4303-476f-8f83-52c16be3713a') - def test_duration(self): - """Test scanning duration - - Tests BT5.0 scanning duration - - Steps: - 1. Start advertising set - 2. Start 5.0 scan - 3. Scan for advertisement event - - Expected Result: - Scan finds a legacy advertisement of proper size - - Returns: - Pass if True - Fail if False - - TAGS: BT5.0, LE, Advertising, Scanning - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_2M", - "interval": 320 - }, self.big_adv_data, None, None, None, 0, 0, adv_callback) - - self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) - - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Scan result not found") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a3704083-0f5c-4a46-b979-32ebc594d6ee') - def test_anonymous_advertising(self): - """Test anonymous advertising. - - Tests test verify that device is able to receive anonymous advertising - on 1M PHY when secondary is 2M PHY. - - Steps: - 1. Start anonymous advertising set on dut1 - 2. Start scanning on dut0, scan filter set to advertiser's device name - 3. Try to find an event, expect found - 4. Stop advertising - - Expected Result: - Scan finds a advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE Advertising Extension, BT5, LE, Advertising, Scanning - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": False, - "anonymous": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_2M", - "interval": 320 - }, self.big_adv_data, None, None, None, 0, 0, adv_callback) - - self.scn_ad.droid.bleSetScanSettingsLegacy(False) - self.scn_ad.droid.bleSetScanSettingsPhy(ble_scan_settings_phys['1m']) - - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - try: - evt = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - address = evt['data']['Result']['deviceInfo']['address'] - asserts.assert_true( - '00:00:00:00:00:00' == address, - "Anonymous address should be 00:00:00:00:00:00, but was " + - str(address)) - except Empty: - self.log.error("Scan result not found") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e3277355-eebf-4760-9502-e49a9289f6ab') - def test_get_own_address(self): - """Test obtaining own address for PTS. - - Test obtaining own address. - - Steps: - 1. Start advertising set dut1 - 2. Grab address - 3. Stop advertising - - Expected Result: - Callback with address is received. - - Returns: - Pass if True - Fail if False - - TAGS: LE Advertising Extension, BT5, LE, Advertising - Priority: 1 - """ - adv_callback = self.adv_ad.droid.bleAdvSetGenCallback() - self.adv_ad.droid.bleAdvSetStartAdvertisingSet({ - "connectable": False, - "anonymous": True, - "legacyMode": False, - "primaryPhy": "PHY_LE_1M", - "secondaryPhy": "PHY_LE_2M", - "interval": 320 - }, self.big_adv_data, None, None, None, 0, 0, adv_callback) - - set_id = -1 - - try: - evt = self.adv_ad.ed.pop_event( - advertising_set_started.format(adv_callback), - self.default_timeout) - self.log.info("data: " + str(evt['data'])) - set_id = evt['data']['setId'] - except Empty: - self.log.error("did not receive the set started event!") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetGetOwnAddress(set_id) - - try: - evt = self.adv_ad.ed.pop_event( - advertising_set_on_own_address_read.format(set_id), - self.default_timeout) - address = evt['data']['address'] - self.log.info("Advertiser address is: " + str(address)) - except Empty: - self.log.error("onOwnAddressRead not received.") - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return False - - self.adv_ad.droid.bleAdvSetStopAdvertisingSet(adv_callback) - return True diff --git a/acts_tests/tests/google/ble/bt5/PhyTest.py b/acts_tests/tests/google/ble/bt5/PhyTest.py index 0b1ecfade8..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/bt5/PhyTest.py +++ b/acts_tests/tests/google/ble/bt5/PhyTest.py @@ -1,248 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises set PHY and read PHY procedures. -""" - -from queue import Empty - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_phy -from acts import signals - -CONNECTION_PRIORITY_HIGH = gatt_connection_priority['high'] -PHY_LE_1M = gatt_phy['1m'] -PHY_LE_2M = gatt_phy['2m'] - - -def lfmt(txPhy, rxPhy): - return '(' + list(gatt_phy.keys())[list(gatt_phy.values()).index( - txPhy)] + ', ' + list(gatt_phy.keys())[list(gatt_phy.values()).index( - rxPhy)] + ')' - - -class PhyTest(GattConnectedBaseTest): - def setup_class(self): - super(PhyTest, self).setup_class() - if not self.cen_ad.droid.bluetoothIsLe2MPhySupported(): - raise signals.TestAbortClass( - "Central device does not support LE 2M PHY") - - if not self.per_ad.droid.bluetoothIsLe2MPhySupported(): - raise signals.TestAbortClass( - "Peripheral device does not support LE 2M PHY") - - # Some controllers auto-update PHY to 2M, and both client and server - # might receive PHY Update event right after connection, if the - # connection was established over 1M PHY. We will ignore this event, but - # must pop it from queue. - def pop_initial_phy_update(self): - try: - maybe_event = gatt_event['phy_update']['evt'].format( - self.gatt_callback) - self.cen_ad.ed.pop_event(maybe_event, 0) - except Empty: - pass - - try: - maybe_event = gatt_event['serv_phy_update']['evt'].format( - self.gatt_server_callback) - self.per_ad.ed.pop_event(maybe_event, 0) - except Empty: - pass - - # this helper method checks wether both client and server received PHY - # update event with proper txPhy and rxPhy - def ensure_both_updated_phy(self, clientTxPhy, clientRxPhy): - event = self._client_wait(gatt_event['phy_update']) - txPhy = event['data']['TxPhy'] - rxPhy = event['data']['RxPhy'] - self.log.info("\tClient PHY updated: " + lfmt(txPhy, rxPhy)) - self.assertEqual(0, event['data']['Status'], "Status should be 0") - self.assertEqual(clientTxPhy, event['data']['TxPhy']) - self.assertEqual(clientRxPhy, event['data']['RxPhy']) - - bt_device_id = 0 - event = self._server_wait(gatt_event['serv_phy_update']) - txPhy = event['data']['TxPhy'] - rxPhy = event['data']['RxPhy'] - self.log.info("\tServer PHY updated: " + lfmt(txPhy, rxPhy)) - self.assertEqual(0, event['data']['Status'], "Status should be 0") - self.assertEqual(clientRxPhy, event['data']['TxPhy']) - self.assertEqual(clientTxPhy, event['data']['RxPhy']) - - # read the client phy, return (txPhy, rxPhy) - def read_client_phy(self): - self.cen_ad.droid.gattClientReadPhy(self.bluetooth_gatt) - event = self._client_wait(gatt_event['phy_read']) - self.assertEqual(0, event['data']['Status'], "Status should be 0") - return (event['data']['TxPhy'], event['data']['RxPhy']) - - # read the server phy, return (txPhy, rxPhy) - def read_server_phy(self): - bt_device_id = 0 - self.per_ad.droid.gattServerReadPhy(self.gatt_server, bt_device_id) - event = self._server_wait(gatt_event['serv_phy_read']) - self.assertEqual(0, event['data']['Status'], "Status should be 0") - return (event['data']['TxPhy'], event['data']['RxPhy']) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='edb95ae1-97e5-4337-9a60-1e113aa43a4d') - def test_phy_read(self): - """Test LE read PHY. - - Test LE read PHY. - - Steps: - 1. Central, Peripheral : read PHY, make sure values are same. - 2. Central: update PHY. - 3. Ensure both Central and Peripheral received PHY update event. - 4. Central, Peripheral: read PHY, make sure values are same. - - Expected Result: - Verify that read PHY works properly. - - Returns: - Pass if True - Fail if False - - TAGS: LE, PHY - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) - self.pop_initial_phy_update() - - # read phy from client and server, make sure they're same - cTxPhy, cRxPhy = self.read_client_phy() - sTxPhy, sRxPhy = self.read_server_phy() - self.assertEqual(cTxPhy, sTxPhy) - self.assertEqual(cRxPhy, sRxPhy) - - self.log.info("Initial connection PHY was: " + lfmt(cTxPhy, cRxPhy)) - - nextTxPhy = (cTxPhy == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M - nextRxPhy = (cRxPhy == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M - - # try to update PHY from Client - self.log.info("Will try to set PHY to: " + lfmt(nextTxPhy, nextRxPhy)) - self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, - nextTxPhy, nextRxPhy, 0) - self.ensure_both_updated_phy(nextTxPhy, nextRxPhy) - - # read phy on client and server, make sure values are same and equal - # the newly set value - cTxPhy, cRxPhy = self.read_client_phy() - sTxPhy, sRxPhy = self.read_server_phy() - self.assertEqual(cTxPhy, sTxPhy) - self.assertEqual(cRxPhy, sRxPhy) - - self.assertEqual(nextTxPhy, cTxPhy) - self.assertEqual(nextRxPhy, cRxPhy) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6b66af0a-35eb-42af-acd5-9634684f275d') - def test_phy_change_20_times(self): - """Test PHY update. - - Test LE PHY update. - - Steps: - 1. Central: read PHY. - 2. Central: update PHY to 1M, 2M, 1M... 20 times, each time ensuring - both client and server received PHY update event. - - Expected Result: - Verify that read update PHY worked properly each time. - - Returns: - Pass if True - Fail if False - - TAGS: LE, PHY - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) - self.pop_initial_phy_update() - - txPhyB, rxPhyB = self.read_client_phy() - txPhyA = (txPhyB == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M - rxPhyA = (rxPhyB == PHY_LE_1M) and PHY_LE_2M or PHY_LE_1M - - self.log.info("Initial connection PHY was: " + lfmt(txPhyB, rxPhyB)) - - for i in range(20): - #swap values between iterations - txPhy = (i & 1) and txPhyB or txPhyA - rxPhy = (i & 1) and rxPhyB or rxPhyA - - self.log.info("Will try to set PHY to: " + lfmt(txPhy, rxPhy)) - self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, - txPhy, rxPhy, 0) - self.ensure_both_updated_phy(txPhy, rxPhy) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='13f28de4-07f4-458c-a3e5-3ba95318616f') - def test_phy_change_asym(self): - """Test PHY update with asymetric rx and tx PHY. - - Test PHY update with asymetric rx and tx PHY. - - Steps: - 1. Central: read PHY. - 2. Central: update PHY to tx: 1M, rx: 2M, ensure both devices received - the asymetric update. - 3. Central: update PHY to tx: 2M, rx: 1M, ensure both devices received - the asymetric update. - - Expected Result: - Verify that read update PHY worked properly each time. - - Returns: - Pass if True - Fail if False - - TAGS: LE, PHY - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, CONNECTION_PRIORITY_HIGH) - self.pop_initial_phy_update() - - txPhy, rxPhy = self.read_client_phy() - - self.log.info("Initial connection PHY was: " + lfmt(txPhy, rxPhy)) - self.log.info("will try to set PHY to: PHY_LE_1M, PHY_LE_2M") - - #try to update PHY to tx 1M, rx 2M from Client - self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, - PHY_LE_1M, PHY_LE_2M, 0) - self.ensure_both_updated_phy(PHY_LE_1M, PHY_LE_2M) - - #try to update PHY to TX 2M, RX 1M from Client - self.log.info("will try to set PHY to: PHY_LE_2M, PHY_LE_1M") - self.cen_ad.droid.gattClientSetPreferredPhy(self.bluetooth_gatt, - PHY_LE_2M, PHY_LE_1M, 0) - self.ensure_both_updated_phy(PHY_LE_2M, PHY_LE_1M) - - return True diff --git a/acts_tests/tests/google/ble/concurrency/ConcurrentBleScanningTest.py b/acts_tests/tests/google/ble/concurrency/ConcurrentBleScanningTest.py index 512aed8f16..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/concurrency/ConcurrentBleScanningTest.py +++ b/acts_tests/tests/google/ble/concurrency/ConcurrentBleScanningTest.py @@ -1,352 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script to exercises Ble Scans can run in concurrency. -This test was designed to be run in a shield box. -""" - -import concurrent -import time - -from queue import Empty -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_failed -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs - - -class ConcurrentBleScanningTest(BluetoothBaseTest): - default_timeout = 20 - max_concurrent_scans = 27 - - def setup_class(self): - super().setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - def on_fail(self, test_name, begin_time): - self.log.debug("Test {} failed. Gathering bugreport and btsnoop logs." - .format(test_name)) - take_btsnoop_logs(self.android_devices, self, test_name) - reset_bluetooth(self.android_devices) - - def setup_test(self): - return reset_bluetooth(self.android_devices) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e7f68b9b-fb3f-48e9-a272-e41c2a32b4bd') - def test_max_concurrent_ble_scans(self): - """Test max LE scans. - - Test that a single device can have max scans concurrently scanning. - - Steps: - 1. Initialize scanner - 2. Initialize advertiser - 3. Start advertising on the device from step 2 - 4. Create max ble scan callbacks - 5. Start ble scan on each callback - 6. Verify that each callback triggers - 7. Stop all scans and advertisements - - Expected Result: - All scanning instances should start without errors and the advertisement - should be found on each scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Concurrency - Priority: 0 - """ - test_result = True - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleSetAdvertiseSettingsIsConnectable(False) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - try: - self.adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), self.default_timeout) - except Empty as error: - self.log.exception("Test failed with Empty error: {}".format( - error)) - test_result = False - except concurrent.futures._base.TimeoutError as error: - self.log.exception( - "Test failed callback onSuccess never occurred: " - "{}".format(error)) - test_result = False - if not test_result: - return test_result - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback_list = [] - for i in range(self.max_concurrent_scans): - self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - scan_callback_list.append(scan_callback) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - self.log.info("Found scan event successfully. Iteration {} " - "successful.".format(i)) - except Exception: - self.log.info("Failed to find a scan result for callback {}" - .format(scan_callback)) - test_result = False - break - for callback in scan_callback_list: - self.scn_ad.droid.bleStopBleScan(callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - if not test_result: - return test_result - self.log.info("Waiting for scan callbacks to stop completely.") - # Wait for all scan callbacks to stop. There is no confirmation - # otherwise. - time.sleep(10) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='58b0c45e-1cbc-420a-9e89-901518ffe3d1') - def test_max_concurrent_ble_scans_then_discover_advertisement(self): - """Test max LE scans variant. - - Test that a single device can have max scans concurrently scanning. - - Steps: - 1. Initialize scanner - 2. Initialize advertiser - 3. Create max ble scan callbacks - 4. Start ble scan on each callback - 5. Start advertising on the device from step 2 - 6. Verify that each callback triggers - 7. Stop all scans and advertisements - - Expected Result: - All scanning instances should start without errors and the advertisement - should be found on each scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Concurrency - Priority: 1 - """ - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback_list = [] - for i in range(self.max_concurrent_scans): - self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - scan_callback_list.append(scan_callback) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - try: - self.adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), self.default_timeout) - except Empty as error: - self.log.exception("Test failed with Empty error: {}".format( - error)) - return False - except concurrent.futures._base.TimeoutError as error: - self.log.exception("Test failed, filtering callback onSuccess " - "never occurred: {}".format(error)) - return False - i = 0 - for callback in scan_callback_list: - try: - self.scn_ad.ed.pop_event( - scan_result.format(callback), self.default_timeout) - self.log.info( - "Found scan event successfully. Iteration {} successful." - .format(i)) - except Exception: - self.log.info("Failed to find a scan result for callback {}" - .format(callback)) - return False - i += 1 - for callback in scan_callback_list: - self.scn_ad.droid.bleStopBleScan(callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7a45e45c-faf3-4e89-abb7-a52f63e53208') - def test_max_concurrent_ble_scans_plus_one(self): - """Test mac LE scans variant. - - Test that a single device can have max scans concurrently scanning. - - Steps: - 1. Initialize scanner - 3. Create max ble scan callbacks plus one - 5. Start ble scan on each callback - 6. Verify that the n+1th scan fails. - 7. Stop all scans - - Expected Result: - The n+1th scan should fail to start. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Concurrency - Priority: 1 - """ - test_result = True - filter_list = self.scn_ad.droid.bleGenFilterList() - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback_list = [] - for i in range(self.max_concurrent_scans): - self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - scan_callback_list.append(scan_callback) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - try: - self.scn_ad.ed.pop_event( - scan_failed.format(scan_callback), self.default_timeout) - self.log.info( - "Found scan event successfully. Iteration {} successful." - .format(self.max_concurrent_scans + 1)) - except Exception: - self.log.error("Failed to find a onScanFailed event for callback {}" - .format(scan_callback)) - test_result = False - for callback in scan_callback_list: - self.scn_ad.droid.bleStopBleScan(callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5a91f612-69e5-490f-b9d0-50d58a3db736') - def test_max_concurrent_ble_scans_verify_scans_stop_independently(self): - """Test max LE scans variant. - - Test that a single device can have max scans concurrently scanning. - - Steps: - 1. Initialize scanner - 2. Initialize advertiser - 3. Create max ble scan callbacks - 4. Start ble scan on each callback - 5. Start advertising on the device from step 2 - 6. Verify that the first callback triggers - 7. Stop the scan and repeat steps 6 and 7 until all scans stopped - - Expected Result: - All scanning instances should start without errors and the advertisement - should be found on each scan instance. All scanning instances should - stop successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning, Concurrency - Priority: 1 - """ - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['all_matches']) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback_list = [] - for i in range(self.max_concurrent_scans): - self.log.debug("Concurrent Ble Scan iteration {}".format(i + 1)) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - scan_callback_list.append(scan_callback) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - try: - self.adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), self.default_timeout) - except Empty as error: - self.log.exception("Test failed with Empty error: {}".format( - error)) - return False - except concurrent.futures._base.TimeoutError as error: - self.log.exception( - "Test failed, filtering callback onSuccess never" - " occurred: {}".format(error)) - return False - i = 0 - for callback in scan_callback_list: - expected_scan_event_name = scan_result.format(scan_callback) - try: - self.scn_ad.ed.pop_event(expected_scan_event_name, - self.default_timeout) - self.log.info( - "Found scan event successfully. Iteration {} successful.". - format(i)) - i += 1 - except Exception: - self.log.info("Failed to find a scan result for callback {}". - format(scan_callback)) - return False - self.scn_ad.droid.bleStopBleScan(callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return True diff --git a/acts_tests/tests/google/ble/concurrency/ConcurrentGattConnectTest.py b/acts_tests/tests/google/ble/concurrency/ConcurrentGattConnectTest.py index ec5e09cae8..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/concurrency/ConcurrentGattConnectTest.py +++ b/acts_tests/tests/google/ble/concurrency/ConcurrentGattConnectTest.py @@ -1,291 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script for concurrent Gatt connections. -Testbed assumes 6 Android devices. One will be the central and the rest -peripherals. -""" - -from queue import Empty -import concurrent.futures -import threading -import time -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import bt_profile_constants -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_gatt_utils import run_continuous_write_descriptor -from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection -from acts.test_utils.bt.gatts_lib import GattServerLib -from acts.test_decorators import test_tracker_info - -service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb' -characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630' -descriptor_uuid = "00000003-0000-1000-8000-00805f9b34fb" - -gatt_server_read_descriptor_sample = { - 'services': [{ - 'uuid': - service_uuid, - 'type': - gatt_service_types['primary'], - 'characteristics': [{ - 'uuid': - characteristic_uuid, - 'properties': - gatt_characteristic['property_write'], - 'permissions': - gatt_characteristic['permission_write'], - 'instance_id': - 0x002a, - 'value_type': - gatt_characteristic_value_format['string'], - 'value': - 'Test Database', - 'descriptors': [{ - 'uuid': descriptor_uuid, - 'permissions': gatt_descriptor['permission_write'], - }] - }] - }] -} - - -class ConcurrentGattConnectTest(BluetoothBaseTest): - bt_default_timeout = 10 - max_connections = 5 - # List of tuples (android_device, advertise_callback) - advertise_callbacks = [] - # List of tuples (android_device, advertisement_name) - advertisement_names = [] - list_of_arguments_list = [] - - def setup_class(self): - super(BluetoothBaseTest, self).setup_class() - self.pri_dut = self.android_devices[0] - - - # Create 5 advertisements from different android devices - for i in range(1, self.max_connections + 1): - # Set device name - ad = self.android_devices[i] - name = "test_adv_{}".format(i) - self.advertisement_names.append((ad, name)) - ad.droid.bluetoothSetLocalName(name) - - # Setup and start advertisements - ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_data = ad.droid.bleBuildAdvertiseData() - advertise_settings = ad.droid.bleBuildAdvertiseSettings() - advertise_callback = ad.droid.bleGenBleAdvertiseCallback() - ad.droid.bleStartBleAdvertising(advertise_callback, advertise_data, - advertise_settings) - self.advertise_callbacks.append((ad, advertise_callback)) - - def obtain_address_list_from_scan(self): - """Returns the address list of all devices that match the scan filter. - - Returns: - A list if all devices are found; None is any devices are not found. - """ - # From central device, scan for all appropriate addresses by name. - filter_list = self.pri_dut.droid.bleGenFilterList() - self.pri_dut.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - scan_settings = self.pri_dut.droid.bleBuildScanSetting() - scan_callback = self.pri_dut.droid.bleGenScanCallback() - for android_device, name in self.advertisement_names: - self.pri_dut.droid.bleSetScanFilterDeviceName(name) - self.pri_dut.droid.bleBuildScanFilter(filter_list) - self.pri_dut.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - address_list = [] - devices_found = [] - # Set the scan time out to 20 sec to provide enough time to discover the - # devices in busy environment - scan_timeout = 20 - end_time = time.time() + scan_timeout - while time.time() < end_time and len(address_list) < len( - self.advertisement_names): - try: - event = self.pri_dut.ed.pop_event( - "BleScan{}onScanResults".format(scan_callback), - self.bt_default_timeout) - - adv_name = event['data']['Result']['deviceInfo']['name'] - mac_address = event['data']['Result']['deviceInfo']['address'] - # Look up the android device handle based on event name - device = [ - item for item in self.advertisement_names - if adv_name in item - ] - devices_found.append(device[0][0].serial) - if len(device) is not 0: - address_list_tuple = (device[0][0], mac_address) - else: - continue - result = [item for item in address_list if mac_address in item] - # if length of result is 0, it indicates that we have discovered - # new mac address. - if len(result) is 0: - self.log.info("Found new mac address: {}".format( - address_list_tuple[1])) - address_list.append(address_list_tuple) - except Empty as err: - self.log.error("Failed to find any scan results.") - return None - if len(address_list) < self.max_connections: - self.log.info("Only found these devices: {}".format(devices_found)) - self.log.error("Could not find all necessary advertisements.") - return None - return address_list - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6638282c-69b5-4237-9f0d-18e131424a9f') - def test_concurrent_gatt_connections(self): - """Test max concurrent GATT connections - - Connect to all peripherals. - - Steps: - 1. Scan - 2. Save addresses - 3. Connect all addresses of the peripherals - - Expected Result: - All connections successful. - - Returns: - Pass if True - Fail if False - - TAGS: Bluetooth, GATT - Priority: 2 - """ - - address_list = self.obtain_address_list_from_scan() - if address_list is None: - return False - - # Connect to all addresses - for address_tuple in address_list: - address = address_tuple[1] - try: - autoconnect = False - bluetooth_gatt, gatt_callback = setup_gatt_connection( - self.pri_dut, address, autoconnect) - self.log.info("Successfully connected to {}".format(address)) - except Exception as err: - self.log.error( - "Failed to establish connection to {}".format(address)) - return False - if (len( - self.pri_dut.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt_server'])) != - self.max_connections): - self.log.error("Did not reach max connection count.") - return False - - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='660bf05e-a8e5-45f3-b42b-b66b4ac0d85f') - def test_data_transfer_to_concurrent_gatt_connections(self): - """Test writing GATT descriptors concurrently to many peripherals. - - Connect to all peripherals and write gatt descriptors concurrently. - - - Steps: - 1. Scan the addresses by names - 2. Save mac addresses of the peripherals - 3. Connect all addresses of the peripherals and write gatt descriptors - - - Expected Result: - All connections and data transfers are successful. - - Returns: - Pass if True - Fail if False - - TAGS: Bluetooth, GATT - Priority: 2 - """ - - address_list = self.obtain_address_list_from_scan() - if address_list is None: - return False - - # Connect to all addresses - executor = concurrent.futures.ThreadPoolExecutor(max_workers=10) - - for address_tuple in address_list: - ad, address = address_tuple - - gatts = GattServerLib(log=self.log, dut=ad) - gatt_server, gatt_server_callback = gatts.setup_gatts_db( - database=gatt_server_read_descriptor_sample) - - try: - bluetooth_gatt, gatt_callback = setup_gatt_connection( - self.pri_dut, address, autoconnect=False) - self.log.info("Successfully connected to {}".format(address)) - - except Exception as err: - self.log.error( - "Failed to establish connection to {}".format(address)) - return False - - if self.pri_dut.droid.gattClientDiscoverServices(bluetooth_gatt): - event = self.pri_dut.ed.pop_event( - "GattConnect{}onServicesDiscovered".format(bluetooth_gatt), - self.bt_default_timeout) - discovered_services_index = event['data']['ServicesIndex'] - else: - self.log.info("Failed to discover services.") - return False - services_count = self.pri_dut.droid.gattClientGetDiscoveredServicesCount( - discovered_services_index) - - arguments_list = [ - self.pri_dut.droid, self.pri_dut.ed, ad.droid, ad.ed, - gatt_server, gatt_server_callback, bluetooth_gatt, - services_count, discovered_services_index, 100 - ] - self.list_of_arguments_list.append(arguments_list) - - for arguments_list in self.list_of_arguments_list: - executor.submit(run_continuous_write_descriptor, *arguments_list) - - executor.shutdown(wait=True) - - if (len( - self.pri_dut.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt_server'])) != - self.max_connections): - self.log.error("Failed to write concurrently.") - return False - - return True diff --git a/acts_tests/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py b/acts_tests/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py index 353f507088..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py +++ b/acts_tests/tests/google/ble/conn_oriented_chan/BleCoc2ConnTest.py @@ -1,510 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Test script to execute Bluetooth Connection-orient Channel (CoC) functionality for -2 connections test cases. This test was designed to be run in a shield box. -""" - -import threading -import time - -from acts import utils -from queue import Empty -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_coc_test_utils import orchestrate_coc_connection -from acts.test_utils.bt.bt_coc_test_utils import do_multi_connection_throughput -from acts.test_utils.bt.bt_constants import default_le_data_length -from acts.test_utils.bt.bt_constants import default_bluetooth_socket_timeout_ms -from acts.test_utils.bt.bt_constants import l2cap_coc_header_size -from acts.test_utils.bt.bt_constants import l2cap_max_inactivity_delay_after_disconnect -from acts.test_utils.bt.bt_constants import le_connection_event_time_step_ms -from acts.test_utils.bt.bt_test_utils import clear_bonded_devices -from acts.test_utils.bt.bt_test_utils import kill_bluetooth_process -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_test_utils import setup_multiple_devices_for_bt_test -from acts.test_utils.bt.bt_test_utils import take_btsnoop_logs -from acts.test_utils.bt.bt_test_utils import write_read_verify_data -from acts.test_utils.bt.bt_test_utils import verify_server_and_client_connected - - -class BleCoc2ConnTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.client_ad = self.android_devices[0] - # The client which is scanning will need location to be enabled in order to - # start scan and get scan results. - utils.set_location_service(self.client_ad, True) - self.server_ad = self.android_devices[1] - # Note that some tests required a third device. - if len(self.android_devices) > 2: - self.server2_ad = self.android_devices[2] - - return setup_multiple_devices_for_bt_test(self.android_devices) - - def teardown_test(self): - self.client_ad.droid.bluetoothSocketConnStop() - self.server_ad.droid.bluetoothSocketConnStop() - # Give sufficient time for the physical LE link to be disconnected. - time.sleep(l2cap_max_inactivity_delay_after_disconnect) - - # This utility function calculates the max and min connection event (ce) time. - # The formula is that the min/max ce time should be less than half the connection - # interval and must be multiples of the le_connection_event_time_step. - def _calc_min_max_ce_time(self, le_connection_interval): - conn_event_time_steps = int((le_connection_interval/2)/le_connection_event_time_step_ms) - conn_event_time_steps -= 1 - return (le_connection_event_time_step_ms * conn_event_time_steps) - - def _run_coc_connection_throughput_2_conn( - self, - is_secured, - buffer_size, - le_connection_interval=0, - le_tx_data_length=default_le_data_length, - min_ce_len=0, - max_ce_len=0): - - # The num_iterations is that number of repetitions of each - # set of buffers r/w. - # number_buffers is the total number of data buffers to transmit per - # set of buffers r/w. - # buffer_size is the number of bytes per L2CAP data buffer. - num_iterations = 10 - number_buffers = 100 - - # Make sure at least 3 phones are setup - if len(self.android_devices) <= 2: - self.log.info("test_coc_connection_throughput_2_conn: " - "Error: 3rd phone not configured in file") - return False - - self.log.info( - "_run_coc_connection_throughput_2_conn: is_secured={}, Interval={}, buffer_size={}, " - "le_tx_data_length={}, min_ce_len={}".format(is_secured, le_connection_interval, - buffer_size, le_tx_data_length, min_ce_len)) - status, client_conn_id1, server_conn_id1 = orchestrate_coc_connection( - self.client_ad, self.server_ad, True, is_secured, - le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms, - min_ce_len, max_ce_len) - if not status: - return False - - status, client_conn_id2, server_conn_id2 = orchestrate_coc_connection( - self.client_ad, self.server2_ad, True, is_secured, - le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms, - min_ce_len, max_ce_len) - if not status: - return False - - list_server_ad = [self.server_ad, self.server2_ad] - list_client_conn_id = [client_conn_id1, client_conn_id2] - data_rate = do_multi_connection_throughput( - self.client_ad, list_server_ad, list_client_conn_id, - num_iterations, number_buffers, buffer_size) - if data_rate <= 0: - return False - - self.log.info( - "test_coc_connection_throughput_2_conn: throughput=%d bytes per " - "sec", data_rate) - - self.client_ad.droid.bluetoothSocketConnStop(client_conn_id1) - self.client_ad.droid.bluetoothSocketConnStop(client_conn_id2) - self.server_ad.droid.bluetoothSocketConnStop(server_conn_id1) - self.server2_ad.droid.bluetoothSocketConnStop(server_conn_id2) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='27226006-b725-4312-920e-6193cf0539d4') - def test_coc_insecured_connection_throughput_2_conn(self): - """Test LE CoC data throughput on two insecured connections - - Test Data Throughput of 2 L2CAP CoC insecured connections. - 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Verify that the L2CAP CoC connection is active from both the client - and server. - 4. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 5. Verify that the L2CAP CoC connection is active from both the client - and server. - 6. Write data from the client to both server#1 and server#2. - 7. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 2 - """ - - # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length - status = self._run_coc_connection_throughput_2_conn(False, 117) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1a5fb032-8a27-42f1-933f-3e39311c09a6') - def test_coc_secured_connection_throughput_2_conn(self): - """Test LE CoC data throughput on two secured connections - - Test Data Throughput of 2 L2CAP CoC secured connections. - 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is secured. - 3. Verify that the L2CAP CoC connection is active from both the client - and server. - 4. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is secured. - 5. Verify that the L2CAP CoC connection is active from both the client - and server. - 6. Write data from the client to both server#1 and server#2. - 7. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 2 - """ - - # Note: A 117 octets buffer size would fix nicely to a 123 bytes Data Length - status = self._run_coc_connection_throughput_2_conn(True, 117) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b198f8cc-26af-44bd-bb4d-7dc8f8645617') - def test_coc_connection_throughput_2_conn_NOSEC_10CI_60SIZE(self): - """Test LE CoC data throughput with 10msec CI and 60bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval - and 60 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 20 msec and buffer size to 60 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 20 msec and buffer size to 60 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 10 - buffer_size = 60 - le_tx_data_length = buffer_size + l2cap_coc_header_size - - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='12dc2a6c-8283-4617-a911-42335dd693a8') - def test_coc_connection_throughput_2_conn_NOSEC_10CI_80SIZE(self): - """Test LE CoC data throughput with 10msec CI and 80bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval - and 80 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 20 msec and buffer size to 80 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 20 msec and buffer size to 80 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 10 - buffer_size = 80 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4730df05-3909-4adf-a365-7f0c3258c402') - def test_coc_connection_throughput_2_conn_NOSEC_10CI_120SIZE(self): - """Test LE CoC data throughput with 10msec CI and 120bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval - and 120 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 20 msec and buffer size to 120 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 20 msec and buffer size to 120 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 10 - buffer_size = 120 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='471a8748-b0a5-4be5-9322-7c75e2b5d048') - def test_coc_connection_throughput_2_conn_NOSEC_15CI_120SIZE(self): - """Test LE CoC data throughput with 15msec CI and 120bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 15msec connection interval - and 120 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 15 msec and buffer size to 120 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 15 msec and buffer size to 120 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 15 - buffer_size = 120 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='053e59c2-f312-4bec-beaf-9e4efdce063a') - def test_coc_connection_throughput_2_conn_NOSEC_15CI_180SIZE(self): - """Test LE CoC data throughput with 15msec CI and 180bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 15msec connection interval - and 120 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 15 msec and buffer size to 180 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 15 msec and buffer size to 180 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 15 - buffer_size = 180 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2b43caa6-76b3-48c5-b342-32ebb31ac52c') - def test_coc_connection_throughput_2_conn_NOSEC_20CI_240SIZE(self): - """Test LE CoC data throughput with 20msec CI and 240bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval - and 240 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 20 msec and buffer size to 240 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 20 msec and buffer size to 240 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 1 - """ - - is_secured = False - le_connection_interval = 20 - buffer_size = 240 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f630df02-3fd6-4aa0-bc15-06837b705e97') - def test_coc_connection_throughput_2_conn_NOSEC_30CI_240SIZE(self): - """Test LE CoC data throughput with 30msec CI and 240bytes buffer size. - - Test data throughput of 2 L2CAP CoC insecured connections with 20msec connection interval - and 240 bytes buffer size. 3 phones are required. - - Steps: - 1. Get the mac address of the server device. - 2. Establish a L2CAP CoC connection from the client to the server#1 AD. - The connection is insecured. - 3. Set the connection interval to 30 msec and buffer size to 240 bytes. - 4. Verify that the L2CAP CoC connection is active from both the client - and server. - 5. Establish a L2CAP CoC connection from the client to the server#2 AD. - The connection is insecured. - 6. Set the connection interval to 30 msec and buffer size to 240 bytes. - 7. Verify that the L2CAP CoC connection is active from both the client - and server. - 8. Write data from the client to both server#1 and server#2. - 9. Verify data matches from client and server - - Expected Result: - L2CAP CoC connections are established and data written correctly to both servers. - - Returns: - Pass if True - Fail if False - - TAGS: BLE, CoC - Priority: 2 - """ - - is_secured = False - le_connection_interval = 30 - buffer_size = 240 - le_tx_data_length = buffer_size + l2cap_coc_header_size - status = self._run_coc_connection_throughput_2_conn( - is_secured, buffer_size, le_connection_interval, le_tx_data_length, - self._calc_min_max_ce_time(le_connection_interval), - self._calc_min_max_ce_time(le_connection_interval)) - return status diff --git a/acts_tests/tests/google/ble/examples/BleExamplesTest.py b/acts_tests/tests/google/ble/examples/BleExamplesTest.py index 1ced2db965..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/examples/BleExamplesTest.py +++ b/acts_tests/tests/google/ble/examples/BleExamplesTest.py @@ -1,143 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This script shows simple examples of how to get started with bluetooth low energy testing in acts. -""" - -import pprint - -from acts.controllers import android_device -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers -from acts.test_utils.bt.bt_test_utils import reset_bluetooth - - -class BleExamplesTest(BluetoothBaseTest): - default_timeout = 10 - active_scan_callback_list = [] - active_adv_callback_list = [] - scn_droid = None - adv_droid = None - - def setup_class(self): - super().setup_class() - self.scn_droid, self.scn_ed = (self.android_devices[0].droid, - self.android_devices[0].ed) - self.adv_droid, self.adv_ed = (self.android_devices[1].droid, - self.android_devices[1].ed) - - def teardown_test(self): - cleanup_scanners_and_advertisers( - self.android_devices[0], self.active_adv_callback_list, - self.android_devices[1], self.active_adv_callback_list) - self.active_adv_callback_list = [] - self.active_scan_callback_list = [] - - # An optional function. This overrides the default - # on_exception in base_test. If the test throws an - # unexpected exception, you can customise it. - def on_exception(self, test_name, begin_time): - self.log.debug("Test {} failed. Gathering bugreport and btsnoop logs". - format(test_name)) - android_devices.take_bug_reports(self.android_devices, test_name, - begin_time) - - @BluetoothBaseTest.bt_test_wrap - def test_bt_toggle(self): - """ - Test that simply toggle bluetooth - :return: - """ - return reset_bluetooth([self.android_devices[0]]) - - ''' - Start: Examples of BLE Scanning - ''' - - @BluetoothBaseTest.bt_test_wrap - def test_start_ble_scan(self): - """Test to demonstrate how to start an LE scan - - Test that shows the steps to start a new ble scan. - - Steps: - 1. Create a scan filter object. - 2. Create a scan setting object. - 3. Create a scan callback object. - 4. Start an LE scan using the objects created in steps 1-3. - 5. Find an advertisement with the scanner's event dispatcher. - - Expected Result: - A generic advertisement is found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Scanning - Priority: 4 - """ - filter_list = self.scn_droid.bleGenFilterList() - scan_settings = self.scn_droid.bleBuildScanSetting() - scan_callback = self.scn_droid.bleGenScanCallback() - self.scn_droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - event_name = scan_result.format(scan_callback) - try: - event = self.scn_ed.pop_event(event_name, self.default_timeout) - self.log.info("Found scan result: {}".format( - pprint.pformat(event))) - except Exception: - self.log.info("Didn't find any scan results.") - return True - - ''' - End: Examples of BLE Scanning - ''' - - @BluetoothBaseTest.bt_test_wrap - def test_start_ble_advertise(self): - """Test to demonstrate how to start an LE advertisement - - Test that shows the steps to start a new ble scan. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising - Priority: 4 - """ - advertise_data = self.adv_droid.bleBuildAdvertiseData() - advertise_settings = self.adv_droid.bleBuildAdvertiseSettings() - advertise_callback = self.adv_droid.bleGenBleAdvertiseCallback() - self.adv_droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.adv_ed.pop_event(adv_succ.format(advertise_callback)) - return True diff --git a/acts_tests/tests/google/ble/examples/GattServerExampleTest.py b/acts_tests/tests/google/ble/examples/GattServerExampleTest.py index e1f6476017..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/examples/GattServerExampleTest.py +++ b/acts_tests/tests/google/ble/examples/GattServerExampleTest.py @@ -1,67 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids -from acts.test_utils.bt.gatts_lib import GattServerLib - -service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb' -characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630' -descriptor_uuid = gatt_char_desc_uuids['client_char_cfg'] - -gatt_server_read_descriptor_sample = { - 'services': [{ - 'uuid': - service_uuid, - 'type': - gatt_service_types['primary'], - 'characteristics': [{ - 'uuid': - characteristic_uuid, - 'properties': - gatt_characteristic['property_read'], - 'permissions': - gatt_characteristic['permission_read'], - 'instance_id': - 0x002a, - 'value_type': - gatt_characteristic_value_format['string'], - 'value': - 'Test Database', - 'descriptors': [{ - 'uuid': descriptor_uuid, - 'permissions': gatt_descriptor['permission_read'], - }] - }] - }] -} - - -class GattServerExampleTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.dut = self.android_devices[0] - - @BluetoothBaseTest.bt_test_wrap - def test_create_gatt_server_db_example(self): - gatts = GattServerLib(log=self.log, dut=self.dut) - gatts.setup_gatts_db(database=gatt_server_read_descriptor_sample) - self.log.info(gatts.list_all_uuids()) - return True diff --git a/acts_tests/tests/google/ble/filtering/FilteringTest.py b/acts_tests/tests/google/ble/filtering/FilteringTest.py index d1bdc399c9..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/filtering/FilteringTest.py +++ b/acts_tests/tests/google/ble/filtering/FilteringTest.py @@ -1,12100 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -import itertools as it -import pprint -import time - -from queue import Empty -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_advertise_settings_tx_powers -from acts.test_utils.bt.bt_constants import java_integer -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import small_timeout -from acts.test_utils.bt.bt_constants import adv_fail -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result - - -class FilteringTest(BluetoothBaseTest): - default_timeout = 30 - default_callback = 1 - default_is_connectable = True - default_advertise_mode = 0 - default_tx_power_level = 2 - - #Data constant variants - manu_sepecific_data_small = [1] - manu_sepecific_data_small_2 = [1, 2] - manu_specific_data_small_3 = [127] - manu_sepecific_data_large = [14, 0, 54, 0, 0, 0, 0, 0] - manu_sepecific_data_mask_small = [1] - manu_specific_data_id_1 = 1 - manu_specific_data_id_2 = 2 - manu_specific_data_id_3 = 65535 - - service_data_small = [13] - service_data_small_2 = [127] - service_data_medium = [11, 14, 50] - service_data_large = [ - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 26, 17, 18, 19, 20, - 21, 22, 23, 24 - ] - - service_mask_1 = "00000000-0000-1000-8000-00805f9b34fb" - service_uuid_1 = "00000000-0000-1000-8000-00805f9b34fb" - service_uuid_2 = "FFFFFFFF-0000-1000-8000-00805f9b34fb" - service_uuid_3 = "3846D7A0-69C8-11E4-BA00-0002A5D5C51B" - - def setup_class(self): - super().setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - self.log.info("Scanner device model: {}".format( - self.scn_ad.droid.getBuildModel())) - self.log.info("Advertiser device model: {}".format( - self.adv_ad.droid.getBuildModel())) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='be72fc18-e7e9-41cf-80b5-e31babd763f6') - def test_filter_combo_0(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='92e11460-1877-4dd1-998b-8f78354dd776') - def test_filter_combo_1(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9cdb7ad3-9f1e-4cbc-ae3f-af27d9833ae3') - def test_filter_combo_2(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ae06ece8-28ae-4c2f-a768-d0e1e60cc253') - def test_filter_combo_3(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7a7c40fb-1398-4659-af46-ba01ca23ba7f') - def test_filter_combo_4(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='85cab0b7-4ba2-408c-b78b-c45d0cad1d1e') - def test_filter_combo_5(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='31e7a496-6626-4d73-8337-b250f7386ab6') - def test_filter_combo_6(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='465f5426-1157-4a6f-8c33-a266ee7439bc') - def test_filter_combo_7(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='77552584-74c7-4a1b-a98e-8863e91f4e74') - def test_filter_combo_8(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fb2b5f08-53cd-400b-98a0-bbd96093e466') - def test_filter_combo_9(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='edacb609-9508-4394-9c94-9ed13a4205b5') - def test_filter_combo_10(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='73a86198-3213-43c5-b083-0a37089b8e44') - def test_filter_combo_11(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9ca92075-d22b-4e82-9e7b-495060f3af45') - def test_filter_combo_12(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a0689f97-c616-49a5-b690-00b6193ac822') - def test_filter_combo_13(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='dbdf3a68-c79a-43a6-89a7-5269a1fad9a5') - def test_filter_combo_14(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='93e45b16-dff0-4067-9c14-7adf32a0f484') - def test_filter_combo_15(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='dace8a1c-e71a-4668-9e8f-b1cb19071087') - def test_filter_combo_16(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='192528e2-4a67-4984-9c68-f9d716470d5b') - def test_filter_combo_17(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2a9ffd92-f02d-45bc-81f5-f398e2572f14') - def test_filter_combo_18(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ab98e5e5-ac35-4ebe-8b37-780b0ab56b82') - def test_filter_combo_19(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0b4ca831-dbf6-44da-84b6-9425b7f50577') - def test_filter_combo_20(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f615206a-16bf-4481-be31-7b2a28d8009b') - def test_filter_combo_21(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e9a0e69e-bc5c-479e-a716-cbb88180e719') - def test_filter_combo_22(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='16c2949d-e7c8-4fa1-a781-3ced2c902c4c') - def test_filter_combo_23(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ffd7a3a8-b9b5-4bf0-84c1-ed3823b8a52c') - def test_filter_combo_24(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='457b5dee-1034-4973-88c1-bde0a6ef700c') - def test_filter_combo_25(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b848e90c-37ed-4ecb-8c49-601f3b66a4cc') - def test_filter_combo_26(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c03df405-b7aa-42cf-b282-adf5c228e513') - def test_filter_combo_27(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='83de681d-89fb-45e1-b8e0-0488e43b3248') - def test_filter_combo_28(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='712bf6b2-0cdc-4782-b593-17a846fd1c65') - def test_filter_combo_29(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='725c37e5-046b-4234-a7eb-ad8836531a74') - def test_filter_combo_30(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='665344f9-c246-4b08-aff6-73f7ff35431b') - def test_filter_combo_31(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6994ceff-fed8-42e4-a3cb-be6ed3a9a5c9') - def test_filter_combo_32(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2fb756c0-8b72-403a-a769-d22d31376037') - def test_filter_combo_33(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='146203bb-04cc-4b3d-b372-66e1b8da3e08') - def test_filter_combo_34(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1e123df5-db37-4e8d-ac1f-9399fe8487f9') - def test_filter_combo_35(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='886f0978-a2df-4005-810b-5e2cc0c2a5a4') - def test_filter_combo_36(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='94f61b07-e90a-42e3-b97b-07afc73755e6') - def test_filter_combo_37(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1dbb67ed-2f9e-464d-8ba8-dd7ac668d765') - def test_filter_combo_38(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3a3e5aa9-a5cc-4e99-aeb4-b32357186e1d') - def test_filter_combo_39(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2c51245a-7be3-4dfb-87c5-7c4530ab5908') - def test_filter_combo_40(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9d33bae5-0a5f-4d2c-96fc-fc1ec8107814') - def test_filter_combo_41(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='05b5ee9e-9a64-4bf8-91ab-a7762358d25e') - def test_filter_combo_42(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='589f4d3f-c644-4981-a0f8-cd9bcf4d5142') - def test_filter_combo_43(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='10ce4d36-081f-4353-a484-2c7988e7cda8') - def test_filter_combo_44(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6f52f24d-adda-4e2d-b52e-1b24b978c343') - def test_filter_combo_45(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5aacbec9-4a8b-4c76-9684-590a29f73854') - def test_filter_combo_46(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e1fa3728-9acb-47e9-bea4-3ac886c68a22') - def test_filter_combo_47(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9ce98edd-5f94-456c-8083-3dd37eefe086') - def test_filter_combo_48(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cb93cdab-6443-4946-a7f6-9c34e0b21272') - def test_filter_combo_49(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d9069a4d-8635-4b91-9a0f-31a64586a216') - def test_filter_combo_50(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='559f4f49-bd6a-4490-b8b3-da13ef57eb83') - def test_filter_combo_51(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d769aa3c-c039-45f3-8ef7-f91ccbbcdfaf') - def test_filter_combo_52(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4c6adf11-7c79-4a97-b507-cc8044d2c7c6') - def test_filter_combo_53(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b99f7238-197b-4fb0-80a9-a51a20c00093') - def test_filter_combo_54(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f1e3e036-b611-4325-81e2-114ad777d00e') - def test_filter_combo_55(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9f786760-8a33-4076-b33e-38acc6689b5c') - def test_filter_combo_56(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9e6466c3-ce73-471e-8b4a-dce1a1c9d046') - def test_filter_combo_57(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b44f6d43-07cb-477d-bcc8-460cc2094475') - def test_filter_combo_58(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='38dcb64b-6564-4116-8abb-3a8e8ed530a9') - def test_filter_combo_59(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b0918c1a-1291-482c-9ecb-2df085ec036f') - def test_filter_combo_60(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6c317053-6fdc-45e1-9109-bd2726b2490f') - def test_filter_combo_61(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='af057157-3ef5-48af-918d-53ba6b2e8405') - def test_filter_combo_62(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4693bb43-a4b6-4595-a75b-ff18c4be50c7') - def test_filter_combo_63(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6e2037c1-5e99-4dc7-8950-5fd3df29fa08') - def test_filter_combo_64(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a85acfbb-e6d2-42f4-b917-6b0bac26e457') - def test_filter_combo_65(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d05f3aaa-833c-40a1-b3a0-c69756919218') - def test_filter_combo_66(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1dd2b27b-f9fe-41e3-b884-3500d6bf9a38') - def test_filter_combo_67(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e31e7d9d-878b-442e-9ae9-b07d5e903df3') - def test_filter_combo_68(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='05c05a71-27a4-4620-940b-ce3747d4e6c5') - def test_filter_combo_69(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c4bb2251-1246-466b-a6bb-76ae13089101') - def test_filter_combo_70(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b284008a-81be-42b6-8176-906a780f92a2') - def test_filter_combo_71(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='01bc025f-4696-4e80-a590-ec7b0eeea1a3') - def test_filter_combo_72(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ef674d1e-f3b1-43fc-a037-718ffe650d12') - def test_filter_combo_73(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cbc29a50-76fe-40b8-93fa-b274605660b2') - def test_filter_combo_74(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0674b703-2571-4bcf-91f2-a34a323e179b') - def test_filter_combo_75(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a65046b3-4aed-47f3-86cd-838155dfd309') - def test_filter_combo_76(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a379dfdd-8924-4e62-95ac-14fe3ae358da') - def test_filter_combo_77(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3ed6b73f-23fb-4ef2-8bd5-e59a34f362cd') - def test_filter_combo_78(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9d3fc46a-07b7-48ad-9a31-fcdba259c670') - def test_filter_combo_79(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9ba5e905-634f-485b-829c-1ef79fa5f116') - def test_filter_combo_80(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b275ff76-eec5-467b-b12d-7440ff588cec') - def test_filter_combo_81(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='009ecb1c-2860-4a4e-867b-c712569ddfd1') - def test_filter_combo_82(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='61c7da36-6b19-49d2-9981-120bb0b76372') - def test_filter_combo_83(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4c22688a-4d03-4145-aa2f-f989832f8086') - def test_filter_combo_84(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cc159f43-5619-46fe-b8ad-209a446f10c0') - def test_filter_combo_85(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9a81d52e-cd46-4e2b-9ac1-ecebcc04d788') - def test_filter_combo_86(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='938c404f-8dd8-46a5-afe4-f87559bb2c9d') - def test_filter_combo_87(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4bc6a2db-e845-435d-8d8e-a990f4b1fcdc') - def test_filter_combo_88(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e245fb6a-35fc-488f-ada6-393fe4a09134') - def test_filter_combo_89(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4dd70ebf-ec85-4e95-a9f5-a10e1791293c') - def test_filter_combo_90(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b0085042-0fd6-4ff3-af69-156f270953b1') - def test_filter_combo_91(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6b9a539b-b6cc-46b1-a9a5-ef20808f5e74') - def test_filter_combo_92(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1f18a94c-a72e-4912-a91a-0be96e708be4') - def test_filter_combo_93(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9f2d3923-a932-40c8-b527-8baedcf3254c') - def test_filter_combo_94(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='edf61fa9-b51f-41fd-b3ca-0035ee7dbd65') - def test_filter_combo_95(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8b8adcf5-adb9-4a48-8570-4e1d2e6b47c6') - def test_filter_combo_96(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cc7857e0-5a5b-468f-bf5e-dc1478716715') - def test_filter_combo_97(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b4c9e01f-944c-4d8e-9a3f-49efaa22887c') - def test_filter_combo_98(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='951e19cf-c138-4d8e-92e6-b42410b8114f') - def test_filter_combo_99(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ad50f0c0-c19e-45b8-8fb2-95afe81f7620') - def test_filter_combo_100(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a7fd36d6-77ec-453e-a67c-0c2fc78e572a') - def test_filter_combo_101(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d661aafd-005d-4a31-88b0-a238e328b16d') - def test_filter_combo_102(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7fe951d2-28c5-43a9-af79-c0fbf3a3388f') - def test_filter_combo_103(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d802f38b-830f-4cd2-af2c-a44ba625a401') - def test_filter_combo_104(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e1a30f67-1577-4cfb-9a0d-c07493a341b2') - def test_filter_combo_105(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='774a6bf9-cfd6-40ef-8b91-3576f23eb01b') - def test_filter_combo_106(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b85d0c78-69bc-42e3-ac78-61ad8176a1d0') - def test_filter_combo_107(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='bd93c530-4ab0-4d9b-b202-ea6dd1c8a27d') - def test_filter_combo_108(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4590bfbb-006f-46be-bd03-5afe8b81ac52') - def test_filter_combo_109(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2626f60e-cb01-45a1-a23e-f1eaa85ac9ce') - def test_filter_combo_110(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='24cf16ac-10a6-4a02-9b72-84c280fa77a2') - def test_filter_combo_111(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6242aadb-028b-4932-9024-8b6d2148c458') - def test_filter_combo_112(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5918fef7-0578-4999-b331-d2948e62e720') - def test_filter_combo_113(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='63160fc2-306f-46a4-bf1f-b512642478c4') - def test_filter_combo_114(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='849749ae-e5f3-4029-be92-66a1353ba165') - def test_filter_combo_115(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5f150448-94f6-4f0b-a8da-0c4a78541a4f') - def test_filter_combo_116(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='39af4eca-990a-4b3b-bcf2-1a840e8a9308') - def test_filter_combo_117(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a59cb1fa-eb7d-4161-84a9-cda157b6b8c5') - def test_filter_combo_118(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cfaf02e5-76e4-4593-849c-b63de4907638') - def test_filter_combo_119(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9eb40c09-89ea-44e9-8514-e58cdce91779') - def test_filter_combo_120(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e2d2a8d5-0554-49cc-9cc9-66e97378d260') - def test_filter_combo_121(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cb72c86a-a7c6-4bf9-9eec-53f7d190a9f1') - def test_filter_combo_122(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cb75e56e-a029-478d-8031-8de12f5fbebf') - def test_filter_combo_123(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='277a98c4-4b1f-428d-8c10-8697a3fe1f0f') - def test_filter_combo_124(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2d884bf2-c678-429c-8aee-3be78b3176ff') - def test_filter_combo_125(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e6b5fcff-8a6e-4eb7-9070-74caf9e18349') - def test_filter_combo_126(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='682ffa88-2d13-4d21-878e-c2a8a510cf71') - def test_filter_combo_127(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a27d8f58-7523-404a-bf99-744afdb52aba') - def test_filter_combo_128(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f2c77cf7-dc52-471d-b66d-54e72f7f7ea0') - def test_filter_combo_129(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3e21ad66-88fc-48ee-a698-6c475f478a86') - def test_filter_combo_130(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='af046c81-524e-4016-b6a8-459538f320c2') - def test_filter_combo_131(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f3aad5f8-6214-4c67-9a84-2da7171fb111') - def test_filter_combo_132(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='16ab8d79-15ca-4ab3-b004-834edb4da37b') - def test_filter_combo_133(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cb37c6a3-496f-49a6-b02a-552b8260205e') - def test_filter_combo_134(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9e3ad4d0-4fab-4d85-9543-5e2c2fea79ec') - def test_filter_combo_135(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='37f93abf-237e-4917-91a6-afa2629b5f98') - def test_filter_combo_136(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1131c908-ddf2-4cdd-b1a2-9b73990e72c3') - def test_filter_combo_137(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1b283fa0-485b-4f45-a353-36f9cdd6c123') - def test_filter_combo_138(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e4bdc84e-413c-4a2b-9049-f5b04e32b5b7') - def test_filter_combo_139(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8791e036-3f30-4a44-b3a8-23371da893a6') - def test_filter_combo_140(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='27201535-9537-4e11-a1d7-1b1f5f01e213') - def test_filter_combo_141(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e40e7b8f-44f0-4f87-8206-fea14d0fef52') - def test_filter_combo_142(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0f369e78-c5ae-4cbc-8511-597cdc38b1ae') - def test_filter_combo_143(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='174418c1-6938-4319-9d8b-361df3fc28f3') - def test_filter_combo_144(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6bc94d17-b532-413b-86fc-185c194b430c') - def test_filter_combo_145(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3c47822e-5e74-4270-bcb4-72e3995bd5c5') - def test_filter_combo_146(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='19515def-b28d-4ef7-bae7-c4f64940879a') - def test_filter_combo_147(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a45abd7c-24ca-400c-b2d5-233431b07522') - def test_filter_combo_148(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4492a245-c91f-4df1-a55b-57541ce410c8') - def test_filter_combo_149(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e4c485af-66a0-413b-b70e-3396e130fffb') - def test_filter_combo_150(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='31369cd6-feb7-47f3-9022-2d619c961ba7') - def test_filter_combo_151(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5cf0da7f-a515-4f67-bae4-956d86275423') - def test_filter_combo_152(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a78293f0-aee5-40d1-9c97-3fdda3ddd43e') - def test_filter_combo_153(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3fd7d0cb-6d98-4ca8-9a14-8ca23b6dae07') - def test_filter_combo_154(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='19434f33-5bc5-427f-b332-36f85c997fe3') - def test_filter_combo_155(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4195c9e1-b87c-4fa1-8039-ec0f2652e216') - def test_filter_combo_156(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0536e50e-f33c-4772-b078-4f95231c3de6') - def test_filter_combo_157(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='116dcfef-caae-496f-abfa-0863f2968f6f') - def test_filter_combo_158(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='00f37533-9ca5-4c58-adb3-d3d709c7b215') - def test_filter_combo_159(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d86e57da-29b5-445e-bf75-3e2843b9b739') - def test_filter_combo_160(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='792736ce-8f43-4d21-b9b9-30d3bfd66b6a') - def test_filter_combo_161(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': False, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ec387a8a-e7b2-4df7-9580-b09362c3dc4d') - def test_filter_combo_162(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='93a8f3b0-0fb0-47bd-88fb-6dc847ac14e4') - def test_filter_combo_163(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='283356e9-58ac-4edc-bf08-0bc9c7313053') - def test_filter_combo_164(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ab4f0d84-58fd-4a2a-b3ed-128231f3e22f') - def test_filter_combo_165(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='02bbbdd0-3c57-41c5-ab32-28185f33802c') - def test_filter_combo_166(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f6c67a80-bede-4186-b7a1-09756b4c1a68') - def test_filter_combo_167(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4fc73f9c-4826-4ff2-bba0-bc64cc469f3a') - def test_filter_combo_168(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='58a6fafc-bbc5-466b-a586-310d9dfc14c1') - def test_filter_combo_169(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='38de3927-212c-4948-bd46-cca1d09ead90') - def test_filter_combo_170(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b03a34cf-c3e1-4954-9cb6-b5f1a59e94e9') - def test_filter_combo_171(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='455ead9d-1e50-46e4-907c-c5b9bbbdcc9c') - def test_filter_combo_172(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a7320afc-affb-4fa5-877d-7eb8bd1f8558') - def test_filter_combo_173(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='163c5c85-bef7-4da6-8e8a-89b0656b71d0') - def test_filter_combo_174(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='31147187-c5a9-4c2e-8be6-b79ff71cdaf3') - def test_filter_combo_175(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='783b5756-ca16-4a17-b1f0-8a16ddc009c4') - def test_filter_combo_176(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='924a107b-fe1c-4b9d-b29b-47c3b2df1de3') - def test_filter_combo_177(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='096a6596-fd8c-4d8c-88c6-45903047fe2c') - def test_filter_combo_178(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e37b2083-a9d0-4337-aa11-d9205c15f456') - def test_filter_combo_179(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3de8087b-7f25-4cda-8f07-fa9326524deb') - def test_filter_combo_180(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f218bf14-0a6e-4c5f-b151-3ac9719ca1a2') - def test_filter_combo_181(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1a13171d-b9a9-4b42-8cec-5c5841c4f3a5') - def test_filter_combo_182(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='53311ac1-239f-4033-aaa6-084523916fc6') - def test_filter_combo_183(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f8bb89b2-2dae-4d41-9d19-6c9af0fe6da8') - def test_filter_combo_184(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4747ab09-8d62-4866-80e6-c9b8e4cf5061') - def test_filter_combo_185(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='be6db894-57dd-452a-8f08-3ce462ac9417') - def test_filter_combo_186(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2070329b-b7c8-4958-af9c-2e1044b71564') - def test_filter_combo_187(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1a428d9e-46fd-4bd2-a12c-25c89ead74b1') - def test_filter_combo_188(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': True, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f07220c2-c0a9-471a-871d-a87931feb278') - def test_filter_combo_189(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b3af8fb0-cd93-4ab0-b8f3-4111969c7cbb') - def test_filter_combo_190(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b630cc10-4cda-487d-ab84-599963c172d7') - def test_filter_combo_191(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9cdbe1df-e3e1-45e4-b816-96b8a6efb90f') - def test_filter_combo_192(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='10cd2757-a182-419f-9512-8b536539a134') - def test_filter_combo_193(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5c7af5b2-8a2c-4c2d-911f-dad8216d849f') - def test_filter_combo_194(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0acb37c7-0ece-4f5b-9294-014dd7fcb3ed') - def test_filter_combo_195(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='14f07972-6403-49be-8eed-ce7294e33d32') - def test_filter_combo_196(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f2db7e80-d3ea-4beb-8e09-24ae33904716') - def test_filter_combo_197(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='30c1303f-956f-4b2d-af6a-3570aa4567fd') - def test_filter_combo_198(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8e210748-f842-4fa1-ac40-2bfd291f08a1') - def test_filter_combo_199(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='756c687d-8183-4bc9-90dc-4e46a5579fca') - def test_filter_combo_200(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8f904946-a9c7-4f7a-af96-0d22c5592709') - def test_filter_combo_201(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='abdfce9f-3529-435b-8fdc-9dd7bf0fc01c') - def test_filter_combo_202(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='71289aa2-f74d-44b7-ad18-515a3c438a15') - def test_filter_combo_203(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='223db6ca-7190-4f3f-89cc-92dcc2dcd109') - def test_filter_combo_204(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8a61a11e-fc25-4e28-928d-e2be2d95af63') - def test_filter_combo_205(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8c62bc17-6998-4ec8-923b-e29fe1693ae3') - def test_filter_combo_206(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': [1, 2], - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='85f168fa-a868-4940-aef1-de063a497083') - def test_filter_combo_207(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7697ca45-fc34-4f8c-9b61-58cc7d4f3321') - def test_filter_combo_208(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f5221c06-c006-4363-ab9c-90b9d8c31b43') - def test_filter_combo_209(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b7119a2d-6269-408c-ae69-39ebad1e4192') - def test_filter_combo_210(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2025037f-433b-4167-a0c9-3265a53fe6ba') - def test_filter_combo_211(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ecf2c84b-88b0-48d9-8a4f-3660f039cd97') - def test_filter_combo_212(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_2, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='844a6bcb-cd5a-4023-9af7-cab68ed2e847') - def test_filter_combo_213(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_medium - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b7e5ff94-93e0-45c9-a160-33628f5fcf9e') - def test_filter_combo_214(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b9781df2-59e4-44ba-9a98-1d35670a6f63') - def test_filter_combo_215(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_3, - 'service_data_uuid': self.service_uuid_1, - 'manufacturer_specific_data': self.manu_specific_data_small_3, - 'include_tx_power_level': False, - 'include_device_name': True, - 'service_data': self.service_data_small_2 - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4ad156f8-8d80-4635-b6d8-7bca07d8a899') - def test_filter_combo_216(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5b68c344-bfd1-44cb-9add-c81122d6b04f') - def test_filter_combo_217(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='355ca57c-998c-4e7e-b0d2-66854b5192bb') - def test_filter_combo_218(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a9ec0f76-6b8f-42e0-8310-07c02de49d9d') - def test_filter_combo_219(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='73f448ff-e9f6-4608-80ba-92131485234f') - def test_filter_combo_220(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='55ec509d-8cdd-4ab5-8e57-2ccadd5f8c0d') - def test_filter_combo_221(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1f6835fd-b33b-4be3-b133-b77f6c9872c8') - def test_filter_combo_222(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='62d483c0-7d08-4b7c-9b1f-3b0324006554') - def test_filter_combo_223(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='01bcb867-3f39-4aef-baf5-50b439768b43') - def test_filter_combo_224(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='faab6211-4408-4272-93d9-7b09b8c3b8cd') - def test_filter_combo_225(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a0f9ad8d-c00a-4420-9205-eeb081bf2b35') - def test_filter_combo_226(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7a2e8186-e8b0-4956-b8bc-fb2ba91b8f67') - def test_filter_combo_227(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='414b5464-b135-453b-acf3-aebc728d0366') - def test_filter_combo_228(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='580e3ff8-4648-402e-a531-ddb85bbf4c89') - def test_filter_combo_229(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7fe0c829-94b5-4e88-aa92-47159c1eb232') - def test_filter_combo_230(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='93c1747d-4b76-4faf-9efc-4ca40e751f08') - def test_filter_combo_231(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='96f7e662-6f74-407a-b1d8-e29ac3405ff4') - def test_filter_combo_232(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cde6415b-1138-4913-ab4f-542d4057542d') - def test_filter_combo_233(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4ca75288-0af8-462b-9146-022b9f915b1f') - def test_filter_combo_234(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4db5dae2-f974-4208-9c01-84ca050f8fc3') - def test_filter_combo_235(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c9f7abf0-b333-4500-9fd0-e4678574cf18') - def test_filter_combo_236(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b8176ca4-478c-49c6-a638-4f53d7d2720c') - def test_filter_combo_237(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7e84c371-f28e-4995-86a9-bb99a4a29d0c') - def test_filter_combo_238(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3b8eb500-6885-4273-9c53-f7930896e895') - def test_filter_combo_239(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f80ef69f-d71c-4c94-893d-363cf5a658f6') - def test_filter_combo_240(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='dca1ab9d-7923-4917-8a82-1917dbad4923') - def test_filter_combo_241(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='36faab09-d874-4f24-b7ea-8985d60dc4c3') - def test_filter_combo_242(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c94b7e3b-064c-4885-a4aa-899e83d0e754') - def test_filter_combo_243(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f6680820-8843-47e4-b4fb-0ee1b76d51f8') - def test_filter_combo_244(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4b1bf9a9-7761-435a-8c6c-511b20312c04') - def test_filter_combo_245(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5c5b0147-cacd-46f0-a6b7-ff8b37cf985b') - def test_filter_combo_246(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c31e26f2-2e82-40bc-a9a5-5ae059b702d8') - def test_filter_combo_247(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': True, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5a1a4438-6bb3-4acc-85ab-b48432c340db') - def test_filter_combo_248(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0dd54bff-d170-441f-81ae-bc11f7c8491b') - def test_filter_combo_249(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='98d878cf-1548-4e79-9527-8741e5b523d0') - def test_filter_combo_250(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ec0c9a9b-3df3-4cba-84fc-9a17a11b1be7') - def test_filter_combo_251(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='eabddddc-29c7-4804-93a8-c259957538ae') - def test_filter_combo_252(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ee0abe8f-254e-4802-b808-4aa8e0306203') - def test_filter_combo_253(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9482cda2-a6f5-4dff-8809-6dfabaaf9f71') - def test_filter_combo_254(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='279f54ee-975b-4edc-a6c8-f018e45846c3') - def test_filter_combo_255(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a3508588-ca01-4063-ae7e-c845ac4a595b') - def test_filter_combo_256(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8bde1746-dec8-4b17-93ba-90448addcb13') - def test_filter_combo_257(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9ae7e798-0981-4501-9302-54553c76a54c') - def test_filter_combo_258(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='28e1efdc-1c5f-44d8-8650-02720db32048') - def test_filter_combo_259(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a309d9d0-bf5e-4878-b6bb-89d3c388d5b2') - def test_filter_combo_260(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b0db2d76-8039-4257-bed0-e5e154a5874f') - def test_filter_combo_261(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='06ecd167-4dbc-4a8c-9c1c-2daea87f7a51') - def test_filter_combo_262(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='12f6c002-8627-4477-8e5a-6d7b5335ed60') - def test_filter_combo_263(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['balanced'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ccd43a09-cb39-4d84-8ffc-99ad8449783b') - def test_filter_combo_264(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f9d9abad-e543-4996-b369-09fddd9c4965') - def test_filter_combo_265(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2a14e619-23a6-4a49-acd6-e712b026d75b') - def test_filter_combo_266(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='2ed25b96-54fd-4a81-b8d1-732b959aff8d') - def test_filter_combo_267(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0ef9198b-78ac-4fa6-afe2-cc87007c2c0d') - def test_filter_combo_268(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='43d97df2-07d7-4c45-bb83-908746e60923') - def test_filter_combo_269(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='55262e57-7b47-45a3-8926-18cea480c2b2') - def test_filter_combo_270(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5ece141d-43ad-448c-900c-500666cb0e1c') - def test_filter_combo_271(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['opportunistic'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='66d3c0de-7e3b-4108-9ab0-3e101c6a14cd') - def test_filter_combo_272(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9703d50a-8b23-4d42-8ed3-9b0704dac9d2') - def test_filter_combo_273(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a5739a21-0e1b-4ba7-b259-acb7b38a8e09') - def test_filter_combo_274(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c399011c-54c0-47a1-9e05-a52c2190f89d') - def test_filter_combo_275(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['balanced'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7854fdcc-5771-463a-91da-5b394484b065') - def test_filter_combo_276(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['high'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fa0fe141-c99f-4228-b249-96232194e740') - def test_filter_combo_277(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d2143fe1-bbec-429a-8241-19f39361b490') - def test_filter_combo_278(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['ultra_low'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='21d025ef-2f89-49fd-bb31-2130dbe83c5c') - def test_filter_combo_279(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_tx_powers['medium'], - 'is_connectable': False, - 'scan_mode': ble_scan_settings_modes['low_power'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='19c5f91d-e10a-43af-8727-c66ee43187f2') - def test_filter_combo_280(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_tx_power_level': True} - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7bda5df3-2644-46ca-b6de-e3d5557395cf') - def test_filter_combo_281(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'filter_device_address': True} - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a80f6a40-9a60-4d68-b5e1-66d6e157cdd8') - def test_filter_combo_282(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='503bfb94-cfb8-4194-b451-23f19aff7b8e') - def test_filter_combo_283(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_large - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9bae0612-559b-460f-9723-fac896974835') - def test_filter_combo_284(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'manufacturer_specific_data_mask': [1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f1ad0e3a-17cd-4e06-a395-7e5dde2268b4') - def test_filter_combo_285(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110A-0000-1000-8000-00805F9B34FB', - 'service_data': self.service_data_large - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='84f29360-9219-4f39-8ead-b43779c65504') - def test_filter_combo_286(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110B-0000-1000-8000-00805F9B34FB', - 'service_data': [13] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='caece017-8379-46a3-913b-a21d3057e096') - def test_filter_combo_287(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110C-0000-1000-8000-00805F9B34FB', - 'service_data': [11, 14, 50] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='37d63f4e-ed0c-4003-8044-f7032238a449') - def test_filter_combo_288(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110D-0000-1000-8000-00805F9B34FB', - 'service_data': [16, 22, 11] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7a57c0d7-1b8d-44e7-b407-7a6c58095058') - def test_filter_combo_289(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110E-0000-1000-8000-00805F9B34FB', - 'service_data': [2, 9, 54] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='38f80b83-2aba-40f4-9238-7e108acea1e4') - def test_filter_combo_290(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110F-0000-1000-8000-00805F9B34FB', - 'service_data': [69, 11, 50] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='adec5d6d-c1f2-46d0-8b05-2c46c02435a6') - def test_filter_combo_291(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001101-0000-1000-8000-00805F9B34FB', - 'service_data': [12, 11, 21] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cd3cbc57-80a6-43d8-8042-9f163beda73a') - def test_filter_combo_292(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001102-0000-1000-8000-00805F9B34FB', - 'service_data': [12, 12, 44] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='35d9ab80-1ceb-4b45-ae9e-304c413f9273') - def test_filter_combo_293(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001103-0000-1000-8000-00805F9B34FB', - 'service_data': [4, 54, 1] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='07cecc9f-6e72-407e-a11d-c982f92c1834') - def test_filter_combo_294(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001104-0000-1000-8000-00805F9B34FB', - 'service_data': [33, 22, 44] - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8c0de318-4c57-47c3-8068-d1b0fde7f448') - def test_filter_combo_295(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': '00000000-0000-1000-8000-00805f9b34fb', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8fbd96a9-5844-4714-8f63-5b92432d23d1') - def test_filter_combo_296(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': 'FFFFFFFF-0000-1000-8000-00805f9b34fb', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d127b973-46ca-4a9f-a1e1-5cda6affaa53') - def test_filter_combo_297(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': '3846D7A0-69C8-11E4-BA00-0002A5D5C51B', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='efaad273-f953-43ca-b4f6-f9eba10d3ba5') - def test_filter_combo_298(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='373ba3e8-01e8-4c26-ad7f-7b7ba69d1a70') - def test_filter_combo_299(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_tx_power_level': True} - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e1848bba-b9a6-473b-bceb-101b14b4ccc1') - def test_filter_combo_300(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'filter_device_address': True} - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3a6068a5-0dd1-4503-b25a-79bc0f4a7006') - def test_filter_combo_301(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c54e14e7-c5f6-4c16-9900-2b8ac9ee96a5') - def test_filter_combo_302(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_large - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='bb188de9-8c63-4eba-96ab-b8577001412d') - def test_filter_combo_303(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'manufacturer_specific_data_id': self.manu_specific_data_id_1, - 'manufacturer_specific_data': self.manu_sepecific_data_small, - 'manufacturer_specific_data_mask': [1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4e42416b-fe86-41e7-99cd-3ea0ab61a027') - def test_filter_combo_304(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110A-0000-1000-8000-00805F9B34FB', - 'service_data': self.service_data_large - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a519609b-cd95-4017-adac-86954153669e') - def test_filter_combo_305(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110B-0000-1000-8000-00805F9B34FB', - 'service_data': [13] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ad1f5bdd-b532-482c-8f62-cc6804f0f8a2') - def test_filter_combo_306(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110C-0000-1000-8000-00805F9B34FB', - 'service_data': [11, 14, 50] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a44af1a3-f5ac-419b-a11b-a72734b57fa7') - def test_filter_combo_307(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110D-0000-1000-8000-00805F9B34FB', - 'service_data': [16, 22, 11] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1b2b17e7-5a1a-4795-974d-3a239c7fccc8') - def test_filter_combo_308(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110E-0000-1000-8000-00805F9B34FB', - 'service_data': [2, 9, 54] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9e9944cc-a85c-4077-9129-ca348a6c0286') - def test_filter_combo_309(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '0000110F-0000-1000-8000-00805F9B34FB', - 'service_data': [69, 11, 50] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e0bb52ea-ac8f-4951-bd00-5322d0e72fd2') - def test_filter_combo_310(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001101-0000-1000-8000-00805F9B34FB', - 'service_data': [12, 11, 21] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='719d258d-6556-47b6-92d6-224c691b5dfd') - def test_filter_combo_311(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001102-0000-1000-8000-00805F9B34FB', - 'service_data': [12, 12, 44] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1ab27561-6e2d-4da8-b2b1-dc4bd2c42f97') - def test_filter_combo_312(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001103-0000-1000-8000-00805F9B34FB', - 'service_data': [4, 54, 1] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5b460a48-f6d6-469c-9553-11817171dacb') - def test_filter_combo_313(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_data_uuid': '00001104-0000-1000-8000-00805F9B34FB', - 'service_data': [33, 22, 44] - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e0439501-b72d-43ac-a51f-c44b4d0c86d9') - def test_filter_combo_314(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': '00000000-0000-1000-8000-00805f9b34fb', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3a7f4527-2a77-4172-8402-78d90fbc5a8a') - def test_filter_combo_315(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': 'FFFFFFFF-0000-1000-8000-00805f9b34fb', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c6661021-33ad-4628-99f0-1a3b4b4a8263') - def test_filter_combo_316(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = { - 'service_uuid': '3846D7A0-69C8-11E4-BA00-0002A5D5C51B', - 'service_mask': '00000000-0000-1000-8000-00805f9b34fb' - } - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='3a633941-1716-4bf6-a8d7-8a4ad0be24aa') - def test_filter_combo_317(self): - """Test a combination scan filter and advertisement - - Test that an advertisement is found and matches corresponding - settings. - - Steps: - 1. Create a advertise data object - 2. Create a advertise settings object. - 3. Create a advertise callback object. - 4. Start an LE advertising using the objects created in steps 1-3. - 5. Find the onSuccess advertisement event. - - Expected Result: - Advertisement is successfully advertising. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - filters = {'include_device_name': True} - settings_in_effect = { - 'scan_mode': ble_scan_settings_modes['low_latency'], - 'mode': ble_advertise_settings_modes['low_latency'] - } - return self._magic((filters, settings_in_effect)) - - def _blescan_verify_onscanresult_event(self, event, filters): - test_result = True - self.log.debug("Verifying onScanResult event: {}".format(event)) - callback_type = event['data']['CallbackType'] - if 'callback_type' in filters.keys(): - if filters['callback_type'] != callback_type: - self.log.error("Expected callback type: {}, Found callback " - "type: {}".format(filters['callback_type'], - callback_type)) - test_result = False - elif self.default_callback != callback_type: - self.log.error("Expected callback type: {}, Found callback type: " - "{}".format(self.default_callback, callback_type)) - test_result = False - if 'include_device_name' in filters.keys() and filters[ - 'include_device_name'] is not False: - if event['data']['Result']['deviceName'] != filters[ - 'include_device_name']: - self.log.error( - "Expected device name: {}, Found device name: {}" - .format(filters['include_device_name'], event['data'][ - 'Result']['deviceName'])) - - test_result = False - elif 'deviceName' in event['data']['Result'].keys(): - self.log.error( - "Device name was found when it wasn't meant to be included.") - test_result = False - if ('include_tx_power_level' in filters.keys() and - filters['include_tx_power_level'] is not False): - if not event['data']['Result']['txPowerLevel']: - self.log.error( - "Expected to find tx power level in event but found none.") - test_result = False - if not event['data']['Result']['rssi']: - self.log.error("Expected rssi in the advertisement, found none.") - test_result = False - if not event['data']['Result']['timestampNanos']: - self.log.error("Expected rssi in the advertisement, found none.") - test_result = False - return test_result - - def _bleadvertise_verify_onsuccess(self, event, settings_in_effect): - self.log.debug("Verifying {} event".format(adv_succ)) - test_result = True - if 'is_connectable' in settings_in_effect.keys(): - if (event['data']['SettingsInEffect']['isConnectable'] != - settings_in_effect['is_connectable']): - self.log.error("Expected is connectable value: {}, Actual is " - "connectable value:".format(settings_in_effect[ - 'is_connectable'], event['data'][ - 'SettingsInEffect']['isConnectable'])) - test_result = False - elif (event['data']['SettingsInEffect']['isConnectable'] != - self.default_is_connectable): - self.log.error( - "Default value for isConnectable did not match what was found.") - test_result = False - if 'mode' in settings_in_effect.keys(): - if (event['data']['SettingsInEffect']['mode'] != - settings_in_effect['mode']): - self.log.error("Expected mode value: {}, Actual mode value: {}" - .format(settings_in_effect['mode'], event[ - 'data']['SettingsInEffect']['mode'])) - test_result = False - elif (event['data']['SettingsInEffect']['mode'] != - self.default_advertise_mode): - self.log.error( - "Default value for filtering mode did not match what was " - "found.") - test_result = False - if 'tx_power_level' in settings_in_effect.keys(): - if (event['data']['SettingsInEffect']['txPowerLevel'] == - java_integer['min']): - self.log.error("Expected tx power level was not meant to be: " - "{}".format(java_integer['min'])) - test_result = False - elif (event['data']['SettingsInEffect']['txPowerLevel'] != - self.default_tx_power_level): - self.log.error( - "Default value for tx power level did not match what" - " was found.") - test_result = False - return test_result - - def _magic(self, params): - (filters, settings_in_effect) = params - test_result = True - - self.log.debug("Settings in effect: {}".format( - pprint.pformat(settings_in_effect))) - self.log.debug("Filters:".format(pprint.pformat(filters))) - if 'is_connectable' in settings_in_effect.keys(): - self.log.debug("Setting advertisement is_connectable to {}".format( - settings_in_effect['is_connectable'])) - self.adv_ad.droid.bleSetAdvertiseSettingsIsConnectable( - settings_in_effect['is_connectable']) - if 'mode' in settings_in_effect.keys(): - self.log.debug("Setting advertisement mode to {}" - .format(settings_in_effect['mode'])) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - settings_in_effect['mode']) - if 'tx_power_level' in settings_in_effect.keys(): - self.log.debug("Setting advertisement tx_power_level to {}".format( - settings_in_effect['tx_power_level'])) - self.adv_ad.droid.bleSetAdvertiseSettingsTxPowerLevel( - settings_in_effect['tx_power_level']) - filter_list = self.scn_ad.droid.bleGenFilterList() - if ('include_device_name' in filters.keys() and - filters['include_device_name'] is not False): - - self.log.debug("Setting advertisement include_device_name to {}" - .format(filters['include_device_name'])) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - filters['include_device_name'] = ( - self.adv_ad.droid.bluetoothGetLocalName()) - self.log.debug("Setting scanner include_device_name to {}".format( - filters['include_device_name'])) - self.scn_ad.droid.bleSetScanFilterDeviceName(filters[ - 'include_device_name']) - else: - self.log.debug( - "Setting advertisement include_device_name to False") - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(False) - if ('include_tx_power_level' in filters.keys() and - filters['include_tx_power_level'] is not False): - self.log.debug( - "Setting advertisement include_tx_power_level to True") - self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) - if 'manufacturer_specific_data_id' in filters.keys(): - if 'manufacturer_specific_data_mask' in filters.keys(): - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( - filters['manufacturer_specific_data_id'], - filters['manufacturer_specific_data']) - self.scn_ad.droid.bleSetScanFilterManufacturerData( - filters['manufacturer_specific_data_id'], - filters['manufacturer_specific_data'], - filters['manufacturer_specific_data_mask']) - else: - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( - filters['manufacturer_specific_data_id'], - filters['manufacturer_specific_data']) - self.scn_ad.droid.bleSetScanFilterManufacturerData( - filters['manufacturer_specific_data_id'], - filters['manufacturer_specific_data']) - if 'service_data' in filters.keys(): - self.adv_ad.droid.bleAddAdvertiseDataServiceData( - filters['service_data_uuid'], filters['service_data']) - self.scn_ad.droid.bleSetScanFilterServiceData( - filters['service_data_uuid'], filters['service_data']) - if 'manufacturer_specific_data_list' in filters.keys(): - for pair in filters['manufacturer_specific_data_list']: - (manu_id, manu_data) = pair - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(manu_id, - manu_data) - if 'service_mask' in filters.keys(): - self.scn_ad.droid.bleSetScanFilterServiceUuid( - filters['service_uuid'].upper(), filters['service_mask']) - self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( - [filters['service_uuid'].upper()]) - elif 'service_uuid' in filters.keys(): - self.scn_ad.droid.bleSetScanFilterServiceUuid(filters[ - 'service_uuid']) - self.adv_ad.droid.bleSetAdvertiseDataSetServiceUuids( - [filters['service_uuid']]) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - if ('scan_mode' in settings_in_effect and - settings_in_effect['scan_mode'] != - ble_scan_settings_modes['opportunistic']): - self.scn_ad.droid.bleSetScanSettingsScanMode(settings_in_effect[ - 'scan_mode']) - else: - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - opportunistic = False - scan_settings2, scan_callback2 = None, None - if ('scan_mode' in settings_in_effect and - settings_in_effect['scan_mode'] == - ble_scan_settings_modes['opportunistic']): - opportunistic = True - scan_settings2 = self.scn_ad.droid.bleBuildScanSetting() - scan_callback2 = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings2, - scan_callback2) - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - regex = "(" + adv_succ.format( - advertise_callback) + "|" + adv_fail.format( - advertise_callback) + ")" - self.log.debug(regex) - try: - event = self.adv_ad.ed.pop_events(regex, self.default_timeout, - small_timeout) - except Empty: - self.adv_ad.log.error("Failed to get success or failed event.") - return False - if event[0]["name"] == adv_succ.format(advertise_callback): - if not self._bleadvertise_verify_onsuccess(event[0], - settings_in_effect): - return False - else: - self.adv_ad.log.info("Advertisement started successfully.") - else: - self.adv_ad.log.error("Failed to start advertisement: {}".format( - event[0]["data"]["Error"])) - expected_scan_event_name = scan_result.format(scan_callback) - try: - event = self.scn_ad.ed.pop_event(expected_scan_event_name, - self.default_timeout) - except Empty: - self.log.error("Scan event not found: {}".format( - expected_scan_event_name)) - return False - if not self._blescan_verify_onscanresult_event(event, filters): - return False - if opportunistic: - expected_scan_event_name = scan_result.format(scan_callback2) - try: - event = self.scn_ad.ed.pop_event(expected_scan_event_name, - self.default_timeout) - except Empty: - self.log.error("Opportunistic scan event not found: {}".format( - expected_scan_event_name)) - return False - if not self._blescan_verify_onscanresult_event(event, filters): - return False - self.scn_ad.droid.bleStopBleScan(scan_callback2) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - self.scn_ad.droid.bleStopBleScan(scan_callback) - return test_result diff --git a/acts_tests/tests/google/ble/filtering/UniqueFilteringTest.py b/acts_tests/tests/google/ble/filtering/UniqueFilteringTest.py index c2e837c567..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/filtering/UniqueFilteringTest.py +++ b/acts_tests/tests/google/ble/filtering/UniqueFilteringTest.py @@ -1,650 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different filters and outcomes not exercised in -FilteringTest. -""" - -import concurrent -import json -import pprint -import time - -from queue import Empty -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import batch_scan_result -from acts.test_utils.bt.bt_constants import scan_result - - -class UniqueFilteringTest(BluetoothBaseTest): - default_timeout = 10 - - def setup_class(self): - super().setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - def blescan_verify_onfailure_event_handler(self, event): - self.log.debug("Verifying onFailure event") - self.log.debug(pprint.pformat(event)) - return event - - def blescan_verify_onscanresult_event_handler(self, - event, - expected_callbacktype=None, - system_time_nanos=None): - test_result = True - self.log.debug("Verifying onScanResult event") - self.log.debug(pprint.pformat(event)) - callbacktype = event['data']['CallbackType'] - if callbacktype != expected_callbacktype: - self.log.debug( - "Expected callback type: {}, Found callback type: {}".format( - expected_callbacktype, callbacktype)) - test_result = False - return test_result - - def blescan_get_mac_address_event_handler(self, event): - return event['data']['Result']['deviceInfo']['address'] - - def blescan_verify_onbatchscanresult_event_handler( - self, event, system_time_nanos=None, report_delay_nanos=None): - test_result = True - self.log.debug("Verifying onBatchScanResult event") - self.log.debug(pprint.pformat(event)) - for result in event['data']['Results']: - timestamp_nanos = result['timestampNanos'] - length_of_time = timestamp_nanos - system_time_nanos - self.log.debug("Difference in time in between scan start and " - "onBatchScanResult: {}".format(length_of_time)) - buffer = 1000000000 # 1 second - if length_of_time > (report_delay_nanos + buffer): - self.log.debug( - "Difference was greater than the allowable difference.") - test_result = False - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c3764358-cd65-451c-9a2d-4bfb6cf98f48') - def test_scan_flush_pending_scan_results(self): - """Test LE scan api flush pending results. - - Test that flush pending scan results doesn't affect onScanResults from - triggering. - - Steps: - 1. Setup the scanning android device. - 2. Setup the advertiser android devices. - 3. Trigger bluetoothFlushPendingScanResults on the scanning droid. - 4. Verify that only one onScanResults callback was triggered. - - Expected Result: - After flushing pending scan results, make sure only one onScanResult - callback was triggered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 1 - """ - test_result = True - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - expected_event_name = scan_result.format(scan_callback) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.scn_ad.droid.bleFlushPendingScanResults(scan_callback) - worker = self.scn_ad.ed.handle_event( - self.blescan_verify_onscanresult_event_handler, - expected_event_name, ([1]), self.default_timeout) - try: - self.log.debug(worker.result(self.default_timeout)) - except Empty as error: - test_result = False - self.log.error("Test failed with Empty error: {}".format(error)) - except concurrent.futures._base.TimeoutError as error: - test_result = False - self.log.error("Test failed with TimeoutError: {}".format(error)) - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4b358654-db69-4b51-98ec-7599aee2db10') - def test_scan_trigger_on_batch_scan_results(self): - """Test triggering batch scan results. - - Test that triggers onBatchScanResults and verifies the time to trigger - within one second leeway. - - Steps: - 1. Setup the scanning android device with report delay seconds set to - 5000. - 2. Setup the advertiser android devices. - 3. Verify that only one onBatchScanResult callback was triggered. - 4. Compare the system time that the scan was started with the elapsed - time that is in the callback. - - Expected Result: - The scan event dispatcher should find an onBatchScanResult event. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Batch Scanning - Priority: 2 - """ - test_result = True - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis(5000) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - expected_event_name = batch_scan_result.format(scan_callback) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - system_time_nanos = self.scn_ad.droid.getSystemElapsedRealtimeNanos() - self.log.debug("Current system time: {}".format(system_time_nanos)) - worker = self.scn_ad.ed.handle_event( - self.blescan_verify_onbatchscanresult_event_handler, - expected_event_name, ([system_time_nanos, 5000000000]), - self.default_timeout) - try: - self.log.debug(worker.result(self.default_timeout)) - except Empty as error: - test_result = False - self.log.debug("Test failed with: {}".format(error)) - except concurrent.futures._base.TimeoutError as error: - test_result = False - self.log.debug("Test failed with: {}".format(error)) - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='94dbe8b2-9e7f-4da4-973e-5162b84a7ce0') - def test_scan_flush_results_without_on_batch_scan_results_triggered(self): - """Test that doesn't expect a batch scan result. - - Test flush pending scan results with a report delay seconds set to 0. - No onBatchScanResults callback should be triggered. - - Steps: - 1. Setup the scanning android device with report delay seconds set to 0 - (or just use default). - 2. Setup the advertiser android devices. - - Expected Result: - Verify that no onBatchScanResults were triggered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Batch Scanning - Priority: 2 - """ - test_result = True - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - expected_event_name = batch_scan_result.format(scan_callback) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - worker = self.scn_ad.ed.handle_event( - self.blescan_verify_onbatchscanresult_event_handler, - expected_event_name, ([]), self.default_timeout) - self.scn_ad.droid.bleFlushPendingScanResults(scan_callback) - try: - event_info = self.scn_ad.ed.pop_event(expected_event_name, 10) - self.log.debug( - "Unexpectedly found an advertiser: {}".format(event_info)) - test_result = False - except Empty: - self.log.debug("No {} events were found as expected.".format( - batch_scan_result)) - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5856882e-3d82-4a6f-b110-389086b0ac41') - def test_scan_non_existent_name_filter(self): - """Test non-existent name filter. - - Test scan filter on non-existent device name. - - Steps: - 1. Setup the scanning android device with scan filter for device name - set to an unexpected value. - 2. Setup the advertiser android devices. - 3. Verify that no onScanResults were triggered. - - Expected Result: - No advertisements were found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - test_result = True - filter_name = "{}_probably_wont_find".format( - self.adv_ad.droid.bluetoothGetLocalName()) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.scn_ad.droid.bleSetScanFilterDeviceName(filter_name) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - expected_event_name = scan_result.format(scan_callback) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - try: - event_info = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - self.log.error( - "Unexpectedly found an advertiser: {}".format(event_info)) - test_result = False - except Empty: - self.log.debug("No events were found as expected.") - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0a54c50b-d4ef-4d8c-8328-775781aab2c7') - def test_scan_advertisement_with_device_service_uuid_filter_expect_no_events( - self): - """Test scan filtering against an advertisement with no data. - - Test that exercises a service uuid filter on the scanner but no server - uuid added to the advertisement. - - Steps: - 1. Setup the scanning android device with scan filter including a - service uuid and mask. - 2. Setup the advertiser android devices. - 3. Verify that no onScanResults were triggered. - - Expected Result: - Verify no advertisements found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 1 - """ - test_result = True - service_uuid = "00000000-0000-1000-8000-00805F9B34FB" - service_mask = "00000000-0000-1000-8000-00805F9B34FA" - self.scn_ad.droid.bleSetScanFilterServiceUuid(service_uuid, - service_mask) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - expected_event_name = scan_result.format(scan_callback) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.adv_ad.droid.bleSetAdvertiseDataIncludeTxPowerLevel(True) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - worker = self.scn_ad.ed.handle_event( - self.blescan_verify_onscanresult_event_handler, - expected_event_name, ([1]), self.default_timeout) - try: - event_info = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - self.log.error( - "Unexpectedly found an advertiser: {}".format(event_info)) - test_result = False - except Empty as error: - self.log.debug("No events were found as expected.") - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='aefbc70c-ea46-4a63-a627-6fcceb72ac9e') - def test_scan_filtering_multiple_advertisements_manufacturer_data(self): - """Test scan filtering against multiple varying advertisements. - - Test scan filtering against multiple varying advertisements. The first - advertisement will have partial manufacturer data that matches the - the full manufacturer data in the second advertisement. - - Steps: - 1. Setup up an advertisement with manufacturer data [1,2,3]. - 2. Setup a second advertisement with manufacturer data - [1,2,3,4,5,6,7,8]. - 3. Start advertising on each advertisement. - 4. Create a scan filter that includes manufacturer data [1,2,3]. - - Expected Result: - TBD. Right now Shamu finds only the first advertisement with - manufacturer data [1,2,3]. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 2 - """ - test_result = True - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId(117, [1, 2, 3]) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( - 117, [1, 2, 3, 4, 5, 6, 7, 8]) - advertise_callback1, advertise_data1, advertise_settings1 = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback1, advertise_data1, advertise_settings1) - - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleSetScanFilterManufacturerData( - 117, [1, 2, 3], [127, 127, 127]) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cdbeeb8e-895e-4d11-9e42-7b89ff6917ce') - def test_scan_filter_device_address(self): - """Test scan filtering of a device address. - - This test will have to create two scanning instances. The first will - have no filters and will find the generic advertisement's mac address. - The second will have a filter of the found mac address. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a new scanner with scan filter with a mac address filter of - what was found in step 3. - 6. Start the scanner. - - Expected Result: - Verify that the advertisement was found in the second scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 1 - """ - test_result = True - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - expected_event_name = scan_result.format(scan_callback) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - try: - event_info = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - except Empty as error: - self.log.error("Could not find initial advertisement.") - return False - mac_address = event_info['data']['Result']['deviceInfo']['address'] - self.log.info( - "Filter advertisement with address {}".format(mac_address)) - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - self.scn_ad.droid.bleSetScanFilterDeviceAddress(mac_address) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - - self.scn_ad.droid.bleBuildScanFilter(filter_list2) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - expected_event_name = scan_result.format(scan_callback2) - found_event = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - if (found_event['data']['Result']['deviceInfo']['address'] != - mac_address): - test_result = False - self.scn_ad.droid.bleStopBleScan(scan_callback2) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return test_result - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a4921d7b-cdd5-4d52-834c-f4bb85a9e2e8') - def test_filter_simulated_ibeacon(self): - """Test scan filtering of a simulated ibeacon. - - This test will setup one Android device as an ibeacon and - a second Android device will be used to test filtering of - the manufacturer data for 60 seconds. - - Steps: - 1. Start an advertisement with manufacturer id set to 0x004c - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a new scanner with scan filter with a mac address filter of - what was found in step 3. - 6. Start the scanner. - - Expected Result: - Verify that the advertisement was found in the second scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 1 - """ - manufacturer_id = 0x4c - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( - manufacturer_id, [0x01]) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - expected_event = adv_succ.format(advertise_callback) - try: - self.adv_ad.ed.pop_event(expected_event) - except Empty: - self.log.info("Failed to start advertisement.") - return False - - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - self.scn_ad.droid.bleSetScanFilterManufacturerData( - manufacturer_id, [0x01]) - filter_list = self.scn_ad.droid.bleGenFilterList() - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_filter = self.scn_ad.droid.bleBuildScanFilter(filter_list) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - # continuously scan for 60 seconds - scan_time = 60 - end_time = time.time() + scan_time - expected_event_name = scan_result.format(scan_callback) - event = None - while time.time() < end_time: - try: - event = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - found_manufacturer_id = json.loads( - event['data']['Result']['manufacturerIdList']) - if found_manufacturer_id[0] != manufacturer_id: - self.log.error( - "Manufacturer id mismatch. Found {}, Expected {}". - format(found_manufacturer_id, manufacturer_id)) - return False - except Empty: - self.log.error("Unable to find ibeacon advertisement.") - return False - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a70a276d-7990-4754-8899-792b586ecce6') - def test_filter_manufacturer_id_bounds(self): - """Test scan filtering of lower and upper bounds of allowed manu data - - This test will setup one Android device as an advertiser and the - second as the scanner and test the upper and lower bounds of - manufacturer data filtering - - Steps: - 1. Start an advertisement with manufacturer id set to 0x004c - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a new scanner with scan filter with a mac address filter of - what was found in step 3. - 6. Start the scanner. - - Expected Result: - Verify that the advertisement was found in the second scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning - Priority: 1 - """ - manufacturer_id_list = [0, 1, 65534, 65535] - for manufacturer_id in manufacturer_id_list: - self.adv_ad.droid.bleAddAdvertiseDataManufacturerId( - manufacturer_id, [0x01]) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - expected_event = adv_succ.format(advertise_callback) - try: - self.adv_ad.ed.pop_event(expected_event) - except Empty: - self.log.info("Failed to start advertisement.") - return False - - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - self.scn_ad.droid.bleSetScanFilterManufacturerData( - manufacturer_id, [0x01]) - filter_list = self.scn_ad.droid.bleGenFilterList() - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_filter = self.scn_ad.droid.bleBuildScanFilter(filter_list) - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - expected_event_name = scan_result.format(scan_callback) - event = None - try: - event = self.scn_ad.ed.pop_event(expected_event_name, - self.default_timeout) - except Empty: - self.log.error("Unable to find beacon advertisement.") - return False - found_manufacturer_id = json.loads( - event['data']['Result']['manufacturerIdList']) - if found_manufacturer_id[0] != manufacturer_id: - self.log.error( - "Manufacturer id mismatch. Found {}, Expected {}".format( - found_manufacturer_id, manufacturer_id)) - return False - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.adv_ad.droid.bleStopBleAdvertising(advertise_callback) - return True diff --git a/acts_tests/tests/google/ble/gatt/GattConnectTest.py b/acts_tests/tests/google/ble/gatt/GattConnectTest.py index 52f3601cd0..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/gatt/GattConnectTest.py +++ b/acts_tests/tests/google/ble/gatt/GattConnectTest.py @@ -1,1184 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different GATT connection tests. -""" - -import pprint -from queue import Empty -import time - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_match_nums -from acts.test_utils.bt.bt_constants import bt_profile_constants -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_service_types -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_state -from acts.test_utils.bt.bt_constants import gatt_mtu_size -from acts.test_utils.bt.bt_constants import gatt_phy_mask -from acts.test_utils.bt.bt_constants import gatt_transport -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError -from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection -from acts.test_utils.bt.bt_gatt_utils import wait_for_gatt_disconnect_event -from acts.test_utils.bt.bt_gatt_utils import close_gatt_client -from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids -from acts.test_utils.bt.bt_gatt_utils import orchestrate_gatt_connection -from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection -from acts.test_utils.bt.bt_gatt_utils import setup_multiple_services -from acts.test_utils.bt.bt_test_utils import get_mac_address_of_generic_advertisement -from acts.test_utils.bt.bt_test_utils import clear_bonded_devices - -PHYSICAL_DISCONNECT_TIMEOUT = 5 - - -class GattConnectTest(BluetoothBaseTest): - adv_instances = [] - bluetooth_gatt_list = [] - gatt_server_list = [] - default_timeout = 10 - default_discovery_timeout = 3 - - def setup_class(self): - super().setup_class() - self.cen_ad = self.android_devices[0] - self.per_ad = self.android_devices[1] - - def setup_test(self): - super(BluetoothBaseTest, self).setup_test() - bluetooth_gatt_list = [] - self.gatt_server_list = [] - self.adv_instances = [] - # Ensure there is ample time for a physical disconnect in between - # testcases. - self.log.info( - "Waiting for {} seconds for physical GATT disconnections".format( - PHYSICAL_DISCONNECT_TIMEOUT)) - time.sleep(PHYSICAL_DISCONNECT_TIMEOUT) - - def teardown_test(self): - for bluetooth_gatt in self.bluetooth_gatt_list: - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - for gatt_server in self.gatt_server_list: - self.per_ad.droid.gattServerClose(gatt_server) - for adv in self.adv_instances: - self.per_ad.droid.bleStopBleAdvertising(adv) - return True - - def _orchestrate_gatt_disconnection(self, bluetooth_gatt, gatt_callback): - self.log.info("Disconnecting from peripheral device.") - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, - gatt_callback) - close_gatt_client(self.cen_ad, bluetooth_gatt) - if bluetooth_gatt in self.bluetooth_gatt_list: - self.bluetooth_gatt_list.remove(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - return True - - def _find_service_added_event(self, gatt_server_cb, uuid): - expected_event = gatt_cb_strings['serv_added'].format(gatt_server_cb) - try: - event = self.per_ad.ed.pop_event(expected_event, - self.default_timeout) - except Empty: - self.log.error( - gatt_cb_strings['serv_added_err'].format(expected_event)) - return False - if event['data']['serviceUuid'].lower() != uuid.lower(): - self.log.error("Uuid mismatch. Found: {}, Expected {}.".format( - event['data']['serviceUuid'], uuid)) - return False - return True - - def _verify_mtu_changed_on_client_and_server( - self, expected_mtu, gatt_callback, gatt_server_callback): - expected_event = gatt_cb_strings['mtu_changed'].format(gatt_callback) - try: - mtu_event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - mtu_size_found = mtu_event['data']['MTU'] - if mtu_size_found != expected_mtu: - self.log.error("MTU size found: {}, expected: {}".format( - mtu_size_found, expected_mtu)) - return False - except Empty: - self.log.error( - gatt_cb_err['mtu_changed_err'].format(expected_event)) - return False - - expected_event = gatt_cb_strings['mtu_serv_changed'].format( - gatt_server_callback) - try: - mtu_event = self.per_ad.ed.pop_event(expected_event, - self.default_timeout) - mtu_size_found = mtu_event['data']['MTU'] - if mtu_size_found != expected_mtu: - self.log.error("MTU size found: {}, expected: {}".format( - mtu_size_found, expected_mtu)) - return False - except Empty: - self.log.error( - gatt_cb_err['mtu_serv_changed_err'].format(expected_event)) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8a3530a3-c8bb-466b-9710-99e694c38618') - def test_gatt_connect(self): - """Test GATT connection over LE. - - Test establishing a gatt connection between a GATT server and GATT - client. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and then disconnected - successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a839b505-03ac-4783-be7e-1d43129a1948') - def test_gatt_connect_stop_advertising(self): - """Test GATT connection over LE then stop advertising - - A test case that verifies the GATT connection doesn't - disconnect when LE advertisement is stopped. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. Stop the advertiser. - 7. Verify no connection state changed happened. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and not disconnected - when advertisement stops. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.per_ad.droid.bleStopBleAdvertising(adv_callback) - try: - event = self.cen_ad.ed.pop_event( - gatt_cb_strings['gatt_conn_change'].format( - gatt_callback, self.default_timeout)) - self.log.error( - "Connection event found when not expected: {}".format(event)) - return False - except Empty: - self.log.info("No connection state change as expected") - try: - self._orchestrate_gatt_disconnection(bluetooth_gatt, gatt_callback) - except Exception as err: - self.log.info("Failed to orchestrate disconnect: {}".format(err)) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b82f91a8-54bb-4779-a117-73dc7fdb28cc') - def test_gatt_connect_autoconnect(self): - """Test GATT connection over LE. - - Test re-establishing a gatt connection using autoconnect - set to True in order to test connection whitelist. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. Disconnect the GATT connection. - 7. Create a GATT connection with autoconnect set to True - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was re-established and then disconnected - successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - autoconnect = False - mac_address, adv_callback, scan_callback = ( - get_mac_address_of_generic_advertisement(self.cen_ad, self.per_ad)) - self.adv_instances.append(adv_callback) - try: - bluetooth_gatt, gatt_callback = setup_gatt_connection( - self.cen_ad, mac_address, autoconnect) - self.cen_ad.droid.bleStopBleScan(scan_callback) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, - gatt_callback) - close_gatt_client(self.cen_ad, bluetooth_gatt) - if bluetooth_gatt in self.bluetooth_gatt_list: - self.bluetooth_gatt_list.remove(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - autoconnect = True - bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( - gatt_callback, mac_address, autoconnect, gatt_transport['auto'], - False, gatt_phy_mask['1m_mask']) - self.bluetooth_gatt_list.append(bluetooth_gatt) - expected_event = gatt_cb_strings['gatt_conn_change'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - except Empty: - self.log.error( - gatt_cb_err['gatt_conn_changed_err'].format(expected_event)) - test_result = False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e506fa50-7cd9-4bd8-938a-6b85dcfe6bc6') - def test_gatt_connect_opportunistic(self): - """Test opportunistic GATT connection over LE. - - Test establishing a gatt connection between a GATT server and GATT - client in opportunistic mode. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create GATT connection 1 between the scanner and advertiser normally - 6. Create GATT connection 2 between the scanner and advertiser using - opportunistic mode - 7. Disconnect GATT connection 1 - - Expected Result: - Verify GATT connection 2 automatically disconnects when GATT connection - 1 disconnect - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - mac_address, adv_callback, scan_callback = ( - get_mac_address_of_generic_advertisement(self.cen_ad, self.per_ad)) - # Make GATT connection 1 - try: - bluetooth_gatt_1, gatt_callback_1 = setup_gatt_connection( - self.cen_ad, - mac_address, - False, - transport=gatt_transport['auto'], - opportunistic=False) - self.cen_ad.droid.bleStopBleScan(scan_callback) - self.adv_instances.append(adv_callback) - self.bluetooth_gatt_list.append(bluetooth_gatt_1) - except GattTestUtilsError as err: - self.log.error(err) - return False - # Make GATT connection 2 - try: - bluetooth_gatt_2, gatt_callback_2 = setup_gatt_connection( - self.cen_ad, - mac_address, - False, - transport=gatt_transport['auto'], - opportunistic=True) - self.bluetooth_gatt_list.append(bluetooth_gatt_2) - except GattTestUtilsError as err: - self.log.error(err) - return False - # Disconnect GATT connection 1 - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt_1, - gatt_callback_1) - close_gatt_client(self.cen_ad, bluetooth_gatt_1) - if bluetooth_gatt_1 in self.bluetooth_gatt_list: - self.bluetooth_gatt_list.remove(bluetooth_gatt_1) - except GattTestUtilsError as err: - self.log.error(err) - return False - # Confirm that GATT connection 2 also disconnects - wait_for_gatt_disconnect_event(self.cen_ad, gatt_callback_2) - close_gatt_client(self.cen_ad, bluetooth_gatt_2) - if bluetooth_gatt_2 in self.bluetooth_gatt_list: - self.bluetooth_gatt_list.remove(bluetooth_gatt_2) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='1e01838e-c4de-4720-9adf-9e0419378226') - def test_gatt_request_min_mtu(self): - """Test GATT connection over LE and exercise MTU sizes. - - Test establishing a gatt connection between a GATT server and GATT - client. Request an MTU size that matches the correct minimum size. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (client) request MTU size change to the - minimum value. - 7. Find the MTU changed event on the client. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and the MTU value found - matches the expected MTU value. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - expected_mtu = gatt_mtu_size['min'] - self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) - if not self._verify_mtu_changed_on_client_and_server( - expected_mtu, gatt_callback, gatt_server_cb): - return False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='c1fa3a2d-fb47-47db-bdd1-458928cd6a5f') - def test_gatt_request_max_mtu(self): - """Test GATT connection over LE and exercise MTU sizes. - - Test establishing a gatt connection between a GATT server and GATT - client. Request an MTU size that matches the correct maximum size. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (client) request MTU size change to the - maximum value. - 7. Find the MTU changed event on the client. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and the MTU value found - matches the expected MTU value. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - expected_mtu = gatt_mtu_size['max'] - self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, expected_mtu) - if not self._verify_mtu_changed_on_client_and_server( - expected_mtu, gatt_callback, gatt_server_cb): - return False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4416d483-dec3-46cb-8038-4d82620f873a') - def test_gatt_request_out_of_bounds_mtu(self): - """Test GATT connection over LE and exercise an out of bound MTU size. - - Test establishing a gatt connection between a GATT server and GATT - client. Request an MTU size that is the MIN value minus 1. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (client) request MTU size change to the - minimum value minus one. - 7. Find the MTU changed event on the client. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that an MTU changed event was not discovered and that - it didn't cause an exception when requesting an out of bounds - MTU. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, MTU - Priority: 0 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - unexpected_mtu = gatt_mtu_size['min'] - 1 - self.cen_ad.droid.gattClientRequestMtu(bluetooth_gatt, unexpected_mtu) - if self._verify_mtu_changed_on_client_and_server( - unexpected_mtu, gatt_callback, gatt_server_cb): - return False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='31ffb9ca-cc75-43fb-9802-c19f1c5856b6') - def test_gatt_connect_trigger_on_read_rssi(self): - """Test GATT connection over LE read RSSI. - - Test establishing a gatt connection between a GATT server and GATT - client then read the RSSI. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner, request to read the RSSI of the advertiser. - 7. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and then disconnected - successfully. Verify that the RSSI was ready correctly. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, RSSI - Priority: 1 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - expected_event = gatt_cb_strings['rd_remote_rssi'].format( - gatt_callback) - if self.cen_ad.droid.gattClientReadRSSI(bluetooth_gatt): - try: - self.cen_ad.ed.pop_event(expected_event, self.default_timeout) - except Empty: - self.log.error( - gatt_cb_err['rd_remote_rssi_err'].format(expected_event)) - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='dee9ef28-b872-428a-821b-cc62f27ba936') - def test_gatt_connect_trigger_on_services_discovered(self): - """Test GATT connection and discover services of peripheral. - - Test establishing a gatt connection between a GATT server and GATT - client the discover all services from the connected device. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (central device), discover services. - 7. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and then disconnected - successfully. Verify that the service were discovered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, Services - Priority: 1 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='01883bdd-0cf8-48fb-bf15-467bbd4f065b') - def test_gatt_connect_trigger_on_services_discovered_iterate_attributes( - self): - """Test GATT connection and iterate peripherals attributes. - - Test establishing a gatt connection between a GATT server and GATT - client and iterate over all the characteristics and descriptors of the - discovered services. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (central device), discover services. - 7. Iterate over all the characteristics and descriptors of the - discovered features. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and then disconnected - successfully. Verify that the services, characteristics, and descriptors - were discovered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, Services - Characteristics, Descriptors - Priority: 1 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - discovered_services_index = event['data']['ServicesIndex'] - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - log_gatt_server_uuids(self.cen_ad, discovered_services_index) - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='d4277bee-da99-4f48-8a4d-f81b5389da18') - def test_gatt_connect_with_service_uuid_variations(self): - """Test GATT connection with multiple service uuids. - - Test establishing a gatt connection between a GATT server and GATT - client with multiple service uuid variations. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. From the scanner (central device), discover services. - 7. Verify that all the service uuid variations are found. - 8. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established and then disconnected - successfully. Verify that the service uuid variations are found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, Services - Priority: 2 - """ - try: - gatt_server_cb, gatt_server = setup_multiple_services(self.per_ad) - self.gatt_server_list.append(gatt_server) - except GattTestUtilsError as err: - self.log.error(err) - return False - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.adv_instances.append(adv_callback) - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - discovered_services_index = event['data']['ServicesIndex'] - log_gatt_server_uuids(self.cen_ad, discovered_services_index) - - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7d3442c5-f71f-44ae-bd35-f2569f01b3b8') - def test_gatt_connect_in_quick_succession(self): - """Test GATT connections multiple times. - - Test establishing a gatt connection between a GATT server and GATT - client with multiple iterations. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 6. Disconnect the GATT connection. - 7. Repeat steps 5 and 6 twenty times. - - Expected Result: - Verify that a connection was established and then disconnected - successfully twenty times. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, Stress - Priority: 1 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - mac_address, adv_callback, scan_callback = get_mac_address_of_generic_advertisement( - self.cen_ad, self.per_ad) - autoconnect = False - for i in range(1000): - self.log.info("Starting connection iteration {}".format(i + 1)) - try: - bluetooth_gatt, gatt_callback = setup_gatt_connection( - self.cen_ad, mac_address, autoconnect) - self.cen_ad.droid.bleStopBleScan(scan_callback) - except GattTestUtilsError as err: - self.log.error(err) - return False - test_result = self._orchestrate_gatt_disconnection( - bluetooth_gatt, gatt_callback) - if not test_result: - self.log.info("Failed to disconnect from peripheral device.") - return False - self.adv_instances.append(adv_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='148469d9-7ab0-4c08-b2e9-7e49e88da1fc') - def test_gatt_connect_mitm_attack(self): - """Test GATT connection with permission write encrypted mitm. - - Test establishing a gatt connection between a GATT server and GATT - client while the GATT server's characteristic includes the property - write value and the permission write encrypted mitm value. This will - prompt LE pairing and then the devices will create a bond. - - Steps: - 1. Create a GATT server and server callback on the peripheral device. - 2. Create a unique service and characteristic uuid on the peripheral. - 3. Create a characteristic on the peripheral with these properties: - gatt_characteristic['property_write'], - gatt_characteristic['permission_write_encrypted_mitm'] - 4. Create a GATT service on the peripheral. - 5. Add the characteristic to the GATT service. - 6. Create a GATT connection between your central and peripheral device. - 7. From the central device, discover the peripheral's services. - 8. Iterate the services found until you find the unique characteristic - created in step 3. - 9. Once found, write a random but valid value to the characteristic. - 10. Start pairing helpers on both devices immediately after attempting - to write to the characteristic. - 11. Within 10 seconds of writing the characteristic, there should be - a prompt to bond the device from the peripheral. The helpers will - handle the UI interaction automatically. (see - BluetoothConnectionFacade.java bluetoothStartPairingHelper). - 12. Verify that the two devices are bonded. - - Expected Result: - Verify that a connection was established and the devices are bonded. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, GATT, Characteristic, MITM - Priority: 1 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - service_uuid = "3846D7A0-69C8-11E4-BA00-0002A5D5C51B" - test_uuid = "aa7edd5a-4d1d-4f0e-883a-d145616a1630" - bonded = False - characteristic = self.per_ad.droid.gattServerCreateBluetoothGattCharacteristic( - test_uuid, gatt_characteristic['property_write'], - gatt_characteristic['permission_write_encrypted_mitm']) - gatt_service = self.per_ad.droid.gattServerCreateService( - service_uuid, gatt_service_types['primary']) - self.per_ad.droid.gattServerAddCharacteristicToService( - gatt_service, characteristic) - self.per_ad.droid.gattServerAddService(gatt_server, gatt_service) - result = self._find_service_added_event(gatt_server_cb, service_uuid) - if not result: - return False - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - self.adv_instances.append(adv_callback) - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - discovered_services_index = event['data']['ServicesIndex'] - else: - self.log.info("Failed to discover services.") - return False - test_value = [1, 2, 3, 4, 5, 6, 7] - services_count = self.cen_ad.droid.gattClientGetDiscoveredServicesCount( - discovered_services_index) - for i in range(services_count): - characteristic_uuids = ( - self.cen_ad.droid.gattClientGetDiscoveredCharacteristicUuids( - discovered_services_index, i)) - for characteristic_uuid in characteristic_uuids: - if characteristic_uuid == test_uuid: - self.cen_ad.droid.bluetoothStartPairingHelper() - self.per_ad.droid.bluetoothStartPairingHelper() - self.cen_ad.droid.gattClientCharacteristicSetValue( - bluetooth_gatt, discovered_services_index, i, - characteristic_uuid, test_value) - self.cen_ad.droid.gattClientWriteCharacteristic( - bluetooth_gatt, discovered_services_index, i, - characteristic_uuid) - start_time = time.time() + self.default_timeout - target_name = self.per_ad.droid.bluetoothGetLocalName() - while time.time() < start_time and bonded == False: - bonded_devices = \ - self.cen_ad.droid.bluetoothGetBondedDevices() - for device in bonded_devices: - if ('name' in device.keys() - and device['name'] == target_name): - bonded = True - break - bonded = False - target_name = self.cen_ad.droid.bluetoothGetLocalName() - while time.time() < start_time and bonded == False: - bonded_devices = \ - self.per_ad.droid.bluetoothGetBondedDevices() - for device in bonded_devices: - if ('name' in device.keys() - and device['name'] == target_name): - bonded = True - break - - # Dual mode devices will establish connection over the classic transport, - # in order to establish bond over both transports, and do SDP. Starting - # disconnection before all this is finished is not safe, might lead to - # race conditions, i.e. bond over classic tranport shows up after LE - # bond is already removed. - time.sleep(4) - - for ad in [self.cen_ad, self.per_ad]: - if not clear_bonded_devices(ad): - return False - - # Necessary sleep time for entries to update unbonded state - time.sleep(2) - - for ad in [self.cen_ad, self.per_ad]: - bonded_devices = ad.droid.bluetoothGetBondedDevices() - if len(bonded_devices) > 0: - self.log.error( - "Failed to unbond devices: {}".format(bonded_devices)) - return False - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cc3fc361-7bf1-4ee2-9e46-4a27c88ce6a8') - def test_gatt_connect_get_connected_devices(self): - """Test GATT connections show up in getConnectedDevices - - Test establishing a gatt connection between a GATT server and GATT - client. Verify that active connections show up using - BluetoothManager.getConnectedDevices API. - - Steps: - 1. Start a generic advertisement. - 2. Start a generic scanner. - 3. Find the advertisement and extract the mac address. - 4. Stop the first scanner. - 5. Create a GATT connection between the scanner and advertiser. - 7. Verify the GATT Client has an open connection to the GATT Server. - 8. Verify the GATT Server has an open connection to the GATT Client. - 9. Disconnect the GATT connection. - - Expected Result: - Verify that a connection was established, connected devices are found - on both the central and peripheral devices, and then disconnected - successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, GATT - Priority: 2 - """ - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - self.gatt_server_list.append(gatt_server) - try: - bluetooth_gatt, gatt_callback, adv_callback = ( - orchestrate_gatt_connection(self.cen_ad, self.per_ad)) - self.bluetooth_gatt_list.append(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - conn_cen_devices = self.cen_ad.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt']) - conn_per_devices = self.per_ad.droid.bluetoothGetConnectedLeDevices( - bt_profile_constants['gatt_server']) - target_name = self.per_ad.droid.bluetoothGetLocalName() - error_message = ("Connected device {} not found in list of connected " - "devices {}") - if not any(d['name'] == target_name for d in conn_cen_devices): - self.log.error(error_message.format(target_name, conn_cen_devices)) - return False - # For the GATT server only check the size of the list since - # it may or may not include the device name. - target_name = self.cen_ad.droid.bluetoothGetLocalName() - if not conn_per_devices: - self.log.error(error_message.format(target_name, conn_per_devices)) - return False - self.adv_instances.append(adv_callback) - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='a0a37ca6-9fa8-4d35-9fdb-0e25b4b8a363') - def test_gatt_connect_second_adv_after_canceling_first_adv(self): - """Test GATT connection to peripherals second advertising address. - - The the ability of cancelling GATT connections and trying to reconnect - to the same device via a different address. - - Steps: - 1. A starts advertising - 2. B starts scanning and finds A's mac address - 3. Stop advertisement from step 1. Start a new advertisement on A and - find the new new mac address, B knows of both old and new address. - 4. B1 sends connect request to old address of A - 5. B1 cancel connect attempt after 10 seconds - 6. B1 sends connect request to new address of A - 7. Verify B1 establish connection to A in less than 10 seconds - - Expected Result: - Verify that a connection was established only on the second - advertisement's mac address. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, GATT - Priority: 3 - """ - autoconnect = False - transport = gatt_transport['auto'] - opportunistic = False - # Setup a basic Gatt server on the peripheral - gatt_server_cb = self.per_ad.droid.gattServerCreateGattServerCallback() - gatt_server = self.per_ad.droid.gattServerOpenGattServer( - gatt_server_cb) - - # Set advertisement settings to include local name in advertisement - # and set the advertising mode to low_latency. - self.per_ad.droid.bleSetAdvertiseSettingsIsConnectable(True) - self.per_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.per_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - - # Setup necessary advertisement objects. - advertise_data = self.per_ad.droid.bleBuildAdvertiseData() - advertise_settings = self.per_ad.droid.bleBuildAdvertiseSettings() - advertise_callback = self.per_ad.droid.bleGenBleAdvertiseCallback() - - # Step 1: Start advertisement - self.per_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - - # Setup scan settings for low_latency scanning and to include the local name - # of the advertisement started in step 1. - filter_list = self.cen_ad.droid.bleGenFilterList() - self.cen_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['one']) - self.cen_ad.droid.bleSetScanFilterDeviceName( - self.per_ad.droid.bluetoothGetLocalName()) - self.cen_ad.droid.bleBuildScanFilter(filter_list) - self.cen_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - - # Setup necessary scan objects. - scan_settings = self.cen_ad.droid.bleBuildScanSetting() - scan_callback = self.cen_ad.droid.bleGenScanCallback() - - # Step 2: Start scanning on central Android device and find peripheral - # address. - self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - expected_event_name = scan_result.format(scan_callback) - try: - mac_address_pre_restart = self.cen_ad.ed.pop_event( - expected_event_name, self.default_timeout)['data']['Result'][ - 'deviceInfo']['address'] - self.log.info( - "Peripheral advertisement found with mac address: {}".format( - mac_address_pre_restart)) - except Empty: - self.log.info("Peripheral advertisement not found") - test_result = False - - # Step 3: Restart peripheral advertising such that a new mac address is - # created. - self.per_ad.droid.bleStopBleAdvertising(advertise_callback) - self.per_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - - mac_address_post_restart = mac_address_pre_restart - - while True: - try: - mac_address_post_restart = self.cen_ad.ed.pop_event( - expected_event_name, self.default_timeout)['data']['Result'][ - 'deviceInfo']['address'] - self.log.info( - "Peripheral advertisement found with mac address: {}".format( - mac_address_post_restart)) - except Empty: - self.log.info("Peripheral advertisement not found") - test_result = False - - if mac_address_pre_restart != mac_address_post_restart: - break - - self.cen_ad.droid.bleStopBleScan(scan_callback) - - # Steps 4: Try to connect to the first mac address - gatt_callback = self.cen_ad.droid.gattCreateGattCallback() - self.log.info( - "Gatt Connect to mac address {}.".format(mac_address_pre_restart)) - bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( - gatt_callback, mac_address_pre_restart, autoconnect, transport, - opportunistic, gatt_phy_mask['1m_mask']) - self.bluetooth_gatt_list.append(bluetooth_gatt) - expected_event = gatt_cb_strings['gatt_conn_change'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - self.log.error( - "Connection callback updated unexpectedly: {}".format(event)) - return False - except Empty: - self.log.info("No connection update as expected.") - - # Step 5: Cancel connection request. - self.cen_ad.droid.gattClientDisconnect(bluetooth_gatt) - close_gatt_client(self.cen_ad, bluetooth_gatt) - if bluetooth_gatt in self.bluetooth_gatt_list: - self.bluetooth_gatt_list.remove(bluetooth_gatt) - - # Step 6: Connect to second mac address. - gatt_callback = self.cen_ad.droid.gattCreateGattCallback() - self.log.info( - "Gatt Connect to mac address {}.".format(mac_address_post_restart)) - bluetooth_gatt = self.cen_ad.droid.gattClientConnectGatt( - gatt_callback, mac_address_post_restart, autoconnect, transport, - opportunistic, gatt_phy_mask['1m_mask']) - self.bluetooth_gatt_list.append(bluetooth_gatt) - expected_event = gatt_cb_strings['gatt_conn_change'].format( - gatt_callback) - - # Step 7: Verify connection was setup successfully. - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.default_timeout) - self.log.info( - "Connection callback updated successfully: {}".format(event)) - if event['data']['State'] != gatt_connection_state['connected']: - self.log.error( - "Could not establish a connection to the peripheral.") - return False - except Empty: - self.log.error("No connection update was found.") - return False - - self.per_ad.droid.bleStopBleAdvertising(advertise_callback) - - return self._orchestrate_gatt_disconnection(bluetooth_gatt, - gatt_callback) diff --git a/acts_tests/tests/google/ble/gatt/GattNotifyTest.py b/acts_tests/tests/google/ble/gatt/GattNotifyTest.py index 7d62d65349..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/gatt/GattNotifyTest.py +++ b/acts_tests/tests/google/ble/gatt/GattNotifyTest.py @@ -1,97 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises GATT notify/indicate procedures. -""" - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids -from math import ceil - - -class GattNotifyTest(GattConnectedBaseTest): - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='e0ba60af-c1f2-4516-a5d5-89e2def0c757') - def test_notify_char(self): - """Test notify characteristic value. - - Test GATT notify characteristic value. - - Steps: - 1. Central: write CCC - register for notifications. - 2. Peripheral: receive CCC modification. - 3. Peripheral: send characteristic notification. - 4. Central: receive notification, verify it's conent matches what was - sent - - Expected Result: - Verify that notification registration and delivery works. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - #write CCC descriptor to enable notifications - self.cen_ad.droid.gattClientDescriptorSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.NOTIFIABLE_CHAR_UUID, - gatt_char_desc_uuids['client_char_cfg'], - gatt_descriptor['enable_notification_value']) - - self.cen_ad.droid.gattClientWriteDescriptor( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.NOTIFIABLE_CHAR_UUID, - gatt_char_desc_uuids['client_char_cfg']) - - #enable notifications in app - self.cen_ad.droid.gattClientSetCharacteristicNotification( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.NOTIFIABLE_CHAR_UUID, True) - - event = self._server_wait(gatt_event['desc_write_req']) - - request_id = event['data']['requestId'] - bt_device_id = 0 - status = 0 - #confirm notification registration was successful - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, 0, []) - #wait for client to get response - event = self._client_wait(gatt_event['desc_write']) - - #set notified value - notified_value = [1, 5, 9, 7, 5, 3, 6, 4, 8, 2] - self.per_ad.droid.gattServerCharacteristicSetValue( - self.notifiable_char_index, notified_value) - - #send notification - self.per_ad.droid.gattServerNotifyCharacteristicChanged( - self.gatt_server, bt_device_id, self.notifiable_char_index, False) - - #wait for client to receive the notification - event = self._client_wait(gatt_event['char_change']) - self.assertEqual(notified_value, event["data"]["CharacteristicValue"]) - - return True diff --git a/acts_tests/tests/google/ble/gatt/GattReadTest.py b/acts_tests/tests/google/ble/gatt/GattReadTest.py index e880757586..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/gatt/GattReadTest.py +++ b/acts_tests/tests/google/ble/gatt/GattReadTest.py @@ -1,198 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different GATT read procedures. -""" - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from math import ceil - - -class GattReadTest(GattConnectedBaseTest): - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='ed8523f4-0eb8-4d14-b558-d3c28902f8bb') - def test_read_char(self): - """Test read characteristic value. - - Test GATT read characteristic value. - - Steps: - 1. Central: send read request. - 2. Peripheral: receive read request . - 3. Peripheral: send read response with status 0 (success), and - characteristic value. - 4. Central: receive read response, verify it's conent matches what was - sent - - Expected Result: - Verify that read request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - self.cen_ad.droid.gattClientReadCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.READABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_read_req']) - - request_id = event['data']['requestId'] - self.assertEqual(0, event['data']['offset'], "offset should be 0") - - bt_device_id = 0 - status = 0 - char_value = [1, 2, 3, 4, 5, 6, 7, 20] - offset = 0 - self.per_ad.droid.gattServerSendResponse(self.gatt_server, - bt_device_id, request_id, - status, offset, char_value) - - event = self._client_wait(gatt_event['char_read']) - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - self.assertEqual(char_value, event["data"]["CharacteristicValue"], - "Read value shall be equal to value sent from server") - - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5916a78d-3db8-4df2-9b96-b25e99096e0d') - def test_read_long_char(self): - """Test read long characteristic value. - - Test GATT read long characteristic value. - - Steps: - 1. Central: send read request. - 2. Peripheral: receive read request . - 3. Peripheral: send read response with status 0 (success), and - characteristic content. - 5. Central: stack receives read response that was full, so stack sends - read blob request with increased offset. - 6. Peripheral: receive read blob request, send read blob response with - next piece of characteristic value. - 7. Central: stack receives read blob response, so stack sends read blob - request with increased offset. No Java callbacks are called here - 8. Repeat steps 6 and 7 until whole characteristic is read. - 9. Central: verify onCharacteristicRead callback is called with whole - characteristic content. - - Expected Result: - Verify that read request/response is properly delivered, and that read - blob reqest/response is properly sent internally by the stack. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - char_value = [] - for i in range(512): - char_value.append(i % 256) - - self.cen_ad.droid.gattClientReadCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.READABLE_CHAR_UUID) - - # characteristic value is divided into packets, each contains MTU-1 - # bytes. Compute number of packets we expect to receive. - num_packets = ceil((len(char_value) + 1) / (self.mtu - 1)) - - for i in range(num_packets): - startOffset = i * (self.mtu - 1) - - event = self._server_wait(gatt_event['char_read_req']) - - request_id = event['data']['requestId'] - self.assertEqual(startOffset, event['data']['offset'], - "offset should be 0") - - bt_device_id = 0 - status = 0 - offset = 0 - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, offset, - char_value[startOffset:startOffset + self.mtu - 1]) - - event = self._client_wait(gatt_event['char_read']) - - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - self.assertEqual(char_value, event["data"]["CharacteristicValue"], - "Read value shall be equal to value sent from server") - - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='12498522-cac5-478b-a0cd-faa542832fa8') - def test_read_using_char_uuid(self): - """Test read using characteristic UUID. - - Test GATT read value using characteristic UUID. - - Steps: - 1. Central: send read by UUID request. - 2. Peripheral: receive read request . - 3. Peripheral: send read response with status 0 (success), and - characteristic value. - 4. Central: receive read response, verify it's conent matches what was - sent - - Expected Result: - Verify that read request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - self.cen_ad.droid.gattClientReadUsingCharacteristicUuid( - self.bluetooth_gatt, self.READABLE_CHAR_UUID, 0x0001, 0xFFFF) - - event = self._server_wait(gatt_event['char_read_req']) - - request_id = event['data']['requestId'] - self.assertEqual(0, event['data']['offset'], "offset should be 0") - - bt_device_id = 0 - status = 0 - char_value = [1, 2, 3, 4, 5, 6, 7, 20] - offset = 0 - self.per_ad.droid.gattServerSendResponse(self.gatt_server, - bt_device_id, request_id, - status, offset, char_value) - - event = self._client_wait(gatt_event['char_read']) - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - self.assertEqual(char_value, event["data"]["CharacteristicValue"], - "Read value shall be equal to value sent from server") - - return True diff --git a/acts_tests/tests/google/ble/gatt/GattToolTest.py b/acts_tests/tests/google/ble/gatt/GattToolTest.py index 8e7a9f0182..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/gatt/GattToolTest.py +++ b/acts_tests/tests/google/ble/gatt/GattToolTest.py @@ -1,445 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script is for partial automation of LE devices - -This script requires these custom parameters in the config file: - -"ble_mac_address" -"service_uuid" -"notifiable_char_uuid" -""" - -import pprint -from queue import Empty -import time - -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import gatt_cb_err -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_transport -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_gatt_utils import GattTestUtilsError -from acts.test_utils.bt.bt_gatt_utils import disconnect_gatt_connection -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_gatt_utils import setup_gatt_connection -from acts.test_utils.bt.bt_gatt_utils import log_gatt_server_uuids -from acts.test_utils.bt.bt_test_utils import reset_bluetooth - - -class GattToolTest(BluetoothBaseTest): - AUTOCONNECT = False - DEFAULT_TIMEOUT = 10 - PAIRING_TIMEOUT = 20 - adv_instances = [] - timer_list = [] - - def setup_class(self): - super().setup_class() - # Central role Android device - self.cen_ad = self.android_devices[0] - self.ble_mac_address = self.user_params['ble_mac_address'] - self.SERVICE_UUID = self.user_params['service_uuid'] - self.NOTIFIABLE_CHAR_UUID = self.user_params['notifiable_char_uuid'] - # CCC == Client Characteristic Configuration - self.CCC_DESC_UUID = "00002902-0000-1000-8000-00805f9b34fb" - - def setup_test(self): - super(BluetoothBaseTest, self).setup_test() - if not self._is_peripheral_advertising(): - input("Press enter when peripheral is advertising...") - return True - - def teardown_test(self): - super(BluetoothBaseTest, self).teardown_test() - self.log_stats() - self.timer_list = [] - return True - - def _pair_with_peripheral(self): - self.cen_ad.droid.bluetoothDiscoverAndBond(self.ble_mac_address) - end_time = time.time() + self.PAIRING_TIMEOUT - self.log.info("Verifying devices are bonded") - while time.time() < end_time: - bonded_devices = self.cen_ad.droid.bluetoothGetBondedDevices() - if self.ble_mac_address in {d['address'] for d in bonded_devices}: - self.log.info("Successfully bonded to device") - return True - return False - - def _is_peripheral_advertising(self): - self.cen_ad.droid.bleSetScanFilterDeviceAddress(self.ble_mac_address) - self.cen_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.cen_ad.droid) - self.cen_ad.droid.bleBuildScanFilter(filter_list) - - self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - expected_event_name = scan_result.format(scan_callback) - test_result = True - try: - self.cen_ad.ed.pop_event(expected_event_name, self.DEFAULT_TIMEOUT) - self.log.info( - "Peripheral found with event: {}".format(expected_event_name)) - except Empty: - self.log.info("Peripheral not advertising or not found: {}".format( - self.ble_mac_address)) - test_result = False - self.cen_ad.droid.bleStopBleScan(scan_callback) - return test_result - - def _unbond_device(self): - self.cen_ad.droid.bluetoothUnbond(self.ble_mac_address) - time.sleep(2) #Grace timeout for unbonding to finish - bonded_devices = self.cen_ad.droid.bluetoothGetBondedDevices() - if bonded_devices: - self.log.error( - "Failed to unbond device... found: {}".format(bonded_devices)) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - def test_gatt_connect_without_scanning(self): - """Test the round trip speed of connecting to a peripheral - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script will measure the amount - of time it takes to establish a GATT connection to the - peripheral. The test will then disconnect - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Start timer - 3. Perform GATT connection to peripheral - 4. Upon successful connection, stop timer - 5. Disconnect from peripheral - - Expected Result: - Device should be connected successfully - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 1 - """ - self.AUTOCONNECT = False - start_time = self._get_time_in_milliseconds() - try: - bluetooth_gatt, gatt_callback = (setup_gatt_connection( - self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, - gatt_transport['le'])) - except GattTestUtilsError as err: - self.log.error(err) - return False - end_time = self._get_time_in_milliseconds() - self.log.info("Total time (ms): {}".format(end_time - start_time)) - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, - gatt_callback) - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - - @BluetoothBaseTest.bt_test_wrap - def test_gatt_connect_stress(self): - """Test the round trip speed of connecting to a peripheral many times - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script will measure the amount - of time it takes to establish a GATT connection to the - peripheral. The test will then disconnect. It will attempt to - repeat this process multiple times. - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Start timer - 3. Perform GATT connection to peripheral - 4. Upon successful connection, stop timer - 5. Disconnect from peripheral - 6. Repeat steps 2-5 1000 times. - - Expected Result: - Test should measure 1000 iterations of connect/disconnect cycles. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 2 - """ - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.cen_ad.droid) - self.cen_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.AUTOCONNECT = False - iterations = 1000 - n = 0 - while n < iterations: - self.start_timer() - try: - bluetooth_gatt, gatt_callback = (setup_gatt_connection( - self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, - gatt_transport['le'])) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.log.info("Total time (ms): {}".format(self.end_timer())) - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, - gatt_callback) - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - n += 1 - return True - - @BluetoothBaseTest.bt_test_wrap - def test_gatt_connect_iterate_uuids(self): - """Test the discovery of uuids of a peripheral - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script connects an Android device - to the periphal and attempt to discover all services, - characteristics, and descriptors. - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Perform GATT connection to peripheral - 3. Upon successful connection, iterate through all services, - characteristics, and descriptors. - 5. Disconnect from peripheral - - Expected Result: - Device services, characteristics, and descriptors should all - be read. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 2 - """ - try: - bluetooth_gatt, gatt_callback = (setup_gatt_connection( - self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, - gatt_transport['le'])) - except GattTestUtilsError as err: - self.log.error(err) - return False - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.DEFAULT_TIMEOUT) - discovered_services_index = event['data']['ServicesIndex'] - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - log_gatt_server_uuids(self.cen_ad, discovered_services_index) - try: - disconnect_gatt_connection(self.cen_ad, bluetooth_gatt, - gatt_callback) - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - except GattTestUtilsError as err: - self.log.error(err) - return False - self.cen_ad.droid.gattClientClose(bluetooth_gatt) - return True - - @BluetoothBaseTest.bt_test_wrap - def test_pairing(self): - """Test pairing to a GATT mac address - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script will bond the Android device - to the peripheral. - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Perform Bluetooth pairing to GATT mac address - 3. Upon successful bonding. - 4. Unbond from device - - Expected Result: - Device services, characteristics, and descriptors should all - be read. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 1 - """ - if not self._pair_with_peripheral(): - return False - self.cen_ad.droid.bluetoothUnbond(self.ble_mac_address) - return self._unbond_device() - - @BluetoothBaseTest.bt_test_wrap - def test_pairing_stress(self): - """Test the round trip speed of pairing to a peripheral many times - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script will measure the amount - of time it takes to establish a pairing with a BLE device. - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Start timer - 3. Perform Bluetooth pairing to GATT mac address - 4. Upon successful bonding, stop timer. - 5. Unbond from device - 6. Repeat steps 2-5 100 times. - - Expected Result: - Test should measure 100 iterations of bonding. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 3 - """ - iterations = 100 - for _ in range(iterations): - start_time = self.start_timer() - if not self._pair_with_peripheral(): - return False - self.log.info("Total time (ms): {}".format(self.end_timer())) - if not self._unbond_device(): - return False - return True - - @BluetoothBaseTest.bt_test_wrap - def test_gatt_notification_longev(self): - """Test GATT characterisitic notifications for long periods of time - - This test will prompt the user to press "Enter" when the - peripheral is in a connecable advertisement state. Once - the user presses enter, this script aims to set characteristic - notification to true on the config file's SERVICE_UUID, - NOTIFIABLE_CHAR_UUID, and CCC_DESC_UUID. This test assumes - the peripheral will constantly write data to a notifiable - characteristic. - - Steps: - 1. Wait for user input to confirm peripheral is advertising. - 2. Perform Bluetooth pairing to GATT mac address - 3. Perform a GATT connection to the periheral - 4. Get the discovered service uuid that matches the user's input - in the config file - 4. Write to the CCC descriptor to enable notifications - 5. Enable notifications on the user's input Characteristic UUID - 6. Continuously wait for Characteristic Changed events which - equate to recieving notifications for 15 minutes. - - Expected Result: - There should be no disconnects and we should constantly receive - Characteristic Changed information. Values should vary upon user - interaction with the peripheral. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT - Priority: 1 - """ - #pair devices - if not self._pair_with_peripheral(): - return False - try: - bluetooth_gatt, gatt_callback = (setup_gatt_connection( - self.cen_ad, self.ble_mac_address, self.AUTOCONNECT, - gatt_transport['le'])) - except GattTestUtilsError as err: - self.log.error(err) - return False - if self.cen_ad.droid.gattClientDiscoverServices(bluetooth_gatt): - expected_event = gatt_cb_strings['gatt_serv_disc'].format( - gatt_callback) - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.DEFAULT_TIMEOUT) - discovered_services_index = event['data']['ServicesIndex'] - except Empty: - self.log.error( - gatt_cb_err['gatt_serv_disc'].format(expected_event)) - return False - # TODO: in setup save service_cound and discovered_services_index - # programatically - services_count = self.cen_ad.droid.gattClientGetDiscoveredServicesCount( - discovered_services_index) - test_service_index = None - for i in range(services_count): - disc_service_uuid = ( - self.cen_ad.droid.gattClientGetDiscoveredServiceUuid( - discovered_services_index, i)) - if disc_service_uuid == self.SERVICE_UUID: - test_service_index = i - break - if not test_service_index: - self.log.error("Service not found.") - return False - - self.cen_ad.droid.gattClientDescriptorSetValue( - bluetooth_gatt, discovered_services_index, test_service_index, - self.NOTIFIABLE_CHAR_UUID, self.CCC_DESC_UUID, - gatt_descriptor['enable_notification_value']) - - self.cen_ad.droid.gattClientWriteDescriptor( - bluetooth_gatt, discovered_services_index, test_service_index, - self.NOTIFIABLE_CHAR_UUID, self.CCC_DESC_UUID) - - self.cen_ad.droid.gattClientSetCharacteristicNotification( - bluetooth_gatt, discovered_services_index, test_service_index, - self.NOTIFIABLE_CHAR_UUID, True) - - # set 15 minute notification test time - notification_test_time = 900 - end_time = time.time() + notification_test_time - expected_event = gatt_cb_strings['char_change'].format(gatt_callback) - while time.time() < end_time: - try: - event = self.cen_ad.ed.pop_event(expected_event, - self.DEFAULT_TIMEOUT) - self.log.info(event) - except Empty as err: - print(err) - self.log.error( - gatt_cb_err['char_change_err'].format(expected_event)) - return False - return True diff --git a/acts_tests/tests/google/ble/gatt/GattWriteTest.py b/acts_tests/tests/google/ble/gatt/GattWriteTest.py index d245e9e36e..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/gatt/GattWriteTest.py +++ b/acts_tests/tests/google/ble/gatt/GattWriteTest.py @@ -1,572 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different GATT write procedures. -""" - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length -from acts.test_utils.bt.bt_constants import gatt_mtu_size -from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu - - -class GattWriteTest(GattConnectedBaseTest): - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='513f4cef-489e-4bb6-96cc-c298c589225c') - def test_write_char(self): - """Test write characteristic value - - Test write characteristic value using Write Request - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write request. - 2. Peripheral: receive the written data. - 3. Peripheral: send response with status 0 (success). - 4. Central: make sure write callback is called. - - Expected Result: - Verify that write request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - char_value = [1, 2, 3, 4, 5, 6, 7] - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_default']) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_write_req']) - - request_id = event['data']['requestId'] - self.assertEqual(True, event['data']['responseNeeded'], - "Should need response") - self.assertEqual(char_value, event['data']['value']) - self.assertEqual(0, event['data']['offset']) - - bt_device_id = 0 - status = 0 - #both offset and return value don't matter, just the status - offset = 0 - self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, offset, []) - - event = self._client_wait(gatt_event['char_write']) - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - # Write response doesn't carry any data expcept status - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='329dbef8-1b54-47e2-a388-b33ef9384464') - def test_write_descr(self): - """Test write descriptor value - - Test write descriptor value - - 1. Central: write WRITABLE_DESC_UUID descriptor with desc_value. - 2. Peripheral: receive the written data. - 3. Peripheral: send response with status 0 (success). - 4. Central: make sure write callback is called. - - Expected Result: - Verify that write request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Descriptor - Priority: 0 - """ - desc_value = [1, 2, 3, 4, 5, 6, 7] - self.cen_ad.droid.gattClientDescriptorSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - self.WRITABLE_DESC_UUID, desc_value) - - self.cen_ad.droid.gattClientWriteDescriptor( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - self.WRITABLE_DESC_UUID) - - event = self._server_wait(gatt_event['desc_write_req']) - - request_id = event['data']['requestId'] - self.assertEqual(True, event['data']['responseNeeded'], - "Should need response") - self.assertEqual(desc_value, event['data']['value']) - self.assertEqual(0, event['data']['offset']) - - bt_device_id = 0 - status = 0 - #both offset and return value don't matter, just the status - offset = 0 - self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, offset, []) - - event = self._client_wait(gatt_event['desc_write']) - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - # Write response doesn't carry any data except status - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='85757307-5bb1-43e5-9331-f1d7bdcbd6a0') - def test_write_char_no_resp(self): - """Test write characteristic value - - Test write characteristic value using Write Command - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write command. - 2. Central: make sure write callback is called. - 3. Peripheral: receive the written data. - - Expected Result: - Verify that write command is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - char_value = [1, 2, 3, 4, 5, 6, 7] - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._client_wait(gatt_event['char_write']) - if event["data"]["Status"] != 0: - self.log.error("Write status should be 0") - return False - - event = self._server_wait(gatt_event['char_write_req']) - - request_id = event['data']['requestId'] - self.assertEqual(False, event['data']['responseNeeded'], - "Should not need response") - self.assertEqual(0, event['data']['offset']) - self.assertEqual(char_value, event['data']['value']) - - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0bf0182a-c315-4160-81be-9ce09f93608b') - def test_write_characteristic_long_no_resp(self): - """Test write characteristic value - - Test write characteristic value using Write Command - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write command. - 2. Central: make sure write callback is called. - 3. Peripheral: receive the written data. Check it was properly trimmed. - - Expected Result: - Verify that write command is properly trimmed and delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - char_value = [] - for i in range(512): - char_value.append(i % 256) - - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_write_req']) - - request_id = event['data']['requestId'] - self.assertEqual(False, event['data']['responseNeeded']) - - # value shall be trimmed to MTU-3 - trimmed_value = char_value[0:self.mtu - 3] - self.assertEqual( - trimmed_value, event['data']['value'], - "Received value should be sent value trimmed to MTU-3") - - event = self._client_wait(gatt_event['char_write']) - if event["data"]["Status"] != 0: - self.log.error("Write status should be 0") - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b80f1b5a-a223-441e-a6ed-d3c284c83cc7') - def test_write_characteristic_value_longer_than_mtu_request(self): - """Test writing characteristic value longer than what mtu limts - - Test establishing a gatt connection between a GATT Peripheral and GATT - Client. Request mtu size equal to the max MTU. - The max number of bytes can be sent within a characteristic is - (MTU - gatt_characteristic_attr_length['attr_2']) since - the gatt_characteristic_attr_length['attr_2'] (3 bytes) are - used for its attribute of the command code and its handle. - Then reduce mtu by 1 and re-send the same characteristic. - Make sure the characteristic value received by the remote side is - also reduced properly. - - Steps: - 1. Create a GATT connection between the scanner(Client) and - advertiser(Peripheral). - 2. Client: request new mtu size change to max MTU. - 3. Client: write a characteristic with char_value of max MTU bytes. - 4. Peripheral: receive the written data. Check it was properly - truncated to (max MTU - gatt_characteristic_attr_length['attr_2']). - 5. Client: request mtu size change to (max MTU - 1). - 6. Client: write the same characteristic again. - 7. Peripheral: receive the written data. Check it was properly - truncated to (max MTU - 1 - gatt_characteristic_attr_length['attr_2']) - 8. Client: return mtu size. - - Expected Result: - Verify that data received by the Peripheral side is properly truncated - when mtu is set. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic, MTU - Priority: 2 - """ - self.mtu = gatt_mtu_size['max'] - self.log.info("Set mtu to max MTU: {}".format(self.mtu)) - # set new MTU to the middle point of min and max of MTU - if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, - self.gatt_callback, self.mtu): - return False - - # create a characteristic with max MTU (217) bytes - char_value = [] - for i in range(gatt_mtu_size['max']): - char_value.append(i) - - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) - - # write data to the characteristic of the Peripheral - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_write_req']) - self.log.info("Received value with mtu = max MTU: {}".format(event[ - 'data']['value'])) - - # check the data received by Peripheral shall be truncated to - # (mtu - gatt_characteristic_attr_length['attr_2']) bytes - data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] - expected_value = char_value[:data_length] - self.assertEqual( - expected_value, event['data']['value'], - "Received value should have {} bytes".format(data_length)) - - # set the mtu to max MTU-1 - self.mtu = gatt_mtu_size['max'] - 1 - self.log.info("Set mtu to max MTU - 1 : {}".format(self.mtu)) - data_length = self.mtu - gatt_characteristic_attr_length['attr_2'] - if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, - self.gatt_callback, self.mtu): - return False - - # write the same characteric to Peripheral again - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_write_req']) - self.log.info("Data received when mtu = max MTU - 1: {}".format(event[ - 'data']['value'])) - - # check the data received by Peripheral shall be truncated to - # (mtu - gatt_characteristic_attr_length['attr_2']) bytes - # when mtu is reduced - expected_value = char_value[:data_length] - self.assertEqual( - expected_value, event['data']['value'], - "Received value should have {} bytes".format(data_length)) - - # return the mtu to default - self.mtu = gatt_mtu_size['min'] - self.log.info("Set mtu to min : {}".format(self.mtu)) - if not setup_gatt_mtu(self.cen_ad, self.bluetooth_gatt, - self.gatt_callback, self.mtu): - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='319eee6d-22d9-4498-bb15-21d0018e45e6') - def test_write_characteristic_stress(self): - """Stress test write characteristic value - - Test write characteristic value using Write Request - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write request. - 2. Peripheral: receive the written data. - 3. Peripheral: send response with status 0 (success). - 4. Central: make sure write callback is called. - 5. Repeat steps 1-4 100 times. - - Expected Result: - Verify that write request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) - - bt_device_id = 0 - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_default']) - - for i in range(100): - - char_value = [] - for j in range(i, i + self.mtu - 3): - char_value.append(j % 256) - - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - event = self._server_wait(gatt_event['char_write_req']) - - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) - request_id = event['data']['requestId'] - found_value = event['data']['value'] - if found_value != char_value: - self.log.info("Values didn't match. Found: {}, " - "Expected: {}".format(found_value, char_value)) - return False - - # only status is sent - status = 0 - offset = 0 - char_value_return = [] - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, offset, - char_value_return) - - event = self._client_wait(gatt_event['char_write']) - if event["data"]["Status"] != status: - self.log.error("Write status should be 0") - return False - - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='b19d42dc-58ba-4b20-b6c1-6628e7d21de4') - def test_write_descriptor_stress(self): - """Stress test write descriptor value - - Stress test write descriptor value - - 1. Central: write WRITABLE_DESC_UUID descriptor with desc_value. - 2. Peripheral: receive the written data. - 3. Peripheral: send response with status 0 (success). - 4. Central: make sure write callback is called. - 5. Repeat 1-4 100 times - - Expected Result: - Verify that write request/response is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Descriptor - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) - - for i in range(100): - - desc_value = [] - for j in range(i, i + self.mtu - 3): - desc_value.append(j % 256) - - self.cen_ad.droid.gattClientDescriptorSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - self.WRITABLE_DESC_UUID, desc_value) - - self.cen_ad.droid.gattClientWriteDescriptor( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - self.WRITABLE_DESC_UUID) - - event = self._server_wait(gatt_event['desc_write_req']) - - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) - - request_id = event['data']['requestId'] - self.assertEqual(True, event['data']['responseNeeded'], - "Should need response") - self.assertEqual(desc_value, event['data']['value']) - self.assertEqual(0, event['data']['offset']) - - bt_device_id = 0 - status = 0 - #both offset and return value don't matter, just the status - offset = 0 - self.per_ad.droid.gattServerGetConnectedDevices(self.gatt_server) - self.per_ad.droid.gattServerSendResponse( - self.gatt_server, bt_device_id, request_id, status, offset, []) - - event = self._client_wait(gatt_event['desc_write']) - self.assertEqual(status, event["data"]["Status"], - "Write status should be 0") - # Write response doesn't carry any data except status - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='74c147eb-2702-4cd8-be1f-efff3e9eaa6c') - def test_write_characteristic_no_resp_stress(self): - """Stress test write characteristic value - - Stress test write characteristic value using Write Command - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write command. - 2. Central: make sure write callback is called. - 3. Peripheral: receive the written data. - 4. Repeat steps 1-3 100 times. - - Expected Result: - Verify that write command is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) - - bt_device_id = 0 - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) - - for i in range(100): - char_value = [] - for j in range(i, i + self.mtu - 3): - char_value.append(j % 256) - - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - # client shall not wait for server, get complete event right away - event = self._client_wait(gatt_event['char_write']) - if event["data"]["Status"] != 0: - self.log.error("Write status should be 0") - return False - - event = self._server_wait(gatt_event['char_write_req']) - - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) - request_id = event['data']['requestId'] - found_value = event['data']['value'] - if found_value != char_value: - self.log.info("Values didn't match. Found: {}, " - "Expected: {}".format(found_value, char_value)) - return False - - return True diff --git a/acts_tests/tests/google/ble/scan/BleBackgroundScanTest.py b/acts_tests/tests/google/ble/scan/BleBackgroundScanTest.py index 68396023b4..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/scan/BleBackgroundScanTest.py +++ b/acts_tests/tests/google/ble/scan/BleBackgroundScanTest.py @@ -1,277 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises background scan test scenarios. -""" - -from queue import Empty - -from acts import utils -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_test_utils import bluetooth_off -from acts.test_utils.bt.bt_test_utils import bluetooth_on -from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers -from acts.test_utils.bt.bt_test_utils import enable_bluetooth -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_constants import bluetooth_le_off -from acts.test_utils.bt.bt_constants import bluetooth_le_on -from acts.test_utils.bt.bt_constants import bt_adapter_states -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import scan_result - -import time - - -class BleBackgroundScanTest(BluetoothBaseTest): - default_timeout = 10 - report_delay = 2000 - scan_callbacks = [] - adv_callbacks = [] - active_scan_callback_list = [] - active_adv_callback_list = [] - - def setup_class(self): - super(BluetoothBaseTest, self).setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - utils.set_location_service(self.scn_ad, True) - utils.set_location_service(self.adv_ad, True) - return True - - def setup_test(self): - # Always start tests with Bluetooth enabled and BLE disabled. - enable_bluetooth(self.scn_ad.droid, self.scn_ad.ed) - self.scn_ad.droid.bluetoothDisableBLE() - for a in self.android_devices: - a.ed.clear_all_events() - return True - - def teardown_test(self): - cleanup_scanners_and_advertisers( - self.scn_ad, self.active_adv_callback_list, self.adv_ad, - self.active_adv_callback_list) - self.active_adv_callback_list = [] - self.active_scan_callback_list = [] - - def _setup_generic_advertisement(self): - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( - self.adv_ad.droid) - self.adv_ad.droid.bleStartBleAdvertising(adv_callback, adv_data, - adv_settings) - self.active_adv_callback_list.append(adv_callback) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4d13c3a8-1805-44ef-a92a-e385540767f1') - def test_background_scan(self): - """Test generic background scan. - - Tests LE background scan. The goal is to find scan results even though - Bluetooth is turned off. - - Steps: - 1. Setup an advertisement on dut1 - 2. Enable LE on the Bluetooth Adapter on dut0 - 3. Toggle BT off on dut1 - 4. Start a LE scan on dut0 - 5. Find the advertisement from dut1 - - Expected Result: - Find a advertisement from the scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Background Scanning - Priority: 0 - """ - self.scn_ad.droid.bluetoothEnableBLE() - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bluetoothToggleState(False) - try: - self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) - except Empty: - self.log.error("Bluetooth Off event not found. Expected {}".format( - bluetooth_off)) - return False - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - expected_event = scan_result.format(scan_callback) - try: - self.scn_ad.ed.pop_event(expected_event, self.default_timeout) - except Empty: - self.log.error("Scan Result event not found. Expected {}".format( - expected_event)) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9c4577f8-5e06-4034-b977-285956734974') - def test_background_scan_ble_disabled(self): - """Test background LE scanning with LE disabled. - - Tests LE background scan. The goal is to find scan results even though - Bluetooth is turned off. - - Steps: - 1. Setup an advertisement on dut1 - 2. Enable LE on the Bluetooth Adapter on dut0 - 3. Toggle BT off on dut1 - 4. Start a LE scan on dut0 - 5. Find the advertisement from dut1 - - Expected Result: - Find a advertisement from the scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Background Scanning - Priority: 0 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bluetoothEnableBLE() - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['low_latency']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bluetoothToggleState(False) - try: - self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) - except Empty: - self.log.info(self.scn_ad.droid.bluetoothCheckState()) - self.log.error("Bluetooth Off event not found. Expected {}".format( - bluetooth_off)) - return False - try: - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - expected_event = scan_result.format(scan_callback) - try: - self.scn_ad.ed.pop_event(expected_event, self.default_timeout) - except Empty: - self.log.error( - "Scan Result event not found. Expected {}".format( - expected_event)) - return False - except Exception: - self.log.info( - "Was not able to start a background scan as expected.") - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='0bdd1764-3dc6-4a82-b041-76e48ed0f424') - def test_airplane_mode_disables_ble(self): - """Try to start LE mode in Airplane Mode. - - This test will enable airplane mode, then attempt to start LE scanning - mode. This should result in bluetooth still being turned off, LE - not enabled. - - Steps: - 1. Start LE only mode. - 2. Bluetooth should be in LE ONLY mode - 2. Turn on airplane mode. - 3. Bluetooth should be OFF - 4. Try to start LE only mode. - 5. Bluetooth should stay in OFF mode (LE only start should fail) - 6. Turn off airplane mode. - 7. Bluetooth should be OFF. - - Expected Result: - No unexpected bluetooth state changes. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Airplane - Priority: 1 - """ - ble_state_error_msg = "Bluetooth LE State not OK {}. Expected {} got {}" - # Enable BLE always available (effectively enabling BT in location) - self.scn_ad.shell.enable_ble_scanning() - self.scn_ad.droid.bluetoothEnableBLE() - self.scn_ad.droid.bluetoothToggleState(False) - try: - self.scn_ad.ed.pop_event(bluetooth_off, self.default_timeout) - except Empty: - self.log.error("Bluetooth Off event not found. Expected {}".format( - bluetooth_off)) - self.log.info(self.scn_ad.droid.bluetoothCheckState()) - return False - - # Sleep because LE turns off after the bluetooth off event fires - time.sleep(self.default_timeout) - state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['ble_on']: - self.log.error( - ble_state_error_msg.format("after BT Disable", - bt_adapter_states['ble_on'], state)) - return False - - self.scn_ad.droid.bluetoothListenForBleStateChange() - self.scn_ad.droid.connectivityToggleAirplaneMode(True) - try: - self.scn_ad.ed.pop_event(bluetooth_le_off, self.default_timeout) - except Empty: - self.log.error( - "Bluetooth LE Off event not found. Expected {}".format( - bluetooth_le_off)) - return False - state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: - self.log.error( - ble_state_error_msg.format("after Airplane Mode ON", - bt_adapter_states['off'], state)) - return False - result = self.scn_ad.droid.bluetoothEnableBLE() - if result: - self.log.error( - "Bluetooth Enable command succeded when it should have failed (in airplane mode)" - ) - return False - state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: - self.log.error( - "Bluetooth LE State not OK after attempted enable. Expected {} got {}". - format(bt_adapter_states['off'], state)) - return False - self.scn_ad.droid.connectivityToggleAirplaneMode(False) - # Sleep to let Airplane Mode disable propogate through the system - time.sleep(self.default_timeout) - state = self.scn_ad.droid.bluetoothGetLeState() - if state != bt_adapter_states['off']: - self.log.error( - ble_state_error_msg.format("after Airplane Mode OFF", - bt_adapter_states['off'], state)) - return False - return True diff --git a/acts_tests/tests/google/ble/scan/BleOnLostOnFoundTest.py b/acts_tests/tests/google/ble/scan/BleOnLostOnFoundTest.py index 01f7976db4..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/scan/BleOnLostOnFoundTest.py +++ b/acts_tests/tests/google/ble/scan/BleOnLostOnFoundTest.py @@ -1,292 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different onLost/onFound scenarios. -""" - -from queue import Empty -from acts import utils -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_callback_types -from acts.test_utils.bt.BleEnum import ScanSettingsMatchMode -from acts.test_utils.bt.BleEnum import ScanSettingsMatchNum -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_match_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_match_nums -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result - - -class BleOnLostOnFoundTest(BluetoothBaseTest): - default_timeout = 10 - active_scan_callback_list = [] - active_adv_callback_list = [] - - def setup_class(self): - super(BluetoothBaseTest, self).setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - utils.set_location_service(self.scn_ad, True) - utils.set_location_service(self.adv_ad, True) - return True - - def teardown_test(self): - cleanup_scanners_and_advertisers( - self.scn_ad, self.active_adv_callback_list, self.adv_ad, - self.active_adv_callback_list) - self.active_adv_callback_list = [] - self.active_scan_callback_list = [] - - def on_exception(self, test_name, begin_time): - reset_bluetooth(self.android_devices) - - def _start_generic_advertisement_include_device_name(self): - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - advertise_data = self.adv_ad.droid.bleBuildAdvertiseData() - advertise_settings = self.adv_ad.droid.bleBuildAdvertiseSettings() - advertise_callback = self.adv_ad.droid.bleGenBleAdvertiseCallback() - self.adv_ad.droid.bleStartBleAdvertising( - advertise_callback, advertise_data, advertise_settings) - self.adv_ad.ed.pop_event( - adv_succ.format(advertise_callback), self.default_timeout) - self.active_adv_callback_list.append(advertise_callback) - return advertise_callback - - def _verify_no_events_found(self, event_name): - try: - self.scn_ad.ed.pop_event(event_name, self.default_timeout) - self.log.error("Found an event when none was expected.") - return False - except Empty: - self.log.info("No scan result found as expected.") - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9bd7fd09-71c9-4623-90f0-9a895eb37409') - def test_onlost_onfound_defaults(self): - """Test generic onlost/onfound defaults. - - Tests basic onFound/onLost functionality. - - Steps: - 1. Setup dut0 scanner and start scan with this setup: - Scan Mode: SCAN_MODE_LOW_LATENCY - Callback Type: CALLBACK_TYPE_FOUND_AND_LOST - Match Mode: AGGRESSIVE - Num of Matches: MATCH_NUM_ONE_ADVERTISEMENT - Filter: Device name of dut1 - 2. Start an advertisement on dut1, include device name - 3. Find an onFound event - 4. Stop the advertisement on dut1 - 5. Find an onLost event - - Expected Result: - Find an onLost and an onFound event successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, onLost, onFound - Priority: 0 - """ - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) - self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['aggresive']) - self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['one']) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - adv_callback = self._start_generic_advertisement_include_device_name() - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 3) - found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: - self.log.info( - "Found Callbacreset_bluetoothkType:{}, Expected CallbackType:{}". - format(found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) - return False - self.adv_ad.droid.bleStopBleAdvertising(adv_callback) - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 4) - found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='10b48dc9-0c2a-46a3-8890-5cde3004a996') - def test_onlost_onfound_match_mode_sticky(self): - """Test generic onlost/onfound in sticky mode. - - Tests basic onFound/onLost functionality. - - Steps: - 1. Setup dut0 scanner and start scan with this setup: - Scan Mode: SCAN_MODE_LOW_LATENCY - Callback Type: CALLBACK_TYPE_FOUND_AND_LOST - Match Mode: STICKY - Num of Matches: MATCH_NUM_ONE_ADVERTISEMENT - Filter: Device name of dut1 - 2. Start an advertisement on dut1, include device name - 3. Find an onFound event - 4. Stop the advertisement on dut1 - 5. Find an onLost event - - Expected Result: - Find an onLost and an onFound event successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, onLost, onFound - Priority: 1 - """ - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) - self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['sticky']) - self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['one']) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - adv_callback = self._start_generic_advertisement_include_device_name() - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 3) - found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) - return False - self.adv_ad.droid.bleStopBleAdvertising(adv_callback) - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 4) - found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4fefed82-7800-41be-8272-aac076640fed') - def test_onlost_onfound_match_num_few(self): - """Test generic onlost/onfound num few. - - Tests basic onFound/onLost functionality. - - Steps: - 1. Setup dut0 scanner and start scan with this setup: - Scan Mode: SCAN_MODE_LOW_LATENCY - Callback Type: CALLBACK_TYPE_FOUND_AND_LOST - Match Mode: AGGRESSIVE - Num of Matches: MATCH_NUM_FEW_ADVERTISEMENT - Filter: Device name of dut1 - 2. Start an advertisement on dut1, include device name - 3. Find an onFound event - 4. Stop the advertisement on dut1 - 5. Find an onLost event - - Expected Result: - Find an onLost and an onFound event successfully. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, onLost, onFound - Priority: 1 - """ - filter_list = self.scn_ad.droid.bleGenFilterList() - self.scn_ad.droid.bleSetScanFilterDeviceName( - self.adv_ad.droid.bluetoothGetLocalName()) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.scn_ad.droid.bleSetScanSettingsCallbackType( - ble_scan_settings_callback_types['found_and_lost']) - self.scn_ad.droid.bleSetScanSettingsMatchMode( - ble_scan_settings_match_modes['aggresive']) - self.scn_ad.droid.bleSetScanSettingsNumOfMatches( - ble_scan_settings_match_nums['few']) - scan_settings = self.scn_ad.droid.bleBuildScanSetting() - scan_callback = self.scn_ad.droid.bleGenScanCallback() - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - adv_callback = self._start_generic_advertisement_include_device_name() - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 3) - found_callback_type = event['data']['CallbackType'] - if event['data']['CallbackType'] != ble_scan_settings_callback_types[ - 'first_match']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'first_match'])) - return False - self.adv_ad.droid.bleStopBleAdvertising(adv_callback) - event = self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout * 4) - found_callback_type = event['data']['CallbackType'] - if found_callback_type != ble_scan_settings_callback_types[ - 'match_lost']: - self.log.info( - "Found CallbackType:{}, Expected CallbackType:{}".format( - found_callback_type, ble_scan_settings_callback_types[ - 'match_lost'])) - return False - return True diff --git a/acts_tests/tests/google/ble/scan/BleOpportunisticScanTest.py b/acts_tests/tests/google/ble/scan/BleOpportunisticScanTest.py index 9e591281b1..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/scan/BleOpportunisticScanTest.py +++ b/acts_tests/tests/google/ble/scan/BleOpportunisticScanTest.py @@ -1,702 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different opportunistic scan scenarios. -It is expected that the second AndroidDevice is able to advertise. - -This test script was designed with this setup in mind: -Shield box one: Android Device, Android Device -""" - -from queue import Empty - -from acts import utils -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import batch_scan_result -from acts.test_utils.bt.bt_test_utils import cleanup_scanners_and_advertisers -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth -from acts.test_utils.bt.bt_constants import scan_result - - -class BleOpportunisticScanTest(BluetoothBaseTest): - default_timeout = 10 - max_scan_instances = 25 - report_delay = 2000 - scan_callbacks = [] - adv_callbacks = [] - active_scan_callback_list = [] - active_adv_callback_list = [] - - def setup_class(self): - super(BluetoothBaseTest, self).setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - utils.set_location_service(self.scn_ad, True) - utils.set_location_service(self.adv_ad, True) - return True - - def teardown_test(self): - cleanup_scanners_and_advertisers( - self.scn_ad, self.active_scan_callback_list, self.adv_ad, - self.active_adv_callback_list) - self.active_adv_callback_list = [] - self.active_scan_callback_list = [] - - def on_exception(self, test_name, begin_time): - reset_bluetooth(self.android_devices) - - def _setup_generic_advertisement(self): - adv_callback, adv_data, adv_settings = generate_ble_advertise_objects( - self.adv_ad.droid) - self.adv_ad.droid.bleStartBleAdvertising(adv_callback, adv_data, - adv_settings) - self.active_adv_callback_list.append(adv_callback) - - def _verify_no_events_found(self, event_name): - try: - event = self.scn_ad.ed.pop_event(event_name, self.default_timeout) - self.log.error("Found an event when none was expected: {}".format( - event)) - return False - except Empty: - self.log.info("No scan result found as expected.") - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6bccfbea-3734-4504-8ea9-3511ad17a3e0') - def test_scan_result_no_advertisement(self): - """Test opportunistic scan with no advertisement. - - Tests opportunistic scan where there are no advertisements. This should - not find any onScanResults. - - Steps: - 1. Initialize scanner with scan mode set to opportunistic mode. - 2. Start scanning on dut 0 - 3. Pop onScanResults event on the scanner - - Expected Result: - Find no advertisements with the opportunistic scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='8430bc57-925c-4b70-a62e-cd34df264ca1') - def test_batch_scan_result_no_advertisement(self): - """Test batch opportunistic scan without an advertisement. - - Tests opportunistic scan where there are no advertisements. This should - not find any onBatchScanResult. - - Steps: - 1. Initialize scanner with scan mode set to opportunistic mode. - 2. Set report delay seconds such that onBatchScanResult events are - expected - 2. Start scanning on dut 0 - 3. Pop onBatchScanResult event on the scanner - - Expected Result: - Find no advertisements with the opportunistic scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning - Priority: 1 - """ - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found( - batch_scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleStopBleScan(scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='4613cb67-0f54-494e-8a56-2e8ce56fad41') - def test_scan_result(self): - """Test opportunistic scan with an advertisement. - - Tests opportunistic scan where it will only report scan results when - other registered scanners find results. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Initialize scanner with scan mode set to opportunistic mode on dut0 - and start scanning - 3. Try to find an event, expect none. - 4. Start a second scanner on dut0, with any other mode set - 5. Pop onScanResults event on the second scanner - 6. Pop onScanResults event on the first scanner - - Expected Result: - Scan result is found on the opportunistic scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Opportunistic scan found no scan results.") - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='5b46fefc-70ef-48a0-acf4-35077cd72202') - def test_batch_scan_result(self): - """Test batch opportunistic scan with advertisement. - - Tests opportunistic scan where it will only report scan results when - other registered scanners find results. Set the report delay millis such - that an onBatchScanResult is expected. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Initialize scanner with scan mode set to opportunistic mode and - set scan settings report delay seconds such that a batch scan is - expected - 3. Start scanning on dut 0 - 4. Try to find an event, expect none. - 5. Start a second scanner on dut0, with any other mode set and set scan - settings report delay millis such that an onBatchScanResult is expected - 6. Pop onBatchScanResult event on the second scanner - 7. Pop onBatchScanResult event on the first scanner - - Expected Result: - Find a batch scan result on both opportunistic scan instances. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found( - batch_scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - batch_scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - try: - self.scn_ad.ed.pop_event( - batch_scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Opportunistic scan found no scan results.") - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='fd85d95e-dc8c-48c1-8d8a-83c3475755ff') - def test_batch_scan_result_not_expected(self): - """Test opportunistic batch scan without expecting an event. - - Tests opportunistic scan where it will only report scan results when - other registered scanners find results. Set the report delay millis such - that a batch scan is not expected. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Initialize scanner with scan mode set to opportunistic mode and - set scan settings report delay seconds such that a batch scan is - expected. - 3. Start scanning on dut 0 - 4. Try to find an event, expect none. - 5. Start a second scanner on dut0, with any other mode set and set scan - settings report delay millis to 0 such that an onBatchScanResult is not - expected. - 6. Pop onScanResults event on the second scanner - 7. Pop onBatchScanResult event on the first scanner - - Expected Result: - Batch scan result is not expected on opportunistic scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found( - batch_scan_result.format(scan_callback)): - - return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - return self._verify_no_events_found( - batch_scan_result.format(scan_callback)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='6138592e-8fd5-444f-9a7c-25cd9695644a') - def test_scan_result_not_expected(self): - """Test opportunistic scan without expecting an event. - - Tests opportunistic scan where it will only report batch scan results - when other registered scanners find results. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Initialize scanner with scan mode set to opportunistic mode. - 3. Start scanning on dut 0 - 4. Try to find an event, expect none. - 5. Start a second scanner on dut0, with any other mode set and set scan - settings - report delay millis such that an onBatchScanResult is expected - 6. Pop onBatchScanResult event on the second scanner - 7. Pop onScanResults event on the first scanner - - Expected Result: - Scan result is not expected on opportunistic scan instance. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - batch_scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - return self._verify_no_events_found(scan_result.format(scan_callback)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='f7aba3d9-d3f7-4b2f-976e-441772705613') - def test_max_opportunistic_scan_instances(self): - """Test max number of opportunistic scan instances. - - Tests max instances of opportunistic scans. Each instances should - find an onScanResults event. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Set scan settings to opportunistic scan on dut0 scan instance - 3. Start scan scan from step 2 - 4. Repeat step two and three until there are max_scan_instances-1 scan - instances - 5. Start a regular ble scan on dut0 with the last available scan - instance - 6. Pop onScanResults event on all scan instances - - Expected Result: - Each opportunistic scan instance finds a advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self._setup_generic_advertisement() - for _ in range(self.max_scan_instances - 1): - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - - for callback in self.active_scan_callback_list: - try: - self.scn_ad.ed.pop_event( - scan_result.format(callback), self.default_timeout) - except Empty: - self.log.error("No scan results found for callback {}".format( - callback)) - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='cf971f08-4d92-4046-bba6-b86a75aa773c') - def test_max_opportunistic_batch_scan_instances(self): - """Test max opportunistic batch scan instances. - - Tests max instances of opportunistic batch scans. Each instances should - find an onBatchScanResult event. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. Set scan settings to opportunistic scan on dut0 scan instance and - set report delay seconds such that an onBatchScanResult is expected - 3. Start scan scan from step 2 - 4. Repeat step two and three until there are max_scan_instances-1 scan - instances - 5. Start a regular ble scan on dut0 with the last available scan - instance - 6. Pop onBatchScanResult event on all scan instances - - Expected Result: - Each opportunistic scan instance finds an advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan, Batch Scanning - Priority: 1 - """ - self._setup_generic_advertisement() - for _ in range(self.max_scan_instances - 1): - self.scn_ad.droid.bleSetScanSettingsScanMode( - ble_scan_settings_modes['opportunistic']) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.scn_ad.droid.bleSetScanSettingsReportDelayMillis( - self.report_delay) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - - for callback in self.active_scan_callback_list: - try: - self.scn_ad.ed.pop_event( - batch_scan_result.format(callback), self.default_timeout) - except Empty: - self.log.error("No scan results found for callback {}".format( - callback)) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='965d84ef-11a7-418a-97e9-2a441c6de776') - def test_discover_opportunistic_scan_result_off_secondary_scan_filter( - self): - """Test opportunistic scan result from secondary scan filter. - - Tests opportunistic scan where the filtered scan instance does not find - an advertisement and the scan instance with scan mode set to - opportunistic scan will also not find an advertisement. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 (make sure the - advertisement is not advertising the device name) - 2. Set scan settings to opportunistic scan on dut0 scan instance - 3. Start scan scan from step 2 - 4. Try to find an event, expect none - 5. Start a second scanner on dut0, with any other mode set and set the - scan filter device name to "opp_test" - 6. Pop onScanResults from the second scanner - 7. Expect no events - 8. Pop onScanResults from the first scanner - 9. Expect no events - - Expected Result: - Opportunistic scan instance finds an advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleBuildScanFilter(filter_list2) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - if not self._verify_no_events_found( - scan_result.format(scan_callback2)): - return False - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='13b0a83f-e96e-4d64-84ef-66351ec5054c') - def test_negative_opportunistic_scan_filter_result_off_secondary_scan_result( - self): - """Test opportunistic scan not found scenario. - - Tests opportunistic scan where the secondary scan instance does find an - advertisement but the scan instance with scan mode set to opportunistic - scan does not find an advertisement due to mismatched scan filters. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 (make sure the - advertisement is not advertising the device name) - 2. Set scan settings to opportunistic scan on dut0 scan instance and set - the scan filter device name to "opp_test" - 3. Start scan scan from step 2 - 4. Try to find an event, expect none - 5. Start a second scanner on dut0, with any other mode set - 6. Pop onScanResults from the second scanner - 7. Pop onScanResults from the first scanner - 8. Expect no events - - Expected Result: - Opportunistic scan instance doesn't find any advertisements. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self._setup_generic_advertisement() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - self.scn_ad.droid.bleSetScanFilterDeviceName("opp_test") - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - return self._verify_no_events_found(scan_result.format(scan_callback)) - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='087f60b2-f6a1-4919-b4c5-cdf3debcfeff') - def test_opportunistic_scan_filter_result_off_secondary_scan_result(self): - """Test opportunistic scan from a secondary scan result. - - Tests opportunistic scan where the scan filters are the same between the - first scan instance with opportunistic scan set and the second instance - with any other mode set. - - Steps: - 1. Initialize advertiser and start advertisement on dut1 - 2. On dut0, set the scan settings mode to opportunistic scan and set - the scan filter device name to the advertiser's device name - 3. Start scan scan from step 2 - 4. Try to find an event, expect none - 5. Start a second scanner on dut0, with any other mode set and set the - scan filter device name to the advertiser's device name - 6. Pop onScanResults from the second scanner - 7. Pop onScanResults from the first scanner - - Expected Result: - Opportunistic scan instance finds a advertisement. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Scanning, Opportunistic Scan - Priority: 1 - """ - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - self._setup_generic_advertisement() - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - self.active_scan_callback_list.append(scan_callback) - if not self._verify_no_events_found(scan_result.format(scan_callback)): - return False - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'low_latency']) - filter_list2, scan_settings2, scan_callback2 = ( - generate_ble_scan_objects(self.scn_ad.droid)) - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - self.scn_ad.droid.bleBuildScanFilter(filter_list2) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - self.active_scan_callback_list.append(scan_callback2) - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.default_timeout) - except Empty: - self.log.error("Opportunistic scan found no scan results.") - return False - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.default_timeout) - except Empty: - self.log.error("Non-Opportunistic scan found no scan results.") - return False - return True diff --git a/acts_tests/tests/google/ble/scan/BleScanScreenStateTest.py b/acts_tests/tests/google/ble/scan/BleScanScreenStateTest.py index 07ae898fbf..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/scan/BleScanScreenStateTest.py +++ b/acts_tests/tests/google/ble/scan/BleScanScreenStateTest.py @@ -1,559 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script exercises different scan filters with different screen states. -""" - -import concurrent -import json -import pprint -import time - -from queue import Empty -from acts import utils -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.bt_constants import adv_succ -from acts.test_utils.bt.bt_constants import ble_advertise_settings_modes -from acts.test_utils.bt.bt_constants import ble_scan_settings_modes -from acts.test_utils.bt.bt_constants import bt_default_timeout -from acts.test_utils.bt.bt_constants import scan_result -from acts.test_utils.bt.bt_test_utils import generate_ble_advertise_objects -from acts.test_utils.bt.bt_test_utils import generate_ble_scan_objects -from acts.test_utils.bt.bt_test_utils import reset_bluetooth - - -class BleScanScreenStateTest(BluetoothBaseTest): - advertise_callback = -1 - max_concurrent_scans = 27 - scan_callback = -1 - shorter_scan_timeout = 4 - - def setup_class(self): - super(BluetoothBaseTest, self).setup_class() - self.scn_ad = self.android_devices[0] - self.adv_ad = self.android_devices[1] - - utils.set_location_service(self.scn_ad, True) - utils.set_location_service(self.adv_ad, True) - return True - - def _setup_generic_advertisement(self): - self.adv_ad.droid.bleSetAdvertiseSettingsAdvertiseMode( - ble_advertise_settings_modes['low_latency']) - self.advertise_callback, advertise_data, advertise_settings = ( - generate_ble_advertise_objects(self.adv_ad.droid)) - self.adv_ad.droid.bleStartBleAdvertising( - self.advertise_callback, advertise_data, advertise_settings) - try: - self.adv_ad.ed.pop_event(adv_succ.format(self.advertise_callback)) - except Empty: - self.log.error("Failed to start advertisement.") - return False - return True - - def _setup_scan_with_no_filters(self): - filter_list, scan_settings, self.scan_callback = \ - generate_ble_scan_objects(self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - self.scan_callback) - - def _scan_found_results(self): - try: - self.scn_ad.ed.pop_event( - scan_result.format(self.scan_callback), bt_default_timeout) - self.log.info("Found an advertisement.") - except Empty: - self.log.info("Did not find an advertisement.") - return False - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='9b695819-e5a8-48b3-87a0-f90422998bf9') - def test_scan_no_filters_screen_on(self): - """Test LE scanning is successful with no filters and screen on. - - Test LE scanning is successful with no filters and screen on. Scan - results should be found. - - Steps: - 1. Setup advertisement - 2. Turn on screen - 3. Start scanner without filters - 4. Verify scan results are found - 5. Teardown advertisement and scanner - - Expected Result: - Scan results should be found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 2 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.wakeUpNow() - - # Step 3 - self._setup_scan_with_no_filters() - - # Step 4 - if not self._scan_found_results(): - return False - - # Step 5 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='38fb6959-f07b-4501-814b-81a498e3efc4') - def test_scan_no_filters_screen_off(self): - """Test LE scanning is successful with no filters and screen off. - - Test LE scanning is successful with no filters and screen off. No scan - results should be found. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner without filters - 4. Verify no scan results are found - 5. Teardown advertisement and scanner - - Expected Result: - No scan results should be found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 1 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - - # Step 3 - self._setup_scan_with_no_filters() - - # Step 4 - if self._scan_found_results(): - return False - - # Step 5 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7186ef2f-096a-462e-afde-b0e3d4ecdd83') - def test_scan_filters_works_with_screen_off(self): - """Test LE scanning is successful with filters and screen off. - - Test LE scanning is successful with no filters and screen off. No scan - results should be found. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner with filters - 4. Verify scan results are found - 5. Teardown advertisement and scanner - - Expected Result: - Scan results should be found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 1 - """ - # Step 1 - adv_device_name = self.adv_ad.droid.bluetoothGetLocalName() - print(adv_device_name) - self.adv_ad.droid.bleSetAdvertiseDataIncludeDeviceName(True) - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.goToSleepNow() - - # Step 3 - self.scn_ad.droid.bleSetScanFilterDeviceName(adv_device_name) - filter_list, scan_settings, self.scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleBuildScanFilter(filter_list) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - self.scan_callback) - - # Step 4 - if not self._scan_found_results(): - return False - - # Step 5 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='02cd6dca-149e-439b-8427-a2edc7864265') - def test_scan_no_filters_screen_off_then_turn_on(self): - """Test start LE scan with no filters while screen is off then turn on. - - Test that a scan without filters will not return results while the - screen is off but will return results when the screen turns on. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner without filters - 4. Verify no scan results are found - 5. Turn screen on - 6. Verify scan results are found - 7. Teardown advertisement and scanner - - Expected Result: - Scan results should only come in when the screen is on. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 2 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - - # Step 3 - self._setup_scan_with_no_filters() - - # Step 4 - if self._scan_found_results(): - return False - - # Step 5 - self.scn_ad.droid.wakeUpNow() - - # Step 6 - if not self._scan_found_results(): - return False - - # Step 7 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='eb9fc373-f5e8-4a55-9750-02b7a11893d1') - def test_scan_no_filters_screen_on_then_turn_off(self): - """Test start LE scan with no filters while screen is on then turn off. - - Test that a scan without filters will not return results while the - screen is off but will return results when the screen turns on. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner without filters - 4. Verify no scan results are found - 5. Turn screen on - 6. Verify scan results are found - 7. Teardown advertisement and scanner - - Expected Result: - Scan results should only come in when the screen is on. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 2 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.wakeUpNow() - - # Step 3 - self._setup_scan_with_no_filters() - - # Step 4 - if not self._scan_found_results(): - return False - - # Step 5 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - self.scn_ad.ed.clear_all_events() - - # Step 6 - if self._scan_found_results(): - return False - - # Step 7 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='41d90e11-b0a8-4eed-bff1-c19678920762') - def test_scan_no_filters_screen_toggling(self): - """Test start LE scan with no filters and test screen toggling. - - Test that a scan without filters will not return results while the - screen is off and return results while the screen is on. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner without filters - 4. Verify no scan results are found - 5. Turn screen on - 6. Verify scan results are found - 7. Repeat steps 1-6 10 times - 7. Teardown advertisement and scanner - - Expected Result: - Scan results should only come in when the screen is on. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 3 - """ - iterations = 10 - # Step 1 - if not self._setup_generic_advertisement(): - return False - - for i in range(iterations): - self.log.info("Starting iteration {}".format(i + 1)) - # Step 2 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - self.scn_ad.ed.clear_all_events() - - # Step 3 - self._setup_scan_with_no_filters() - - # Step 4 - if self._scan_found_results(): - return False - - # Step 5 - self.scn_ad.droid.wakeUpNow() - - # Step 6 - if not self._scan_found_results(): - return False - - # Step 7 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(self.scan_callback) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='7a2fe7ef-b15f-4e93-a2f0-40e2f7d9cbcb') - def test_opportunistic_scan_no_filters_screen_off_then_on(self): - """Test opportunistic scanning does not find results with screen off. - - Test LE scanning is successful with no filters and screen off. No scan - results should be found. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start opportunistic scan without filters - 4. Start scan without filters - 5. Verify no scan results are found on either scan instance - 6. Wake up phone - 7. Verify scan results on each scan instance - 8. Teardown advertisement and scanner - - Expected Result: - No scan results should be found. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 1 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - - # Step 3 - self.scn_ad.droid.bleSetScanSettingsScanMode(ble_scan_settings_modes[ - 'opportunistic']) - filter_list, scan_settings, scan_callback = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - - # Step 4 - filter_list2, scan_settings2, scan_callback2 = generate_ble_scan_objects( - self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list2, scan_settings2, - scan_callback2) - - # Step 5 - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.shorter_scan_timeout) - self.log.error("Found an advertisement on opportunistic scan.") - return False - except Empty: - self.log.info("Did not find an advertisement.") - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.shorter_scan_timeout) - self.log.error("Found an advertisement on scan instance.") - return False - except Empty: - self.log.info("Did not find an advertisement.") - - # Step 6 - self.scn_ad.droid.wakeUpNow() - - # Step 7 - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback), self.shorter_scan_timeout) - self.log.info("Found an advertisement on opportunistic scan.") - except Empty: - self.log.error( - "Did not find an advertisement on opportunistic scan.") - return False - try: - self.scn_ad.ed.pop_event( - scan_result.format(scan_callback2), self.shorter_scan_timeout) - self.log.info("Found an advertisement on scan instance.") - except Empty: - self.log.info("Did not find an advertisement.") - return False - - # Step 8 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - self.scn_ad.droid.bleStopBleScan(scan_callback) - self.scn_ad.droid.bleStopBleScan(scan_callback2) - return True - - @BluetoothBaseTest.bt_test_wrap - @test_tracker_info(uuid='406f1a2e-160f-4fb2-8a87-6403996df36e') - def test_max_scan_no_filters_screen_off_then_turn_on(self): - """Test start max scans with no filters while screen is off then turn on - - Test that max LE scan without filters will not return results while the - screen is off but will return results when the screen turns on. - - Steps: - 1. Setup advertisement - 2. Turn off screen - 3. Start scanner without filters and verify no scan results - 4. Turn screen on - 5. Verify scan results are found on each scan callback - 6. Teardown advertisement and all scanner - - Expected Result: - Scan results should only come in when the screen is on. - - Returns: - Pass if True - Fail if False - - TAGS: LE, Advertising, Filtering, Scanning, Screen - Priority: 2 - """ - # Step 1 - if not self._setup_generic_advertisement(): - return False - - # Step 2 - self.scn_ad.droid.goToSleepNow() - # Give the device time to go to sleep - time.sleep(2) - - # Step 3 - scan_callback_list = [] - for _ in range(self.max_concurrent_scans): - filter_list, scan_settings, scan_callback = \ - generate_ble_scan_objects(self.scn_ad.droid) - self.scn_ad.droid.bleStartBleScan(filter_list, scan_settings, - scan_callback) - scan_callback_list.append(scan_callback) - try: - self.scn_ad.ed.pop_event( - scan_result.format(self.scan_callback), - self.shorter_scan_timeout) - self.log.info("Found an advertisement.") - return False - except Empty: - self.log.info("Did not find an advertisement.") - - # Step 4 - self.scn_ad.droid.wakeUpNow() - - # Step 5 - for callback in scan_callback_list: - try: - self.scn_ad.ed.pop_event( - scan_result.format(callback), self.shorter_scan_timeout) - self.log.info("Found an advertisement.") - except Empty: - self.log.info("Did not find an advertisement.") - return False - - # Step 7 - self.adv_ad.droid.bleStopBleAdvertising(self.advertise_callback) - for callback in scan_callback_list: - self.scn_ad.droid.bleStopBleScan(callback) - return True diff --git a/acts_tests/tests/google/ble/system_tests/GattLongevityTest.py b/acts_tests/tests/google/ble/system_tests/GattLongevityTest.py index bb13646625..e69de29bb2 100644 --- a/acts_tests/tests/google/ble/system_tests/GattLongevityTest.py +++ b/acts_tests/tests/google/ble/system_tests/GattLongevityTest.py @@ -1,102 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -This test script for GATT longevity tests. -""" - -from acts.test_decorators import test_tracker_info -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest -from acts.test_utils.bt.GattConnectedBaseTest import GattConnectedBaseTest -from acts.test_utils.bt.bt_constants import gatt_characteristic -from acts.test_utils.bt.bt_constants import gatt_descriptor -from acts.test_utils.bt.bt_constants import gatt_event -from acts.test_utils.bt.bt_constants import gatt_cb_strings -from acts.test_utils.bt.bt_constants import gatt_connection_priority -from acts.test_utils.bt.bt_constants import gatt_characteristic_attr_length -from acts.test_utils.bt.GattEnum import MtuSize -from acts.test_utils.bt.bt_gatt_utils import setup_gatt_mtu - - -class GattLongevityTest(GattConnectedBaseTest): - longevity_iterations = 1100000 - - @test_tracker_info(uuid='d7d378f4-89d8-4330-bb80-0054b92020bb') - def test_write_characteristic_no_resp_longevity(self): - """Longevity test write characteristic value - - Longevity test to write characteristic value for - self.longevity_iteration times. This is to test the - integrity of written data and the robustness of central - and peripheral mode of the Android devices under test. - - 1. Central: write WRITABLE_CHAR_UUID characteristic with char_value - using write command. - 2. Central: make sure write callback is called. - 3. Peripheral: receive the written data. - 4. Verify data written matches data received. - 5. Repeat steps 1-4 self.longevity_iterations times. - - Expected Result: - Verify that write command is properly delivered. - - Returns: - Pass if True - Fail if False - - TAGS: LE, GATT, Characteristic, Longevity - Priority: 0 - """ - self.cen_ad.droid.gattClientRequestConnectionPriority( - self.bluetooth_gatt, gatt_connection_priority['high']) - - self.cen_ad.droid.gattClientCharacteristicSetWriteType( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, - gatt_characteristic['write_type_no_response']) - - for i in range(self.longevity_iterations): - self.log.debug("Iteration {} started.".format(i + 1)) - char_value = [] - for j in range(i, i + self.mtu - 3): - char_value.append(j % 256) - - self.cen_ad.droid.gattClientCharacteristicSetValue( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID, char_value) - - self.cen_ad.droid.gattClientWriteCharacteristic( - self.bluetooth_gatt, self.discovered_services_index, - self.test_service_index, self.WRITABLE_CHAR_UUID) - - # client shall not wait for server, get complete event right away - event = self._client_wait(gatt_event['char_write']) - if event["data"]["Status"] != 0: - self.log.error("Write status should be 0") - return False - - event = self._server_wait(gatt_event['char_write_req']) - - self.log.info("{} event found: {}".format(gatt_cb_strings[ - 'char_write_req'].format(self.gatt_server_callback), event[ - 'data']['value'])) - request_id = event['data']['requestId'] - found_value = event['data']['value'] - if found_value != char_value: - self.log.info("Values didn't match. Found: {}, " - "Expected: {}".format(found_value, char_value)) - return False - - return True diff --git a/acts_tests/tests/google/bt/sar/BleSarPowerLimitTest.py b/acts_tests/tests/google/bt/sar/BleSarPowerLimitTest.py index d732e7788e..490cb30cc0 100644 --- a/acts_tests/tests/google/bt/sar/BleSarPowerLimitTest.py +++ b/acts_tests/tests/google/bt/sar/BleSarPowerLimitTest.py @@ -46,6 +46,9 @@ class BleSarPowerLimitTest(BtSarBaseTest): #self.dut.droid.bluetoothFactoryReset() #bt_utils.enable_bluetooth(self.dut.droid, self.bt_device.ed) + #Reset SAR test result to 0 before every test + self.sar_test_result.metric_value = 0 + # To prevent default file from being overwritten self.dut.adb.shell('cp {} {}'.format(self.power_file_paths[0], self.power_file_paths[1])) diff --git a/acts_tests/tests/google/bt/sar/BtSarPowerLimitTest.py b/acts_tests/tests/google/bt/sar/BtSarPowerLimitTest.py index f4e667ce3a..74a1000231 100644 --- a/acts_tests/tests/google/bt/sar/BtSarPowerLimitTest.py +++ b/acts_tests/tests/google/bt/sar/BtSarPowerLimitTest.py @@ -18,8 +18,10 @@ import os import time import acts.test_utils.bt.bt_test_utils as bt_utils from acts.test_utils.bt.BtSarBaseTest import BtSarBaseTest +from acts.test_utils.power.PowerBTBaseTest import ramp_attenuation import acts.test_utils.wifi.wifi_performance_test_utils as wifi_utils +SLEEP_DURATION = 2 class BtSarPowerLimitTest(BtSarBaseTest): """Class to define BT SAR power cap tests. @@ -58,10 +60,15 @@ class BtSarPowerLimitTest(BtSarBaseTest): def test_bt_sar_custom_table(self): self.push_table(self.dut, self.custom_sar_path) + self.attenuator.set_atten(0) # Connect master and slave + self.bt_device.reset() + self.dut.droid.bluetoothFactoryReset() bt_utils.connect_phone_to_headset(self.dut, self.bt_device, 60) - + time.sleep(SLEEP_DURATION) + ramp_attenuation(self.attenuator, self.pl10_atten) + time.sleep(SLEEP_DURATION) sar_df = self.sweep_table() sar_df = self.process_table(sar_df) self.process_results(sar_df) diff --git a/acts_tests/tests/google/bt/sar/BtSarSanityTest.py b/acts_tests/tests/google/bt/sar/BtSarSanityTest.py index db12cad48b..4b386d27b1 100644 --- a/acts_tests/tests/google/bt/sar/BtSarSanityTest.py +++ b/acts_tests/tests/google/bt/sar/BtSarSanityTest.py @@ -19,6 +19,7 @@ import re import time from acts import asserts +import acts.test_utils.bt.bt_test_utils as bt_utils from acts.test_utils.bt.BtSarBaseTest import BtSarBaseTest @@ -28,6 +29,7 @@ class BtSarSanityTest(BtSarBaseTest): This class defines sanity test cases on BT SAR. The tests include a software state sanity check and a software power sanity check. """ + def setup_class(self): super().setup_class() @@ -47,6 +49,15 @@ class BtSarSanityTest(BtSarBaseTest): self.log.info('Regulatory files backed up') + def setup_test(self): + + #Reset SAR test result to 0 before every test + self.sar_test_result.metric_value = 0 + + # Starting BT on the master + self.dut.droid.bluetoothFactoryReset() + bt_utils.enable_bluetooth(self.dut.droid, self.dut.ed) + def teardown_class(self): for key in self.reg_domain_dict.keys(): reg_file_path = os.path.join( @@ -112,56 +123,8 @@ class BtSarSanityTest(BtSarBaseTest): the BT SAR file to the power cap read from logcat """ - sar_df = self.bt_sar_df - sar_df['BDR_power_cap'] = -128 - sar_df['EDR_power_cap'] = -128 - sar_df['BLE_power_cap'] = -128 - - if self.sar_version_2: - power_column_dict = { - 'BDR': 'BluetoothBDRPower', - 'EDR': 'BluetoothEDRPower', - 'BLE': 'BluetoothLEPower' - } - else: - power_column_dict = {'EDR': self.power_column} - - power_cap_error = False - - for type, column_name in power_column_dict.items(): + power_cap_error = self.sweep_power_cap() - self.log.info("Performing sanity test on {}".format(type)) - #Iterating through the BT SAR scenarios - for scenario in range(0, self.bt_sar_df.shape[0]): - - # Reading BT SAR table row into dict - read_scenario = sar_df.loc[scenario].to_dict() - start_time = self.dut.adb.shell('date +%s.%m') - time.sleep(1) - - #Setting SAR state to the read BT SAR row - self.set_sar_state(self.dut, read_scenario, self.country_code) - - #Reading device power cap from logcat after forcing SAR State - scenario_power_cap = self.get_current_power_cap(self.dut, - start_time, - type=type) - sar_df.loc[scenario, - '{}_power_cap'.format(type)] = scenario_power_cap - self.log.info('scenario: {}, ' - 'sar_power: {}, power_cap:{}'.format( - scenario, sar_df.loc[scenario, column_name], - sar_df.loc[scenario, - '{}_power_cap'.format(type)])) - - if not sar_df['{}_power_cap'.format(type)].equals(sar_df[column_name]): - power_cap_error = True - - results_file_path = os.path.join( - self.log_path, '{}.csv'.format(self.current_test_name)) - sar_df.to_csv(results_file_path) - - # Comparing read device power cap to expected device power cap if power_cap_error: asserts.fail("Power Caps didn't match powers in the SAR table") else: @@ -189,8 +152,7 @@ class BtSarSanityTest(BtSarBaseTest): set_regulatory_domain = self.get_country_code( self.dut, start_time) - if set_regulatory_domain != self.REG_DOMAIN_DICT[ - country_code_tuple]: + if set_regulatory_domain != self.REG_DOMAIN_DICT[country_code_tuple]: error_flag = 1 self.log.error( 'Country Code: {} set to regulatory domain: {}'.format( @@ -217,33 +179,43 @@ class BtSarSanityTest(BtSarBaseTest): regulatory domain files """ - reg_domain_error_flag = False + reg_domain_test_error_flag = True reg_file_phone_path = os.path.dirname(self.sar_file_path) #For different reg domain, sweep the sar table - for cc in self.REG_DOMAIN_DICT.values(): + for cc, reg_domain in self.REG_DOMAIN_DICT.items(): + self.country_code = cc[0] for file in self.custom_files: - if 'bluetooth_power_limits_{}.csv'.format(cc) in file: + if 'bluetooth_power_limits_{}.csv'.format(reg_domain) in file: custom_reg_file = file + reg_file_name = os.path.join( + reg_file_phone_path, + 'bluetooth_power_limits_{}.csv'.format(reg_domain)) break else: - self.log.error('Regulatory file for {} missing'.format(cc.upper())) + self.log.error( + 'Regulatory file for {} missing'.format(reg_domain)) - reg_file_name = os.path.join(reg_file_phone_path, custom_reg_file) self.push_table(self.dut, custom_reg_file, reg_file_name) - self.set_country_code(self.dut, cc.lower()) - self.bt_sar_df = self.read_sar_table(self.dut) + start_time = self.dut.adb.shell('date +%s.%m') + self.set_country_code(self.dut, cc[0]) + # Read regulatory code from logcat + read_reg_domain = self.get_country_code(self.dut, start_time) + self.log.info( + 'Regulatory domain set to {}'.format(read_reg_domain)) + self.bt_sar_df = self.read_sar_table(self.dut, custom_reg_file) + + reg_domain_error_flag = self.sweep_power_cap() - sar_df = self.sweep_table() - if (sar_df[self.power_column] == self.bt_sar_df[self.power_column] - ).bool: + if not reg_domain_error_flag: self.log.info( - 'Regulatory Domain Sanity Test for {} passed'.format(cc)) - else: - reg_domain_error_flag = True + 'Regulatory Domain Sanity Test for {} passed'.format( + reg_domain)) + + reg_domain_test_error_flag &= reg_domain_error_flag - if reg_domain_error_flag: + if reg_domain_test_error_flag: asserts.fail('Regulatory domain sanity tests failed') else: self.sar_test_result.metric_value = 1 diff --git a/acts_tests/tests/google/bt/sar/BtSarTpcTest.py b/acts_tests/tests/google/bt/sar/BtSarTpcTest.py index 2162683600..cf29d68180 100644 --- a/acts_tests/tests/google/bt/sar/BtSarTpcTest.py +++ b/acts_tests/tests/google/bt/sar/BtSarTpcTest.py @@ -42,11 +42,9 @@ class BtSarTpcTest(BtSarBaseTest): def setup_class(self): super().setup_class() - self.sar_tpc_test_result = 0 self.push_table(self.dut, self.custom_sar_path) self.attenuator.set_atten(self.atten_min) self.pathloss = int(self.calibration_params['pathloss']) - self.sar_df = self.bt_sar_df.copy() self.sar_df['power_cap'] = -128 self.sar_df['TPC_result'] = -1 @@ -56,6 +54,7 @@ class BtSarTpcTest(BtSarBaseTest): self.tpc_sweep_range = range(self.atten_min, self.pl10_atten) self.log.info(self.current_test_name) + self.tpc_plots_figure = wifi_utils.BokehFigure( title='{}_{}'.format(self.current_test_name, 'curve'), x_label='Pathloss(dBm)', @@ -99,33 +98,37 @@ class BtSarTpcTest(BtSarBaseTest): """ tpc_verdict = 'FAIL' + tx_power_derivative = np.diff(tx_power_list) + + #Remove the PL transition points when checking pass/fail + pwlv_list_int = [item % 1 for item in pwlv_list] + pwlv_steady_index = [ + idx for idx, val in enumerate(pwlv_list_int) if val == 0 + ] + pwlv_steady_state_list = [ + pwlv_list[index] for index in pwlv_steady_index + ] + tx_power_steady_state_list = [ + tx_power_list[index] for index in pwlv_steady_index + ] + tx_power_steady_state_derivative = np.diff(tx_power_steady_state_list) + + #Report issue if the transition period is too long + transition_points_count = len( + [i for i in list(np.diff(pwlv_steady_index)) if i > 3]) + if transition_points_count > 0: + self.log.warning('TPC transition takes too long') + return [tpc_verdict, tx_power_derivative] # Locating power level changes in the sweep - pwlv_derivative_bool = list( - np.diff([pwlv_list[0]] + np.rint(pwlv_list)) == 1) - - # Diff-ing the list to get derivative of the list - tx_power_derivative = np.diff([tx_power_list[0]] + tx_power_list) - - # Checking for negative peaks - negative_peaks = tx_power_derivative[np.where( - tx_power_derivative < self.tpc_threshold['negative'])] - for negative_peak in negative_peaks: - dip_index = list(tx_power_derivative).index(negative_peak) - # Compensating for TPC algo quirk - if (pwlv_list[dip_index - 2] - == 8.0) & (pwlv_list[dip_index - 1] > - 8.0) & (pwlv_list[dip_index] == 8.0): - pass - else: - return [tpc_verdict, tx_power_derivative] + pwlv_derivative_bool = list(np.diff(pwlv_steady_state_list) == 1) # Locating legitimate tx power changes tx_power_derivative_bool = [ self.tpc_threshold['positive'][0] < x < - self.tpc_threshold['positive'][1] for x in tx_power_derivative + self.tpc_threshold['positive'][1] + for x in tx_power_steady_state_derivative ] - # Ensuring that changes in power level correspond to tx power changes if pwlv_derivative_bool == tx_power_derivative_bool: tpc_verdict = 'PASS' @@ -177,12 +180,12 @@ class BtSarTpcTest(BtSarBaseTest): ] = self.process_tpc_results(master_tx_power_list, pwlv_list) # Plot TPC curves - self.tpc_plots_figure.add_line(self.tpc_sweep_range, + self.tpc_plots_figure.add_line(self.tpc_sweep_range[:-1], master_tx_power_list, str(scenario), marker='circle') - self.tpc_plots_derivative_figure.add_line(self.tpc_sweep_range, + self.tpc_plots_derivative_figure.add_line(self.tpc_sweep_range[:-1], tx_power_derivative, str(scenario), marker='circle') @@ -202,6 +205,6 @@ class BtSarTpcTest(BtSarBaseTest): asserts.fail('TPC sweep failed for scenario: {}'.format(scenario)) else: - self.sar_tpc_test_result.metric_value += 1 + self.sar_test_result.metric_value = 1 asserts.explicit_pass( 'TPC sweep passed for scenario: {}'.format(scenario)) diff --git a/acts_tests/tests/google/fuchsia/ram/RamTest.py b/acts_tests/tests/google/fuchsia/ram/RamTest.py new file mode 100644 index 0000000000..b9bd75cc49 --- /dev/null +++ b/acts_tests/tests/google/fuchsia/ram/RamTest.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2020 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +import os +import time +import uuid + +from acts import asserts, signals +from acts.base_test import BaseTestClass +from acts.libs.proc.job import Error +from acts.test_utils.tel.tel_test_utils import setup_droid_properties + +# Some number bigger than the minimum 512k: +MEMORY_CYCLES_TO_MEASURE = 1024 * 1024 +# Taken from the commandline tool. +#TODO(48254): Convert driver to fill in these values automatically. +MEMORY_CHANNELS = [1, 2, 0x600110, 0x1F0000, 0, 0, 0, 0] + + +class RamTest(BaseTestClass): + def setup_class(self): + super().setup_class() + self.fd = self.fuchsia_devices[0] + + def test_bandwidth(self): + """Test MeasureBandwidth FIDL calls. + + There should be no noticable effect. This test will only run + if the device config has a 'ram_tests' entry. + """ + asserts.skip_if('ram_tests' not in self.user_params, + 'ram_tests not specified in the config') + + result = self.fd.ram_lib.measureBandwidth(MEMORY_CYCLES_TO_MEASURE, + MEMORY_CHANNELS) + asserts.assert_true( + result['error'] is None, + "MeasureBandwidth failed with: {}".format(result['error'])) + + def test_get_ddr_results(self): + """Test GetDdrWindowingResults FIDL calls. + + There should be no noticable effect. This test will only run + if the device config has a 'ram_tests' entry. + """ + asserts.skip_if('ram_tests' not in self.user_params, + 'ram_tests not specified in the config') + + result = self.fd.ram_lib.getDdrWindowingResults() + asserts.assert_true( + result['error'] is None, + "GetDdrWindowingResults failed with: {}".format(result['error'])) diff --git a/acts_tests/tests/google/fuchsia/wlan/PingStressTest.py b/acts_tests/tests/google/fuchsia/wlan/PingStressTest.py index a810d9a740..8577f49e03 100644 --- a/acts_tests/tests/google/fuchsia/wlan/PingStressTest.py +++ b/acts_tests/tests/google/fuchsia/wlan/PingStressTest.py @@ -68,8 +68,8 @@ class PingStressTest(BaseTestClass): interval=1000, timeout=1000, size=25): - ping_result = self.wlan_device.ping(dest_ip, count, interval, timeout, - size) + ping_result = self.wlan_device.can_ping(dest_ip, count, interval, + timeout, size) if ping_result: self.log.info('Ping was successful.') else: @@ -81,7 +81,7 @@ class PingStressTest(BaseTestClass): return True def ping_thread(self, dest_ip): - ping_result = self.wlan_device.ping(dest_ip, count=10, size=50) + ping_result = self.wlan_device.can_ping(dest_ip, count=10, size=50) if ping_result: self.log.info('Success pinging: %s' % dest_ip) else: diff --git a/acts_tests/tests/google/fuchsia/wlan/SoftApTest.py b/acts_tests/tests/google/fuchsia/wlan/SoftApTest.py index ffd9fc46a2..76ed0d252f 100644 --- a/acts_tests/tests/google/fuchsia/wlan/SoftApTest.py +++ b/acts_tests/tests/google/fuchsia/wlan/SoftApTest.py @@ -16,6 +16,7 @@ from mobly import signals import multiprocessing as mp +import random import time from acts import utils @@ -27,13 +28,17 @@ from acts.controllers.ap_lib import hostapd_constants from acts.controllers.ap_lib import hostapd_security from acts.test_utils.abstract_devices.utils_lib import wlan_utils from acts.test_utils.abstract_devices.wlan_device import create_wlan_device -from acts.test_utils.abstract_devices.utils_lib.wlan_utils import setup_ap_and_associate -from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest +from acts.test_utils.abstract_devices.utils_lib.wlan_utils import setup_ap -ANDROID_DEFAULT_WLAN_PORT = 'wlan0' +ANDROID_DEFAULT_WLAN_INTERFACE = 'wlan0' CONNECTIVITY_MODE_LOCAL = 'local_only' CONNECTIVITY_MODE_UNRESTRICTED = 'unrestricted' +DEFAULT_AP_PROFILE = 'whirlwind' DEFAULT_IPERF_PORT = 5201 +DEFAULT_STRESS_TEST_ITERATIONS = 10 +DEFAULT_TIMEOUT = 30 +DEFAULT_IPERF_TIMEOUT = 60 +DEFAULT_NO_ADDR_EXPECTED_TIMEOUT = 5 INTERFACE_ROLE_AP = 'Ap' INTERFACE_ROLE_CLIENT = 'Client' INTERFACE_ROLES = {INTERFACE_ROLE_AP, INTERFACE_ROLE_CLIENT} @@ -45,6 +50,8 @@ SECURITY_WEP = 'wep' SECURITY_WPA = 'wpa' SECURITY_WPA2 = 'wpa2' SECURITY_WPA3 = 'wpa3' +STATE_UP = True +STATE_DOWN = False TEST_TYPE_ASSOCIATE_ONLY = 'associate_only' TEST_TYPE_ASSOCIATE_AND_PING = 'associate_and_ping' TEST_TYPE_ASSOCIATE_AND_PASS_TRAFFIC = 'associate_and_pass_traffic' @@ -54,18 +61,69 @@ TEST_TYPES = { } -def generate_test_name(settings): - """Generates a string test name based on the channel and band. +def get_test_name_from_settings(settings): + return settings['test_name'] + + +def get_ap_params_from_config_or_default(config): + """Retrieves AP parameters from ACTS config, or returns default settings. + + Args: + config: dict, from ACTS config, that may contain custom ap parameters + + Returns: + dict, containing all AP parameters + """ + profile = config.get('profile', DEFAULT_AP_PROFILE) + ssid = config.get( + 'ssid', utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)) + channel = config.get('channel', hostapd_constants.AP_DEFAULT_CHANNEL_2G) + security_mode = config.get('security_mode', None) + password = config.get('password', None) + if security_mode: + security = hostapd_security.Security(security_mode, password) + else: + security = None + + return { + 'profile': profile, + 'ssid': ssid, + 'channel': channel, + 'security': security, + 'password': password + } + + +def get_soft_ap_params_from_config_or_default(config): + """Retrieves SoftAp parameters from ACTS config or returns default settings. Args: - settings A dict with the soft ap config parameteres. + config: dict, from ACTS config, that may contain custom soft ap + parameters Returns: - A string test case name. + dict, containing all soft AP parameters """ - return 'test_soft_ap_band_%s_security_%s_mode_%s_loops_%s' % ( - settings['operating_band'], settings['security_type'], - settings['connectivity_mode'], settings['reconnect_loops']) + ssid = config.get( + 'ssid', utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)) + connectivity_mode = config.get('connectivity_mode', + CONNECTIVITY_MODE_LOCAL) + operating_band = config.get('operating_band', OPERATING_BAND_2G) + security_type = config.get('security_type', SECURITY_OPEN) + password = config.get('password', '') + + return { + 'ssid': ssid, + 'connectivity_mode': connectivity_mode, + 'operating_band': operating_band, + 'security_type': security_type, + 'password': password + } + + +class StressTestIterationFailure(Exception): + """Used to differentiate a subtest failure from an actual exception""" + pass class SoftApClient(object): @@ -85,10 +143,18 @@ class SoftApTest(BaseTestClass): """Tests for Fuchsia SoftAP Testbed requirement: - * One Fuchsia Device - * One Client (Android) Device + * One Fuchsia device + * At least one dlient (Android) device + * For multi-client tests, at least two dlient (Android) devices are + required. Test will be skipped if less than two client devices are + present. + * For any tests that exercise client-mode (e.g. toggle tests, simultaneous + tests), a physical AP (whirlwind) is also required. Those tests will be + skipped if physical AP is not present. """ def setup_class(self): + self.soft_ap_test_params = self.user_params.get( + 'soft_ap_test_params', {}) self.dut = create_wlan_device(self.fuchsia_devices[0]) self.dut.device.netstack_lib.init() @@ -112,9 +178,11 @@ class SoftApTest(BaseTestClass): except AttributeError: self.access_point = None + self.ap_iperf_client = iperf_client.IPerfClientOverSsh( + self.user_params['AccessPoint'][0]['ssh_config']) + def teardown_class(self): - # Because this is using killall, it will stop all iperf processes, - # making it a great teardown cleanup + # Because this is using killall, it will stop all iperf processes self.iperf_server.stop() def setup_test(self): @@ -125,7 +193,7 @@ class SoftApTest(BaseTestClass): client.w_device.disconnect() client.w_device.reset_wifi() client.w_device.wifi_toggle_state(True) - self.dut.device.wlan_ap_policy_lib.wlanStopAllAccessPoint() + self.stop_all_soft_aps() if self.access_point: self.access_point.stop_all_aps() self.dut.disconnect() @@ -136,7 +204,7 @@ class SoftApTest(BaseTestClass): for ad in self.android_devices: ad.droid.wakeLockRelease() ad.droid.goToSleepNow() - self.dut.device.wlan_ap_policy_lib.wlanStopAllAccessPoint() + self.stop_all_soft_aps() if self.access_point: self.access_point.stop_all_aps() self.dut.disconnect() @@ -165,17 +233,48 @@ class SoftApTest(BaseTestClass): connectivity_mode = settings['connectivity_mode'] operating_band = settings['operating_band'] - self.log.info('Attempting to start SoftAP on DUT with settings: %s' % - settings) + self.log.info('Starting SoftAP on DUT with settings: %s' % settings) response = self.dut.device.wlan_ap_policy_lib.wlanStartAccessPoint( ssid, security_type, password, connectivity_mode, operating_band) if response.get('error'): - raise EnvironmentError('Failed to setup SoftAP. Err: %s' % + raise EnvironmentError('SL4F: Failed to setup SoftAP. Err: %s' % response['error']) self.log.info('SoftAp network (%s) is up.' % ssid) + def stop_soft_ap(self, settings): + """ Stops a specific SoftAP On Fuchsia device. + + Args: + settings: a dict containing softAP config params (see start_soft_ap) + for details + + Raises: + EnvironmentError, if StopSoftAP call fails. + """ + ssid = settings['ssid'] + security_type = settings['security_type'] + password = settings.get('password', '') + + response = self.dut.device.wlan_ap_policy_lib.wlanStopAccessPoint( + ssid, security_type, password) + if response.get('error'): + raise EnvironmentError('SL4F: Failed to stop SoftAP. Err: %s' % + response['error']) + + def stop_all_soft_aps(self): + """ Stops all SoftAPs on Fuchsia Device. + + Raises: + EnvironmentError, if StopAllAps call fails. + """ + response = self.dut.device.wlan_ap_policy_lib.wlanStopAllAccessPoint() + if response.get('error'): + raise EnvironmentError( + 'SL4F: Failed to stop all SoftAPs. Err: %s' % + response['error']) + def associate_with_soft_ap(self, w_device, settings): """Associates client device with softAP on Fuchsia device. @@ -200,9 +299,11 @@ class SoftApTest(BaseTestClass): check_connectivity=check_connectivity) if not associated: - asserts.fail('Failed to connect to SoftAP.') + self.log.error('Failed to connect to SoftAp.') + return False self.log.info('Client successfully associated with SoftAP.') + return True def disconnect_from_soft_ap(self, w_device): """Disconnects client device from SoftAP. @@ -214,7 +315,9 @@ class SoftApTest(BaseTestClass): w_device.device.serial) w_device.disconnect() - def get_dut_interface_by_role(self, role): + def get_dut_interface_by_role(self, + role, + wait_for_addr_timeout=DEFAULT_TIMEOUT): """Retrieves interface information from the FuchsiaDevice DUT based on the role. @@ -231,7 +334,6 @@ class SoftApTest(BaseTestClass): if not role in INTERFACE_ROLES: raise ValueError('Unsupported interface role %s' % role) - self.log.info('Getting %s interface info from DUT.' % role) interface = WlanInterface() # Determine WLAN interface with role @@ -251,7 +353,7 @@ class SoftApTest(BaseTestClass): interface.mac_addr = iface_info['result']['mac_addr'] break else: - raise AttributeError('Failed to find a %s interface.' % role) + raise LookupError('Failed to find a %s interface.' % role) # Retrieve interface info from netstack netstack_ifaces = self.dut.device.netstack_lib.netstackListInterfaces() @@ -270,12 +372,17 @@ class SoftApTest(BaseTestClass): for byte in netstack_iface['ipv4_addresses'][0]) else: interface.ipv4 = self.wait_for_ipv4_address( - self.dut, interface.name) + self.dut, + interface.name, + timeout=wait_for_addr_timeout) self.log.info('DUT %s interface: %s. Has ipv4 address %s' % (role, interface.name, interface.ipv4)) return interface - def wait_for_ipv4_address(self, w_device, interface_name, timeout=10): + def wait_for_ipv4_address(self, + w_device, + interface_name, + timeout=DEFAULT_TIMEOUT): # TODO(fxb/51315): Once subnet information is available in netstack, add a # subnet verification here. """ Waits for interface on a wlan_device to get an ipv4 address. @@ -288,10 +395,6 @@ class SoftApTest(BaseTestClass): Raises: ValueError, if interface does not have an ipv4 address after timeout """ - self.log.info( - 'Checking if device %s interface %s has an ipv4 address. ' - 'Will retrying for %s seconds.' % - (w_device.device.serial, interface_name, timeout)) end_time = time.time() + timeout while time.time() < end_time: @@ -303,12 +406,39 @@ class SoftApTest(BaseTestClass): return ips['ipv4_private'][0] else: time.sleep(1) - raise ValueError( - 'After %s seconds, device %s still doesn not have an ipv4 address ' + raise ConnectionError( + 'After %s seconds, device %s still does not have an ipv4 address ' 'on interface %s.' % (timeout, w_device.device.serial, interface_name)) - def verify_ping(self, w_device, dest_ip): + def get_ap_ipv4_address(self, channel, timeout=DEFAULT_TIMEOUT): + """Get APs ipv4 address (actual AP, not soft ap on DUT) + + Args: + channel: int, channel of the network used to determine + which interface to use + """ + lowest_5ghz_channel = 36 + if channel < lowest_5ghz_channel: + ap_interface = self.access_point.wlan_2g + else: + ap_interface = self.access_point.wlan_5g + end_time = time.time() + timeout + while time.time() < end_time: + ap_ipv4_addresses = utils.get_interface_ip_addresses( + self.access_point.ssh, ap_interface)['ipv4_private'] + if len(ap_ipv4_addresses) > 0: + return ap_ipv4_addresses[0] + else: + self.log.debug( + 'Access point does not have an ipv4 address on interface ' + '%s. Retrying in 1 second.' % ap_interface) + else: + raise ConnectionError( + 'Access point never had an ipv4 address on interface %s.' % + ap_interface) + + def device_can_ping_addr(self, w_device, dest_ip, timeout=DEFAULT_TIMEOUT): """ Verify wlan_device can ping a destination ip. Args: @@ -318,12 +448,24 @@ class SoftApTest(BaseTestClass): Raises: TestFailure, if ping fails """ - self.log.info('Attempting to ping from device %s to dest ip %s' % - (w_device.device.serial, dest_ip)) - if not w_device.ping(dest_ip): - asserts.fail('Device %s could not ping dest ip %s' % - (w_device.device.serial, dest_ip)) - self.log.info('Ping successful.') + end_time = time.time() + timeout + while time.time() < end_time: + with utils.SuppressLogOutput(): + ping_result = w_device.can_ping(dest_ip) + + if ping_result: + self.log.info('Ping successful from device %s to dest ip %s.' % + (w_device.identifier, dest_ip)) + return True + else: + self.log.debug( + 'Device %s could not ping dest ip %s. Retrying in 1 second.' + % (w_device.identifier, dest_ip)) + time.sleep(1) + else: + self.log.info('Failed to ping from device %s to dest ip %s.' % + (w_device.identifier, dest_ip)) + return False def run_iperf_traffic(self, ip_client, server_address, server_port=5201): """Runs traffic between client and ap an verifies throughput. @@ -337,6 +479,7 @@ class SoftApTest(BaseTestClass): TestFailure, if no traffic passes in either direction """ ip_client_identifier = self.get_iperf_client_identifier(ip_client) + self.log.info( 'Running traffic from iperf client %s to iperf server %s.' % (ip_client_identifier, server_address)) @@ -344,19 +487,9 @@ class SoftApTest(BaseTestClass): server_address, '-i 1 -t 10 -J -p %s' % server_port, 'client_to_soft_ap') - self.log.info( - 'Running traffic from iperf server %s to iperf client %s.' % - (server_address, ip_client_identifier)) - ap_to_client_path = ip_client.start( - server_address, '-i 1 -t 10 -R -J -p %s' % server_port, - 'soft_ap_to_client') - self.log.info('Getting iperf results') - client_to_ap_result = iperf_server.IPerfResult(client_to_ap_path) - ap_to_client_result = iperf_server.IPerfResult(ap_to_client_path) - if (not client_to_ap_result.avg_receive_rate): - asserts.fail( + raise ConnectionError( 'Failed to pass traffic from iperf client %s to iperf server %s.' % (ip_client_identifier, server_address)) @@ -365,8 +498,16 @@ class SoftApTest(BaseTestClass): 'rate of %s MB/s.' % (ip_client_identifier, server_address, client_to_ap_result.avg_receive_rate)) + self.log.info( + 'Running traffic from iperf server %s to iperf client %s.' % + (server_address, ip_client_identifier)) + ap_to_client_path = ip_client.start( + server_address, '-i 1 -t 10 -R -J -p %s' % server_port, + 'soft_ap_to_client') + + ap_to_client_result = iperf_server.IPerfResult(ap_to_client_path) if (not ap_to_client_result.avg_receive_rate): - asserts.fail( + raise ConnectionError( 'Failed to pass traffic from iperf server %s to iperf client %s.' % (server_address, ip_client_identifier)) @@ -393,7 +534,7 @@ class SoftApTest(BaseTestClass): self.run_iperf_traffic(ip_client, server_address, server_port=server_port) - except Exception as err: + except ConnectionError as err: error_queue.put('In iperf process from %s to %s: %s' % (self.get_iperf_client_identifier(ip_client), server_address, err)) @@ -408,508 +549,1026 @@ class SoftApTest(BaseTestClass): return ip_client._android_device_or_serial return ip_client._ssh_settings.hostname - def run_config_stress_test(self, settings): - """Runs test based on config parameters. + def dut_is_connected_as_client(self, + channel, + check_traffic=False, + wait_for_addr_timeout=DEFAULT_TIMEOUT): + """Checks if DUT is successfully connected to AP. + + Args: + channel: int, channel of the AP network (to retrieve interfaces) + check_traffic: bool, if true, verifies traffic between DUT and AP, + else just checks ping. + wait_for_addr_timeout: int, time, in seconds, to wait when getting + DUT and AP addresses + + Returns: + True, if connected correctly + False, otherwise + """ + try: + dut_client_interface = self.get_dut_interface_by_role( + INTERFACE_ROLE_CLIENT, + wait_for_addr_timeout=wait_for_addr_timeout) + ap_ipv4 = self.get_ap_ipv4_address(channel, + timeout=wait_for_addr_timeout) + except ConnectionError as err: + self.log.error( + 'Failed to retrieve interfaces and addresses. Err: %s' % err) + return False + + if not self.device_can_ping_addr(self.dut, ap_ipv4): + self.log.error('Failed to ping from DUT to AP.') + return False + + if not self.device_can_ping_addr(self.access_point, + dut_client_interface.ipv4): + self.log.error('Failed to ping from AP to DUT.') + return False + + if check_traffic: + try: + self.run_iperf_traffic(self.ap_iperf_client, + dut_client_interface.ipv4) + except ConnectionError as err: + self.log.error('Failed to run traffic between DUT and AP.') + return False + return True + + def client_is_connected_to_soft_ap( + self, + client, + client_interface=ANDROID_DEFAULT_WLAN_INTERFACE, + check_traffic=False, + wait_for_addr_timeout=DEFAULT_TIMEOUT): + """Checks if client is successfully connected to DUT SoftAP. + + Args: + client: SoftApClient to check + client_interface: string, wlan interface name of client + check_traffic: bool, if true, verifies traffic between client and + DUT, else just checks ping. + wait_for_addr_timeout: int, time, in seconds, to wait when getting + DUT and client addresses + + Returns: + True, if connected correctly + False, otherwise + """ + + try: + dut_ap_interface = self.get_dut_interface_by_role( + INTERFACE_ROLE_AP, wait_for_addr_timeout=wait_for_addr_timeout) + client_ipv4 = self.wait_for_ipv4_address( + client.w_device, + client_interface, + timeout=wait_for_addr_timeout) + except ConnectionError as err: + self.log.error( + 'Failed to retrieve interfaces and addresses. Err: %s' % err) + return False + + if not self.device_can_ping_addr(self.dut, client_ipv4): + self.log.error('Failed to ping client (%s) from DUT.' % + client_ipv4) + return False + if not self.device_can_ping_addr(client.w_device, + dut_ap_interface.ipv4): + self.log.error('Failed to ping DUT from client (%s)' % client_ipv4) + return False + + if check_traffic: + try: + self.run_iperf_traffic(client.ip_client, dut_ap_interface.ipv4) + except ConnectionError as err: + self.log.error( + 'Failed to pass traffic between client (%s) and DUT.' % + client_ipv4) + return False + return True + + def verify_soft_ap_connectivity_from_state(self, state, client): + """Verifies SoftAP state based on a client connection. + + Args: + state: bool, whether SoftAP should be up + client: SoftApClient, to verify connectivity (or lack therof) + """ + if state == STATE_UP: + return self.client_is_connected_to_soft_ap(client) + else: + with utils.SuppressLogOutput(): + return not self.client_is_connected_to_soft_ap( + client, + wait_for_addr_timeout=DEFAULT_NO_ADDR_EXPECTED_TIMEOUT) + + def verify_client_mode_connectivity_from_state(self, state, channel): + """Verifies client mode state based on DUT-AP connection. + + Args: + state: bool, whether client mode should be up + channel: int, channel of the APs network + """ + if state == STATE_UP: + return self.dut_is_connected_as_client(channel) + else: + with utils.SuppressLogOutput(): + return not self.dut_is_connected_as_client( + channel, + wait_for_addr_timeout=DEFAULT_NO_ADDR_EXPECTED_TIMEOUT) + +# Test Types + + def verify_soft_ap_associate_only(self, client, settings): + if not self.associate_with_soft_ap(client.w_device, settings): + asserts.fail('Failed to associate client with SoftAP.') + + def verify_soft_ap_associate_and_ping(self, client, settings): + self.verify_soft_ap_associate_only(client, settings) + if not self.client_is_connected_to_soft_ap(client): + asserts.fail('Client and SoftAP could not ping eachother.') + + def verify_soft_ap_associate_and_pass_traffic(self, client, settings): + self.verify_soft_ap_associate_only(client, settings) + if not self.client_is_connected_to_soft_ap(client, check_traffic=True): + asserts.fail( + 'Client and SoftAP not responding to pings and passing traffic ' + 'as expected.') + +# Runners for Generated Test Cases + + def run_soft_ap_association_stress_test(self, settings): + """Sets up a SoftAP, and repeatedly associates and disassociates a + client. Args: settings: test configuration settings, see - test_soft_ap_stress_from_config for details + test_soft_ap_association_stress for details """ client = settings['client'] + soft_ap_params = settings['soft_ap_params'] test_type = settings['test_type'] if not test_type in TEST_TYPES: raise ValueError('Unrecognized test type %s' % test_type) - reconnect_loops = settings['reconnect_loops'] - self.log.info('Running test type %s in loop %s times' % - (test_type, reconnect_loops)) + iterations = settings['iterations'] + self.log.info( + 'Running association stress test type %s in iteration %s times' % + (test_type, iterations)) - self.start_soft_ap(settings) + self.start_soft_ap(soft_ap_params) passed_count = 0 - for run in range(reconnect_loops): + for run in range(iterations): try: - # Associate with SoftAp - self.log.info('Starting SoftApTest run %s' % str(run + 1)) - self.associate_with_soft_ap(client.w_device, settings) - - if test_type != TEST_TYPE_ASSOCIATE_ONLY: - # Verify client and SoftAP can ping - dut_ap_interface = self.get_dut_interface_by_role( - INTERFACE_ROLE_AP) - client_ipv4 = self.wait_for_ipv4_address( - client.w_device, ANDROID_DEFAULT_WLAN_PORT) - self.verify_ping(client.w_device, dut_ap_interface.ipv4) - self.verify_ping(self.dut, client_ipv4) - - if test_type != TEST_TYPE_ASSOCIATE_AND_PING: - # Run traffic between client and SoftAp - self.run_iperf_traffic(client.ip_client, - dut_ap_interface.ipv4) - # Disconnect - self.disconnect_from_soft_ap(client.w_device) + self.log.info('Starting SoftAp association run %s' % + str(run + 1)) + + if test_type == TEST_TYPE_ASSOCIATE_ONLY: + self.verify_soft_ap_associate_only(client, soft_ap_params) + + elif test_type == TEST_TYPE_ASSOCIATE_AND_PING: + self.verify_soft_ap_associate_and_ping( + client, soft_ap_params) + + elif test_type == TEST_TYPE_ASSOCIATE_AND_PASS_TRAFFIC: + self.verify_soft_ap_associate_and_pass_traffic( + client, soft_ap_params) + + else: + raise AttributeError('Invalid test type: %s' % test_type) except signals.TestFailure as err: - self.log.error('SoftApTest run %s failed. Err: %s' % - (str(run + 1), err.details)) + self.log.error( + 'SoftAp association stress run %s failed. Err: %s' % + (str(run + 1), err.details)) else: - self.log.info('SoftApTest run %s successful.' % run) + self.log.info('SoftAp association stress run %s successful.' % + str(run + 1)) passed_count += 1 - if passed_count < reconnect_loops: - asserts.fail('SoftAp reconnect test passed on %s/%s runs.' % - (passed_count, reconnect_loops)) + if passed_count < iterations: + asserts.fail( + 'SoftAp association stress test passed on %s/%s runs.' % + (passed_count, iterations)) - asserts.explicit_pass('SoftAp reconnect test passed on %s/%s runs.' % - (passed_count, reconnect_loops)) + asserts.explicit_pass( + 'SoftAp association stress test passed on %s/%s runs.' % + (passed_count, iterations)) - # Test helper functions - def verify_soft_ap_associate_only(self, client, settings): - self.start_soft_ap(settings) - self.associate_with_soft_ap(client.w_device, settings) +# Alternate SoftAP and Client mode test - def verify_soft_ap_associate_and_ping(self, client, settings): - self.start_soft_ap(settings) - self.associate_with_soft_ap(client.w_device, settings) - dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) - client_ipv4 = self.wait_for_ipv4_address(self.primary_client.w_device, - ANDROID_DEFAULT_WLAN_PORT) - self.verify_ping(client.w_device, dut_ap_interface.ipv4) - self.verify_ping(self.dut, client_ipv4) + def run_soft_ap_and_client_mode_alternating_test(self, settings): + """Runs a single soft_ap and client alternating stress test. - def verify_soft_ap_associate_and_pass_traffic(self, client, settings): - self.start_soft_ap(settings) - self.associate_with_soft_ap(client.w_device, settings) - dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) - client_ipv4 = self.wait_for_ipv4_address(self.primary_client.w_device, - ANDROID_DEFAULT_WLAN_PORT) - self.verify_ping(client.w_device, dut_ap_interface.ipv4) - self.verify_ping(self.dut, client_ipv4) - self.run_iperf_traffic(client.ip_client, dut_ap_interface.ipv4) + See test_soft_ap_and_client_mode_alternating_stress for details. + """ + iterations = settings['iterations'] + pass_count = 0 + client = self.primary_client + current_soft_ap_state = STATE_DOWN + current_client_mode_state = STATE_DOWN + + self.client_mode_toggle_pre_test(settings) + for iteration in range(iterations): + passes = True + + # Attempt to toggle SoftAP on, then off + for _ in range(2): + (current_soft_ap_state, err) = self.run_toggle_iteration_func( + self.soft_ap_toggle_test_iteration, settings, + current_soft_ap_state) + if err: + self.log.error('Iteration %s failed. Err: %s' % + (str(iteration + 1), err)) + passes = False + if current_soft_ap_state == STATE_DOWN: + break + + # Attempt to toggle Client mode on, then off + for _ in range(2): + (current_client_mode_state, + err) = self.run_toggle_iteration_func( + self.client_mode_toggle_test_iteration, settings, + current_client_mode_state) + if err: + self.log.error('Iteration %s failed. Err: %s' % + (str(iteration + 1), err)) + passes = False + if current_client_mode_state == STATE_DOWN: + break + + if passes: + pass_count += 1 + + if pass_count == iterations: + asserts.explicit_pass( + 'Toggle SoftAP and client mode stress test passed %s/%s times.' + % (pass_count, iterations)) + else: + asserts.fail( + 'Toggle SoftAP and client mode stress test only passed %s/%s ' + 'times.' % (pass_count, iterations)) + +# Toggle Stress Test Helper Functions + + def run_toggle_stress_test(self, settings): + """Runner function for toggle stress tests. + + Repeats some test function through stress test iterations, logging + failures, tracking pass rate, managing states, etc. + + Args: + settings: dict, stress test settings + + Asserts: + PASS: if all iterations of the test function pass + FAIL: if any iteration of the test function fails + """ + test_runner_func = settings['test_runner_func'] + pre_test_func = settings.get('pre_test_func', None) + iterations = settings['iterations'] + if pre_test_func: + pre_test_func(settings) + + pass_count = 0 + current_state = STATE_DOWN + for iteration in range(iterations): + (current_state, + err) = self.run_toggle_iteration_func(test_runner_func, settings, + current_state) + if err: + self.log.error('Iteration %s failed. Err: %s' % + (str(iteration + 1), err)) + else: + pass_count += 1 + + if pass_count == iterations: + asserts.explicit_pass('Stress test passed %s/%s times.' % + (pass_count, iterations)) + else: + asserts.fail('Stress test only passed %s/%s ' + 'times.' % (pass_count, iterations)) + + def run_toggle_iteration_func(self, func, settings, current_state): + """Runs a toggle iteration function, updating the current state + based on what the toggle iteration function raises. + + Used for toggle stress tests. + + Note on EnvironmentError vs StressTestIterationFailure: + StressTestIterationFailure is raised by func when the toggle occurs + but connectivty or some other post-toggle check fails (i.e. the + next iteration should toggle to the next state.) + + EnvironmentError is raise by func when the toggle itself fails (i.e + the next iteration should retry the same toggle again.) + + Args: + func: toggle iteration func to run (e.g soft_ap_toggle_iteration) + settings: dict, stress test settings + current_state: bool, the current state of the mode being toggled + + Returns: + (new_state, err): + new_state: bool, state of the mode after toggle attempt + err: exception, if any are raise, else None + """ + try: + func(settings, current_state) + except EnvironmentError as err: + return (current_state, err) + except StressTestIterationFailure as err: + return (not current_state, err) + else: + return (not current_state, None) + +# Stress Test Toggle Functions + + def start_soft_ap_and_verify_connected(self, client, soft_ap_params): + """Sets up SoftAP, associates a client, then verifies connection. + + Args: + client: SoftApClient, client to use to verify SoftAP + soft_ap_params: dict, containing parameters to setup softap + + Raises: + StressTestIterationFailure, if toggle occurs, but connection + is not functioning as expected + """ + # Change SSID every time, to avoid client connection issues. + soft_ap_params['ssid'] = utils.rand_ascii_str( + hostapd_constants.AP_SSID_LENGTH_2G) + self.start_soft_ap(soft_ap_params) + associated = self.associate_with_soft_ap(client.w_device, + soft_ap_params) + if not associated: + raise StressTestIterationFailure( + 'Failed to associated client to DUT SoftAP. ' + 'Continuing with iterations.') + + if not self.verify_soft_ap_connectivity_from_state(STATE_UP, client): + raise StressTestIterationFailure( + 'Failed to ping between client and DUT. Continuing ' + 'with iterations.') + + def stop_soft_ap_and_verify_disconnected(self, client, soft_ap_params): + """Tears down SoftAP, and verifies connection is down. + + Args: + client: SoftApClient, client to use to verify SoftAP + soft_ap_params: dict, containing parameters of SoftAP to teardown + + Raise: + EnvironmentError, if client and AP can still communicate + """ + self.log.info('Stopping SoftAP on DUT.') + self.stop_soft_ap(soft_ap_params) + + if not self.verify_soft_ap_connectivity_from_state(STATE_DOWN, client): + raise EnvironmentError( + 'Client can still ping DUT. Continuing with ' + 'iterations.') + + def start_client_mode_and_verify_connected(self, ap_params): + """Connects DUT to AP in client mode and verifies connection + + Args: + ap_params: dict, containing parameters of the AP network + + Raises: + EnvironmentError, if DUT fails to associate altogether + StressTestIterationFailure, if DUT associates but connection is not + functioning as expected. + """ + ap_ssid = ap_params['ssid'] + ap_password = ap_params['password'] + ap_channel = ap_params['channel'] + self.log.info('Associating DUT with AP network: %s' % ap_ssid) + associated = self.dut.associate(target_ssid=ap_ssid, + target_pwd=ap_password) + if not associated: + raise EnvironmentError('Failed to associate DUT in client mode.') + else: + self.log.info('Association successful.') + + if not self.verify_client_mode_connectivity_from_state( + STATE_UP, ap_channel): + raise StressTestIterationFailure('Failed to ping AP from DUT.') + + def stop_client_mode_and_verify_disconnected(self, ap_params): + """Disconnects DUT from AP and verifies connection is down. + + Args: + ap_params: dict, containing parameters of the AP network + + Raises: + EnvironmentError, if DUT and AP can still communicate + """ + self.log.info('Disconnecting DUT from AP.') + self.dut.disconnect() + if not self.verify_client_mode_connectivity_from_state( + STATE_DOWN, ap_params['channel']): + raise EnvironmentError('DUT can still ping AP.') + +# Toggle Stress Test Iteration and Pre-Test Functions + +# SoftAP Toggle Stress Test Helper Functions + + def soft_ap_toggle_test_iteration(self, settings, current_state): + """Runs a single iteration of SoftAP toggle stress test + + Args: + settings: dict, containing test settings + current_state: bool, current state of SoftAP (True if up, + else False) + + Raises: + StressTestIterationFailure, if toggle occurs but mode isn't + functioning correctly. + EnvironmentError, if toggle fails to occur at all + """ + soft_ap_params = settings['soft_ap_params'] + self.log.info('Toggling SoftAP %s.' % + ('down' if current_state else 'up')) + + if current_state == STATE_DOWN: + self.start_soft_ap_and_verify_connected(self.primary_client, + soft_ap_params) + + else: + self.stop_soft_ap_and_verify_disconnected(self.primary_client, + soft_ap_params) + +# Client Mode Toggle Stress Test Helper Functions + + def client_mode_toggle_pre_test(self, settings): + """Prepares the AP before client mode toggle tests + + Args: + settings: dict, stress test settings + + Raises: + ConnectionError, if AP setup fails + """ + ap_params = settings['ap_params'] + ap_channel = ap_params['channel'] + ap_profile = ap_params.pop('profile') + self.log.info('Setting up AP with params: %s' % ap_params) + setup_ap(access_point=self.access_point, + profile_name=ap_profile, + **ap_params) + # Confirms AP assigned itself an address + self.get_ap_ipv4_address(ap_channel) + + def client_mode_toggle_test_iteration(self, settings, current_state): + """Runs a single iteration of client mode toggle stress test + + Args: + settings: dict, containing test settings + current_state: bool, current state of client mode (True if up, + else False) + + Raises: + StressTestIterationFailure, if toggle occurs but mode isn't + functioning correctly. + EnvironmentError, if toggle fails to occur at all + """ + # TODO(b/168054673): Use client connections and policy connect + ap_params = settings['ap_params'] + self.log.info('Toggling client mode %s' % + ('off' if current_state else 'on')) + + if current_state == STATE_DOWN: + self.start_client_mode_and_verify_connected(ap_params) + + else: + self.stop_client_mode_and_verify_disconnected(ap_params) + +# Toggle SoftAP with Client Mode Up Test Helper Functions + + def soft_ap_toggle_with_client_mode_pre_test(self, settings): + """Sets up and verifies client mode before SoftAP toggle test. + Args: + settings: dict, stress test settings + + Raises: + ConnectionError, if client mode setup fails + """ + self.client_mode_toggle_pre_test(settings) + try: + self.start_client_mode_and_verify_connected(settings['ap_params']) + except StressTestIterationFailure as err: + # This prevents it being treated as a routine error + raise ConnectionError( + 'Failed to set up DUT client mode before SoftAP toggle test.' + 'Err: %s' % err) + + def soft_ap_toggle_with_client_mode_iteration( + self, + settings, + current_state, + ): + """Runs single iteration of SoftAP toggle stress with client mode test. + + Args: + settings: dict, containing test settings + current_state: bool, current state of SoftAP (True if up, + else False) + + Raises: + StressTestIterationFailure, if toggle occurs but mode isn't + functioning correctly. + EnvironmentError, if toggle fails to occur at all + """ + ap_params = settings['ap_params'] + ap_channel = ap_params['channel'] + self.soft_ap_toggle_test_iteration(settings, current_state) + if not self.dut_is_connected_as_client(ap_channel): + raise StressTestIterationFailure( + 'DUT client mode is no longer functional after SoftAP toggle.') + +# Toggle Client Mode with SoftAP Up Test Helper Functions + + def client_mode_toggle_with_soft_ap_pre_test(self, settings): + """Sets up and verifies softap before client mode toggle test. + Args: + settings: dict, stress test settings + + Raises: + ConnectionError, if softap setup fails + """ + self.client_mode_toggle_pre_test(settings) + try: + self.start_soft_ap_and_verify_connected(self.primary_client, + settings['soft_ap_params']) + except StressTestIterationFailure as err: + # This prevents it being treated as a routine error + raise ConnectionError( + 'Failed to set up SoftAP before client mode toggle test. Err: %s' + % err) + + def client_mode_toggle_with_soft_ap_iteration(self, settings, + current_state): + """Runs single iteration of client mode toggle stress with SoftAP test. + + Args: + settings: dict, containing test settings + current_state: bool, current state of client mode (True if up, + else False) + + Raises: + StressTestIterationFailure, if toggle occurs but mode isn't + functioning correctly. + EnvironmentError, if toggle fails to occur at all + """ + self.client_mode_toggle_test_iteration(settings, current_state) + if not self.client_is_connected_to_soft_ap(self.primary_client): + raise StressTestIterationFailure( + 'SoftAP is no longer functional after client mode toggle.') + +# Toggle SoftAP and Client Mode Randomly + + def run_soft_ap_and_client_mode_random_toggle_stress_test(self, settings): + """Runner function for SoftAP and client mode random toggle tests. + + Each iteration, randomly chooses if a mode will be toggled or not. + + Args: + settings: dict, containing test settings + """ + iterations = settings['iterations'] + pass_count = 0 + current_soft_ap_state = STATE_DOWN + current_client_mode_state = STATE_DOWN + ap_channel = settings['ap_params']['channel'] + + self.client_mode_toggle_pre_test(settings) + for iteration in range(iterations): + self.log.info('Starting iteration %s out of %s.' % + (str(iteration + 1), iterations)) + passes = True + + # Randomly determine if softap, client mode, or both should + # be toggled. + rand_toggle_choice = random.randrange(0, 3) + if rand_toggle_choice <= 1: + (current_soft_ap_state, err) = self.run_toggle_iteration_func( + self.soft_ap_toggle_test_iteration, settings, + current_soft_ap_state) + if err: + self.log.error( + 'Iteration %s failed toggling SoftAP. Err: %s' % + (str(iteration + 1), err)) + passes = False + if rand_toggle_choice >= 1: + (current_client_mode_state, + err) = self.run_toggle_iteration_func( + self.client_mode_toggle_test_iteration, settings, + current_client_mode_state) + if err: + self.log.error( + 'Iteration %s failed toggling client mode. Err: %s' % + (str(iteration + 1), err)) + passes = False + + soft_ap_verified = self.verify_soft_ap_connectivity_from_state( + current_soft_ap_state, self.primary_client) + client_mode_verified = self.verify_client_mode_connectivity_from_state( + current_client_mode_state, ap_channel) + + if not soft_ap_verified or not client_mode_verified: + passes = False + if passes: + pass_count += 1 + + if pass_count == iterations: + asserts.explicit_pass('Stress test passed %s/%s times.' % + (pass_count, iterations)) + else: + asserts.fail('Stress test only passed %s/%s ' + 'times.' % (pass_count, iterations)) # Test Cases def test_soft_ap_2g_open_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, - 'operating_band': OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_open_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, - 'operating_band': OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_open_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, - 'operating_band': OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wep_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wep_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wep_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, ) def test_soft_ap_2g_wpa_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wpa2_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa2_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa2_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wpa3_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa3_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa3_local(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_LOCAL, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_open_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_open_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_open_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': utils.rand_ascii_str( - hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_OPEN, + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wep_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wep_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wep_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WEP, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WEP, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wpa_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wpa2_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa2_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_5G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_5G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa2_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA2, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA2, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_2g_wpa3_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_2G - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_2G + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_5g_wpa3_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_ANY - }) + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) def test_soft_ap_any_wpa3_unrestricted(self): - self.verify_soft_ap_associate_and_pass_traffic( - self.primary_client, { - 'ssid': - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), - 'security_type': - SECURITY_WPA3, - 'password': - utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), - 'connectivity_mode': - CONNECTIVITY_MODE_UNRESTRICTED, - 'operating_band': - OPERATING_BAND_ANY - }) - - def test_multi_client_open(self): + soft_ap_params = { + 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_5G), + 'security_type': SECURITY_WPA3, + 'password': + utils.rand_ascii_str(hostapd_constants.MIN_WPA_PSK_LENGTH), + 'connectivity_mode': CONNECTIVITY_MODE_UNRESTRICTED, + 'operating_band': OPERATING_BAND_ANY + } + self.start_soft_ap(soft_ap_params) + self.verify_soft_ap_associate_and_pass_traffic(self.primary_client, + soft_ap_params) + + def test_multi_client(self): """Tests multi-client association with a single soft AP network. This tests associates a variable length list of clients, verfying it can @@ -917,27 +1576,37 @@ class SoftApTest(BaseTestClass): associated clients can still ping and pass traffic. The same occurs in reverse for disassocations. + + SoftAP parameters can be changed from default via ACTS config: + Example Config + "soft_ap_test_params" : { + "multi_client_test_params": { + "ssid": "testssid", + "security_type": "wpa2", + "password": "password", + "connectivity_mode": "local_only", + "operating_band": "only_2_4_ghz" + } + } """ + # TODO(fxb/59335): Validate clients on network can reach eachother. asserts.skip_if( len(self.clients) < 2, 'Test requires at least 2 SoftAPClients') - settings = { - 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, - 'operating_band': OPERATING_BAND_ANY - } - self.start_soft_ap(settings) + test_params = self.soft_ap_test_params.get('multi_client_test_params', + {}) + soft_ap_params = get_soft_ap_params_from_config_or_default(test_params) + + self.start_soft_ap(soft_ap_params) dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) associated = [] for client in self.clients: # Associate new client - self.associate_with_soft_ap(client.w_device, settings) + self.verify_soft_ap_associate_and_ping(client, soft_ap_params) client_ipv4 = self.wait_for_ipv4_address( - client.w_device, ANDROID_DEFAULT_WLAN_PORT) - self.run_iperf_traffic(client.ip_client, dut_ap_interface.ipv4) + client.w_device, ANDROID_DEFAULT_WLAN_INTERFACE) # Verify previously associated clients still behave as expected for client_map in associated: @@ -946,18 +1615,13 @@ class SoftApTest(BaseTestClass): self.log.info( 'Verifying previously associated client %s still functions correctly.' % associated_client.w_device.device.serial) - try: - self.verify_ping(self.dut, associated_client_ipv4) - self.verify_ping(associated_client.w_device, - dut_ap_interface.ipv4) - self.run_iperf_traffic(associated_client.ip_client, - dut_ap_interface.ipv4) - except signals.TestFailure as err: + if not self.client_is_connected_to_soft_ap(associated_client, + check_traffic=True): asserts.fail( 'Previously associated client %s failed checks after ' - 'client %s associated. Error: %s' % + 'client %s associated.' % (associated_client.w_device.device.serial, - client.w_device.device.serial, err)) + client.w_device.device.serial)) associated.append({'client': client, 'ipv4': client_ipv4}) @@ -973,26 +1637,21 @@ class SoftApTest(BaseTestClass): for client_map in associated: associated_client = client_map['client'] associated_client_ipv4 = client_map['ipv4'] - try: - self.log.info( - 'Verifying still associated client %s still functions ' - 'correctly.' % - associated_client.w_device.device.serial) - self.verify_ping(self.dut, associated_client_ipv4) - self.verify_ping(associated_client.w_device, - dut_ap_interface.ipv4) - self.run_iperf_traffic(associated_client.ip_client, - dut_ap_interface.ipv4) - except signals.TestFailure as err: + + self.log.info( + 'Verifying still associated client %s still functions ' + 'correctly.' % associated_client.w_device.device.serial) + if not self.client_is_connected_to_soft_ap(associated_client, + check_traffic=True): asserts.fail( 'Previously associated client %s failed checks after' - ' client %s disassociated. Error: %s' % + ' client %s disassociated.' % (associated_client.w_device.device.serial, - client.w_device.device.serial, err)) + client.w_device.device.serial)) self.log.info('All disassociations occurred smoothly.') - def test_soft_ap_and_client(self): + def test_simultaneous_soft_ap_and_client(self): """ Tests FuchsiaDevice DUT can act as a client and a SoftAP simultaneously. @@ -1002,72 +1661,37 @@ class SoftApTest(BaseTestClass): TestFailure: if DUT fails to pass traffic as either a client or an AP """ + # TODO(fxb/59306): Fix flakey parallel streams. asserts.skip_if(not self.access_point, 'No access point provided.') self.log.info('Setting up AP using hostapd.') + test_params = self.soft_ap_test_params.get( + 'soft_ap_and_client_test_params', {}) # Configure AP - ap_params = self.user_params.get('soft_ap_test_params', - {}).get('ap_params', {}) - channel = ap_params.get('channel', 11) - ssid = ap_params.get('ssid', 'apnet') - security_mode = ap_params.get('security_mode', None) - password = ap_params.get('password', None) - if security_mode: - security = hostapd_security.Security(security_mode, password) - else: - security = None + ap_params = get_ap_params_from_config_or_default( + test_params.get('ap_params', {})) # Setup AP and associate DUT - if not setup_ap_and_associate(access_point=self.access_point, - client=self.dut, - profile_name='whirlwind', - channel=channel, - security=security, - password=password, - ssid=ssid): - raise ConnectionError( - 'FuchsiaDevice DUT failed to connect as client to AP.') - self.log.info('DUT successfully associated to AP network.') - - # Verify FuchsiaDevice's client interface has an ip address from AP - dut_client_interface = self.get_dut_interface_by_role( - INTERFACE_ROLE_CLIENT) - - # Verify FuchsiaDevice can ping AP - lowest_5ghz_channel = 36 - if channel < lowest_5ghz_channel: - ap_interface = self.access_point.wlan_2g - else: - ap_interface = self.access_point.wlan_5g - ap_ipv4 = utils.get_interface_ip_addresses( - self.access_point.ssh, ap_interface)['ipv4_private'][0] - - self.verify_ping(self.dut, ap_ipv4) + ap_profile = ap_params.pop('profile') + setup_ap(access_point=self.access_point, + profile_name=ap_profile, + **ap_params) + try: + self.start_client_mode_and_verify_connected(ap_params) + except Exception as err: + asserts.fail('Failed to set up client mode. Err: %s' % err) # Setup SoftAP - soft_ap_settings = { - 'ssid': utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G), - 'security_type': SECURITY_OPEN, - 'connectivity_mode': CONNECTIVITY_MODE_LOCAL, - 'operating_band': OPERATING_BAND_2G - } - self.start_soft_ap(soft_ap_settings) + soft_ap_params = get_soft_ap_params_from_config_or_default( + test_params.get('soft_ap_params', {})) + self.start_soft_ap_and_verify_connected(self.primary_client, + soft_ap_params) # Get FuchsiaDevice's AP interface info dut_ap_interface = self.get_dut_interface_by_role(INTERFACE_ROLE_AP) - - # Associate primary client with SoftAP - self.associate_with_soft_ap(self.primary_client.w_device, - soft_ap_settings) - - # Verify primary client has an ip address from SoftAP - client_ipv4 = self.wait_for_ipv4_address(self.primary_client.w_device, - ANDROID_DEFAULT_WLAN_PORT) - - # Verify primary client can ping SoftAP, and reverse - self.verify_ping(self.primary_client.w_device, dut_ap_interface.ipv4) - self.verify_ping(self.dut, client_ipv4) + dut_client_interface = self.get_dut_interface_by_role( + INTERFACE_ROLE_CLIENT) # Set up secondary iperf server of FuchsiaDevice self.log.info('Setting up second iperf server on FuchsiaDevice DUT.') @@ -1099,13 +1723,16 @@ class SoftApTest(BaseTestClass): # Run iperf processes simultaneously self.log.info('Running simultaneous iperf traffic: between AP and DUT ' 'client interface, and DUT AP interface and client.') + iperf_soft_ap.start() iperf_fuchsia_client.start() # Block until processes can join or timeout for proc in [iperf_soft_ap, iperf_fuchsia_client]: - proc.join(timeout=30) + proc.join(timeout=DEFAULT_IPERF_TIMEOUT) if proc.is_alive(): + proc.terminate() + proc.join() raise RuntimeError('Failed to join process %s' % proc) # Stop iperf server (also stopped in teardown class as failsafe) @@ -1124,54 +1751,294 @@ class SoftApTest(BaseTestClass): 'FuchsiaDevice failed to pass traffic as a client and an AP ' 'simultaneously.') - def test_soft_ap_stress_from_config(self): - """ Runs tests from ACTS config file. + def test_soft_ap_association_stress(self): + """ Sets up a single AP and repeatedly associate/disassociate + a client, verifying connection every time + + Each test creates 1 SoftAP and repeatedly associates/disassociates + client. Example Config "soft_ap_test_params" : { - "soft_ap_tests": [ + "soft_ap_association_stress_tests": [ { "ssid": "test_network", "security_type": "wpa2", "password": "password", "connectivity_mode": "local_only", "operating_band": "only_2_4_ghz", - "reconnect_loops": 10 + "iterations": 10 } ] } """ - tests = self.user_params.get('soft_ap_test_params', - {}).get('soft_ap_tests') - asserts.skip_if(not tests, 'No soft ap tests in the ACTS config.') + tests = self.soft_ap_test_params.get( + 'test_soft_ap_association_stress', + [dict(test_name='test_soft_ap_association_stress_default')]) test_settings_list = [] - for config_settings in self.user_params['soft_ap_test_params'][ - 'soft_ap_tests']: - ssid = config_settings.get( - 'ssid', - utils.rand_ascii_str(hostapd_constants.AP_SSID_LENGTH_2G)) - security_type = config_settings.get('security_type', SECURITY_OPEN) - password = config_settings.get('password', '') - connectivity_mode = config_settings.get('connectivity_mode', - CONNECTIVITY_MODE_LOCAL) - operating_band = config_settings.get('operating_band', - OPERATING_BAND_ANY) + for config_settings in tests: + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings) test_type = config_settings.get('test_type', 'associate_and_pass_traffic') - reconnect_loops = config_settings.get('reconnect_loops', 1) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) test_settings = { + 'test_name': config_settings['test_name'], 'client': self.primary_client, - 'ssid': ssid, - 'security_type': security_type, - 'password': password, - 'connectivity_mode': connectivity_mode, - 'operating_band': operating_band, + 'soft_ap_params': soft_ap_params, 'test_type': test_type, - 'reconnect_loops': reconnect_loops + 'iterations': iterations } test_settings_list.append(test_settings) - self.run_generated_testcases(self.run_config_stress_test, + self.run_generated_testcases(self.run_soft_ap_association_stress_test, test_settings_list, - name_func=generate_test_name)
\ No newline at end of file + name_func=get_test_name_from_settings) + + def test_soft_ap_and_client_mode_alternating_stress(self): + """ Runs tests that alternate between SoftAP and Client modes. + + Each tests sets up an AP. Then, for each iteration: + - DUT starts up SoftAP, client associates with SoftAP, + connection is verified, then disassociates + - DUT associates to the AP, connection is verified, then + disassociates + + Example Config: + "soft_ap_test_params": { + "toggle_soft_ap_and_client_tests": [ + { + "test_name": "test_wpa2_client_ap_toggle", + "ap_params": { + "channel": 6, + "ssid": "test-ap-network", + "security_mode": "wpa2", + "password": "password" + }, + "soft_ap_params": { + "ssid": "test-soft-ap-network", + "security_type": "wpa2", + "password": "other-password", + "connectivity_mode": "local_only", + "operating_band": "only_2_4_ghz" + }, + "iterations": 5 + } + ] + } + """ + asserts.skip_if(not self.access_point, 'No access point provided.') + tests = self.soft_ap_test_params.get( + 'test_soft_ap_and_client_mode_alternating_stress', [ + dict(test_name= + 'test_soft_ap_and_client_mode_alternating_stress_default') + ]) + + test_settings_list = [] + for config_settings in tests: + ap_params = get_ap_params_from_config_or_default( + config_settings.get('ap_params', {})) + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings.get('soft_ap_params', {})) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + + test_settings = { + 'test_name': config_settings['test_name'], + 'iterations': iterations, + 'soft_ap_params': soft_ap_params, + 'ap_params': ap_params, + } + + test_settings_list.append(test_settings) + self.run_generated_testcases( + test_func=self.run_soft_ap_and_client_mode_alternating_test, + settings=test_settings_list, + name_func=get_test_name_from_settings) + + def test_soft_ap_toggle_stress(self): + """ Runs SoftAP toggling stress test. + + Each iteration toggles SoftAP to the opposite state (up or down). + + If toggled up, a client is associated and connection is verified + If toggled down, test verifies client is not connected + + Will run with default params, but custom tests can be provided in the + ACTS config. + + Example Config + "soft_ap_test_params" : { + "test_soft_ap_toggle_stress": [ + "soft_ap_params": { + "security_type": "wpa2", + "password": "password", + "connectivity_mode": "local_only", + "operating_band": "only_2_4_ghz", + }, + "iterations": 10 + ] + } + """ + tests = self.soft_ap_test_params.get( + 'test_soft_ap_toggle_stress', + [dict(test_name='test_soft_ap_toggle_stress_default')]) + + test_settings_list = [] + for config_settings in tests: + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + test_settings = { + 'test_name': config_settings['test_name'], + 'test_runner_func': self.soft_ap_toggle_test_iteration, + 'soft_ap_params': soft_ap_params, + 'iterations': iterations + } + test_settings_list.append(test_settings) + + self.run_generated_testcases(self.run_toggle_stress_test, + test_settings_list, + name_func=get_test_name_from_settings) + + def test_client_mode_toggle_stress(self): + """ Runs client mode toggling stress test. + + Each iteration toggles client mode to the opposite state (up or down). + + If toggled up, DUT associates to AP, and connection is verified + If toggled down, test verifies DUT is not connected to AP + + Will run with default params, but custom tests can be provided in the + ACTS config. + + Example Config + "soft_ap_test_params" : { + "test_client_mode_toggle_stress": [ + "soft_ap_params": { + 'ssid': ssid, + 'channel': channel, + 'security_mode': security, + 'password': password + }, + "iterations": 10 + ] + } + """ + asserts.skip_if(not self.access_point, 'No access point provided.') + tests = self.soft_ap_test_params.get( + 'test_client_mode_toggle_stress', + [dict(test_name='test_client_mode_toggle_stress_default')]) + + test_settings_list = [] + for config_settings in tests: + ap_params = get_ap_params_from_config_or_default(config_settings) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + test_settings = { + 'test_name': config_settings['test_name'], + 'test_runner_func': self.client_mode_toggle_test_iteration, + 'pre_test_func': self.client_mode_toggle_pre_test, + 'ap_params': ap_params, + 'iterations': iterations + } + test_settings_list.append(test_settings) + self.run_generated_testcases(self.run_toggle_stress_test, + test_settings_list, + name_func=get_test_name_from_settings) + + def test_soft_ap_toggle_stress_with_client_mode(self): + """Same as test_soft_ap_toggle_stress, but client mode is set up + at test start and verified after every toggle.""" + asserts.skip_if(not self.access_point, 'No access point provided.') + tests = self.soft_ap_test_params.get( + 'test_soft_ap_toggle_stress_with_client_mode', [ + dict(test_name= + 'test_soft_ap_toggle_stress_with_client_mode_default') + ]) + + test_settings_list = [] + for config_settings in tests: + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings) + ap_params = get_ap_params_from_config_or_default(config_settings) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + test_settings = { + 'test_name': config_settings['test_name'], + 'test_runner_func': + self.soft_ap_toggle_with_client_mode_iteration, + 'pre_test_func': self.soft_ap_toggle_with_client_mode_pre_test, + 'soft_ap_params': soft_ap_params, + 'ap_params': ap_params, + 'iterations': iterations + } + test_settings_list.append(test_settings) + self.run_generated_testcases(self.run_toggle_stress_test, + test_settings_list, + name_func=get_test_name_from_settings) + + def test_client_mode_toggle_stress_with_soft_ap(self): + """Same as test_client_mode_toggle_stress, but softap is set up at + test start and verified after every toggle.""" + asserts.skip_if(not self.access_point, 'No access point provided.') + tests = self.soft_ap_test_params.get( + 'test_client_mode_toggle_stress_with_soft_ap', [ + dict(test_name= + 'test_client_mode_toggle_stress_with_soft_ap_default') + ]) + + test_settings_list = [] + for config_settings in tests: + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings) + ap_params = get_ap_params_from_config_or_default(config_settings) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + test_settings = { + 'test_name': config_settings['test_name'], + 'test_runner_func': + self.client_mode_toggle_with_soft_ap_iteration, + 'pre_test_func': self.client_mode_toggle_with_soft_ap_pre_test, + 'soft_ap_params': soft_ap_params, + 'ap_params': ap_params, + 'iterations': iterations + } + test_settings_list.append(test_settings) + self.run_generated_testcases(self.run_toggle_stress_test, + test_settings_list, + name_func=get_test_name_from_settings) + + def test_soft_ap_and_client_mode_random_toggle_stress(self): + """Same as above toggle stres tests, but each iteration, either softap, + client mode, or both are toggled, then states are verified.""" + asserts.skip_if(not self.access_point, 'No access point provided.') + tests = self.soft_ap_test_params.get( + 'test_soft_ap_and_client_mode_random_toggle_stress', [ + dict( + test_name= + 'test_soft_ap_and_client_mode_random_toggle_stress_default' + ) + ]) + + test_settings_list = [] + for config_settings in tests: + soft_ap_params = get_soft_ap_params_from_config_or_default( + config_settings) + ap_params = get_ap_params_from_config_or_default(config_settings) + iterations = config_settings.get('iterations', + DEFAULT_STRESS_TEST_ITERATIONS) + test_settings = { + 'test_name': config_settings['test_name'], + 'soft_ap_params': soft_ap_params, + 'ap_params': ap_params, + 'iterations': iterations + } + test_settings_list.append(test_settings) + self.run_generated_testcases( + self.run_soft_ap_and_client_mode_random_toggle_stress_test, + test_settings_list, + name_func=get_test_name_from_settings) diff --git a/acts_tests/tests/google/fuchsia/wlan/WlanRvrTest.py b/acts_tests/tests/google/fuchsia/wlan/WlanRvrTest.py index 8d80e2a944..87bf1a72a8 100644 --- a/acts_tests/tests/google/fuchsia/wlan/WlanRvrTest.py +++ b/acts_tests/tests/google/fuchsia/wlan/WlanRvrTest.py @@ -335,7 +335,7 @@ class WlanRvrTest(AbstractDeviceWlanDeviceBaseTest): else: raise ValueError('Invalid IP version: %s' % ip_version) if ip_address_checker_counter == ip_address_checker_max_attempts: - if self.dut.ping(iperf_server_ip_address): + if self.dut.can_ping(iperf_server_ip_address): self.log.error('IPerf server is pingable. Continuing with ' 'test. The missing IP address information ' 'should be marked as a bug.') @@ -477,7 +477,7 @@ class WlanRvrTest(AbstractDeviceWlanDeviceBaseTest): else: self.log.info('DUT has the following IPv6 address: "%s"' % dut_ip_addresses['ipv6_link_local'][0]) - server_pingable = self.dut.ping(iperf_server_ip_address) + server_pingable = self.dut.can_ping(iperf_server_ip_address) if not server_pingable: self.log.info('Iperf server "%s" is not pingable. Marking ' 'a 0 %s for throughput. Skipping running ' diff --git a/acts_tests/tests/google/fugu/AndroidFuguRemotePairingTest.py b/acts_tests/tests/google/fugu/AndroidFuguRemotePairingTest.py index a41f9fce79..e69de29bb2 100644 --- a/acts_tests/tests/google/fugu/AndroidFuguRemotePairingTest.py +++ b/acts_tests/tests/google/fugu/AndroidFuguRemotePairingTest.py @@ -1,81 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2017 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -""" -Test script to test pairing of an Android Device to a Fugu Remote -""" -import time - -from acts.controllers.relay_lib.relay import SynchronizeRelays -from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest - -class AndroidFuguRemotePairingTest(BluetoothBaseTest): - def setup_class(self): - super().setup_class() - self.dut = self.android_devices[0] - self.fugu_remote = self.relay_devices[0] - - def setup_test(self): - super(BluetoothBaseTest, self).setup_test() - self.fugu_remote.setup() - return True - - def teardown_test(self): - super(BluetoothBaseTest, self).teardown_test() - self.fugu_remote.clean_up() - return True - - @BluetoothBaseTest.bt_test_wrap - def test_pairing(self): - """Test pairing between a fugu device and a remote controller. - - Test the remote controller can be paired to fugu. - - Steps: - 1. Find the MAC address of remote controller from relay config file. - 2. Start the device paring process. - 3. Enable remote controller in pairing mode. - 4. Verify the remote is paired. - - Expected Result: - Remote controller is paired. - - Returns: - Pass if True - Fail if False - - TAGS: fugu - Priority: 1 - """ - - self.dut.droid.bluetoothStartPairingHelper(False) - self.fugu_remote.enter_pairing_mode() - self.dut.droid.bluetoothDiscoverAndBond(self.fugu_remote.mac_address) - - end_time = time.time() + 20 - self.dut.log.info("Verifying devices are bonded") - while time.time() < end_time: - bonded_devices = self.dut.droid.bluetoothGetBondedDevices() - - for d in bonded_devices: - if d['address'] == self.fugu_remote.mac_address: - self.dut.log.info("Successfully bonded to device.") - self.log.info("Fugu Bonded devices:\n{}".format( - bonded_devices)) - return True - # Timed out trying to bond. - self.dut.log.info("Failed to bond devices.") - - return False diff --git a/acts_tests/tests/google/fugu/fugu_pairing_test.json b/acts_tests/tests/google/fugu/fugu_pairing_test.json index 59f45e35af..e69de29bb2 100644 --- a/acts_tests/tests/google/fugu/fugu_pairing_test.json +++ b/acts_tests/tests/google/fugu/fugu_pairing_test.json @@ -1,39 +0,0 @@ -{ - "_description": "Test configuration for Fugu pairing the remote controller", - "logpath": "/tmp/logs", - "testpaths": ["."], - "no_bug_report_on_fail": "True", - - "testbed": [ - { - "_description": "A testbed for RelayDevices", - "name": "7A18F48B", - "AndroidDevice": ["7A18F48B"], - "RelayDevice": "tests/google/fugu/relay.json" - }, - { - "_description": "A testbed for RelayDevices", - "name": "164FE498", - "AndroidDevice": ["164FE498"], - "RelayDevice": "tests/google/fugu/relay.json" - }, - { - "_description": "A testbed for RelayDevices", - "name": "B8B20856", - "AndroidDevice": ["B8B20856"], - "RelayDevice": "tests/google/fugu/relay.json" - }, - { - "_description": "A testbed for RelayDevices", - "name": "121A69F0", - "AndroidDevice": ["121A69F0"], - "RelayDevice": "tests/google/fugu/relay.json" - }, - { - "_description": "A testbed for RelayDevices", - "name": "BBDAC5ED", - "AndroidDevice": ["BBDAC5ED"], - "RelayDevice": "tests/google/fugu/relay.json" - } - ] -} diff --git a/acts_tests/tests/google/fugu/relay.json b/acts_tests/tests/google/fugu/relay.json index c3ab9db3d1..e69de29bb2 100644 --- a/acts_tests/tests/google/fugu/relay.json +++ b/acts_tests/tests/google/fugu/relay.json @@ -1,21 +0,0 @@ -{ - "boards": [ - { - "type": "SainSmartBoard", - "name": "ss0", - "base_url": "http://192.168.1.4/30000/" - } - ], - "devices": [ - { - "type": "FuguRemote", - "name": "Fugu0", - "mac_address" : "AC:9E:17:53:AC:3A", - "relays": { - "Play": "ss0/1", - "Home": "ss0/2", - "Back": "ss0/3" - } - } - ] -} diff --git a/acts_tests/tests/google/gnss/GnssSimInventoryTest.py b/acts_tests/tests/google/gnss/GnssSimInventoryTest.py index 2daa598d52..8844cbc064 100644 --- a/acts_tests/tests/google/gnss/GnssSimInventoryTest.py +++ b/acts_tests/tests/google/gnss/GnssSimInventoryTest.py @@ -1,4 +1,7 @@ import time +import os +import tempfile + from acts import utils from acts import signals from acts.base_test import BaseTestClass @@ -22,25 +25,32 @@ class GnssSimInventoryTest(BaseTestClass): if not is_sim_ready_by_adb(self.ad.log, self.ad): raise signals.TestFailure("SIM card is not loaded and ready.") - def test_gnss_sim_inventory(self): - self.check_device_status() - android_version = int(self.ad.adb.getprop("ro.build.version.release")) - if android_version == 10: - imsi = str(self.ad.adb.shell("service call iphonesubinfo 7")) - elif android_version == 11: - imsi = str(self.ad.adb.shell("service call iphonesubinfo 8")) - else: - raise signals.TestFailure("Couldn't get imsi") + def get_imsi(self): + self.ad.log.info("Get imsi from netpolicy.xml") + tmp_path = tempfile.mkdtemp() + self.ad.pull_files("/data/system/netpolicy.xml", tmp_path) + netpolicy_path = os.path.join(tmp_path, "netpolicy.xml") + with open(netpolicy_path, "r", encoding="utf-8") as file: + for line in file.readlines(): + if "subscriberId" in line: + imsi = line.split(" ")[2].split("=")[-1].strip('"') + return imsi + raise signals.TestFailure("Fail to get imsi") + + def get_iccid(self): iccid = str(get_iccid_by_adb(self.ad)) if not isinstance(iccid, int): self.ad.log.info("Unable to get iccid via adb. Changed to isub.") iccid = str(self.ad.adb.shell( "dumpsys isub | grep iccid")).split(" ")[4].strip(",") - if not iccid: - raise signals.TestFailure("Couldn't get iccid") - sms_message = "imsi: %s, iccid: %s, ldap: %s, model: %s, sn: %s" % \ - (imsi, iccid, self.sim_inventory_ldap, self.ad.model, - self.ad.serial) + return iccid + raise signals.TestFailure("Fail to get iccid") + + def test_gnss_sim_inventory(self): + self.check_device_status() + sms_message = "imsi: %s, iccid: %s, ldap: %s, model: %s, sn: %s" % ( + self.get_imsi(), self.get_iccid(), self.sim_inventory_ldap, + self.ad.model, self.ad.serial) self.ad.log.info(sms_message) try: self.ad.log.info("Send SMS by SL4A.") diff --git a/acts_tests/tests/google/native/NativeTest.py b/acts_tests/tests/google/native/NativeTest.py index 90ebceb28c..e69de29bb2 100644 --- a/acts_tests/tests/google/native/NativeTest.py +++ b/acts_tests/tests/google/native/NativeTest.py @@ -1,60 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy of -# the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. - -import time -from acts.base_test import BaseTestClass -from acts.test_utils.bt.native_bt_test_utils import setup_native_bluetooth -from acts.test_utils.bt.bt_test_utils import generate_id_by_size - -class NativeTest(BaseTestClass): - tests = None - - def __init__(self, controllers): - BaseTestClass.__init__(self, controllers) - self.tests = ( - "test_bool_return_true", - "test_bool_return_false", - "test_null_return", - "test_string_empty_return", - "test_max_param_size", - ) - - def setup_class(self): - super().setup_class() - self.droid = self.native_android_devices[0].droid - - def test_bool_return_true(self): - return self.droid.TestBoolTrueReturn() - - def test_bool_return_false(self): - return not self.droid.TestBoolFalseReturn() - - def test_null_return(self): - return not self.droid.TestNullReturn() - - def test_string_empty_return(self): - return self.droid.TestStringEmptyReturn() == "" - - def test_max_param_size(self): - json_buffer_size = 64 - max_sl4n_buffer_size = 4096 - test_string = "x" * (max_sl4n_buffer_size - json_buffer_size) - return test_string == self.droid.TestStringMaxReturn(test_string) - - def test_specific_param_naming(self): - a = [{"string_test":"test", "int_test":1}] - return self.droid.TestSpecificParamNaming(a) - diff --git a/acts_tests/tests/google/native/bt/BtNativeTest.py b/acts_tests/tests/google/native/bt/BtNativeTest.py index 55674bcb42..e69de29bb2 100644 --- a/acts_tests/tests/google/native/bt/BtNativeTest.py +++ b/acts_tests/tests/google/native/bt/BtNativeTest.py @@ -1,63 +0,0 @@ -from acts.base_test import BaseTestClass -from acts.controllers import native_android_device -from acts.test_utils.bt.native_bt_test_utils import setup_native_bluetooth -from acts.test_utils.bt.bt_test_utils import generate_id_by_size - - -class BtNativeTest(BaseTestClass): - tests = None - - def __init__(self, controllers): - BaseTestClass.__init__(self, controllers) - self.tests = ( - "test_binder_get_name", - "test_binder_get_name_invalid_parameter", - "test_binder_set_name_get_name", - "test_binder_get_address", ) - - def setup_class(self): - setup_native_bluetooth(self.native_android_devices) - self.droid = self.native_android_devices[0].droid - if len(self.native_android_devices) > 1: - self.droid1 = self.native_android_devices[1].droid - self.tests = self.tests + ("test_two_devices_set_get_name", ) - - def test_binder_get_name(self): - result = self.droid.BtBinderGetName() - self.log.info("Bluetooth device name: {}".format(result)) - return True - - def test_binder_get_name_invalid_parameter(self): - try: - self.droid.BtBinderGetName("unexpected_parameter") - return False - except Exception: - return True - - def test_binder_set_name_get_name(self): - test_name = generate_id_by_size(4) - result = self.droid.BtBinderSetName(test_name) - if not result: - return False - name = self.droid.BtBinderGetName() - if test_name != name: - return False - return True - - def test_binder_get_address(self): - result = self.droid.BtBinderGetAddress() - self.log.info("Found BT address: {}".format(result)) - if not result: - return False - return True - - def test_two_devices_set_get_name(self): - test_name = generate_id_by_size(4) - for n in self.native_android_devices: - d = n.droid - d.BtBinderSetName(test_name) - name = d.BtBinderGetName() - if name != test_name: - return False - return True - diff --git a/acts_tests/tests/google/net/IKEv2VpnOverLTETest.py b/acts_tests/tests/google/net/IKEv2VpnOverLTETest.py index 3a00a7d40c..cd9c41ac53 100644 --- a/acts_tests/tests/google/net/IKEv2VpnOverLTETest.py +++ b/acts_tests/tests/google/net/IKEv2VpnOverLTETest.py @@ -53,60 +53,47 @@ class IKEv2VpnOverLTETest(base_test.BaseTestClass): for ad in self.android_devices: ad.take_bug_report(test_name, begin_time) - ### Test cases ### + ### Helper methods ### - @test_tracker_info(uuid="") - def test_ikev2_psk_vpn_tmo(self): - vpn = VPN_TYPE.IKEV2_IPSEC_PSK + def _test_ikev2_vpn(self, ad, vpn, hostname=None): + """Verify IKEv2 VPN connection. + + Args: + ad: android device to run the test. + vpn: type of VPN. + hostname: hostname or IP address of the server. + """ server_addr = self.vpn_server_addresses[vpn.name][0] + self.vpn_params["server_addr"] = server_addr + if not hostname: + hostname = server_addr vpn_addr = self.vpn_verify_addresses[vpn.name][0] vpn_profile = nutils.generate_ikev2_vpn_profile( - self.tmo_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.tmo_dut, vpn_profile, vpn_addr) + ad, self.vpn_params, vpn, hostname, self.log_path) + nutils.legacy_vpn_connection_test_logic(ad, vpn_profile, vpn_addr) - @test_tracker_info(uuid="") + ### Test cases ### + + @test_tracker_info(uuid="31fac6c5-f76c-403c-8b76-29c01557a48a") + def test_ikev2_psk_vpn_tmo(self): + self._test_ikev2_vpn(self.tmo_dut, VPN_TYPE.IKEV2_IPSEC_PSK) + + @test_tracker_info(uuid="c28adef0-6578-4841-a833-e52a5b16a390") def test_ikev2_mschapv2_vpn_tmo(self): - vpn = VPN_TYPE.IKEV2_IPSEC_USER_PASS - server_addr = self.vpn_server_addresses[vpn.name][0] - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.tmo_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.tmo_dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(self.tmo_dut, VPN_TYPE.IKEV2_IPSEC_USER_PASS) - @test_tracker_info(uuid="") + @test_tracker_info(uuid="6c7daad9-ae7a-493d-bbab-9001068f22c5") def test_ikev2_rsa_vpn_tmo(self): - vpn = VPN_TYPE.IKEV2_IPSEC_RSA - server_addr = self.vpn_server_addresses[vpn.name][0] - self.vpn_params["server_addr"] = server_addr - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.tmo_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.tmo_dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(self.tmo_dut, VPN_TYPE.IKEV2_IPSEC_RSA) - @test_tracker_info(uuid="") + @test_tracker_info(uuid="1275a2f-e939-4557-879d-fbbd9c5dbd93") def test_ikev2_psk_vpn_vzw(self): - vpn = VPN_TYPE.IKEV2_IPSEC_PSK - server_addr = self.vpn_server_addresses[vpn.name][0] - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.vzw_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.vzw_dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(self.vzw_dut, VPN_TYPE.IKEV2_IPSEC_PSK) - @test_tracker_info(uuid="") + @test_tracker_info(uuid="fd146163-f28d-4514-96a0-82f51b70e218") def test_ikev2_mschapv2_vpn_vzw(self): - vpn = VPN_TYPE.IKEV2_IPSEC_USER_PASS - server_addr = self.vpn_server_addresses[vpn.name][0] - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.vzw_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.vzw_dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(self.vzw_dut, VPN_TYPE.IKEV2_IPSEC_USER_PASS) - @test_tracker_info(uuid="") + @test_tracker_info(uuid="722de9b5-834f-4854-b4a6-e31860628fe9") def test_ikev2_rsa_vpn_vzw(self): - vpn = VPN_TYPE.IKEV2_IPSEC_RSA - server_addr = self.vpn_server_addresses[vpn.name][0] - self.vpn_params["server_addr"] = server_addr - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.vzw_dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.vzw_dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(self.vzw_dut, VPN_TYPE.IKEV2_IPSEC_RSA) diff --git a/acts_tests/tests/google/net/IKEv2VpnOverWifiTest.py b/acts_tests/tests/google/net/IKEv2VpnOverWifiTest.py index 8717541196..1f36e9a573 100644 --- a/acts_tests/tests/google/net/IKEv2VpnOverWifiTest.py +++ b/acts_tests/tests/google/net/IKEv2VpnOverWifiTest.py @@ -53,32 +53,46 @@ class IKEv2VpnOverWifiTest(base_test.BaseTestClass): def on_fail(self, test_name, begin_time): self.dut.take_bug_report(test_name, begin_time) - ### Test cases ### + ### Helper methods ### + def _test_ikev2_vpn(self, vpn, hostname=None): + """Verify IKEv2 VPN connection. - @test_tracker_info(uuid="") - def test_ikev2_psk_vpn_wifi(self): - vpn = VPN_TYPE.IKEV2_IPSEC_PSK + Args: + vpn: type of VPN. + hostname: hostname or IP address of the server. + """ server_addr = self.vpn_server_addresses[vpn.name][0] + self.vpn_params["server_addr"] = server_addr + if not hostname: + hostname = server_addr vpn_addr = self.vpn_verify_addresses[vpn.name][0] vpn_profile = nutils.generate_ikev2_vpn_profile( - self.dut, self.vpn_params, vpn, server_addr, self.log_path) + self.dut, self.vpn_params, vpn, hostname, self.log_path) nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr) - @test_tracker_info(uuid="") + ### Test cases ### + + @test_tracker_info(uuid="4991755c-321d-4e9a-ada9-fc821a35bb5b") + def test_ikev2_psk_vpn_wifi(self): + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_PSK) + + @test_tracker_info(uuid="04d88575-7b96-4746-bff8-a1d6841e202e") def test_ikev2_mschapv2_vpn_wifi(self): - vpn = VPN_TYPE.IKEV2_IPSEC_USER_PASS - server_addr = self.vpn_server_addresses[vpn.name][0] - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_USER_PASS) - @test_tracker_info(uuid="") + @test_tracker_info(uuid="e65f8a3e-f807-4493-822e-377dd6fa89cd") def test_ikev2_rsa_vpn_wifi(self): - vpn = VPN_TYPE.IKEV2_IPSEC_RSA - server_addr = self.vpn_server_addresses[vpn.name][0] - self.vpn_params["server_addr"] = server_addr - vpn_addr = self.vpn_verify_addresses[vpn.name][0] - vpn_profile = nutils.generate_ikev2_vpn_profile( - self.dut, self.vpn_params, vpn, server_addr, self.log_path) - nutils.legacy_vpn_connection_test_logic(self.dut, vpn_profile, vpn_addr) + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_RSA) + + @test_tracker_info(uuid="bdd8a967-8dac-4e48-87b7-2ce9f7d32158") + def test_ikev2_psk_vpn_wifi_with_hostname(self): + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_PSK, self.vpn_server_hostname) + + @test_tracker_info(uuid="19692520-c123-4b42-8549-08dda9c4873e") + def test_ikev2_mschapv2_vpn_wifi_with_hostname(self): + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_USER_PASS, + self.vpn_server_hostname) + + @test_tracker_info(uuid="bdaaf6e3-6671-4533-baba-2951009c7d69") + def test_ikev2_rsa_vpn_wifi_with_hostname(self): + self._test_ikev2_vpn(VPN_TYPE.IKEV2_IPSEC_RSA, self.vpn_server_hostname) diff --git a/acts_tests/tests/google/net/IpSecTest.py b/acts_tests/tests/google/net/IpSecTest.py index 83d1cb8e89..1b4a14468c 100644 --- a/acts_tests/tests/google/net/IpSecTest.py +++ b/acts_tests/tests/google/net/IpSecTest.py @@ -25,6 +25,7 @@ from acts.test_utils.net.net_test_utils import stop_tcpdump from acts.test_utils.wifi import wifi_test_utils as wutils import random +import time WLAN = "wlan0" WAIT_FOR_IP = 15 diff --git a/acts_tests/tests/google/nfc/NfcBasicFunctionalityTest.py b/acts_tests/tests/google/nfc/NfcBasicFunctionalityTest.py index 5d531d1931..e69de29bb2 100644 --- a/acts_tests/tests/google/nfc/NfcBasicFunctionalityTest.py +++ b/acts_tests/tests/google/nfc/NfcBasicFunctionalityTest.py @@ -1,111 +0,0 @@ -#!/usr/bin/env python3.4 -# -# Copyright 2017 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import time - -from acts.base_test import BaseTestClass -from acts.test_decorators import test_tracker_info - - -class NfcBasicFunctionalityTest(BaseTestClass): - nfc_on_event = "NfcStateOn" - nfc_off_event = "NfcStateOff" - timeout = 5 - - def setup_class(self): - self.dut = self.android_devices[0] - self._ensure_nfc_enabled(self.dut) - self.dut.droid.nfcStartTrackingStateChange() - self.dut.adb.shell("setprop nfc.app_log_level 255") - self.dut.adb.shell("setprop nfc.enable_protocol_log 255") - self.dut.adb.shell("setprop nfc.nxp_log_level_global 5") - self.dut.adb.shell("setprop nfc.nxp_log_level_extns 5") - self.dut.adb.shell("setprop nfc.nxp_log_level_hal 5") - self.dut.adb.shell("setprop nfc.nxp_log_level_nci 5") - self.dut.adb.shell("setprop nfc.nxp_log_level_tml 5") - self.dut.adb.shell("setprop nfc.nxp_log_level_dnld 5") - self._ensure_nfc_disabled(self.dut) - return True - - def _ensure_nfc_enabled(self, dut): - end_time = time.time() + 10 - while end_time > time.time(): - try: - dut.ed.pop_event(self.nfc_on_event, self.timeout) - self.log.info("Event {} found".format(self.nfc_on_event)) - return True - except Exception as err: - self.log.debug( - "Event {} not yet found".format(self.nfc_on_event)) - return False - - def _ensure_nfc_disabled(self, dut): - end_time = time.time() + 10 - while end_time > time.time(): - try: - dut.ed.pop_event(self.nfc_off_event, self.timeout) - self.log.info("Event {} found".format(self.nfc_off_event)) - return True - except Exception as err: - self.log.debug( - "Event {} not yet found".format(self.nfc_off_event)) - return False - - def setup_test(self): - # Every test starts with the assumption that NFC is enabled - if not self.dut.droid.nfcIsEnabled(): - self.dut.droid.nfcEnable() - else: - return True - if not self._ensure_nfc_enabled(self.dut): - self.log.error("Failed to toggle NFC on") - return False - return True - - def on_fail(self, test_name, begin_time): - self.dut.take_bug_report(test_name, begin_time) - - @test_tracker_info(uuid='d57fcdd8-c56c-4ab0-81fb-e2218b100de9') - def test_nfc_toggle_state_100_iterations(self): - """Test toggling NFC state 100 times. - - Verify that NFC toggling works. Test assums NFC is on. - - Steps: - 1. Toggle NFC off - 2. Toggle NFC on - 3. Repeat steps 1-2 100 times. - - Expected Result: - RFCOMM connection is established then disconnected succcessfully. - - Returns: - Pass if True - Fail if False - - TAGS: NFC - Priority: 1 - """ - iterations = 100 - for i in range(iterations): - self.log.info("Starting iteration {}".format(i + 1)) - self.dut.droid.nfcDisable() - if not self._ensure_nfc_disabled(self.dut): - return False - self.dut.droid.nfcEnable() - if not self._ensure_nfc_enabled(self.dut): - return False - return True diff --git a/acts_tests/tests/google/tel/live/TelLiveDataTest.py b/acts_tests/tests/google/tel/live/TelLiveDataTest.py index 6185ab8e1d..a2493ed299 100755 --- a/acts_tests/tests/google/tel/live/TelLiveDataTest.py +++ b/acts_tests/tests/google/tel/live/TelLiveDataTest.py @@ -57,6 +57,7 @@ from acts.test_utils.tel.tel_defines import TETHERING_MODE_WIFI from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_REBOOT from acts.test_utils.tel.tel_defines import WAIT_TIME_AFTER_MODE_CHANGE from acts.test_utils.tel.tel_defines import WAIT_TIME_ANDROID_STATE_SETTLING +from acts.test_utils.tel.tel_defines import MAX_WAIT_TIME_USER_PLANE_DATA from acts.test_utils.tel.tel_defines import WAIT_TIME_BETWEEN_REG_AND_CALL from acts.test_utils.tel.tel_defines import \ WAIT_TIME_DATA_STATUS_CHANGE_DURING_WIFI_TETHERING @@ -378,6 +379,68 @@ class TelLiveDataTest(TelephonyBaseTest): return False + @test_tracker_info(uuid="a3229fbf-48d8-4b88-9a36-4875b55426de") + @TelephonyBaseTest.tel_test_wrap + def test_5g_nsa_data_stall_recovery(self): + """ Verifies 5G NSA data stall + + Set Mode to 5G + Wait for 5G attached on NSA + Browse websites for success + Trigger data stall and verify browsing fails + Resume data and verify browsing success + + Returns: + True if pass; False if fail. + """ + ad = self.android_devices[0] + result = True + wifi_toggle_state(ad.log, ad, False) + toggle_airplane_mode(ad.log, ad, False) + + set_preferred_mode_for_5g(ad) + if not is_current_network_5g_nsa(ad): + ad.log.error("Phone not attached on 5G NSA") + return False + + cmd = ('ss -l -p -n | grep "tcp.*droid_script" | tr -s " " ' + '| cut -d " " -f 5 | sed s/.*://g') + sl4a_port = ad.adb.shell(cmd) + + if not test_data_browsing_success_using_sl4a(ad.log, ad): + ad.log.error("Browsing failed before the test, aborting!") + return False + + begin_time = get_device_epoch_time(ad) + break_internet_except_sl4a_port(ad, sl4a_port) + + if not test_data_browsing_failure_using_sl4a(ad.log, ad): + ad.log.error("Browsing success even after breaking " \ + "the internet, aborting!") + result = False + + if not check_data_stall_detection(ad): + ad.log.warning("NetworkMonitor unable to detect Data Stall") + + if not check_network_validation_fail(ad, begin_time): + ad.log.warning("Unable to detect NW validation fail") + + if not check_data_stall_recovery(ad, begin_time): + ad.log.error("Recovery was not triggered") + result = False + + resume_internet_with_sl4a_port(ad, sl4a_port) + time.sleep(MAX_WAIT_TIME_USER_PLANE_DATA) + if not test_data_browsing_success_using_sl4a(ad.log, ad): + ad.log.error("Browsing failed after resuming internet") + result = False + if result: + ad.log.info("PASS - data stall over 5G NSA") + else: + ad.log.error("FAIL - data stall over 5G NSA") + return result + + @test_tracker_info(uuid="1b0354f3-8668-4a28-90a5-3b3d2b2756d3") @TelephonyBaseTest.tel_test_wrap def test_airplane_mode(self): diff --git a/acts_tests/tests/google/tel/live/TelLiveSmsTest.py b/acts_tests/tests/google/tel/live/TelLiveSmsTest.py index ac2e0ad71f..95ed75a1b0 100644 --- a/acts_tests/tests/google/tel/live/TelLiveSmsTest.py +++ b/acts_tests/tests/google/tel/live/TelLiveSmsTest.py @@ -49,6 +49,7 @@ from acts.test_utils.tel.tel_test_utils import set_mobile_data_usage_limit from acts.test_utils.tel.tel_test_utils import setup_sim from acts.test_utils.tel.tel_test_utils import sms_send_receive_verify from acts.test_utils.tel.tel_test_utils import set_wfc_mode +from acts.test_utils.tel.tel_test_utils import toggle_airplane_mode from acts.test_utils.tel.tel_test_utils import \ sms_in_collision_send_receive_verify from acts.test_utils.tel.tel_test_utils import \ @@ -94,7 +95,7 @@ class TelLiveSmsTest(TelephonyBaseTest): is_roaming = False for ad in self.android_devices: ad.sms_over_wifi = False - #verizon supports sms over wifi. will add more carriers later + # verizon supports sms over wifi. will add more carriers later for sub in ad.telephony["subscription"].values(): if sub["operator"] in SMS_OVER_WIFI_PROVIDERS: ad.sms_over_wifi = True @@ -456,13 +457,13 @@ class TelLiveSmsTest(TelephonyBaseTest): message_array = [rand_ascii_str(length)] message_array2 = [rand_ascii_str(length)] if not sms_in_collision_send_receive_verify( - self.log, - ads[0], - ads[0], - ads[1], - ads[2], - message_array, - message_array2): + self.log, + ads[0], + ads[0], + ads[1], + ads[2], + message_array, + message_array2): ads[0].log.warning( "Test of SMS collision with length %s failed", length) return False @@ -477,14 +478,14 @@ class TelLiveSmsTest(TelephonyBaseTest): def _sms_in_collision_when_power_off_test(self, ads): for length in self.message_lengths: if not sms_rx_power_off_multiple_send_receive_verify( - self.log, - ads[0], - ads[1], - ads[2], - length, - length, - 5, - 5): + self.log, + ads[0], + ads[1], + ads[2], + length, + length, + 5, + 5): ads[0].log.warning( "Test of SMS collision when power off with length %s failed", length) @@ -704,7 +705,6 @@ class TelLiveSmsTest(TelephonyBaseTest): return self._sms_test_mo(ads) - @test_tracker_info(uuid="17fafc41-7e12-47ab-a4cc-fb9bd94e79b9") @TelephonyBaseTest.tel_test_wrap def test_sms_mt_2g(self): @@ -1701,6 +1701,65 @@ class TelLiveSmsTest(TelephonyBaseTest): return True + @test_tracker_info(uuid="fe862c8a-9fe0-4563-885e-9a819f5c8ba6") + @TelephonyBaseTest.tel_test_wrap + def test_sms_mo_mt_in_call_volte_5g_nsa(self): + """ Test MO SMS during a MO VoLTE call over 5G NSA. + + Make sure PhoneA/B are in 5G NSA (with VoLTE). + Make sure PhoneA/B is able to make/receive call. + Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA. + Make sure PhoneA/B are in 5G NSA + + Returns: + True if pass; False if fail. + """ + ads = self.android_devices + + tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte, + (self.log, ads[1]))] + if not multithread_func(self.log, tasks): + self.log.error("Phone Failed to Set Up Properly.") + return False + time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) + + # Mode Pref + tasks = [(set_preferred_mode_for_5g, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Failed to set preferred network mode.") + return False + + # Attach 5g + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA before call.") + return False + + self.log.info("Begin In Call SMS Test.") + if not call_setup_teardown( + self.log, + ads[0], + ads[1], + ad_hangup=None, + verify_caller_func=is_phone_in_call_volte, + verify_callee_func=None): + return False + + if not self._sms_test_mo(ads): + self.log.error("SMS test fail.") + return False + + # Check if phoneA/B are attached to 5g after sending mms. + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA after call.") + return False + + return True + @test_tracker_info(uuid="3bf8ff74-baa6-4dc6-86eb-c13816fa9bc8") @TelephonyBaseTest.tel_test_wrap def test_mms_mo_in_call_volte(self): @@ -1773,6 +1832,65 @@ class TelLiveSmsTest(TelephonyBaseTest): return True + @test_tracker_info(uuid="ffcb1afe-0118-40f8-9830-35847826d405") + @TelephonyBaseTest.tel_test_wrap + def test_mms_mo_mt_in_call_volte_5g_nsa(self): + """ Test MO MMS during a MO VoLTE call over 5G NSA. + + Make sure PhoneA/B are in 5G NSA (with VoLTE). + Make sure PhoneA/B is able to make/receive call. + Call from PhoneA to PhoneB, accept on PhoneB, send SMS on PhoneA. + Make sure PhoneA/B are in 5G NSA. + + Returns: + True if pass; False if fail. + """ + ads = self.android_devices + + tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte, + (self.log, ads[1]))] + if not multithread_func(self.log, tasks): + self.log.error("Phone Failed to Set Up Properly.") + return False + time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) + + # Mode Pref + tasks = [(set_preferred_mode_for_5g, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Failed to set preferred network mode.") + return False + + # Attach 5g + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA before call.") + return False + + self.log.info("Begin In Call MMS Test.") + if not call_setup_teardown( + self.log, + ads[0], + ads[1], + ad_hangup=None, + verify_caller_func=is_phone_in_call_volte, + verify_callee_func=None): + return False + + if not self._mms_test_mo(ads): + self.log.error("MMS test fail.") + return False + + # Check if phoneA/B are attached to 5g after sending mms. + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA after call.") + return False + + return True + @test_tracker_info(uuid="5654d974-3c32-4cce-9d07-0c96213dacc5") @TelephonyBaseTest.tel_test_wrap def test_mms_mo_in_call_volte_wifi(self): @@ -1851,6 +1969,72 @@ class TelLiveSmsTest(TelephonyBaseTest): return True + @test_tracker_info(uuid="a5b95867-133f-4576-8a44-bd057ee0188f") + @TelephonyBaseTest.tel_test_wrap + def test_mms_mo_mt_in_call_volte_wifi_5g_nsa(self): + """ Test MO MMS during a MO VoLTE call over 5G NSA. + + Make sure PhoneA/B are in 5G NSA (with VoLTE). + Make sure PhoneA/B are able to make/receive call. + Connect PhoneA/B to Wifi. + Call from PhoneA to PhoneB, accept on PhoneB, send MMS on PhoneA. + Make sure PhoneA/B are in 5G NSA. + + Returns: + True if pass; False if fail. + """ + ads = self.android_devices + + tasks = [(phone_setup_volte, (self.log, ads[0])), (phone_setup_volte, + (self.log, ads[1]))] + if not multithread_func(self.log, tasks): + self.log.error("Phone Failed to Set Up Properly.") + return False + time.sleep(WAIT_TIME_ANDROID_STATE_SETTLING) + + # Mode Pref + tasks = [(set_preferred_mode_for_5g, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Failed to set preferred network mode.") + return False + + # Attach 5g + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA before call.") + return False + + tasks = [(ensure_wifi_connected, (self.log, ad, self.wifi_network_ssid, + self.wifi_network_pass)) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone Failed to connect to wifi.") + return False + self.log.info("Begin In Call MMS Test.") + if not call_setup_teardown( + self.log, + ads[0], + ads[1], + ad_hangup=None, + verify_caller_func=is_phone_in_call_volte, + verify_callee_func=None): + return False + + if not self._mms_test_mo(ads): + self.log.error("MMS test fail.") + return False + + # Check if phoneA/B are attached to 5g after sending mms. + tasks = [(is_current_network_5g_nsa, [ad]) + for ad in self.android_devices] + if not multithread_func(self.log, tasks): + self.log.error("Phone not attached on 5G NSA after call.") + return False + + return True + @test_tracker_info(uuid="b6e9ce80-8577-48e5-baa7-92780932f278") @TelephonyBaseTest.tel_test_wrap def test_sms_mo_in_call_csfb(self): @@ -2144,6 +2328,7 @@ class TelLiveSmsTest(TelephonyBaseTest): def test_sms_mo_mt_iwlan_5g_nsa(self): """ Test SMS text function between two phones, Phones in APM, WiFi connected, WFC Cell Preferred mode. + Make sure airplane mode is off Set Phones are operated at 5G NSA Make sure Phones are operated at 5G NSA Make sure PhoneA/B APM, WiFi connected, WFC wifi preferred mode. @@ -2157,6 +2342,14 @@ class TelLiveSmsTest(TelephonyBaseTest): ads = self.android_devices + # Turn off airplane mode to ensure attaching to 5g nsa is working + self.log.info("Turn off APM mode before starting testing.") + tasks = [(toggle_airplane_mode, (self.log, ads[0], False)), + (toggle_airplane_mode, (self.log, ads[1], False))] + if not multithread_func(self.log, tasks): + self.log.error("Failed to turn off airplane mode") + return False + # Mode Pref tasks = [(set_preferred_mode_for_5g, [ad]) for ad in self.android_devices] @@ -2194,6 +2387,7 @@ class TelLiveSmsTest(TelephonyBaseTest): def test_mms_mo_mt_iwlan_5g_nsa(self): """ Test MMS text function between two phones, Phones in APM, WiFi connected, WFC Cell Preferred mode. + Make sure airplane mode is off Set Phones are operated at 5G NSA Make sure Phones are operated at 5G NSA Make sure PhoneA/B APM, WiFi connected, WFC wifi preferred mode. @@ -2207,6 +2401,14 @@ class TelLiveSmsTest(TelephonyBaseTest): ads = self.android_devices + # Turn off airplane mode to ensure attaching to 5g nsa is working + self.log.info("Turn off APM mode before starting testing.") + tasks = [(toggle_airplane_mode, (self.log, ads[0], False)), + (toggle_airplane_mode, (self.log, ads[1], False))] + if not multithread_func(self.log, tasks): + self.log.error("Failed to turn off airplane mode") + return False + # Mode Pref tasks = [(set_preferred_mode_for_5g, [ad]) for ad in self.android_devices] @@ -2583,7 +2785,7 @@ class TelLiveSmsTest(TelephonyBaseTest): tasks = [(ensure_wifi_connected, (self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass, 3, True)), (phone_setup_voice_general, - (self.log, ads[1]))] + (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up Properly.") return False @@ -2611,7 +2813,7 @@ class TelLiveSmsTest(TelephonyBaseTest): tasks = [(ensure_wifi_connected, (self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass, 3, True)), (phone_setup_voice_general, - (self.log, ads[1]))] + (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up Properly.") return False @@ -2639,7 +2841,7 @@ class TelLiveSmsTest(TelephonyBaseTest): tasks = [(ensure_wifi_connected, (self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass, 3, True)), (phone_setup_voice_general, - (self.log, ads[1]))] + (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up Properly.") return False @@ -2667,7 +2869,7 @@ class TelLiveSmsTest(TelephonyBaseTest): tasks = [(ensure_wifi_connected, (self.log, ads[0], self.wifi_network_ssid, self.wifi_network_pass, 3, True)), (phone_setup_voice_general, - (self.log, ads[1]))] + (self.log, ads[1]))] if not multithread_func(self.log, tasks): self.log.error("Phone Failed to Set Up Properly.") return False diff --git a/acts_tests/tests/google/usb/UsbTetheringFunctionsTest.py b/acts_tests/tests/google/usb/UsbTetheringFunctionsTest.py index 3f0393ba01..e69de29bb2 100644 --- a/acts_tests/tests/google/usb/UsbTetheringFunctionsTest.py +++ b/acts_tests/tests/google/usb/UsbTetheringFunctionsTest.py @@ -1,419 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2019 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import re -import time -from queue import Empty - -from acts import utils -from acts import base_test -from acts.libs.proc import job -from acts import signals -from acts.test_decorators import test_tracker_info -from acts.test_utils.wifi import wifi_test_utils as wutils -from acts.test_utils.tel import tel_test_utils as tutils -from acts.test_utils.tel import tel_defines -from acts.test_utils.tel.anritsu_utils import wait_for_sms_sent_success -from acts.test_utils.tel.tel_defines import EventMmsSentSuccess - -# Time it takes for the usb tethering IP to -# show up in ifconfig and function waiting. -DEFAULT_SETTLE_TIME = 5 -WifiEnums = wutils.WifiEnums -USB_CHARGE_MODE = 'svc usb setFunctions' -USB_TETHERING_MODE = 'svc usb setFunctions rndis' -USB_MTP_MODE = 'svc usb setFunctions mtp' -DEVICE_IP_ADDRESS = 'ip address' - - -class UsbTetheringFunctionsTest(base_test.BaseTestClass): - """Tests for usb tethering throughput test. - - Test Bed Requirement: - * One Android device. - * Wi-Fi networks visible to the device. - * Sim card with data call. - """ - - def setup_class(self): - self.dut = self.android_devices[0] - req_params = ['wifi_network', 'receiver_number', 'ping_count'] - self.unpack_userparams(req_param_names=req_params) - - self.ssid_map = {} - for network in self.wifi_network: - SSID = network['SSID'].replace('-', '_') - self.ssid_map[SSID] = network - self.dut.droid.setMobileDataEnabled() - if not tutils.verify_internet_connection( - self.dut.log, self.dut, retries=3): - tutils.abort_all_tests(self.dut.log, 'Internet connection Failed.') - - def setup_test(self): - self.dut.droid.wakeLockAcquireBright() - self.dut.droid.wakeUpNow() - self.dut.unlock_screen() - - def teardown_test(self): - wutils.wifi_toggle_state(self.dut, False) - self.dut.droid.wakeLockRelease() - self.dut.droid.goToSleepNow() - self.dut.droid.setMobileDataEnabled() - self.dut.droid.connectivityStopTethering(tel_defines.TETHERING_WIFI) - self.dut.stop_services() - # Set usb function back to charge mode. - self.dut.adb.shell(USB_CHARGE_MODE) - self.dut.adb.wait_for_device() - self.dut.start_services() - - def teardown_class(self): - wutils.reset_wifi(self.dut) - - def on_fail(self, test_name, begin_time): - self.dut.take_bug_report(test_name, begin_time) - self.dut.cat_adb_log(test_name, begin_time) - - def enable_usb_tethering(self, attempts=3): - """Stop SL4A service and enable usb tethering. - - Logic steps are - 1. Stop SL4A service. - 2. Enable usb tethering. - 3. Restart SL4A service. - 4. Check usb tethering enabled. - 5. Attempt if fail to enable usb tethering. - - Args: - attempts: number of times for enable usb tethering. - - Raises: - TestFailure when unable to find rndis string. - """ - for i in range(attempts): - self.dut.stop_services() - self.dut.adb.shell(USB_TETHERING_MODE, ignore_status=True) - self.dut.adb.wait_for_device() - self.dut.start_services() - if 'rndis' in self.dut.adb.shell(DEVICE_IP_ADDRESS): - self.log.info('Usb tethering is enabled.') - return - else: - self.log.info('Enable usb tethering - attempt %d' % (i + 1)) - raise signals.TestFailure('Unable to enable USB tethering.') - - def connect_to_wifi_network(self, network): - """Connection logic for wifi network. - - Args: - network: Dictionary with network info. - """ - SSID = network[WifiEnums.SSID_KEY] - self.dut.ed.clear_all_events() - wutils.start_wifi_connection_scan(self.dut) - scan_results = self.dut.droid.wifiGetScanResults() - wutils.assert_network_in_list({WifiEnums.SSID_KEY: SSID}, scan_results) - wutils.wifi_connect(self.dut, network, num_of_tries=3) - - def enable_wifi_hotspot(self): - """Enable wifi hotspot.""" - sap_config = wutils.create_softap_config() - wutils.start_wifi_tethering(self.dut, - sap_config[wutils.WifiEnums.SSID_KEY], - sap_config[wutils.WifiEnums.PWD_KEY], - wutils.WifiEnums.WIFI_CONFIG_APBAND_2G) - - def get_rndis_interface(self): - """Check rndis interface after usb tethering enable. - - Returns: - Usb tethering interface from Android device. - - Raises: - TestFailure when unable to find correct usb tethering interface. - """ - time.sleep(DEFAULT_SETTLE_TIME) - check_usb_tethering = job.run('ifconfig').stdout - # A regex that stores the tethering interface in group 1. - tethered_interface_regex = r'^(enp.*?):.*?broadcast 192.168.42.255' - match = re.search(tethered_interface_regex, check_usb_tethering, - re.DOTALL + re.MULTILINE) - if match: - return match.group(1) - else: - raise signals.TestFailure( - 'Unable to find tethering interface. The device may not be tethered.' - ) - - def can_ping(self, ip, extra_params='', count=10): - """Run ping test and check and check ping lost rate. - - Args: - ip: ip address for ping. - extra_params: params for ping test. - count: default ping count. - - Returns: - True: If no packet loss. - False: Otherwise. - """ - out = job.run( - 'ping -c {} {} {}'.format(count, extra_params, ip), - ignore_status=True).stdout - self.log.info(out) - return '0%' in out.split(' ') - - def can_ping_through_usb_interface(self): - """Run ping test and check result after usb tethering enabled. - - Raises: - TestFailure when unable to ping through usb tethering interface. - """ - ip = '8.8.8.8' - interface = self.get_rndis_interface() - if not self.can_ping( - ip, '-I {}'.format(interface), count=self.ping_count): - raise signals.TestFailure( - 'Fail to ping through usb tethering interface.') - - def enable_usb_mtp(self): - """Enable usb mtp mode. - - Raises: - TestFailure when unable to set mtp mode. - """ - try: - self.dut.stop_services() - self.dut.adb.shell(USB_MTP_MODE, ignore_status=True) - self.dut.adb.wait_for_device() - self.dut.start_services() - except: - raise signals.TestFailure('Device can not enable mtp mode.') - - def check_sms_send_status(self, message='usb_sms_test'): - """Send a SMS and check send status. - - Args: - message: SMS string. - - Raises: - Exception when unable to send SMS. - """ - self.dut.droid.smsSendTextMessage(self.receiver_number, message, False) - self.log.info('Waiting for SMS sent event') - test_status = wait_for_sms_sent_success(self.log, self.dut) - if not test_status: - raise Exception('Failed to send SMS') - - def check_mms_send_status(self, - subject='usb_subject', - message='usb_mms_test'): - """Send a MMS and check send status. - - Args: - subject: MMS subject. - message: MMS string. - - Raises: - Exception when unable to send MMS. - """ - # Permission require for send MMS. - self.dut.adb.shell('su root setenforce 0') - self.dut.droid.smsSendMultimediaMessage(self.receiver_number, subject, - message) - self.log.info('Waiting for MMS sent event') - test_status = self.wait_for_mms_sent_success() - if not test_status: - raise Exception('Failed to send MMS') - - def wait_for_mms_sent_success(self, time_to_wait=60): - """Check MMS send status. - - Args: - time_to_wait: Time out for check MMS. - - Returns: - status = MMS send status. - """ - mms_sent_event = EventMmsSentSuccess - try: - event = self.dut.ed.pop_event(mms_sent_event, time_to_wait) - self.log.info(event) - except Empty: - self.log.error('Timeout: Expected event is not received.') - return False - return True - - @test_tracker_info(uuid="7c2ae85e-32a2-416e-a65e-c15a15e76f86") - def test_usb_tethering_wifi_only(self): - """Enable usb tethering with wifi only then executing ping test. - - Steps: - 1. Stop SL4A services. - 2. Enable usb tethering. - 3. Restart SL4A services. - 4. Mobile data disable and wifi enable. - 5. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - self.log.info('Disable mobile data.') - self.dut.droid.setMobileDataEnabled(False) - self.log.info('Enable wifi.') - wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network( - self.ssid_map[self.wifi_network[0]['SSID']]) - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="8910b07b-0beb-4d9d-b901-c4195b4e0930") - def test_usb_tethering_data_only(self): - """Enable usb tethering with data only then executing ping test. - - Steps: - 1. Stop SL4A services. - 2. Enable usb tethering. - 3. Restart SL4A services. - 4. Wifi disable and mobile data enable. - 5. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - wutils.wifi_toggle_state(self.dut, False) - self.dut.droid.setMobileDataEnabled() - time.sleep(DEFAULT_SETTLE_TIME) - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="f971806e-e003-430a-bc80-321f128d31cb") - def test_usb_tethering_after_airplane_mode(self): - """Enable usb tethering after airplane mode then executing ping test. - - Steps: - 1. Stop SL4A services. - 2. Enable usb tethering. - 3. Restart SL4A services. - 4. Wifi disable and mobile data enable. - 5. Enable/disable airplane mode. - 6. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - wutils.wifi_toggle_state(self.dut, False) - self.log.info('Enable airplane mode.') - utils.force_airplane_mode(self.dut, True) - self.log.info('Disable airplane mode.') - utils.force_airplane_mode(self.dut, False) - time.sleep(DEFAULT_SETTLE_TIME) - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="db1c561d-67bd-47d7-b65e-d882f0e2641e") - def test_usb_tethering_coexist_wifi_hotspot(self): - """Enable usb tethering with hotspot then executing ping test. - - Steps: - 1. Enable hotspot - 2. Stop SL4A services. - 3. Enable usb tethering. - 4. Restart SL4A services. - 5. Run ping test through tethering interface during hotspot enable. - 6. Run ping test through tethering interface during hotspot disable. - """ - self.log.info('Enable wifi hotspot.') - self.enable_wifi_hotspot() - self.enable_usb_tethering() - self.log.info('Ping test with hotspot enable.') - self.can_ping_through_usb_interface() - self.log.info('Disable wifi hotspot.') - self.dut.droid.connectivityStopTethering(tel_defines.TETHERING_WIFI) - self.log.info('Ping test with hotspot disable.') - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="7018abdb-049e-41aa-a4f9-e11012369d9b") - def test_usb_tethering_after_mtp(self): - """Enable usb tethering after mtp enable then executing ping test. - - Steps: - 1. Stop SL4A services. - 2. Enable usb tethering. - 3. Restart SL4A services. - 4. Enable usb mtp mode. - 5. Enable usb tethering and mtp will disable. - 6. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - self.log.info('Enable usb mtp mode.') - self.enable_usb_mtp() - # Turn on mtp mode for 5 sec. - time.sleep(DEFAULT_SETTLE_TIME) - self.enable_usb_tethering() - self.log.info('Usb tethering enable, usb mtp mode disabled.') - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="f1ba2cbc-1cb2-4b8a-92eb-9b366c3f4c37") - def test_usb_tethering_after_sms_mms(self): - """Enable usb tethering after send sms and mms then executing ping test. - - Steps: - 1. Stop SL4A services. - 2. Enable usb tethering. - 3. Restart SL4A services. - 4. Send a sms and mms. - 5. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - self.log.info('Start send SMS and check status.') - self.check_sms_send_status() - time.sleep(DEFAULT_SETTLE_TIME) - self.log.info('Start send MMS and check status.') - self.check_mms_send_status() - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="e6586b30-4886-4c3e-8225-633aa9333968") - def test_usb_tethering_after_reboot(self): - """Enable usb tethering after reboot then executing ping test. - - Steps: - 1. Reboot device. - 2. Stop SL4A services. - 3. Enable usb tethering. - 4. Restart SL4A services. - 5. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - self.log.info('Reboot device.') - self.dut.reboot() - self.dut.droid.setMobileDataEnabled() - self.log.info('Start usb tethering and ping test.') - self.enable_usb_tethering() - self.can_ping_through_usb_interface() - - @test_tracker_info(uuid="40093ab8-6db4-4af4-97ae-9467bf33bf23") - def test_usb_tethering_after_wipe(self): - """Enable usb tethering after wipe. - - Steps: - 1. Enable usb tethering. - 2. Wipe device. - 3. Wake up device and unlock screen. - 4. Enable usb tethering. - 5. Run ping test through usb tethering interface. - """ - self.enable_usb_tethering() - tutils.fastboot_wipe(self.dut) - time.sleep(DEFAULT_SETTLE_TIME) - # Skip setup wizard after wipe. - self.dut.adb.shell( - 'am start -a com.android.setupwizard.EXIT', ignore_status=True) - self.dut.droid.setMobileDataEnabled() - self.dut.droid.wakeUpNow() - self.dut.unlock_screen() - self.enable_usb_tethering() - self.can_ping_through_usb_interface()
\ No newline at end of file diff --git a/acts_tests/tests/google/usb/UsbTetheringThroughputTest.py b/acts_tests/tests/google/usb/UsbTetheringThroughputTest.py index ebe13b8529..e69de29bb2 100644 --- a/acts_tests/tests/google/usb/UsbTetheringThroughputTest.py +++ b/acts_tests/tests/google/usb/UsbTetheringThroughputTest.py @@ -1,292 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright 2019 - The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import re -import time - -from acts import base_test -from acts.libs.proc import job -from acts import signals -from acts.test_decorators import test_tracker_info - -# Time it takes for the usb tethering IP to show up in ifconfig. -IFCONFIG_SETTLE_TIME = 5 -USB_CHARGE_MODE = 'svc usb setFunctions' -USB_TETHERING_MODE = 'svc usb setFunctions rndis' -DEVICE_IP_ADDRESS = 'ip address' - - -class UsbTetheringThroughputTest(base_test.BaseTestClass): - """Tests for usb tethering throughput test. - - Test Bed Requirement: - * One Android device. - * Sim card with data call. - """ - - def setup_class(self): - """ Setup devices for usb tethering """ - self.dut = self.android_devices[0] - self.ip_server = self.iperf_servers[0] - self.port_num = self.ip_server.port - req_params = [ - 'iperf_usb_3_criteria', 'iperf_usb_2_criteria', 'controller_path', - 'iperf_test_sec' - ] - self.unpack_userparams(req_param_names=req_params) - if self.dut.model in self.user_params.get('legacy_projects', []): - self.usb_controller_path = self.user_params[ - 'legacy_controller_path'] - else: - self.usb_controller_path = self.controller_path - - def setup_test(self): - self.dut.adb.wait_for_device() - self.dut.droid.wakeLockAcquireBright() - self.dut.droid.wakeUpNow() - self.dut.unlock_screen() - - def teardown_test(self): - self.dut.droid.wakeLockRelease() - self.dut.droid.goToSleepNow() - # Reboot device to avoid the side effect that cause adb missing after echo usb speed. - self.dut.reboot() - - def on_fail(self, test_name, begin_time): - self.dut.take_bug_report(test_name, begin_time) - self.dut.cat_adb_log(test_name, begin_time) - - def enable_usb_tethering(self): - """Stop SL4A service and enable usb tethering. - - Logic steps are - 1. Stop SL4A service. - 2. Enable usb tethering. - 3. Restart SL4A service. - 4. Check usb tethering enabled. - - Raises: - Signals.TestFailure is raised by not find rndis string. - """ - self.dut.stop_services() - self.dut.adb.shell(USB_TETHERING_MODE, ignore_status=True) - self.dut.adb.wait_for_device() - self.dut.start_services() - if 'rndis' not in self.dut.adb.shell(DEVICE_IP_ADDRESS): - raise signals.TestFailure('Unable to enable USB tethering.') - - def get_pc_tethering_ip(self): - """Check usb tethering IP from PC. - - Returns: - Usb tethering IP from PC. - - Raises: - Signals.TestFailure is raised by not find usb tethering IP. - """ - time.sleep(IFCONFIG_SETTLE_TIME) - check_usb_tethering = job.run('ifconfig').stdout - matches = re.findall('inet (\d+.\d+.42.\d+)', check_usb_tethering) - if not matches: - raise signals.TestFailure( - 'Unable to find tethering IP. The device may not be tethered.') - else: - return matches[0] - - def get_dut_tethering_ip(self): - """Check usb tethering IP from Android device. - - Returns: - Usb tethering IP from Android device. - - Raises: - Signals.TestFailure is raised by not find usb tethering IP. - """ - time.sleep(IFCONFIG_SETTLE_TIME) - check_usb_tethering = self.dut.adb.shell('ifconfig') - matches = re.findall('addr:(\d+.\d+.42.\d+)', check_usb_tethering) - if not matches: - raise signals.TestFailure( - 'Unable to find tethering IP. The device may not be tethered.') - else: - return matches[0] - - def pc_can_ping(self, count=3): - """Run ping traffic from PC side. - - Logic steps are - 1. PC ping the usb server ip. - 2. Check the packet loss rate. - - Args: - count : count for ping test. - - Returns: - True: If no packet loss. - False: Otherwise. - """ - ip = self.get_dut_tethering_ip() - ping = job.run( - 'ping -c {} {}'.format(count, ip), ignore_status=True).stdout - self.log.info(ping) - return '0% packet loss' in ping - - def dut_can_ping(self, count=3): - """Run ping traffic from Android device side. - - Logic steps are - 1. Android device ping the 8.8.8.8. - 2. Check the packet loss rate. - - Args: - count : count for ping test. - - Returns: - True: If no packet loss. - False: Otherwise. - """ - ip = '8.8.8.8' - ping = self.dut.adb.shell( - 'ping -c {} {}'.format(count, ip), ignore_status=True) - self.log.info(ping) - return '0% packet loss' in ping - - def run_iperf_client(self, dut_ip, extra_params=''): - """Run iperf client command after iperf server enabled. - - Args: - dut_ip: string which contains the ip address. - extra_params: params to be added to the iperf client. - - Returns: - Success: True if the iperf execute. False otherwise. - Rate: throughput data. - """ - self.log.info('Run iperf process.') - cmd = "iperf3 -c {} {} -p {}".format(dut_ip, extra_params, - self.port_num) - self.log.info(cmd) - try: - result = self.dut.adb.shell(cmd, ignore_status=True) - self.log.info(result) - except: - self.log.error('Fail to execute iperf client.') - return False, 0 - rate = re.findall('(\d+.\d+) (.)bits/sec.*receiver', result) - return True, rate[0][0], rate[0][1] - - def run_iperf_tx_rx(self, usb_speed, criteria): - """Run iperf tx and rx. - - Args: - usb_speed: string which contains the speed info. - criteria: usb performance criteria. - - Raises: - Signals.TestFailure is raised by usb tethering under criteria. - """ - self.enable_usb_tethering() - self.dut.adb.wait_for_device() - self.ip_server.start() - pc_ip = self.get_pc_tethering_ip() - tx_success, tx_rate, tx_unit = self.run_iperf_client( - pc_ip, '-t{} -i1 -w2M'.format(self.iperf_test_sec)) - rx_success, rx_rate, rx_unit = self.run_iperf_client( - pc_ip, '-t{} -i1 -w2M -R'.format(self.iperf_test_sec)) - self.log.info('TestResult iperf_{}_rx'.format(usb_speed) + rx_rate + - ' ' + rx_unit + 'bits/sec') - self.log.info('TestResult iperf_{}_tx'.format(usb_speed) + tx_rate + - ' ' + tx_unit + 'bits/sec') - self.ip_server.stop() - if not tx_success or (float(tx_rate) < criteria and tx_unit != "G"): - raise signals.TestFailure('Iperf {}_tx test is {} {}bits/sec, ' - 'the throughput result failed.'.format( - usb_speed, tx_rate, tx_unit)) - if not rx_success or (float(rx_rate) < criteria and rx_unit != "G"): - raise signals.TestFailure('Iperf {}_rx test is {} {}bits/sec, ' - 'the throughput result failed.'.format( - usb_speed, rx_rate, rx_unit)) - - def get_usb_speed(self): - """Get current usb speed.""" - usb_controller_address = self.dut.adb.shell( - 'getprop sys.usb.controller', ignore_status=True) - usb_speed = self.dut.adb.shell( - 'cat sys/class/udc/{}/current_speed'.format( - usb_controller_address)) - return usb_speed, usb_controller_address - - @test_tracker_info(uuid="e7e0dfdc-3d1c-4642-a468-27326c49e4cb") - def test_tethering_ping(self): - """Enable usb tethering then executing ping test. - - Steps: - 1. Stop SL4A service. - 2. Enable usb tethering. - 3. Restart SL4A service. - 4. Execute ping test from PC and Android Device. - 5. Check the ping lost rate. - """ - self.enable_usb_tethering() - if self.pc_can_ping() and self.dut_can_ping(): - raise signals.TestPass( - 'Ping test is passed. Network is reachable.') - raise signals.TestFailure( - 'Ping test failed. Maybe network is unreachable.') - - @test_tracker_info(uuid="8263c880-8a7e-4a68-b47f-e7caba3e9968") - def test_usb_tethering_iperf_super_speed(self): - """Enable usb tethering then executing iperf test. - - Steps: - 1. Stop SL4A service. - 2. Enable usb tethering. - 3. Restart SL4A service. - 4. Skip test if device not support super-speed. - 5. Execute iperf test for usb tethering and get the throughput result. - 6. Check the iperf throughput result. - """ - if (self.get_usb_speed()[0] != 'super-speed'): - raise signals.TestSkip( - 'USB 3 not available for the device, skip super-speed performance test.' - ) - self.run_iperf_tx_rx('usb_3', self.iperf_usb_3_criteria) - - @test_tracker_info(uuid="5d8a22fd-1f9b-4758-a6b4-855d134b348a") - def test_usb_tethering_iperf_high_speed(self): - """Enable usb tethering then executing iperf test. - - Steps: - 1. Stop SL4A service. - 2. Enable usb tethering. - 3. Restart SL4A service. - 4. Force set usb speed to high-speed if default is super-speed. - 5. Execute iperf test for usb tethering and get the throughput result. - 6. Check the iperf throughput result. - """ - if (self.get_usb_speed()[0] != 'high-speed'): - self.log.info( - 'Default usb speed is USB 3,Force set usb to high-speed.') - self.dut.stop_services() - self.dut.adb.wait_for_device() - self.dut.adb.shell( - 'echo high > {}{}.ssusb/speed'.format( - self.usb_controller_path, - self.get_usb_speed()[1].strip('.dwc3')), - ignore_status=True) - self.dut.adb.wait_for_device() - self.dut.start_services() - self.run_iperf_tx_rx('usb_2', self.iperf_usb_2_criteria) diff --git a/acts_tests/tests/google/wifi/WifiAutoUpdateTest.py b/acts_tests/tests/google/wifi/WifiAutoUpdateTest.py index 33369a2775..8e8c163bf1 100755 --- a/acts_tests/tests/google/wifi/WifiAutoUpdateTest.py +++ b/acts_tests/tests/google/wifi/WifiAutoUpdateTest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3.4 +# !/usr/bin/env python3.4 # # Copyright 2017 - The Android Open Source Project # @@ -14,22 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -import itertools -import pprint -import queue -import time - -import acts.base_test -import acts.signals as signals -import acts.test_utils.wifi.wifi_test_utils as wutils -import acts.utils - +import re from acts import asserts +from acts.controllers.android_device import SL4A_APK_NAME from acts.libs.ota import ota_updater +import acts.signals as signals from acts.test_decorators import test_tracker_info +from acts.test_utils.tel.tel_test_utils import WIFI_CONFIG_APBAND_5G +import acts.test_utils.wifi.wifi_test_utils as wutils from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest +import acts.utils as utils WifiEnums = wutils.WifiEnums +SSID = WifiEnums.SSID_KEY +PWD = WifiEnums.PWD_KEY +NETID = WifiEnums.NETID_KEY # Default timeout used for reboot, toggle WiFi and Airplane mode, # for the system to settle down after the operation. DEFAULT_TIMEOUT = 10 @@ -51,50 +50,52 @@ class WifiAutoUpdateTest(WifiBaseTest): self.tests = ( "test_check_wifi_state_after_au", "test_verify_networks_after_au", + "test_configstore_after_au", + "test_mac_randomization_after_au", + "test_wifi_hotspot_5g_psk_after_au", "test_all_networks_connectable_after_au", - "test_connection_to_new_networks", + "test_connect_to_network_suggestion_after_au", "test_check_wifi_toggling_after_au", + "test_connection_to_new_networks", "test_reset_wifi_after_au") def setup_class(self): super(WifiAutoUpdateTest, self).setup_class() ota_updater.initialize(self.user_params, self.android_devices) self.dut = self.android_devices[0] + self.dut_client = self.android_devices[1] wutils.wifi_test_device_init(self.dut) - req_params = [] - opt_param = [ - "open_network", "reference_networks", "iperf_server_address" - ] - self.unpack_userparams( - req_param_names=req_params, opt_param_names=opt_param) - - if "AccessPoint" in self.user_params: - self.legacy_configure_ap_and_start() - - asserts.assert_true( - len(self.reference_networks) > 0, - "Need at least two reference network with psk.") - asserts.assert_true( - len(self.open_network) > 0, - "Need at least two open network with psk.") wutils.wifi_toggle_state(self.dut, True) + # configure APs + self.legacy_configure_ap_and_start(wpa_network=True) + self.wpapsk_2g = self.reference_networks[0]["2g"] + self.wpapsk_5g = self.reference_networks[0]["5g"] + self.open_2g = self.open_network[0]["2g"] + self.open_5g = self.open_network[0]["5g"] + + # saved & connected networks, network suggestions + # and new networks + self.saved_networks = [self.open_2g] + self.network_suggestions = [self.wpapsk_5g] + self.connected_networks = [self.wpapsk_2g, self.open_5g] + self.new_networks = [self.reference_networks[1]["2g"], + self.open_network[1]["5g"]] + + # add pre ota upgrade configuration self.wifi_config_list = [] - - # Disabling WiFi setup before OTA for debugging. - # Setup WiFi and add few open and wpa networks before OTA. - # self.add_network_and_enable(self.open_network[0]['2g']) - # self.add_network_and_enable(self.reference_networks[0]['5g']) - - # Add few dummy networks to the list. - # self.add_and_enable_dummy_networks() + self.pre_default_mac = {} + self.pre_random_mac = {} + self.pst_default_mac = {} + self.pst_random_mac = {} + self.add_pre_update_configuration() # Run OTA below, if ota fails then abort all tests. try: ota_updater.update(self.dut) - except Exception as err: + except Exception as e: raise signals.TestAbortClass( - "Failed up apply OTA update. Aborting tests") + "Failed up apply OTA update. Aborting tests: %s" % e) def setup_test(self): self.dut.droid.wakeLockAcquireBright() @@ -113,45 +114,121 @@ class WifiAutoUpdateTest(WifiBaseTest): del self.user_params["reference_networks"] del self.user_params["open_network"] - """Helper Functions""" + ### Helper Methods + + def add_pre_update_configuration(self): + self.add_network_suggestions(self.network_suggestions) + self.add_network_and_enable(self.saved_networks[0]) + self.add_wifi_hotspot() + self.connect_to_multiple_networks(self.connected_networks) + + def add_wifi_hotspot(self): + self.wifi_hotspot = {"SSID": "hotspot_%s" % utils.rand_ascii_str(6), + "password": "pass_%s" % utils.rand_ascii_str(6)} + band = WIFI_CONFIG_APBAND_5G + if self.dut.build_info["build_id"].startswith("Q"): + band = WifiEnums.WIFI_CONFIG_APBAND_5G_OLD + self.wifi_hotspot[WifiEnums.AP_BAND_KEY] = band + asserts.assert_true( + self.dut.droid.wifiSetWifiApConfiguration(self.wifi_hotspot), + "Failed to set WifiAp Configuration") + wifi_ap = self.dut.droid.wifiGetApConfiguration() + asserts.assert_true( + wifi_ap[WifiEnums.SSID_KEY] == self.wifi_hotspot[WifiEnums.SSID_KEY], + "Hotspot SSID doesn't match with expected SSID") + return + wutils.save_wifi_soft_ap_config(self.dut, self.wifi_hotspot, band) + + def verify_wifi_hotspot(self): + """Verify wifi tethering.""" + wutils.start_wifi_tethering_saved_config(self.dut) + wutils.connect_to_wifi_network(self.dut_client, + self.wifi_hotspot, + check_connectivity=False) + wutils.stop_wifi_tethering(self.dut) + + def connect_to_multiple_networks(self, networks): + """Connect to a list of wifi networks. + + Args: + networks : list of wifi networks. + """ + self.log.info("Connect to multiple wifi networks") + for network in networks: + ssid = network[SSID] + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, ssid) + wutils.wifi_connect(self.dut, network, num_of_tries=6) + self.wifi_config_list.append(network) + self.pre_default_mac[network[SSID]] = self.get_sta_mac_address() + self.pre_random_mac[network[SSID]] = \ + self.dut.droid.wifigetRandomizedMacAddress(network) + + def get_sta_mac_address(self): + """Gets the current MAC address being used for client mode.""" + out = self.dut.adb.shell("ifconfig wlan0") + res = re.match(".* HWaddr (\S+).*", out, re.S) + return res.group(1) + + def add_network_suggestions(self, network_suggestions): + """Add wifi network suggestions to DUT. + + Args: + network_suggestions : suggestions to add. + """ + self.dut.log.info("Adding network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions(network_suggestions), + "Failed to add suggestions") + + # Enable suggestions by the app. + self.dut.log.debug("Enabling suggestions from test") + self.dut.adb.shell( + "cmd wifi network-suggestions-set-user-approved %s yes" % \ + SL4A_APK_NAME) + + def remove_suggestions_and_ensure_no_connection(self, + network_suggestions, + expected_ssid): + """Remove network suggestions. + + Args: + network_suggestions : suggestions to remove. + expected_ssid : SSID to verify that DUT is not connected. + """ + # remove network suggestion and verify disconnect + self.dut.log.info("Removing network suggestions") + asserts.assert_true( + self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), + "Failed to remove suggestions") + + wutils.wait_for_disconnect(self.dut) + self.dut.ed.clear_all_events() + + # Now ensure that we didn't connect back. + asserts.assert_false( + wutils.wait_for_connect(self.dut, + expected_ssid, + assert_on_fail=False), + "Device should not connect back") def add_network_and_enable(self, network): """Add a network and enable it. Args: network : Network details for the network to be added. - """ + self.log.info("Add a wifi network and enable it") ret = self.dut.droid.wifiAddNetwork(network) asserts.assert_true(ret != -1, "Add network %r failed" % network) - self.wifi_config_list.append({ - WifiEnums.SSID_KEY: network[WifiEnums.SSID_KEY], - WifiEnums.NETID_KEY: ret}) + self.wifi_config_list.append({SSID: network[SSID], NETID: ret}) self.dut.droid.wifiEnableNetwork(ret, 0) - def add_and_enable_dummy_networks(self, num_networks=5): - """Add some dummy networks to the device and enable them. - - Args: - num_networks: Number of networks to add. - """ - ssid_name_base = "dummy_network_" - for i in range(0, num_networks): - network = {} - network[WifiEnums.SSID_KEY] = ssid_name_base + str(i) - network[WifiEnums.PWD_KEY] = "dummynet_password" - self.add_network_and_enable(network) - def check_networks_after_autoupdate(self, networks): - """Verify that all previously configured networks are presistent after - reboot. + """Verify that all previously configured networks are persistent. Args: networks: List of network dicts. - - Return: - None. Raises TestFailure. - """ network_info = self.dut.droid.wifiGetConfiguredNetworks() if len(network_info) != len(networks): @@ -160,21 +237,35 @@ class WifiAutoUpdateTest(WifiBaseTest): "don't match. \nBefore reboot = %s \n After reboot = %s" % (networks, network_info)) raise signals.TestFailure(msg) - current_count = 0 + # For each network, check if it exists in configured list after Auto- # update. for network in networks: - exists = wutils.match_networks({ - WifiEnums.SSID_KEY: network[WifiEnums.SSID_KEY] - }, network_info) - if not len(exists): + exists = wutils.match_networks({SSID: network[SSID]}, network_info) + if not exists: raise signals.TestFailure("%s network is not present in the" " configured list after Auto-update" % - network[WifiEnums.SSID_KEY]) + network[SSID]) # Get the new network id for each network after reboot. - network[WifiEnums.NETID_KEY] = exists[0]['networkId'] + network[NETID] = exists[0]["networkId"] - """Tests""" + def get_enabled_network(self, network1, network2): + """Check network status and return currently unconnected network. + + Args: + network1: dict representing a network. + network2: dict representing a network. + + Returns: + Network dict of the unconnected network. + """ + wifi_info = self.dut.droid.wifiGetConnectionInfo() + enabled = network1 + if wifi_info[SSID] == network1[SSID]: + enabled = network2 + return enabled + + ### Tests @test_tracker_info(uuid="9ff1f01e-e5ff-408b-9a95-29e87a2df2d8") def test_check_wifi_state_after_au(self): @@ -192,6 +283,78 @@ class WifiAutoUpdateTest(WifiBaseTest): """ self.check_networks_after_autoupdate(self.wifi_config_list) + @test_tracker_info(uuid="799e83c2-305d-4510-921e-dac3c0dbb6c5") + def test_configstore_after_au(self): + """Verify DUT automatically connects to wifi networks after ota. + + Steps: + 1. Connect to two wifi networks pre ota. + 2. Verify DUT automatically connects to 1 after ota. + 3. Re-connect to the other wifi network. + """ + wifi_info = self.dut.droid.wifiGetConnectionInfo() + self.pst_default_mac[wifi_info[SSID]] = self.get_sta_mac_address() + self.pst_random_mac[wifi_info[SSID]] = \ + self.dut.droid.wifigetRandomizedMacAddress(wifi_info) + reconnect_to = self.get_enabled_network(self.wifi_config_list[1], + self.wifi_config_list[2]) + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, reconnect_to[SSID]) + wutils.wifi_connect_by_id(self.dut, reconnect_to[NETID]) + connect_data = self.dut.droid.wifiGetConnectionInfo() + connect_ssid = connect_data[SSID] + self.log.info("Expected SSID = %s" % reconnect_to[SSID]) + self.log.info("Connected SSID = %s" % connect_ssid) + if connect_ssid != reconnect_to[SSID]: + raise signals.TestFailure( + "Device failed to reconnect to the correct" + " network after reboot.") + self.pst_default_mac[wifi_info[SSID]] = self.get_sta_mac_address() + self.pst_random_mac[wifi_info[SSID]] = \ + self.dut.droid.wifigetRandomizedMacAddress(wifi_info) + + for network in self.connected_networks: + wutils.wifi_forget_network(self.dut, network[SSID]) + + @test_tracker_info(uuid="e26d0ed9-9457-4a95-a962-4d43b0032bac") + def test_mac_randomization_after_au(self): + """Verify randomized MAC addrs are persistent after ota. + + Steps: + 1. Reconnect to the wifi networks configured pre ota. + 2. Get the randomized MAC addrs. + """ + for ssid, mac in self.pst_random_mac.items(): + asserts.assert_true( + self.pre_random_mac[ssid] == mac, + "MAC addr of %s is %s after ota. Expected %s" % + (ssid, mac, self.pre_random_mac[ssid])) + + @test_tracker_info(uuid="f68a65e6-97b7-4746-bad8-4c206551d87e") + def test_wifi_hotspot_5g_psk_after_au(self): + """Verify hotspot after ota upgrade. + + Steps: + 1. Start wifi hotspot on the saved config. + 2. Verify DUT client connects to it. + """ + self.verify_wifi_hotspot() + + @test_tracker_info(uuid="21f91372-88a6-44b9-a4e8-d4664823dffb") + def test_connect_to_network_suggestion_after_au(self): + """Verify connection to network suggestion after ota. + + Steps: + 1. DUT has network suggestion added before OTA. + 2. Wait for the device to connect to it. + 3. Remove the suggestions and ensure the device does not + connect back. + """ + wutils.start_wifi_connection_scan_and_return_status(self.dut) + wutils.wait_for_connect(self.dut, self.network_suggestions[0][SSID]) + self.remove_suggestions_and_ensure_no_connection( + self.network_suggestions, self.network_suggestions[0][SSID]) + @test_tracker_info(uuid="b8e47a4f-62fe-4a0e-b999-27ae1ebf4d19") def test_connection_to_new_networks(self): """Check if we can connect to new networks after Auto-update. @@ -201,14 +364,11 @@ class WifiAutoUpdateTest(WifiBaseTest): 2. Connect to an open network. 3. Forget ntworks added in 1 & 2. TODO: (@bmahadev) Add WEP network once it's ready. - """ - wutils.connect_to_wifi_network(self.dut, self.open_network[0]['5g']) - wutils.connect_to_wifi_network(self.dut, self.reference_networks[0]['2g']) - wutils.wifi_forget_network(self.dut, - self.reference_networks[0]['2g'][WifiEnums.SSID_KEY]) - wutils.wifi_forget_network(self.dut, - self.open_network[0]['5g'][WifiEnums.SSID_KEY]) + for network in self.new_networks: + wutils.connect_to_wifi_network(self.dut, network) + for network in self.new_networks: + wutils.wifi_forget_network(self.dut, network[SSID]) @test_tracker_info(uuid="1d8309e4-d5a2-4f48-ba3b-895a58c9bf3a") def test_all_networks_connectable_after_au(self): @@ -218,15 +378,14 @@ class WifiAutoUpdateTest(WifiBaseTest): 1. Connect to previously added PSK network using network id. 2. Connect to previously added open network using network id. TODO: (@bmahadev) Add WEP network once it's ready. - """ - for network in self.wifi_config_list: - if 'dummy' not in network[WifiEnums.SSID_KEY]: - if not wutils.connect_to_wifi_network_with_id(self.dut, - network[WifiEnums.NETID_KEY], - network[WifiEnums.SSID_KEY]): - raise signals.TestFailure("Failed to connect to %s after \ - Auto-update" % network[WifiEnums.SSID_KEY]) + network = self.wifi_config_list[0] + if not wutils.connect_to_wifi_network_with_id(self.dut, + network[NETID], + network[SSID]): + raise signals.TestFailure("Failed to connect to %s after OTA" % + network[SSID]) + wutils.wifi_forget_network(self.dut, network[SSID]) @test_tracker_info(uuid="05671859-38b1-4dbf-930c-18048971d075") def test_check_wifi_toggling_after_au(self): diff --git a/acts_tests/tests/google/wifi/WifiCrashTest.py b/acts_tests/tests/google/wifi/WifiCrashTest.py index d43a0b9c0c..e6cbe2e86b 100644 --- a/acts_tests/tests/google/wifi/WifiCrashTest.py +++ b/acts_tests/tests/google/wifi/WifiCrashTest.py @@ -29,9 +29,8 @@ from acts.test_decorators import test_tracker_info from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest WifiEnums = wutils.WifiEnums -# Default timeout used for reboot, toggle WiFi and Airplane mode, -# for the system to settle down after the operation. -DEFAULT_TIMEOUT = 10 +# Timeout used for crash recovery. +RECOVERY_TIMEOUT = 15 WIFICOND_KILL_SHELL_COMMAND = "killall wificond" WIFI_VENDOR_HAL_KILL_SHELL_COMMAND = "killall android.hardware.wifi@1.0-service vendor.google.wifi_ext@1.0-service-vendor" SUPPLICANT_KILL_SHELL_COMMAND = "killall wpa_supplicant" @@ -100,7 +99,7 @@ class WifiCrashTest(WifiBaseTest): self.dut.restart_runtime() # We won't get the disconnect broadcast because framework crashed. # wutils.wait_for_disconnect(self.dut) - time.sleep(DEFAULT_TIMEOUT) + time.sleep(RECOVERY_TIMEOUT) wifi_info = self.dut.droid.wifiGetConnectionInfo() if wifi_info[WifiEnums.SSID_KEY] != self.network[WifiEnums.SSID_KEY]: raise signals.TestFailure("Device did not connect to the" @@ -123,7 +122,7 @@ class WifiCrashTest(WifiBaseTest): self.log.info("Crashing wificond") self.dut.adb.shell(WIFICOND_KILL_SHELL_COMMAND) wutils.wait_for_disconnect(self.dut) - time.sleep(DEFAULT_TIMEOUT) + time.sleep(RECOVERY_TIMEOUT) wifi_info = self.dut.droid.wifiGetConnectionInfo() if wifi_info[WifiEnums.SSID_KEY] != self.network[WifiEnums.SSID_KEY]: raise signals.TestFailure("Device did not connect to the" @@ -146,7 +145,7 @@ class WifiCrashTest(WifiBaseTest): self.log.info("Crashing wifi HAL") self.dut.adb.shell(WIFI_VENDOR_HAL_KILL_SHELL_COMMAND) wutils.wait_for_disconnect(self.dut) - time.sleep(DEFAULT_TIMEOUT) + time.sleep(RECOVERY_TIMEOUT) wifi_info = self.dut.droid.wifiGetConnectionInfo() if wifi_info[WifiEnums.SSID_KEY] != self.network[WifiEnums.SSID_KEY]: raise signals.TestFailure("Device did not connect to the" @@ -169,7 +168,7 @@ class WifiCrashTest(WifiBaseTest): self.log.info("Crashing wpa_supplicant") self.dut.adb.shell(SUPPLICANT_KILL_SHELL_COMMAND) wutils.wait_for_disconnect(self.dut) - time.sleep(DEFAULT_TIMEOUT) + time.sleep(RECOVERY_TIMEOUT) wifi_info = self.dut.droid.wifiGetConnectionInfo() if wifi_info[WifiEnums.SSID_KEY] != self.network[WifiEnums.SSID_KEY]: raise signals.TestFailure("Device did not connect to the" diff --git a/acts_tests/tests/google/wifi/WifiDppTest.py b/acts_tests/tests/google/wifi/WifiDppTest.py index 42591b03f2..85d25239fa 100644 --- a/acts_tests/tests/google/wifi/WifiDppTest.py +++ b/acts_tests/tests/google/wifi/WifiDppTest.py @@ -49,19 +49,33 @@ class WifiDppTest(WifiBaseTest): DPP_TEST_MESSAGE_TYPE = "Type" DPP_TEST_MESSAGE_STATUS = "Status" DPP_TEST_MESSAGE_NETWORK_ID = "NetworkId" + DPP_TEST_MESSAGE_FAILURE_SSID = "onFailureSsid" + DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST = "onFailureChannelList" + DPP_TEST_MESSAGE_FAILURE_BAND_LIST = "onFailureBandList" DPP_TEST_NETWORK_ROLE_STA = "sta" DPP_TEST_NETWORK_ROLE_AP = "ap" + DPP_TEST_PARAM_SSID = "SSID" + DPP_TEST_PARAM_PASSWORD = "Password" + WPA_SUPPLICANT_SECURITY_SAE = "sae" WPA_SUPPLICANT_SECURITY_PSK = "psk" + DPP_EVENT_PROGRESS_AUTHENTICATION_SUCCESS = 0 + DPP_EVENT_PROGRESS_RESPONSE_PENDING = 1 + DPP_EVENT_PROGRESS_CONFIGURATION_SENT_WAITING_RESPONSE = 2 + DPP_EVENT_PROGRESS_CONFIGURATION_ACCEPTED = 3 + + DPP_EVENT_SUCCESS_CONFIGURATION_SENT = 0 + DPP_EVENT_SUCCESS_CONFIGURATION_APPLIED = 1 + def setup_class(self): """ Sets up the required dependencies from the config file and configures the device for WifiService API tests. Returns: - True is successfully configured the requirements for testig. + True is successfully configured the requirements for testing. """ # Device 0 is under test. Device 1 performs the responder role @@ -75,6 +89,41 @@ class WifiDppTest(WifiBaseTest): utils.require_sl4a((self.dut,)) utils.sync_device_time(self.dut) + req_params = ["dpp_r1_test_only"] + opt_param = ["wifi_psk_network", "wifi_sae_network"] + self.unpack_userparams( + req_param_names=req_params, opt_param_names=opt_param) + + self.dut.log.info( + "Parsed configs: %s %s" % (self.wifi_psk_network, self.wifi_sae_network)) + + # Set up the networks. This is optional. In case these networks are not initialized, + # the script will create random ones. However, a real AP is required to pass DPP R2 test. + # Most efficient setup would be to use an AP in WPA2/WPA3 transition mode. + if self.DPP_TEST_PARAM_SSID in self.wifi_psk_network: + self.psk_network_ssid = self.wifi_psk_network[self.DPP_TEST_PARAM_SSID] + else: + self.psk_network_ssid = None + + if self.DPP_TEST_PARAM_PASSWORD in self.wifi_psk_network: + self.psk_network_password = self.wifi_psk_network[self.DPP_TEST_PARAM_PASSWORD] + else: + self.psk_network_ssid = None + + if self.DPP_TEST_PARAM_SSID in self.wifi_sae_network: + self.sae_network_ssid = self.wifi_sae_network[self.DPP_TEST_PARAM_SSID] + else: + self.sae_network_ssid = None + + if self.DPP_TEST_PARAM_PASSWORD in self.wifi_sae_network: + self.sae_network_password = self.wifi_sae_network[self.DPP_TEST_PARAM_PASSWORD] + else: + self.sae_network_ssid = None + + if self.dpp_r1_test_only == "False": + if not self.wifi_psk_network or not self.wifi_sae_network: + asserts.fail("Must specify wifi_psk_network and wifi_sae_network for DPP R2 tests") + # Enable verbose logging on the dut self.dut.droid.wifiEnableVerboseLogging(1) asserts.assert_true(self.dut.droid.wifiGetVerboseLoggingLevel() == 1, @@ -87,18 +136,42 @@ class WifiDppTest(WifiBaseTest): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) - def create_and_save_wifi_network_config(self, security): + def create_and_save_wifi_network_config(self, security, random_network=False, + r2_auth_error=False): """ Create a config with random SSID and password. Args: security: Security type: PSK or SAE + random_network: A boolean that indicates if to create a random network + r2_auth_error: A boolean that indicates if to create a network with a bad password Returns: A tuple with the config and networkId for the newly created and saved network. """ - config_ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8) - config_password = utils.rand_ascii_str(8) + if security == self.DPP_TEST_SECURITY_PSK: + if self.psk_network_ssid is None or self.psk_network_password is None or \ + random_network is True: + config_ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8) + config_password = utils.rand_ascii_str(8) + else: + config_ssid = self.psk_network_ssid + if r2_auth_error: + config_password = utils.rand_ascii_str(8) + else: + config_password = self.psk_network_password + else: + if self.sae_network_ssid is None or self.sae_network_password is None or \ + random_network is True: + config_ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8) + config_password = utils.rand_ascii_str(8) + else: + config_ssid = self.sae_network_ssid + if r2_auth_error: + config_password = utils.rand_ascii_str(8) + else: + config_password = self.sae_network_password + self.dut.log.info( "creating config: %s %s %s" % (config_ssid, config_password, security)) config = { @@ -231,9 +304,9 @@ class WifiDppTest(WifiBaseTest): cmd = "wpa_cli DPP_BOOTSTRAP_REMOVE %s" % uri_id result = device.adb.shell(cmd) - if "FAIL" in result: - asserts.fail("del_uri: Failed to delete URI. Command used: %s" % cmd) - device.log.info("Deleted URI, id = %s" % uri_id) + # If URI was already flushed, ignore a failure here + if "FAIL" not in result: + device.log.info("Deleted URI, id = %s" % uri_id) def start_responder_configurator(self, device, @@ -269,15 +342,23 @@ class WifiDppTest(WifiBaseTest): self.log.warning("SAE not supported on device! reverting to PSK") security = self.DPP_TEST_SECURITY_PSK_PASSPHRASE + ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8) + password = utils.rand_ascii_str(8) + if security == self.DPP_TEST_SECURITY_SAE: conf += self.WPA_SUPPLICANT_SECURITY_SAE + if not self.sae_network_ssid is None: + ssid = self.sae_network_ssid + password = self.sae_network_password elif security == self.DPP_TEST_SECURITY_PSK_PASSPHRASE: conf += self.WPA_SUPPLICANT_SECURITY_PSK + if not self.psk_network_ssid is None: + ssid = self.psk_network_ssid + password = self.psk_network_password else: conf += self.WPA_SUPPLICANT_SECURITY_PSK use_psk = True - ssid = self.DPP_TEST_SSID_PREFIX + utils.rand_ascii_str(8) self.log.debug("SSID = %s" % ssid) ssid_encoded = binascii.hexlify(ssid.encode()).decode() @@ -291,7 +372,6 @@ class WifiDppTest(WifiBaseTest): psk_encoded = psk self.log.debug("PSK = %s" % psk) else: - password = utils.rand_ascii_str(8) if not invalid_config: password_encoded = binascii.b2a_hex(password.encode()).decode() else: @@ -356,9 +436,11 @@ class WifiDppTest(WifiBaseTest): if "FAIL" in result: asserts.fail("start_responder_enrollee: Failure. Command used: %s" % cmd) + device.adb.shell("wpa_cli set dpp_config_processing 2") + device.log.info("Started responder in enrollee mode") - def stop_responder(self, device): + def stop_responder(self, device, flush=False): """Stop responder on helper device Args: @@ -368,7 +450,9 @@ class WifiDppTest(WifiBaseTest): if "FAIL" in result: asserts.fail("stop_responder: Failed to stop responder") device.adb.shell("wpa_cli set dpp_configurator_params") - + device.adb.shell("wpa_cli set dpp_config_processing 0") + if flush: + device.adb.shell("wpa_cli flush") device.log.info("Stopped responder") def start_dpp_as_initiator_configurator(self, @@ -379,7 +463,9 @@ class WifiDppTest(WifiBaseTest): net_role=DPP_TEST_NETWORK_ROLE_STA, cause_timeout=False, fail_authentication=False, - invalid_uri=False): + invalid_uri=False, + r2_no_ap=False, + r2_auth_error=False): """ Test Easy Connect (DPP) as initiator configurator. 1. Enable wifi, if needed @@ -406,13 +492,16 @@ class WifiDppTest(WifiBaseTest): fail_authentication: Fail authentication by corrupting the responder's key invalid_uri: Use garbage string instead of a URI + r2_no_ap: Indicates if to test DPP R2 no AP failure event + r2_auth_error: Indicates if to test DPP R2 authentication failure """ if not self.dut.droid.wifiIsEasyConnectSupported(): self.log.warning("Easy Connect is not supported on device!") return wutils.wifi_toggle_state(self.dut, True) - test_network_id = self.create_and_save_wifi_network_config(security) + test_network_id = self.create_and_save_wifi_network_config(security, random_network=r2_no_ap, + r2_auth_error=r2_auth_error) if use_mac: mac = autils.get_mac_addr(self.helper_dev, "wlan0") @@ -454,34 +543,57 @@ class WifiDppTest(WifiBaseTest): == self.DPP_TEST_EVENT_ENROLLEE_SUCCESS: asserts.fail("DPP failure, unexpected result!") break - if dut_event[self.DPP_TEST_EVENT_DATA][ - self - .DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_CONFIGURATOR_SUCCESS: - if cause_timeout or fail_authentication or invalid_uri: + if dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_TYPE] \ + == self.DPP_TEST_EVENT_CONFIGURATOR_SUCCESS: + if cause_timeout or fail_authentication or invalid_uri or r2_no_ap or r2_auth_error: asserts.fail( "Unexpected DPP success, status code: %s" % dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS]) else: val = dut_event[self.DPP_TEST_EVENT_DATA][ self.DPP_TEST_MESSAGE_STATUS] - if val == 0: + if val == self.DPP_EVENT_SUCCESS_CONFIGURATION_SENT: self.dut.log.info("DPP Configuration sent success") + if val == self.DPP_EVENT_SUCCESS_CONFIGURATION_APPLIED: + self.dut.log.info("DPP Configuration applied by enrollee") break - if dut_event[self.DPP_TEST_EVENT_DATA][ - self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_PROGRESS: + if dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_TYPE] \ + == self.DPP_TEST_EVENT_PROGRESS: self.dut.log.info("DPP progress event") val = dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS] - if val == 0: + if val == self.DPP_EVENT_PROGRESS_AUTHENTICATION_SUCCESS: self.dut.log.info("DPP Authentication success") - elif val == 1: + elif val == self.DPP_EVENT_PROGRESS_RESPONSE_PENDING: self.dut.log.info("DPP Response pending") + elif val == self.DPP_EVENT_PROGRESS_CONFIGURATION_SENT_WAITING_RESPONSE: + self.dut.log.info("DPP Configuration sent, waiting response") + elif val == self.DPP_EVENT_PROGRESS_CONFIGURATION_ACCEPTED: + self.dut.log.info("Configuration accepted") continue if dut_event[self.DPP_TEST_EVENT_DATA][ self.DPP_TEST_MESSAGE_TYPE] == self.DPP_TEST_EVENT_FAILURE: - if cause_timeout or fail_authentication or invalid_uri: + if cause_timeout or fail_authentication or invalid_uri or r2_no_ap or r2_auth_error: self.dut.log.info( "Error %s occurred, as expected" % dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_STATUS]) + if r2_no_ap or r2_auth_error: + if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_SSID]: + asserts.fail("Expected SSID value in DPP R2 onFailure event") + self.dut.log.info( + "Enrollee searched for SSID %s" % + dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_SSID]) + if r2_no_ap: + if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST]: + asserts.fail("Expected Channel list value in DPP R2 onFailure event") + self.dut.log.info( + "Enrollee scanned the following channels: %s" % + dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_CHANNEL_LIST]) + if r2_no_ap or r2_auth_error: + if not dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_BAND_LIST]: + asserts.fail("Expected Band Support list value in DPP R2 onFailure event") + self.dut.log.info( + "Enrollee supports the following bands: %s" % + dut_event[self.DPP_TEST_EVENT_DATA][self.DPP_TEST_MESSAGE_FAILURE_BAND_LIST]) else: asserts.fail( "DPP failure, status code: %s" % @@ -492,7 +604,7 @@ class WifiDppTest(WifiBaseTest): self.dut.ed.clear_all_events() # Stop responder - self.stop_responder(self.helper_dev) + self.stop_responder(self.helper_dev, flush=True) if not invalid_uri: # Delete URI @@ -607,7 +719,7 @@ class WifiDppTest(WifiBaseTest): self.dut.ed.clear_all_events() # Stop responder - self.stop_responder(self.helper_dev) + self.stop_responder(self.helper_dev, flush=True) # Delete URI self.del_uri(self.helper_dev, uri_id) @@ -792,4 +904,18 @@ class WifiDppTest(WifiBaseTest): use_mac=True, cause_timeout=True) - """ Tests End """ + @test_tracker_info(uuid="23601af8-118e-4ba8-89e3-5da2e37bbd7d") + def test_dpp_as_initiator_configurator_fail_r2_no_ap(self): + asserts.skip_if(self.dpp_r1_test_only == "True", + "DPP R1 test, skipping this test for DPP R2 only") + self.start_dpp_as_initiator_configurator( + security=self.DPP_TEST_SECURITY_PSK, use_mac=True, r2_no_ap=True) + + @test_tracker_info(uuid="7f9756d3-f28f-498e-8dcf-ac3816303998") + def test_dpp_as_initiator_configurator_fail_r2_auth_error(self): + asserts.skip_if(self.dpp_r1_test_only == "True", + "DPP R1 test, skipping this test for DPP R2 only") + self.start_dpp_as_initiator_configurator( + security=self.DPP_TEST_SECURITY_PSK, use_mac=True, r2_auth_error=True) + +""" Tests End """ diff --git a/acts_tests/tests/google/wifi/WifiEnterpriseTest.py b/acts_tests/tests/google/wifi/WifiEnterpriseTest.py index 6ba5eb4fb5..a76f5684ec 100644 --- a/acts_tests/tests/google/wifi/WifiEnterpriseTest.py +++ b/acts_tests/tests/google/wifi/WifiEnterpriseTest.py @@ -55,7 +55,8 @@ class WifiEnterpriseTest(WifiBaseTest): "radius_conf_pwd") self.unpack_userparams(required_userparam_names, roaming_consortium_ids=None, - plmn=None) + plmn=None, + ocsp=0) if "AccessPoint" in self.user_params: self.legacy_configure_ap_and_start( @@ -76,6 +77,7 @@ class WifiEnterpriseTest(WifiBaseTest): Ent.PASSWORD: self.eap_password, Ent.PHASE2: int(EapPhase2.MSCHAPV2), WifiEnums.SSID_KEY: self.ent_network_5g[WifiEnums.SSID_KEY], + Ent.OCSP: self.ocsp, } self.config_peap1 = dict(self.config_peap0) self.config_peap1[WifiEnums.SSID_KEY] = \ @@ -87,6 +89,7 @@ class WifiEnterpriseTest(WifiBaseTest): Ent.CLIENT_CERT: self.client_cert, Ent.PRIVATE_KEY_ID: self.client_key, Ent.IDENTITY: self.eap_identity, + Ent.OCSP: self.ocsp, } self.config_ttls = { Ent.EAP: int(EAP.TTLS), @@ -95,6 +98,7 @@ class WifiEnterpriseTest(WifiBaseTest): Ent.PASSWORD: self.eap_password, Ent.PHASE2: int(EapPhase2.MSCHAPV2), WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + Ent.OCSP: self.ocsp, } self.config_pwd = { Ent.EAP: int(EAP.PWD), diff --git a/acts_tests/tests/google/wifi/WifiLinkProbeTest.py b/acts_tests/tests/google/wifi/WifiLinkProbeTest.py index 7e6d58ffd7..fdf81787bc 100644 --- a/acts_tests/tests/google/wifi/WifiLinkProbeTest.py +++ b/acts_tests/tests/google/wifi/WifiLinkProbeTest.py @@ -47,6 +47,7 @@ class WifiLinkProbeTest(WifiBaseTest): if "AccessPoint" in self.user_params: self.legacy_configure_ap_and_start() + self.configure_packet_capture() asserts.assert_true(len(self.reference_networks) > 0, "Need at least one reference network with psk.") @@ -58,13 +59,19 @@ class WifiLinkProbeTest(WifiBaseTest): wutils.wifi_toggle_state(self.dut, True) self.attenuators[0].set_atten(0) self.attenuators[1].set_atten(0) + self.pcap_procs = wutils.start_pcap( + self.packet_capture, 'dual', self.test_name) def teardown_test(self): self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() wutils.reset_wifi(self.dut) + def on_pass(self, test_name, begin_time): + wutils.stop_pcap(self.packet_capture, self.pcap_procs, True) + def on_fail(self, test_name, begin_time): + wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) diff --git a/acts_tests/tests/google/wifi/WifiMacRandomizationTest.py b/acts_tests/tests/google/wifi/WifiMacRandomizationTest.py index 68cf85417c..cfbd0a3926 100644 --- a/acts_tests/tests/google/wifi/WifiMacRandomizationTest.py +++ b/acts_tests/tests/google/wifi/WifiMacRandomizationTest.py @@ -66,7 +66,7 @@ class WifiMacRandomizationTest(WifiBaseTest): self.dut_client = self.android_devices[1] wutils.wifi_test_device_init(self.dut) wutils.wifi_test_device_init(self.dut_client) - req_params = ["dbs_supported_models"] + req_params = ["dbs_supported_models", "roaming_attn"] opt_param = [ "open_network", "reference_networks", "wep_networks" ] @@ -79,8 +79,7 @@ class WifiMacRandomizationTest(WifiBaseTest): self.configure_packet_capture() if "AccessPoint" in self.user_params: - if "AccessPoint" in self.user_params: - self.legacy_configure_ap_and_start(wep_network=True, ap_count=2) + self.legacy_configure_ap_and_start(wep_network=True, ap_count=2) asserts.assert_true( len(self.reference_networks) > 0, @@ -242,8 +241,9 @@ class WifiMacRandomizationTest(WifiBaseTest): for pkt in packets: self.log.debug("Packet Summary = %s" % pkt.summary()) if mac in pkt.summary(): - raise signals.TestFailure("Caught Factory MAC in packet sniffer." - "Packet = %s" % pkt.show()) + raise signals.TestFailure("Caught Factory MAC in packet sniffer" + "Packet = %s Device = %s" + % (pkt.show(), self.dut)) def verify_mac_is_found_in_pcap(self, mac, packets): for pkt in packets: @@ -251,7 +251,7 @@ class WifiMacRandomizationTest(WifiBaseTest): if mac in pkt.summary(): return raise signals.TestFailure("Did not find MAC = %s in packet sniffer." - % mac) + "for device %s" % (mac, self.dut)) def get_sta_mac_address(self): """Gets the current MAC address being used for client mode.""" @@ -348,7 +348,7 @@ class WifiMacRandomizationTest(WifiBaseTest): """ self.check_mac_persistence(self.wpapsk_2g, TOGGLE) - @test_tracker_info(uuid="a514f-8562-44e8-bfe0-4ecab9af165b") + @test_tracker_info(uuid="b3aa514f-8562-44e8-bfe0-4ecab9af165b") def test_persistent_mac_after_device_reboot(self): """Check if MAC is persistent after a device reboot. @@ -490,18 +490,18 @@ class WifiMacRandomizationTest(WifiBaseTest): """ AP1_network = self.reference_networks[0]["5g"] AP2_network = self.reference_networks[1]["5g"] - wutils.set_attns(self.attenuators, "AP1_on_AP2_off") + wutils.set_attns(self.attenuators, "AP1_on_AP2_off", self.roaming_attn) mac_before_roam = self.connect_to_network_and_verify_mac_randomization( AP1_network) wutils.trigger_roaming_and_validate(self.dut, self.attenuators, - "AP1_off_AP2_on", AP2_network) + "AP1_off_AP2_on", AP2_network, self.roaming_attn) mac_after_roam = self.get_randomized_mac(AP2_network) if mac_after_roam != mac_before_roam: raise signals.TestFailure("Randomized MAC address changed after " "roaming from AP1 to AP2.\nMAC before roam = %s\nMAC after " "roam = %s" %(mac_before_roam, mac_after_roam)) wutils.trigger_roaming_and_validate(self.dut, self.attenuators, - "AP1_on_AP2_off", AP1_network) + "AP1_on_AP2_off", AP1_network, self.roaming_attn) mac_after_roam = self.get_randomized_mac(AP1_network) if mac_after_roam != mac_before_roam: raise signals.TestFailure("Randomized MAC address changed after " diff --git a/acts_tests/tests/google/wifi/WifiManagerTest.py b/acts_tests/tests/google/wifi/WifiManagerTest.py index a4ef011f35..d7107ca9e4 100644 --- a/acts_tests/tests/google/wifi/WifiManagerTest.py +++ b/acts_tests/tests/google/wifi/WifiManagerTest.py @@ -90,6 +90,8 @@ class WifiManagerTest(WifiBaseTest): ad.droid.wakeLockRelease() ad.droid.goToSleepNow() self.turn_location_off_and_scan_toggle_off() + if self.dut.droid.wifiIsApEnabled(): + wutils.stop_wifi_tethering(self.dut) wutils.reset_wifi(self.dut) if self.dut_client: wutils.reset_wifi(self.dut_client) @@ -97,6 +99,8 @@ class WifiManagerTest(WifiBaseTest): def on_fail(self, test_name, begin_time): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) + if self.dut_client: + self.dut_client.take_bug_report(test_name, begin_time) def teardown_class(self): if "AccessPoint" in self.user_params: @@ -568,6 +572,24 @@ class WifiManagerTest(WifiBaseTest): wutils.start_wifi_connection_scan_and_ensure_network_found( self.dut, ssid) + @test_tracker_info(uuid="558652de-c802-405f-b9dc-b7fcc9237673") + def test_scan_after_reboot_with_wifi_off_and_location_scan_on(self): + """Put wifi in scan only mode""" + self.turn_location_on_and_scan_toggle_on() + wutils.wifi_toggle_state(self.dut, False) + + # Reboot the device. + self.dut.reboot() + time.sleep(DEFAULT_TIMEOUT) + + """Test wifi connection scan can start and find expected networks.""" + ssid = self.open_network_2g[WifiEnums.SSID_KEY] + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, ssid) + ssid = self.open_network_5g[WifiEnums.SSID_KEY] + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, ssid) + @test_tracker_info(uuid="770caebe-bcb1-43ac-95b6-5dd52dd90e80") def test_scan_with_wifi_off_and_location_scan_off(self): """Turn off wifi and location scan""" @@ -614,32 +636,6 @@ class WifiManagerTest(WifiBaseTest): nw[WifiEnums.BSSID_KEY] != ssid, "Found forgotten network %s in configured networks." % ssid) - @test_tracker_info(uuid="b306d65c-6df3-4eb5-a178-6278bdc76c3e") - def test_reconnect_to_connected_network(self): - """Connect to a network and immediately issue reconnect. - - Steps: - 1. Connect to a 2GHz network. - 2. Reconnect to the network using its network id. - 3. Connect to a 5GHz network. - 4. Reconnect to the network using its network id. - - """ - connect_2g_data = self.get_connection_data(self.dut, self.wpapsk_2g) - reconnect_2g = self.connect_to_wifi_network_with_id( - connect_2g_data[WifiEnums.NETID_KEY], - connect_2g_data[WifiEnums.SSID_KEY]) - if not reconnect_2g: - raise signals.TestFailure("Device did not connect to the correct" - " 2GHz network.") - connect_5g_data = self.get_connection_data(self.dut, self.wpapsk_5g) - reconnect_5g = self.connect_to_wifi_network_with_id( - connect_5g_data[WifiEnums.NETID_KEY], - connect_5g_data[WifiEnums.SSID_KEY]) - if not reconnect_5g: - raise signals.TestFailure("Device did not connect to the correct" - " 5GHz network.") - @test_tracker_info(uuid="3cff17f6-b684-4a95-a438-8272c2ad441d") def test_reconnect_to_previously_connected(self): """Connect to multiple networks and reconnect to the previous network. @@ -943,12 +939,33 @@ class WifiManagerTest(WifiBaseTest): 3. Let DUT sleep for 5 minutes 4. Check DUT can be pinged by DUT_Client """ + asserts.skip_if(len(self.android_devices) < 3, "Need 3 devices") + self.dut_client_a = self.android_devices[1] + self.dut_client_b = self.android_devices[2] + + # enable hotspot on dut and connect client devices to it + ap_ssid = "softap_" + acts.utils.rand_ascii_str(8) + ap_password = acts.utils.rand_ascii_str(8) + self.dut.log.info("softap setup: %s %s", ap_ssid, ap_password) + config = {wutils.WifiEnums.SSID_KEY: ap_ssid} + config[wutils.WifiEnums.PWD_KEY] = ap_password + wutils.start_wifi_tethering( + self.dut, + config[wutils.WifiEnums.SSID_KEY], + config[wutils.WifiEnums.PWD_KEY], + wutils.WifiEnums.WIFI_CONFIG_APBAND_AUTO) + # DUT connect to AP - wutils.connect_to_wifi_network(self.dut, self.wpa_networks[0]["2g"]) - wutils.connect_to_wifi_network(self.dut_client, self.wpa_networks[0]["2g"]) + wutils.connect_to_wifi_network( + self.dut_client_a, config, check_connectivity=False) + wutils.connect_to_wifi_network( + self.dut_client_b, config, check_connectivity=False) # Check DUT and DUT_Client can ping each other successfully - self.verify_traffic_between_devices(self.dut,self.dut_client) - self.verify_traffic_between_devices(self.dut_client,self.dut) + self.verify_traffic_between_devices(self.dut_client_a, + self.dut_client_b) + self.verify_traffic_between_devices(self.dut_client_a, + self.dut_client_b) + # DUT turn off screen and go sleep for 5 mins self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() @@ -957,7 +974,8 @@ class WifiManagerTest(WifiBaseTest): self.log.info("Sleep for 5 minutes") time.sleep(300) # Verify DUT_Client can ping DUT when DUT sleeps - self.verify_traffic_between_devices(self.dut,self.dut_client) + self.verify_traffic_between_devices(self.dut_client_a, + self.dut_client_b) self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() @@ -976,3 +994,42 @@ class WifiManagerTest(WifiBaseTest): "wifi state changed after reboot") disable_bluetooth(self.dut.droid) + + @test_tracker_info(uuid="d0e14a2d-a28f-4551-8988-1e15d9d8bb1a") + def test_scan_result_api(self): + """Register scan result callback, start scan and wait for event""" + self.dut.ed.clear_all_events() + self.dut.droid.wifiStartScanWithListener() + try: + events = self.dut.ed.pop_events( + "WifiManagerScanResultsCallbackOnSuccess", 60) + except queue.Empty: + asserts.fail( + "Wi-Fi scan results did not become available within 60s.") + + @test_tracker_info(uuid="03cfbc86-7fcc-48d8-ab0f-1f6f3523e596") + def test_enable_disable_auto_join_saved_network(self): + """ + Add a saved network, simulate user change the auto join to false, ensure the device doesn't + auto connect to this network + + Steps: + 1. Create a saved network. + 2. Add this saved network, and ensure we connect to this network + 3. Simulate user change the auto join to false. + 4. Toggle the Wifi off and on + 4. Ensure device doesn't connect to his network + """ + network = self.open_network_5g + wutils.connect_to_wifi_network(self.dut, network) + info = self.dut.droid.wifiGetConnectionInfo() + network_id = info[WifiEnums.NETID_KEY] + self.dut.log.info("Disable auto join on network") + self.dut.droid.wifiEnableAutojoin(network_id, False) + wutils.wifi_toggle_state(self.dut, False) + wutils.wifi_toggle_state(self.dut, True) + asserts.assert_false( + wutils.wait_for_connect(self.dut, network[WifiEnums.SSID_KEY], + assert_on_fail=False), "Device should not connect.") + self.dut.droid.wifiEnableAutojoin(network_id, True) + wutils.wait_for_connect(self.dut, network[WifiEnums.SSID_KEY], assert_on_fail=False) diff --git a/acts_tests/tests/google/wifi/WifiNetworkRequestTest.py b/acts_tests/tests/google/wifi/WifiNetworkRequestTest.py index 7fed0ad1c7..58e90caf40 100644 --- a/acts_tests/tests/google/wifi/WifiNetworkRequestTest.py +++ b/acts_tests/tests/google/wifi/WifiNetworkRequestTest.py @@ -84,6 +84,10 @@ class WifiNetworkRequestTest(WifiBaseTest): self.dut.droid.wifiReleaseNetworkAll() self.dut.droid.wifiDisconnect() wutils.reset_wifi(self.dut) + # Ensure we disconnected from the current network before the next test. + if self.dut.droid.wifiGetConnectionInfo()["supplicant_state"] != "disconnected": + wutils.wait_for_disconnect(self.dut) + wutils.wifi_toggle_state(self.dut, False) self.dut.ed.clear_all_events() def on_fail(self, test_name, begin_time): @@ -200,6 +204,7 @@ class WifiNetworkRequestTest(WifiBaseTest): # Ensure we disconnected from the previous network. wutils.wait_for_disconnect(self.dut) self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g) + self.dut.ed.clear_all_events() # Complete flow for the second request. wutils.wifi_connect_using_network_request(self.dut, self.open_5g, self.open_5g) @@ -333,8 +338,7 @@ class WifiNetworkRequestTest(WifiBaseTest): self.wpa_psk_2g) # Simulate user forgeting the ephemeral network. - self.dut.droid.wifiDisableEphemeralNetwork( - self.wpa_psk_2g[WifiEnums.SSID_KEY]) + self.dut.droid.wifiUserDisconnectNetwork(self.wpa_psk_2g[WifiEnums.SSID_KEY]) # Ensure we disconnected from the network. wutils.wait_for_disconnect(self.dut) self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g) @@ -385,11 +389,17 @@ class WifiNetworkRequestTest(WifiBaseTest): that does not match any networks. Steps: - 1. Send a network specifier with the non-matching SSID pattern. - 2. Ensure that the platform does not retrun any matching networks. - 3. Wait for the request to timeout. + 1. Trigger a connect to one of the networks (as a saved network). + 2. Send a network specifier with the non-matching SSID pattern. + 3. Ensure that the platform does not return any matching networks. + 4. Wait for the request to timeout. """ network = self.wpa_psk_5g + + # Trigger a connection to a network as a saved network before the + # request and ensure that this does not change the behavior. + wutils.connect_to_wifi_network(self.dut, network, check_connectivity=False) + network_specifier = self.wpa_psk_5g.copy(); # Remove ssid & replace with invalid ssid pattern. network_ssid = network_specifier.pop(WifiEnums.SSID_KEY) @@ -406,19 +416,17 @@ class WifiNetworkRequestTest(WifiBaseTest): time.sleep(wifi_constants.NETWORK_REQUEST_CB_REGISTER_DELAY_SEC) self.dut.droid.wifiRegisterNetworkRequestMatchCallback() # Wait for the request to timeout. - timeout_secs = \ - NETWORK_REQUEST_TIMEOUT_MS / 1000 + NETWORK_REQUEST_INSTANT_FAILURE_TIMEOUT_SEC + timeout_secs = NETWORK_REQUEST_TIMEOUT_MS * 2 / 1000 try: on_unavailable_event = self.dut.ed.pop_event( wifi_constants.WIFI_NETWORK_CB_ON_UNAVAILABLE, timeout_secs) asserts.assert_true(on_unavailable_event, "Network request did not timeout") - except queue.Empty: asserts.fail("No events returned") finally: self.dut.droid.wifiStopTrackingStateChange() - @test_tracker_info(uuid="760c3768-697d-442b-8d61-cfe02f10ceff") + @test_tracker_info(uuid="caa96f57-840e-4997-9280-655edd3b76ee") def test_connect_failure_user_rejected(self): """ Initiates a connection to network via network request with specific SSID diff --git a/acts_tests/tests/google/wifi/WifiNetworkSelectorTest.py b/acts_tests/tests/google/wifi/WifiNetworkSelectorTest.py index 5af4ad9584..41f723c599 100644 --- a/acts_tests/tests/google/wifi/WifiNetworkSelectorTest.py +++ b/acts_tests/tests/google/wifi/WifiNetworkSelectorTest.py @@ -35,9 +35,13 @@ AP_1_2G_ATTENUATOR = 0 AP_1_5G_ATTENUATOR = 1 AP_2_2G_ATTENUATOR = 2 AP_2_5G_ATTENUATOR = 3 -ATTENUATOR_INITIAL_SETTING = 60 # WifiNetworkSelector imposes a 10 seconds gap between two selections NETWORK_SELECTION_TIME_GAP = 12 +LVL1_ATTN = 15 +LVL2_ATTN = 30 +MIN_ATTN = 0 +MAX_ATTN = 95 +ATTN_SLEEP = 12 class WifiNetworkSelectorTest(WifiBaseTest): @@ -50,44 +54,31 @@ class WifiNetworkSelectorTest(WifiBaseTest): self.dut = self.android_devices[0] wutils.wifi_test_device_init(self.dut) - req_params = [] - opt_param = ["open_network", "reference_networks"] - self.unpack_userparams( - req_param_names=req_params, opt_param_names=opt_param) - - if hasattr(self, 'access_points'): - self.legacy_configure_ap_and_start(ap_count=2) - - if hasattr(self, 'packet_capture'): - self.configure_packet_capture() + self.legacy_configure_ap_and_start(ap_count=2, mirror_ap=False) + self.configure_packet_capture() def setup_test(self): - #reset and clear all saved networks on the DUT - wutils.reset_wifi(self.dut) - #move the APs out of range - for attenuator in self.attenuators: - attenuator.set_atten(ATTENUATOR_INITIAL_SETTING) - #turn on the screen self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() self.dut.ed.clear_all_events() - - if hasattr(self, 'packet_capture'): - self.pcap_procs = wutils.start_pcap( - self.packet_capture, 'dual', self.test_name) + self.pcap_procs = wutils.start_pcap( + self.packet_capture, 'dual', self.test_name) + for a in self.attenuators: + a.set_atten(MAX_ATTN) + time.sleep(ATTN_SLEEP) def teardown_test(self): - #turn off the screen + for a in self.attenuators: + a.set_atten(MIN_ATTN) + wutils.reset_wifi(self.dut) self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() def on_pass(self, test_name, begin_time): - if hasattr(self, 'packet_capture'): - wutils.stop_pcap(self.packet_capture, self.pcap_procs, True) + wutils.stop_pcap(self.packet_capture, self.pcap_procs, True) def on_fail(self, test_name, begin_time): - if hasattr(self, 'packet_capture'): - wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) + wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) @@ -108,13 +99,14 @@ class WifiNetworkSelectorTest(WifiBaseTest): """ for network in networks: ret = ad.droid.wifiAddNetwork(network) - asserts.assert_true(ret != -1, "Failed to add network %s" % - network) + asserts.assert_true(ret != -1, + "Failed to add network %s" % network) ad.droid.wifiEnableNetwork(ret, 0) + configured_networks = ad.droid.wifiGetConfiguredNetworks() - logging.debug("Configured networks: %s", configured_networks) + self.log.info("Configured networks: %s", configured_networks) - def connect_and_verify_connected_bssid(self, expected_bssid): + def connect_and_verify_connected_bssid(self, network): """Start a scan to get the DUT connected to an AP and verify the DUT is connected to the correct BSSID. @@ -124,22 +116,19 @@ class WifiNetworkSelectorTest(WifiBaseTest): Returns: True if connection to given network happen, else return False. """ - #wait for the attenuator to stablize - time.sleep(10) - #force start a single scan so we don't have to wait for the - #WCM scheduled scan. - wutils.start_wifi_connection_scan(self.dut) - #wait for connection + expected_ssid = network['SSID'] + expected_bssid = network['bssid'] + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, expected_ssid) time.sleep(20) - #verify connection actual_network = self.dut.droid.wifiGetConnectionInfo() - logging.info("Actual network: %s", actual_network) - try: - asserts.assert_equal(expected_bssid, - actual_network[WifiEnums.BSSID_KEY]) - except: - msg = "Device did not connect to any network." - raise signals.TestFailure(msg) + self.log.info("Actual network: %s", actual_network) + asserts.assert_true( + actual_network and WifiEnums.BSSID_KEY in actual_network and \ + expected_bssid == actual_network[WifiEnums.BSSID_KEY], + "Expected BSSID: %s, Actual BSSID: %s" % + (expected_bssid, actual_network[WifiEnums.BSSID_KEY])) + self.log.info("DUT connected to valid network: %s" % expected_bssid) """ Tests Begin """ @@ -150,14 +139,17 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2. Move the DUT in range. 3. Verify the DUT is connected to the network. """ - #add a saved network to DUT + # add a saved network to DUT networks = [self.reference_networks[AP_1]['5g']] self.add_networks(self.dut, networks) - #move the DUT in range - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(0) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) + + # move the DUT in range + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(MIN_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT is connected to AP_1 5g network + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) @test_tracker_info(uuid="3ea818f2-10d7-4aad-bfab-7d8fb25aae78") def test_network_selector_basic_connection_prefer_5g(self): @@ -166,18 +158,19 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2. Move the DUT in range. 3. Verify the DUT is connected to the 5G BSSID. """ - #add a saved network with both 2G and 5G BSSIDs to DUT - # TODO: bmahadev Change this to a single SSID once we migrate tests to - # use dynamic AP. + # add a saved network with both 2G and 5G BSSIDs to DUT networks = [self.reference_networks[AP_1]['2g'], self.reference_networks[AP_1]['5g']] self.add_networks(self.dut, networks) - #move the DUT in range - self.attenuators[AP_1_2G_ATTENUATOR].set_atten(0) - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(0) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) + + # Move DUT in range + self.attenuators[AP_1_2G_ATTENUATOR].set_atten(MIN_ATTN) + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(MIN_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT is connected to 5G network + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) @test_tracker_info(uuid="bebb29ca-4486-4cde-b390-c5f8f2e1580c") def test_network_selector_prefer_stronger_rssi(self): @@ -187,18 +180,19 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2. Move the DUT in range. 3. Verify the DUT is connected to the SSID with stronger RSSI. """ - #add a 2G and a 5G saved network to DUT - networks = [ - self.reference_networks[AP_1]['2g'], self.reference_networks[AP_2][ - '2g'] - ] + # add a 2G and a 5G saved network to DUT + networks = [self.reference_networks[AP_1]['2g'], + self.reference_networks[AP_2]['2g']] self.add_networks(self.dut, networks) - #move the DUT in range - self.attenuators[AP_1_2G_ATTENUATOR].set_atten(20) - self.attenuators[AP_2_2G_ATTENUATOR].set_atten(40) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '2g']['bssid']) + + # move the DUT in range + self.attenuators[AP_1_2G_ATTENUATOR].set_atten(LVL1_ATTN) + self.attenuators[AP_2_2G_ATTENUATOR].set_atten(LVL2_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT is connected AP_1 + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['2g']) @test_tracker_info(uuid="f9f72dc5-034f-4fe2-a27d-df1b6cae76cd") def test_network_selector_prefer_secure_over_open_network(self): @@ -208,17 +202,18 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2. Move the DUT in range. 3. Verify the DUT is connected to the secure network that uses WPA2. """ - #add a open network and a secure saved network to DUT - networks = [ - self.open_network[AP_1]['5g'], self.reference_networks[AP_1]['5g'] - ] + # add a open network and a secure saved network to DUT + networks = [self.open_network[AP_1]['5g'], + self.reference_networks[AP_1]['5g']] self.add_networks(self.dut, networks) - #move the DUT in range - #TODO: control open network attenuator - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(0) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) + + # Move DUT in range + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(MIN_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT connects to secure network + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) @test_tracker_info(uuid="ab2c527c-0f9c-4f09-a13f-e3f461b7da52") def test_network_selector_blacklist_by_connection_failure(self): @@ -228,26 +223,30 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2. Move the DUT in range. 3. Verify the DUT is connected to network Y. """ - #add two saved networks to DUT, and one of them is configured with incorrect password + # add two saved networks to DUT, and one of them is configured with + # incorrect password wrong_passwd_network = self.reference_networks[AP_1]['5g'].copy() wrong_passwd_network['password'] += 'haha' networks = [wrong_passwd_network, self.reference_networks[AP_2]['5g']] self.add_networks(self.dut, networks) - #make both AP_1 5G and AP_2 5G in range, and AP_1 5G has stronger RSSI than AP_2 5G - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(0) - self.attenuators[AP_2_5G_ATTENUATOR].set_atten(10) - #start 3 scans to get AP_1 5G blacklisted because of the incorrect password - count = 0 - while count < 3: - wutils.start_wifi_connection_scan(self.dut) + + # make AP_1 5G has stronger RSSI than AP_2 5G + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(MIN_ATTN) + self.attenuators[AP_2_5G_ATTENUATOR].set_atten(LVL1_ATTN) + time.sleep(ATTN_SLEEP) + + # start 3 scans to get AP_1 5G blacklisted because of the incorrect + # password + for _ in range(3): + wutils.start_wifi_connection_scan_and_return_status(self.dut) time.sleep(NETWORK_SELECTION_TIME_GAP) - count += 1 - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_2][ - '5g']['bssid']) + + # verify DUT is connect AP_2 5G + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_2]['5g']) @test_tracker_info(uuid="71d88fcf-c7b8-4fd2-a7cb-84ac4a130ecf") - def test_network_selector_2g_to_5g_prefer_same_SSID(self): + def network_selector_2g_to_5g_prefer_same_SSID(self): """ 1. Add SSID_A and SSID_B to DUT. Both SSIDs have both 2G and 5G BSSIDs. @@ -277,7 +276,7 @@ class WifiNetworkSelectorTest(WifiBaseTest): '5g']['bssid']) @test_tracker_info(uuid="c1243cf4-d96e-427e-869e-3d640bee3f28") - def test_network_selector_2g_to_5g_different_ssid(self): + def network_selector_2g_to_5g_different_ssid(self): """ 1. Add SSID_A and SSID_B to DUT. Both SSIDs have both 2G and 5G BSSIDs. @@ -287,14 +286,13 @@ class WifiNetworkSelectorTest(WifiBaseTest): 2G RSSI. 4. Verify the DUT switches to SSID_B's 5G. """ - #add two saved networks to DUT - networks = [ - self.reference_networks[AP_1]['2g'], self.reference_networks[AP_2][ - '2g'] - ] + # add two saved networks to DUT + networks = [self.reference_networks[AP_1]['2g'], + self.reference_networks[AP_2]['2g']] self.add_networks(self.dut, networks) - #make both AP_1 2G and AP_2 5G in range, and AP_1 2G - #has much stronger RSSI than AP_2 5G + + # make both AP_1 2G and AP_2 5G in range, and AP_1 2G + # has much stronger RSSI than AP_2 5G self.attenuators[AP_1_2G_ATTENUATOR].set_atten(0) self.attenuators[AP_2_5G_ATTENUATOR].set_atten(20) #verify @@ -310,7 +308,7 @@ class WifiNetworkSelectorTest(WifiBaseTest): '5g']['bssid']) @test_tracker_info(uuid="10da95df-83ed-4447-89f8-735b08dbe2eb") - def test_network_selector_5g_to_2g_same_ssid(self): + def network_selector_5g_to_2g_same_ssid(self): """ 1. Add one SSID that has both 2G and 5G to the DUT. 2. Attenuate down the 2G RSSI. @@ -346,26 +344,30 @@ class WifiNetworkSelectorTest(WifiBaseTest): 3. Change attenuation so that Y's RSSI goes above X's. 4. Verify the DUT stays on X. """ - #add two saved networks to DUT - networks = [ - self.reference_networks[AP_1]['5g'], self.reference_networks[AP_2][ - '5g'] - ] + # add two saved networks to DUT + networks = [self.reference_networks[AP_1]['5g'], + self.reference_networks[AP_2]['5g']] self.add_networks(self.dut, networks) - #make both AP_1 5G and AP_2 5G in range, and AP_1 5G - #has stronger RSSI than AP_2 5G - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(10) - self.attenuators[AP_2_5G_ATTENUATOR].set_atten(20) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) - #bump up AP_2 5G RSSI over AP_1 5G RSSI - self.attenuators[AP_2_5G_ATTENUATOR].set_atten(0) - #ensure the time gap between two network selections + + # make both AP_1 5G and AP_2 5G in range, and AP_1 5G + # has stronger RSSI than AP_2 5G + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(LVL1_ATTN) + self.attenuators[AP_2_5G_ATTENUATOR].set_atten(LVL2_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT is connected to AP_1 + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) + + # bump up AP_2 5G RSSI over AP_1 5G RSSI + self.attenuators[AP_2_5G_ATTENUATOR].set_atten(MIN_ATTN) + + # ensure the time gap between two network selections time.sleep(NETWORK_SELECTION_TIME_GAP) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) + + # verify DUT is still connected to AP_1 + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) @test_tracker_info(uuid="5470010f-8b62-4b1c-8b83-1f91422eced0") def test_network_selector_stay_on_user_selected_network(self): @@ -375,23 +377,23 @@ class WifiNetworkSelectorTest(WifiBaseTest): 3. Start a scan and network selection. 4. Verify DUT stays on SSID_A. """ - #make AP_1 5G in range with a low RSSI - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(10) - #connect to AP_1 via user selection - wutils.wifi_connect(self.dut, self.reference_networks[AP_1]['5g']) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) - #make AP_2 5G in range with a strong RSSI - self.attenuators[AP_2_5G_ATTENUATOR].set_atten(0) - #add AP_2 as a saved network to DUT + # set max attenuation on AP_2 and make AP_1 5G in range with low RSSI + self.attenuators[AP_2_5G_ATTENUATOR].set_atten(MIN_ATTN) + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(LVL1_ATTN) + time.sleep(ATTN_SLEEP) + + # connect to AP_1 via user selection and add, save AP_2 + wutils.connect_to_wifi_network( + self.dut, self.reference_networks[AP_1]['5g']) networks = [self.reference_networks[AP_2]['5g']] self.add_networks(self.dut, networks) - #ensure the time gap between two network selections + + # ensure the time gap between two network selections time.sleep(NETWORK_SELECTION_TIME_GAP) - #verify we are still connected to AP_1 5G - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) + + # verify we are still connected to AP_1 5G + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) @test_tracker_info(uuid="f08d8f73-8c94-42af-bba9-4c49bbf16420") def test_network_selector_reselect_after_forget_network(self): @@ -402,22 +404,25 @@ class WifiNetworkSelectorTest(WifiBaseTest): 3. Forget X. 5. Verify the DUT reselect and connect to Y. """ - #add two saved networks to DUT - networks = [ - self.reference_networks[AP_1]['5g'], self.reference_networks[AP_2][ - '5g'] - ] + # add two networks to DUT + networks = [self.reference_networks[AP_1]['5g'], + self.reference_networks[AP_2]['5g']] self.add_networks(self.dut, networks) - #make both AP_1 5G and AP_2 5G in range. AP_1 5G has stronger - #RSSI than AP_2 5G - self.attenuators[AP_1_5G_ATTENUATOR].set_atten(0) - self.attenuators[AP_2_5G_ATTENUATOR].set_atten(10) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_1][ - '5g']['bssid']) - #forget AP_1 - wutils.wifi_forget_network(self.dut, - self.reference_networks[AP_1]['5g']['SSID']) - #verify - self.connect_and_verify_connected_bssid(self.reference_networks[AP_2][ - '5g']['bssid']) + + # make both AP_1 5G and AP_2 5G in range. AP_1 5G has stronger + # RSSI than AP_2 5G + self.attenuators[AP_1_5G_ATTENUATOR].set_atten(MIN_ATTN) + self.attenuators[AP_2_5G_ATTENUATOR].set_atten(LVL1_ATTN) + time.sleep(ATTN_SLEEP) + + # verify DUT connected to AP1 + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_1]['5g']) + + # forget AP_1 + wutils.wifi_forget_network( + self.dut, self.reference_networks[AP_1]['5g']['SSID']) + + # verify DUT connected to AP2 + self.connect_and_verify_connected_bssid( + self.reference_networks[AP_2]['5g']) diff --git a/acts_tests/tests/google/wifi/WifiNetworkSuggestionTest.py b/acts_tests/tests/google/wifi/WifiNetworkSuggestionTest.py index 6d6da35b42..ba37b4e2cc 100644 --- a/acts_tests/tests/google/wifi/WifiNetworkSuggestionTest.py +++ b/acts_tests/tests/google/wifi/WifiNetworkSuggestionTest.py @@ -36,10 +36,19 @@ EAP = WifiEnums.Eap EapPhase2 = WifiEnums.EapPhase2 # Enterprise Config Macros Ent = WifiEnums.Enterprise +ATT = 2 +# Suggestion network Macros +Untrusted = "untrusted" +AutoJoin = "enableAutojoin" +# Network request Macros +ClearCapabilities = "ClearCapabilities" +TransportType = "TransportType" + # Default timeout used for reboot, toggle WiFi and Airplane mode, # for the system to settle down after the operation. DEFAULT_TIMEOUT = 10 +PASSPOINT_TIMEOUT = 30 class WifiNetworkSuggestionTest(WifiBaseTest): @@ -56,13 +65,11 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.dut = self.android_devices[0] wutils.wifi_test_device_init(self.dut) - req_params = [] opt_param = [ - "open_network", "reference_networks", "radius_conf_2g", "radius_conf_5g", "ca_cert", - "eap_identity", "eap_password", "hidden_networks" - ] - self.unpack_userparams( - req_param_names=req_params, opt_param_names=opt_param) + "open_network", "reference_networks", "hidden_networks", "radius_conf_2g", + "radius_conf_5g", "ca_cert", "eap_identity", "eap_password", "passpoint_networks", + "altsubject_match"] + self.unpack_userparams(opt_param_names=opt_param,) if "AccessPoint" in self.user_params: self.legacy_configure_ap_and_start( @@ -70,21 +77,20 @@ class WifiNetworkSuggestionTest(WifiBaseTest): radius_conf_2g=self.radius_conf_2g, radius_conf_5g=self.radius_conf_5g,) - asserts.assert_true( - len(self.reference_networks) > 0, - "Need at least one reference network with psk.") - if hasattr(self, "reference_networks"): - self.wpa_psk_2g = self.reference_networks[0]["2g"] - self.wpa_psk_5g = self.reference_networks[0]["5g"] - if hasattr(self, "open_network"): + if hasattr(self, "reference_networks") and \ + isinstance(self.reference_networks, list): + self.wpa_psk_2g = self.reference_networks[0]["2g"] + self.wpa_psk_5g = self.reference_networks[0]["5g"] + if hasattr(self, "open_network") and isinstance(self.open_network,list): self.open_2g = self.open_network[0]["2g"] self.open_5g = self.open_network[0]["5g"] - if hasattr(self, "ent_networks"): + if hasattr(self, "ent_networks") and isinstance(self.ent_networks,list): self.ent_network_2g = self.ent_networks[0]["2g"] self.ent_network_5g = self.ent_networks[0]["5g"] self.config_aka = { Ent.EAP: int(EAP.AKA), WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + "carrierId": str(self.dut.droid.telephonyGetSimCarrierId()), } self.config_ttls = { Ent.EAP: int(EAP.TTLS), @@ -93,17 +99,23 @@ class WifiNetworkSuggestionTest(WifiBaseTest): Ent.PASSWORD: self.eap_password, Ent.PHASE2: int(EapPhase2.MSCHAPV2), WifiEnums.SSID_KEY: self.ent_network_2g[WifiEnums.SSID_KEY], + Ent.ALTSUBJECT_MATCH: self.altsubject_match, } - if hasattr(self, "hidden_networks"): - self.hidden_network = self.hidden_networks[0] + if hasattr(self, "hidden_networks") and \ + isinstance(self.hidden_networks, list): + self.hidden_network = self.hidden_networks[0] self.dut.droid.wifiRemoveNetworkSuggestions([]) + self.dut.adb.shell( + "pm disable com.google.android.apps.carrier.carrierwifi") def setup_test(self): self.dut.droid.wakeLockAcquireBright() self.dut.droid.wakeUpNow() - self.clear_deleted_ephemeral_networks() + self.dut.unlock_screen() + self.clear_user_disabled_networks() wutils.wifi_toggle_state(self.dut, True) self.dut.ed.clear_all_events() + self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId())) def teardown_test(self): self.dut.droid.wakeLockRelease() @@ -113,12 +125,15 @@ class WifiNetworkSuggestionTest(WifiBaseTest): wutils.reset_wifi(self.dut) wutils.wifi_toggle_state(self.dut, False) self.dut.ed.clear_all_events() + self.clear_carrier_approved(str(self.dut.droid.telephonyGetSimCarrierId())) def on_fail(self, test_name, begin_time): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) def teardown_class(self): + self.dut.adb.shell( + "pm enable com.google.android.apps.carrier.carrierwifi") if "AccessPoint" in self.user_params: del self.user_params["reference_networks"] del self.user_params["open_network"] @@ -137,10 +152,28 @@ class WifiNetworkSuggestionTest(WifiBaseTest): + " " + SL4A_APK_NAME) return True if (is_approved_str == "yes") else False - def clear_deleted_ephemeral_networks(self): - self.dut.log.debug("Clearing deleted ephemeral networks") + def set_carrier_approved(self, carrier_id, approved): + self.dut.log.debug(("Setting IMSI protection exemption for carrier: " + carrier_id + + "approved" if approved else "not approved")) + self.dut.adb.shell("cmd wifi imsi-protection-exemption-set-user-approved-for-carrier" + + " " + carrier_id + + " " + ("yes" if approved else "no")) + + def is_carrier_approved(self, carrier_id): + is_approved_str = self.dut.adb.shell( + "cmd wifi imsi-protection-exemption-has-user-approved-for-carrier" + + " " + carrier_id) + return True if (is_approved_str == "yes") else False + + def clear_carrier_approved(self, carrier_id): + self.dut.adb.shell( + "cmd wifi imsi-protection-exemption-clear-user-approved-for-carrier" + + " " + carrier_id) + + def clear_user_disabled_networks(self): + self.dut.log.debug("Clearing user disabled networks") self.dut.adb.shell( - "cmd wifi clear-deleted-ephemeral-networks") + "cmd wifi clear-user-disabled-networks") def add_suggestions_and_ensure_connection(self, network_suggestions, expected_ssid, @@ -148,18 +181,21 @@ class WifiNetworkSuggestionTest(WifiBaseTest): if expect_post_connection_broadcast is not None: self.dut.droid.wifiStartTrackingNetworkSuggestionStateChange() - self.dut.log.info("Adding network suggestions"); + self.dut.log.info("Adding network suggestions") asserts.assert_true( self.dut.droid.wifiAddNetworkSuggestions(network_suggestions), "Failed to add suggestions") # Enable suggestions by the app. - self.dut.log.debug("Enabling suggestions from test"); + self.dut.log.debug("Enabling suggestions from test") self.set_approved(True) wutils.start_wifi_connection_scan_and_return_status(self.dut) + # if suggestion is passpoint wait longer for connection. + if "profile" in network_suggestions: + time.sleep(PASSPOINT_TIMEOUT) wutils.wait_for_connect(self.dut, expected_ssid) if expect_post_connection_broadcast is None: - return; + return # Check if we expected to get the broadcast. try: @@ -180,15 +216,11 @@ class WifiNetworkSuggestionTest(WifiBaseTest): def remove_suggestions_disconnect_and_ensure_no_connection_back(self, network_suggestions, expected_ssid): + # Remove suggestion trigger disconnect and wait for the disconnect. self.dut.log.info("Removing network suggestions") asserts.assert_true( self.dut.droid.wifiRemoveNetworkSuggestions(network_suggestions), "Failed to remove suggestions") - # Ensure we did not disconnect - wutils.ensure_no_disconnect(self.dut) - - # Trigger a disconnect and wait for the disconnect. - self.dut.droid.wifiDisconnect() wutils.wait_for_disconnect(self.dut) self.dut.ed.clear_all_events() @@ -219,6 +251,11 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.remove_suggestions_disconnect_and_ensure_no_connection_back( network_suggestions, wifi_network[WifiEnums.SSID_KEY]) + # Reboot with empty suggestion, verify user approval is kept. + self.dut.reboot() + time.sleep(DEFAULT_TIMEOUT) + asserts.assert_true(self.is_approved(), "User approval should be kept") + @test_tracker_info(uuid="bda8ed20-4382-4380-831a-64cf77eca108") def test_connect_to_wpa_psk_2g(self): """ Adds a network suggestion and ensure that the device connected. @@ -237,6 +274,95 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.remove_suggestions_disconnect_and_ensure_no_connection_back( [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) + @test_tracker_info(uuid="b2df6ebe-9c5b-4e84-906a-e76f96fcef56") + def test_connect_to_wpa_psk_2g_with_screen_off(self): + """ Adds a network suggestion and ensure that the device connected + when the screen is off. + + Steps: + 1. Send an invalid suggestion to the device (Needed for PNO scan to start). + 2. Toggle screen off. + 3. Send a valid network suggestion to the device. + 4. Wait for the device to connect to it. + 5. Ensure that we did not receive the post connection broadcast + (isAppInteractionRequired = False). + 6. Remove the suggestions and ensure the device does not connect back. + """ + invalid_suggestion = self.wpa_psk_5g + network_ssid = invalid_suggestion.pop(WifiEnums.SSID_KEY) + invalid_suggestion[WifiEnums.SSID_KEY] = network_ssid + "blah" + + self.dut.log.info("Adding invalid suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([invalid_suggestion]), + "Failed to add suggestions") + + # Approve suggestions by the app. + self.set_approved(True) + + # Turn screen off to ensure PNO kicks-in. + self.dut.droid.wakeLockRelease() + self.dut.droid.goToSleepNow() + time.sleep(10) + + # Add valid suggestions & ensure we restart PNO and connect to it. + self.add_suggestions_and_ensure_connection( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], + False) + + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY]) + + @test_tracker_info(uuid="f18bf994-ef3b-45d6-aba0-dd6338b07979") + def test_connect_to_wpa_psk_2g_modify_meteredness(self): + """ Adds a network suggestion and ensure that the device connected. + Change the meteredness of the network after the connection. + + Steps: + 1. Send a network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did not receive the post connection broadcast + (isAppInteractionRequired = False). + 4. Mark the network suggestion metered. + 5. Ensure that the device disconnected and reconnected back to the + suggestion. + 6. Mark the network suggestion unmetered. + 7. Ensure that the device did not disconnect. + 8. Remove the suggestions and ensure the device does not connect back. + """ + self.add_suggestions_and_ensure_connection( + [self.wpa_psk_2g], self.wpa_psk_2g[WifiEnums.SSID_KEY], + False) + + mod_suggestion = self.wpa_psk_2g + + # Mark the network metered. + self.dut.log.debug("Marking suggestion as metered") + mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = True + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]), + "Failed to add suggestions") + # Wait for disconnect. + wutils.wait_for_disconnect(self.dut) + self.dut.log.info("Disconnected from network %s", mod_suggestion) + self.dut.ed.clear_all_events() + # Wait for reconnect. + wutils.wait_for_connect(self.dut, mod_suggestion[WifiEnums.SSID_KEY]) + + # Mark the network unmetered. + self.dut.log.debug("Marking suggestion as unmetered") + mod_suggestion[WifiEnums.IS_SUGGESTION_METERED] = False + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([mod_suggestion]), + "Failed to add suggestions") + # Ensure there is no disconnect. + wutils.ensure_no_disconnect(self.dut) + self.dut.ed.clear_all_events() + + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [mod_suggestion], mod_suggestion[WifiEnums.SSID_KEY]) + + @test_tracker_info(uuid="f54bc250-d9e9-4f00-8b5b-b866e8550b43") def test_connect_to_highest_priority(self): """ @@ -247,8 +373,11 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 1. Send 2 network suggestions to the device (with different priorities). 2. Wait for the device to connect to the network with the highest priority. - 3. Re-add the suggestions with the priorities reversed. - 4. Again wait for the device to connect to the network with the highest + 3. In-place modify network suggestions with priorities reversed + 4. Restart wifi, wait for the device to connect to the network with the highest + priority. + 5. Re-add the suggestions with the priorities reversed again. + 6. Again wait for the device to connect to the network with the highest priority. """ network_suggestion_2g = self.wpa_psk_2g @@ -262,16 +391,33 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.wpa_psk_2g[WifiEnums.SSID_KEY], None) + # In-place modify Reverse the priority, should be no disconnect + network_suggestion_2g[WifiEnums.PRIORITY] = 2 + network_suggestion_5g[WifiEnums.PRIORITY] = 5 + self.dut.log.info("Modifying network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([network_suggestion_2g, + network_suggestion_5g]), + "Failed to add suggestions") + wutils.ensure_no_disconnect(self.dut) + + # Disable and re-enable wifi, should connect to higher priority + wutils.wifi_toggle_state(self.dut, False) + time.sleep(DEFAULT_TIMEOUT) + wutils.wifi_toggle_state(self.dut, True) + wutils.start_wifi_connection_scan_and_return_status(self.dut) + wutils.wait_for_connect(self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY]) + self.remove_suggestions_disconnect_and_ensure_no_connection_back( - [], self.wpa_psk_2g[WifiEnums.SSID_KEY]) + [], self.wpa_psk_5g[WifiEnums.SSID_KEY]) # Reverse the priority. # Add suggestions & wait for the connection event. - network_suggestion_2g[WifiEnums.PRIORITY] = 2 - network_suggestion_5g[WifiEnums.PRIORITY] = 5 + network_suggestion_2g[WifiEnums.PRIORITY] = 5 + network_suggestion_5g[WifiEnums.PRIORITY] = 2 self.add_suggestions_and_ensure_connection( [network_suggestion_2g, network_suggestion_5g], - self.wpa_psk_5g[WifiEnums.SSID_KEY], + self.wpa_psk_2g[WifiEnums.SSID_KEY], None) @test_tracker_info(uuid="b1d27eea-23c8-4c4f-b944-ef118e4cc35f") @@ -308,6 +454,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 4. Reboot the device. 5. Wait for the device to connect to back to it. 6. Remove the suggestions and ensure the device does not connect back. + 7. Reboot the device again, ensure user approval is kept """ self._test_connect_to_wifi_network_reboot_config_store( [self.wpa_psk_5g], self.wpa_psk_5g) @@ -325,9 +472,14 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 4. Reboot the device. 5. Wait for the device to connect to the wifi network. 6. Remove suggestions and ensure device doesn't connect back to it. + 7. Reboot the device again, ensure user approval is kept """ + if "carrierId" in self.config_aka: + self.set_carrier_approved(self.config_aka["carrierId"], True) self._test_connect_to_wifi_network_reboot_config_store( [self.config_aka], self.ent_network_2g) + if "carrierId" in self.config_aka: + self.clear_carrier_approved(self.config_aka["carrierId"]) @test_tracker_info(uuid="98b2d40a-acb4-4a2f-aba1-b069e2a1d09d") def test_connect_to_wpa_ent_config_ttls_pap_reboot_config_store(self): @@ -342,6 +494,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 4. Reboot the device. 5. Wait for the device to connect to the wifi network. 6. Remove suggestions and ensure device doesn't connect back to it. + 7. Reboot the device again, ensure user approval is kept """ config = dict(self.config_ttls) config[WifiEnums.Enterprise.PHASE2] = WifiEnums.EapPhase2.PAP.value @@ -362,7 +515,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): 3. Now approve the app. 4. Wait for the device to connect to it. """ - self.dut.log.info("Adding network suggestions"); + self.dut.log.info("Adding network suggestions") asserts.assert_true( self.dut.droid.wifiAddNetworkSuggestions([self.wpa_psk_5g]), "Failed to add suggestions") @@ -385,7 +538,7 @@ class WifiNetworkSuggestionTest(WifiBaseTest): self.dut, self.wpa_psk_5g[WifiEnums.SSID_KEY], assert_on_fail=False), "Should not connect to network suggestions from unapproved app") - self.dut.log.info("Enabling suggestions from test"); + self.dut.log.info("Enabling suggestions from test") # Now Enable suggestions by the app & ensure we connect to the network. self.set_approved(True) @@ -421,8 +574,8 @@ class WifiNetworkSuggestionTest(WifiBaseTest): [network_suggestion], self.wpa_psk_2g[WifiEnums.SSID_KEY], True) - # Simulate user forgetting the ephemeral network. - self.dut.droid.wifiDisableEphemeralNetwork( + # Simulate user disconnect the network. + self.dut.droid.wifiUserDisconnectNetwork( self.wpa_psk_2g[WifiEnums.SSID_KEY]) wutils.wait_for_disconnect(self.dut) self.dut.log.info("Disconnected from network %s", self.wpa_psk_2g) @@ -456,3 +609,259 @@ class WifiNetworkSuggestionTest(WifiBaseTest): [network_suggestion], network_suggestion[WifiEnums.SSID_KEY], False) self.remove_suggestions_disconnect_and_ensure_no_connection_back( [network_suggestion], network_suggestion[WifiEnums.SSID_KEY]) + + @test_tracker_info(uuid="806dff14-7543-482b-bd0a-598de59374b3") + def test_connect_to_passpoint_network_with_post_connection_broadcast(self): + """ Adds a passpoint network suggestion and ensure that the device connected. + + Steps: + 1. Send a network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did receive the post connection broadcast + (isAppInteractionRequired = true). + 4. Remove the suggestions and ensure the device does not connect back. + """ + asserts.skip_if(not hasattr(self, "passpoint_networks"), + "No passpoint networks, skip this test") + passpoint_config = self.passpoint_networks[ATT] + passpoint_config[WifiEnums.IS_APP_INTERACTION_REQUIRED] = True + if "carrierId" in passpoint_config: + self.set_carrier_approved(passpoint_config["carrierId"], True) + self.add_suggestions_and_ensure_connection([passpoint_config], + passpoint_config[WifiEnums.SSID_KEY], True) + self.remove_suggestions_disconnect_and_ensure_no_connection_back( + [passpoint_config], passpoint_config[WifiEnums.SSID_KEY]) + if "carrierId" in passpoint_config: + self.clear_carrier_approved(passpoint_config["carrierId"]) + + @test_tracker_info(uuid="159b8b8c-fb00-4d4e-a29f-606881dcbf44") + def test_connect_to_passpoint_network_reboot_config_store(self): + """ + Adds a passpoint network suggestion and ensure that the device connects to it + after reboot. + + Steps: + 1. Send a network suggestion to the device. + 2. Wait for the device to connect to it. + 3. Ensure that we did not receive the post connection broadcast + (isAppInteractionRequired = False). + 4. Reboot the device. + 5. Wait for the device to connect to back to it. + 6. Remove the suggestions and ensure the device does not connect back. + 7. Reboot the device again, ensure user approval is kept + """ + asserts.skip_if(not hasattr(self, "passpoint_networks"), + "No passpoint networks, skip this test") + passpoint_config = self.passpoint_networks[ATT] + if "carrierId" in passpoint_config: + self.set_carrier_approved(passpoint_config["carrierId"], True) + self._test_connect_to_wifi_network_reboot_config_store([passpoint_config], + passpoint_config) + if "carrierId" in passpoint_config: + self.clear_carrier_approved(passpoint_config["carrierId"]) + + @test_tracker_info(uuid="34f3d28a-bedf-43fe-a12d-2cfadf6bc6eb") + def test_fail_to_connect_to_passpoint_network_when_not_approved(self): + """ + Adds a passpoint network suggestion and ensure that the device does not + connect to it until we approve the app. + + Steps: + 1. Send a network suggestion to the device with the app not approved. + 2. Ensure the network is present in scan results, but we don't connect + to it. + 3. Now approve the app. + 4. Wait for the device to connect to it. + """ + asserts.skip_if(not hasattr(self, "passpoint_networks"), + "No passpoint networks, skip this test") + passpoint_config = self.passpoint_networks[ATT] + if "carrierId" in passpoint_config: + self.set_carrier_approved(passpoint_config["carrierId"], True) + self.dut.log.info("Adding network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]), + "Failed to add suggestions") + + # Disable suggestions by the app. + self.set_approved(False) + + # Ensure the app is not approved. + asserts.assert_false( + self.is_approved(), + "Suggestions should be disabled") + + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, passpoint_config[WifiEnums.SSID_KEY]) + + # Ensure we don't connect to the network. + asserts.assert_false( + wutils.wait_for_connect( + self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False), + "Should not connect to network suggestions from unapproved app") + + self.dut.log.info("Enabling suggestions from test") + # Now Enable suggestions by the app & ensure we connect to the network. + self.set_approved(True) + + # Ensure the app is approved. + asserts.assert_true( + self.is_approved(), + "Suggestions should be enabled") + + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, passpoint_config[WifiEnums.SSID_KEY]) + time.sleep(PASSPOINT_TIMEOUT) + wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY]) + if "carrierId" in passpoint_config: + self.clear_carrier_approved(passpoint_config["carrierId"]) + + @test_tracker_info(uuid="cf624cda-4d25-42f1-80eb-6c717fb08338") + def test_fail_to_connect_to_passpoint_network_when_imsi_protection_exemption_not_approved(self): + """ + Adds a passpoint network suggestion using SIM credential without IMSI privacy protection. + Before user approves the exemption, ensure that the device does noconnect to it until we + approve the carrier exemption. + + Steps: + 1. Send a network suggestion to the device with IMSI protection exemption not approved. + 2. Ensure the network is present in scan results, but we don't connect + to it. + 3. Now approve the carrier. + 4. Wait for the device to connect to it. + """ + asserts.skip_if(not hasattr(self, "passpoint_networks"), + "No passpoint networks, skip this test") + passpoint_config = self.passpoint_networks[ATT] + asserts.skip_if("carrierId" not in passpoint_config, + "Not a SIM based passpoint network, skip this test") + + # Ensure the carrier is not approved. + asserts.assert_false( + self.is_carrier_approved(passpoint_config["carrierId"]), + "Carrier shouldn't be approved") + + self.dut.log.info("Adding network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([passpoint_config]), + "Failed to add suggestions") + + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, passpoint_config[WifiEnums.SSID_KEY]) + + # Ensure we don't connect to the network. + asserts.assert_false( + wutils.wait_for_connect( + self.dut, passpoint_config[WifiEnums.SSID_KEY], assert_on_fail=False), + "Should not connect to network suggestions from unapproved app") + + self.dut.log.info("Enabling suggestions from test") + # Now approve IMSI protection exemption by carrier & ensure we connect to the network. + self.set_carrier_approved(passpoint_config["carrierId"], True) + + # Ensure the carrier is approved. + asserts.assert_true( + self.is_carrier_approved(passpoint_config["carrierId"]), + "Carrier should be approved") + + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, passpoint_config[WifiEnums.SSID_KEY]) + time.sleep(PASSPOINT_TIMEOUT) + wutils.wait_for_connect(self.dut, passpoint_config[WifiEnums.SSID_KEY]) + self.clear_carrier_approved(passpoint_config["carrierId"]) + + @test_tracker_info(uuid="e35f99c8-78a4-4b96-9258-f9834b6ddd33") + def test_initial_auto_join_on_network_suggestion(self): + """ + Add a network suggestion with enableAutojoin bit set to false, ensure the device doesn't + auto connect to this network + + Steps: + 1. Create a network suggestion. + 2. Set EnableAutojoin to false. + 3. Add this suggestion + 4. Ensure device doesn't connect to his network + """ + network_suggestion = self.wpa_psk_5g + # Set suggestion auto join initial to false. + network_suggestion[AutoJoin] = False + self.dut.log.info("Adding network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]), + "Failed to add suggestions") + # Enable suggestions by the app. + self.dut.log.debug("Enabling suggestions from test") + self.set_approved(True) + wutils.start_wifi_connection_scan_and_return_status(self.dut) + asserts.assert_false( + wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY], + assert_on_fail=False), "Device should not connect.") + + @test_tracker_info(uuid="ff4e451f-a380-4ff5-a5c2-dd9b1633d5e5") + def test_user_override_auto_join_on_network_suggestion(self): + """ + Add a network suggestion, user change the auto join to false, ensure the device doesn't + auto connect to this network + + Steps: + 1. Create a network suggestion. + 2. Add this suggestion, and ensure we connect to this network + 3. Simulate user change the auto join to false. + 4. Toggle the Wifi off and on + 4. Ensure device doesn't connect to his network + """ + network_suggestion = self.wpa_psk_5g + self.add_suggestions_and_ensure_connection([network_suggestion], + network_suggestion[WifiEnums.SSID_KEY], False) + wifi_info = self.dut.droid.wifiGetConnectionInfo() + self.dut.log.info(wifi_info) + network_id = wifi_info[WifiEnums.NETID_KEY] + # Simulate user disable auto join through Settings. + self.dut.log.info("Disable auto join on suggestion") + self.dut.droid.wifiEnableAutojoin(network_id, False) + wutils.wifi_toggle_state(self.dut, False) + wutils.wifi_toggle_state(self.dut, True) + asserts.assert_false( + wutils.wait_for_connect(self.dut, network_suggestion[WifiEnums.SSID_KEY], + assert_on_fail=False), "Device should not connect.") + + @test_tracker_info(uuid="32201b1c-76a0-46dc-9983-2cd24312a783") + def test_untrusted_suggestion_without_untrusted_request(self): + """ + Add an untrusted network suggestion, when no untrusted request, will not connect to it. + Steps: + 1. Create a untrusted network suggestion. + 2. Add this suggestion, and ensure device do not connect to this network + 3. Request untrusted network and ensure device connect to this network + """ + network_suggestion = self.open_5g + network_suggestion[Untrusted] = True + self.dut.log.info("Adding network suggestions") + asserts.assert_true( + self.dut.droid.wifiAddNetworkSuggestions([network_suggestion]), + "Failed to add suggestions") + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, network_suggestion[WifiEnums.SSID_KEY]) + + # Ensure we don't connect to the network. + asserts.assert_false( + wutils.wait_for_connect( + self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False), + "Should not connect to untrusted network suggestions with no request") + network_request = {ClearCapabilities: True, TransportType: 1} + req_key = self.dut.droid.connectivityRequestNetwork(network_request) + + # Start a new scan to trigger auto-join. + wutils.start_wifi_connection_scan_and_ensure_network_found( + self.dut, network_suggestion[WifiEnums.SSID_KEY]) + + wutils.wait_for_connect( + self.dut, network_suggestion[WifiEnums.SSID_KEY], assert_on_fail=False) + + self.dut.droid.connectivityUnregisterNetworkCallback(req_key) + diff --git a/acts_tests/tests/google/wifi/WifiPasspointTest.py b/acts_tests/tests/google/wifi/WifiPasspointTest.py index b867faad98..962d9dba2f 100755 --- a/acts_tests/tests/google/wifi/WifiPasspointTest.py +++ b/acts_tests/tests/google/wifi/WifiPasspointTest.py @@ -85,6 +85,9 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): def teardown_test(self): self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() + passpoint_configs = self.dut.droid.getPasspointConfigs() + for config in passpoint_configs: + wutils.delete_passpoint(self.dut, config) wutils.reset_wifi(self.dut) @@ -119,20 +122,18 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): """ ad = self.dut ad.ed.clear_all_events() - wutils.start_wifi_connection_scan(ad) - scan_results = ad.droid.wifiGetScanResults() - # Wait for scan to complete. - time.sleep(5) - ssid = passpoint_network - wutils.assert_network_in_list({WifiEnums.SSID_KEY: ssid}, scan_results) - # Passpoint network takes longer time to connect than normal networks. - # Every try comes with a timeout of 30s. Setting total timeout to 120s. - wutils.wifi_passpoint_connect(self.dut, passpoint_network, num_of_tries=4) + try: + wutils.start_wifi_connection_scan_and_return_status(ad) + wutils.wait_for_connect(ad) + except: + pass # Re-verify we are connected to the correct network. network_info = self.dut.droid.wifiGetConnectionInfo() - if network_info[WifiEnums.SSID_KEY] != passpoint_network: - raise signals.TestFailure("Device did not connect to the passpoint" - " network.") + self.log.info("Network Info: %s" % network_info) + if not network_info or not network_info[WifiEnums.SSID_KEY] or \ + network_info[WifiEnums.SSID_KEY] not in passpoint_network: + raise signals.TestFailure( + "Device did not connect to passpoint network.") def get_configured_passpoint_and_delete(self): @@ -342,6 +343,7 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): wutils.wait_for_disconnect(self.dut) + @test_tracker_info(uuid="37ae0223-0cb7-43f3-8ba8-474fad6e4b71") def test_install_att_passpoint_profile(self): """Add an AT&T Passpoint profile. @@ -395,3 +397,26 @@ class WifiPasspointTest(acts.base_test.BaseTestClass): @test_tracker_info(uuid="f43ea759-673f-4567-aa11-da3bc2cabf08") def test_start_subscription_provisioning_and_toggle_wifi(self): self.start_subscription_provisioning(TOGGLE) + + @test_tracker_info(uuid="ad6d5eb8-a3c5-4ce0-9e10-d0f201cd0f40") + def test_user_override_auto_join_on_passpoint_network(self): + """Add a Passpoint network, simulate user change the auto join to false, ensure the device + doesn't auto connect to this passponit network + + Steps: + 1. Install a Passpoint Profile. + 2. Verify the device connects to the required Passpoint SSID. + 3. Disable auto join Passpoint configuration using its FQDN. + 4. disable and enable Wifi toggle, ensure we don't connect back + """ + passpoint_config = self.passpoint_networks[BOINGO] + self.install_passpoint_profile(passpoint_config) + ssid = passpoint_config[WifiEnums.SSID_KEY] + self.check_passpoint_connection(ssid) + self.dut.log.info("Disable auto join on passpoint") + self.dut.droid.wifiEnableAutojoinPasspoint(passpoint_config['fqdn'], False) + wutils.wifi_toggle_state(self.dut, False) + wutils.wifi_toggle_state(self.dut, True) + asserts.assert_false( + wutils.wait_for_connect(self.dut, ssid, assert_on_fail=False), + "Device should not connect.") diff --git a/acts_tests/tests/google/wifi/WifiPingTest.py b/acts_tests/tests/google/wifi/WifiPingTest.py index cd9c52c39d..181d04d73f 100644 --- a/acts_tests/tests/google/wifi/WifiPingTest.py +++ b/acts_tests/tests/google/wifi/WifiPingTest.py @@ -188,20 +188,18 @@ class WifiPingTest(base_test.BaseTestClass): Args: result: dict containing ping results and meta data """ - # Get target range - #rvr_range = self.get_range_from_rvr() - # Set Blackbox metric - if self.publish_testcase_metrics: - self.testcase_metric_logger.add_metric('ping_range', - result['range']) # Evaluate test pass/fail test_message = ('Attenuation at range is {}dB. ' 'LLStats at Range: {}'.format( result['range'], result['llstats_at_range'])) if result['peak_throughput_pct'] < 95: asserts.fail("(RESULT NOT RELIABLE) {}".format(test_message)) - else: - asserts.explicit_pass(test_message) + + # If pass, set Blackbox metric + if self.publish_testcase_metrics: + self.testcase_metric_logger.add_metric('ping_range', + result['range']) + asserts.explicit_pass(test_message) def pass_fail_check(self, result): if 'range' in result['testcase_params']['test_type']: diff --git a/acts_tests/tests/google/wifi/WifiRoamingTest.py b/acts_tests/tests/google/wifi/WifiRoamingTest.py index 4a64ec1318..b0f1a71f7f 100644 --- a/acts_tests/tests/google/wifi/WifiRoamingTest.py +++ b/acts_tests/tests/google/wifi/WifiRoamingTest.py @@ -16,6 +16,8 @@ import pprint import random import time +from acts import context +from scapy.all import * from acts import asserts from acts import base_test @@ -25,6 +27,11 @@ from acts.test_utils.wifi import wifi_test_utils as wutils from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest WifiEnums = wutils.WifiEnums +DEF_ATTN = 60 +MAX_ATTN = 95 +ROAM_DBM = -75 +WAIT_AFTER_ATTN = 12 +ATTN_STEP = 5 class WifiRoamingTest(WifiBaseTest): @@ -54,7 +61,9 @@ class WifiRoamingTest(WifiBaseTest): asserts.assert_true( len(self.open_network) > 1, "Need at least two open networks for roaming") - wutils.wifi_toggle_state(self.dut, True) + + + self.configure_packet_capture() def teardown_class(self): self.dut.ed.clear_all_events() @@ -71,6 +80,8 @@ class WifiRoamingTest(WifiBaseTest): self.dut.droid.wakeLockRelease() self.dut.droid.goToSleepNow() wutils.reset_wifi(self.dut) + for a in self.attenuators: + a.set_atten(0) def on_fail(self, test_name, begin_time): self.dut.cat_adb_log(test_name, begin_time) @@ -91,10 +102,89 @@ class WifiRoamingTest(WifiBaseTest): 5. Validate connection information and ping. """ wutils.set_attns(self.attenuators, "AP1_on_AP2_off") - wutils.wifi_connect(self.dut, AP1_network) + wifi_config = AP1_network.copy() + wifi_config.pop("bssid") + wutils.connect_to_wifi_network(self.dut, wifi_config) self.log.info("Roaming from %s to %s", AP1_network, AP2_network) - wutils.trigger_roaming_and_validate(self.dut, self.attenuators, - "AP1_off_AP2_on", AP2_network) + wutils.trigger_roaming_and_validate( + self.dut, self.attenuators, "AP1_off_AP2_on", AP2_network) + + def get_rssi(self, pcap_file, expected_bssid): + """Get signal strength of the wifi network attenuated. + + Args: + pcap_file: PCAP file path. + expected_bssid: BSSID of the wifi network attenuated. + """ + packets = [] + try: + packets = rdpcap(pcap_file) + except Scapy_Exception: + self.log.error("Failed to read pcap file") + if not packets: + return 0 + + dbm = -100 + for pkt in packets: + if pkt and hasattr(pkt, 'type') and pkt.type == 0 and \ + pkt.subtype == 8 and hasattr(pkt, 'info'): + bssid = pkt.addr3 + if expected_bssid == bssid: + dbm = int(pkt.dBm_AntSignal) + self.log.info("RSSI: %s" % dbm) + return dbm + + def trigger_roaming_and_verify_attenuation(self, network): + """Trigger roaming and verify signal strength is below roaming limit. + + Args: + network: Wifi network that is being attenuated. + """ + wutils.set_attns_steps(self.attenuators, "AP1_off_AP2_on") + band = '5G' if network['SSID'].startswith('5g_') else '2G' + attn = DEF_ATTN + ATTN_STEP + while attn <= MAX_ATTN: + self.pcap_procs = wutils.start_pcap( + self.packet_capture, 'dual', self.test_name) + time.sleep(WAIT_AFTER_ATTN/3) + wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) + pcap_file = os.path.join( + context.get_current_context().get_full_output_path(), + 'PacketCapture', + '%s_%s.pcap' % (self.test_name, band)) + + rssi = self.get_rssi(pcap_file, network["bssid"]) + if rssi == 0: + self.log.error("Failed to verify signal strength") + break + if self.get_rssi(pcap_file, network["bssid"]) < ROAM_DBM: + break + + self.attenuators[0].set_atten(attn) + self.attenuators[1].set_atten(attn) + time.sleep(WAIT_AFTER_ATTN) # allow some time for attenuation + attn += 5 + + def validate_roaming(self, expected_con): + """Validate roaming. + + Args: + expected_con: Expected wifi network after roaming. + """ + expected_con = { + WifiEnums.SSID_KEY: expected_con[WifiEnums.SSID_KEY], + WifiEnums.BSSID_KEY: expected_con["bssid"], + } + curr_con = self.dut.droid.wifiGetConnectionInfo() + for key in expected_con: + if expected_con[key] != curr_con[key]: + asserts.fail("Expected '%s' to be %s, actual is %s." % + (key, expected_con[key], curr_con[key])) + self.log.info("Roamed to %s successfully", + expected_con[WifiEnums.BSSID_KEY]) + if not wutils.validate_connection(self.dut): + raise signals.TestFailure("Fail to connect to internet on %s" % + expected_con[WifiEnums.BSSID_KEY]) """ Tests Begin. diff --git a/acts_tests/tests/google/wifi/WifiRvrTest.py b/acts_tests/tests/google/wifi/WifiRvrTest.py index 8a8c8431f4..3033c59360 100644 --- a/acts_tests/tests/google/wifi/WifiRvrTest.py +++ b/acts_tests/tests/google/wifi/WifiRvrTest.py @@ -62,7 +62,6 @@ class WifiRvrTest(base_test.BaseTestClass): This function initializes hardwares and compiles parameters that are common to all tests in this class. """ - self.dut = self.android_devices[-1] req_params = [ 'RetailAccessPoints', 'rvr_test_params', 'testbed_params', 'RemoteServer', 'main_network' @@ -97,10 +96,11 @@ class WifiRvrTest(base_test.BaseTestClass): # Turn WiFi ON if self.testclass_params.get('airplane_mode', 1): - self.log.info('Turning on airplane mode.') - asserts.assert_true(utils.force_airplane_mode(self.dut, True), - "Can not turn on airplane mode.") - wutils.wifi_toggle_state(self.dut, True) + for dev in self.android_devices: + self.log.info('Turning on airplane mode.') + asserts.assert_true(utils.force_airplane_mode(dev, True), + "Can not turn on airplane mode.") + wutils.wifi_toggle_state(dev, True) def teardown_test(self): self.iperf_server.stop() @@ -150,7 +150,8 @@ class WifiRvrTest(base_test.BaseTestClass): try: throughput_limits = self.compute_throughput_limits(rvr_result) except: - asserts.fail('Test failed: Golden file not found') + asserts.explicit_pass( + 'Test passed by default. Golden file not found') failure_count = 0 for idx, current_throughput in enumerate( @@ -352,7 +353,9 @@ class WifiRvrTest(base_test.BaseTestClass): """ self.log.info('Start running RvR') # Refresh link layer stats before test - llstats_obj = wputils.LinkLayerStats(self.dut) + llstats_obj = wputils.LinkLayerStats( + self.monitored_dut, + self.testclass_params.get('monitor_llstats', 1)) zero_counter = 0 throughput = [] llstats = [] @@ -374,20 +377,33 @@ class WifiRvrTest(base_test.BaseTestClass): bw=int(testcase_params['mode'][3:]), duration=self.testclass_params['iperf_duration'] / 5) # Start iperf session + if self.testclass_params.get('monitor_rssi', 1): + rssi_future = wputils.get_connected_rssi_nb( + self.monitored_dut, + self.testclass_params['iperf_duration'] - 1, + 1, + 1, + interface=self.monitored_interface) self.iperf_server.start(tag=str(atten)) - rssi_future = wputils.get_connected_rssi_nb( - self.dut, self.testclass_params['iperf_duration'] - 1, 1, 1) client_output_path = self.iperf_client.start( testcase_params['iperf_server_address'], testcase_params['iperf_args'], str(atten), self.testclass_params['iperf_duration'] + self.TEST_TIMEOUT) server_output_path = self.iperf_server.stop() - rssi_result = rssi_future.result() - current_rssi = { - 'signal_poll_rssi': rssi_result['signal_poll_rssi']['mean'], - 'chain_0_rssi': rssi_result['chain_0_rssi']['mean'], - 'chain_1_rssi': rssi_result['chain_1_rssi']['mean'] - } + if self.testclass_params.get('monitor_rssi', 1): + rssi_result = rssi_future.result() + current_rssi = { + 'signal_poll_rssi': + rssi_result['signal_poll_rssi']['mean'], + 'chain_0_rssi': rssi_result['chain_0_rssi']['mean'], + 'chain_1_rssi': rssi_result['chain_1_rssi']['mean'] + } + else: + current_rssi = { + 'signal_poll_rssi': float('nan'), + 'chain_0_rssi': float('nan'), + 'chain_1_rssi': float('nan') + } rssi.append(current_rssi) # Stop sniffer if self.testbed_params['sniffer_enable']: @@ -477,26 +493,33 @@ class WifiRvrTest(base_test.BaseTestClass): Args: testcase_params: dict containing AP and other test params """ + self.sta_dut = self.android_devices[0] # Check battery level before test if not wputils.health_check( - self.dut, 20) and testcase_params['traffic_direction'] == 'UL': + self.sta_dut, + 20) and testcase_params['traffic_direction'] == 'UL': asserts.skip('Overheating or Battery level low. Skipping test.') # Turn screen off to preserve battery - self.dut.go_to_sleep() - if wputils.validate_network(self.dut, + self.sta_dut.go_to_sleep() + if wputils.validate_network(self.sta_dut, testcase_params['test_network']['SSID']): self.log.info('Already connected to desired network') else: - wutils.reset_wifi(self.dut) - wutils.set_wifi_country_code(self.dut, + wutils.reset_wifi(self.sta_dut) + wutils.set_wifi_country_code(self.sta_dut, self.testclass_params['country_code']) - testcase_params['test_network']['channel'] = testcase_params[ - 'channel'] - wutils.wifi_connect(self.dut, + if self.testbed_params['sniffer_enable']: + self.sniffer.start_capture( + network={'SSID': testcase_params['test_network']['SSID']}, + chan=testcase_params['channel'], + bw=testcase_params['mode'][3:], + duration=180) + wutils.wifi_connect(self.sta_dut, testcase_params['test_network'], num_of_tries=5, check_connectivity=True) - self.dut_ip = self.dut.droid.connectivityGetIPv4Addresses('wlan0')[0] + if self.testbed_params['sniffer_enable']: + self.sniffer.stop_capture(tag='connection_setup') def setup_rvr_test(self, testcase_params): """Function that gets devices ready for the test. @@ -518,12 +541,17 @@ class WifiRvrTest(base_test.BaseTestClass): time.sleep(first_test_delay) self.setup_dut(testcase_params) # Get iperf_server address + sta_dut_ip = self.sta_dut.droid.connectivityGetIPv4Addresses( + 'wlan0')[0] if isinstance(self.iperf_server, ipf.IPerfServerOverAdb): - testcase_params['iperf_server_address'] = self.dut_ip + testcase_params['iperf_server_address'] = sta_dut_ip else: testcase_params[ 'iperf_server_address'] = wputils.get_server_address( - self.remote_server, self.dut_ip, '255.255.255.0') + self.remote_server, sta_dut_ip, '255.255.255.0') + # Set DUT to monitor RSSI and LLStats on + self.monitored_dut = self.sta_dut + self.monitored_interface = None def compile_test_params(self, testcase_params): """Function that completes all test params based on the test name. @@ -542,6 +570,16 @@ class WifiRvrTest(base_test.BaseTestClass): band = self.access_point.band_lookup_by_channel( testcase_params['channel']) testcase_params['test_network'] = self.main_network[band] + if testcase_params['traffic_type'] == 'TCP': + testcase_params['iperf_socket_size'] = self.testclass_params.get( + 'tcp_socket_size', None) + testcase_params['iperf_processes'] = self.testclass_params.get( + 'tcp_processes', 1) + elif testcase_params['traffic_type'] == 'UDP': + testcase_params['iperf_socket_size'] = self.testclass_params.get( + 'udp_socket_size', None) + testcase_params['iperf_processes'] = self.testclass_params.get( + 'udp_processes', 1) if (testcase_params['traffic_direction'] == 'DL' and not isinstance(self.iperf_server, ipf.IPerfServerOverAdb) ) or (testcase_params['traffic_direction'] == 'UL' @@ -549,13 +587,17 @@ class WifiRvrTest(base_test.BaseTestClass): testcase_params['iperf_args'] = wputils.get_iperf_arg_string( duration=self.testclass_params['iperf_duration'], reverse_direction=1, - traffic_type=testcase_params['traffic_type']) + traffic_type=testcase_params['traffic_type'], + socket_size=testcase_params['iperf_socket_size'], + num_processes=testcase_params['iperf_processes']) testcase_params['use_client_output'] = True else: testcase_params['iperf_args'] = wputils.get_iperf_arg_string( duration=self.testclass_params['iperf_duration'], reverse_direction=0, - traffic_type=testcase_params['traffic_type']) + traffic_type=testcase_params['traffic_type'], + socket_size=testcase_params['iperf_socket_size'], + num_processes=testcase_params['iperf_processes']) testcase_params['use_client_output'] = False return testcase_params diff --git a/acts_tests/tests/google/wifi/WifiScannerScanTest.py b/acts_tests/tests/google/wifi/WifiScannerScanTest.py index 05945dcbc3..89ce0d69c6 100755 --- a/acts_tests/tests/google/wifi/WifiScannerScanTest.py +++ b/acts_tests/tests/google/wifi/WifiScannerScanTest.py @@ -95,9 +95,6 @@ class WifiScannerScanTest(WifiBaseTest): } self.log.debug("Run extended test: {}".format(self.run_extended_test)) self.wifi_chs = wutils.WifiChannelUS(self.dut.model) - asserts.assert_true(self.dut.droid.wifiIsScannerSupported(), - "Device %s doesn't support WifiScanner, abort." % - self.dut.model) self.attenuators = wutils.group_attenuators(self.attenuators) self.attenuators[0].set_atten(0) self.attenuators[1].set_atten(0) @@ -548,9 +545,10 @@ class WifiScannerScanTest(WifiBaseTest): band: wifi band.""" r = self.dut.droid.wifiScannerGetAvailableChannels(band) - self.log.debug(band) - self.log.debug(r) + self.log.info("Band: %s" % band) + self.log.info("Available channels: %s" % r) expected = self.wifi_chs.band_to_freq(band) + self.log.info("Expected channels: %s" % expected) asserts.assert_equal(set(r), set(expected), "Band %s failed." % band) def connect_to_reference_network(self): diff --git a/acts_tests/tests/google/wifi/WifiSoftApAcsTest.py b/acts_tests/tests/google/wifi/WifiSoftApAcsTest.py index edd76368ee..dc993816f0 100644 --- a/acts_tests/tests/google/wifi/WifiSoftApAcsTest.py +++ b/acts_tests/tests/google/wifi/WifiSoftApAcsTest.py @@ -34,7 +34,8 @@ from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest from threading import Thread WifiEnums = wutils.WifiEnums -WIFI_CONFIG_APBAND_AUTO = -1 +WIFI_CONFIG_APBAND_AUTO = WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G_5G +GET_FREQUENCY_NUM_RETRIES = 3 class WifiSoftApAcsTest(WifiBaseTest): """Tests for Automatic Channel Selection. @@ -103,9 +104,8 @@ class WifiSoftApAcsTest(WifiBaseTest): self.access_points[0].close() def on_fail(self, test_name, begin_time): - self.dut.take_bug_report(test_name, begin_time) - self.dut.cat_adb_log(test_name, begin_time) for ad in self.android_devices: + ad.take_bug_report(test_name, begin_time) wutils.get_cnss_diag_log(ad, test_name) """Helper Functions""" @@ -155,10 +155,15 @@ class WifiSoftApAcsTest(WifiBaseTest): """ wutils.connect_to_wifi_network(self.dut_client, softap, check_connectivity=False) - softap_info = self.dut_client.droid.wifiGetConnectionInfo() - self.log.debug("DUT is connected to softAP %s with details: %s" % - (softap[wutils.WifiEnums.SSID_KEY], softap_info)) - frequency = softap_info['frequency'] + for _ in range(GET_FREQUENCY_NUM_RETRIES): + softap_info = self.dut_client.droid.wifiGetConnectionInfo() + self.log.debug("DUT is connected to softAP %s with details: %s" % + (softap[wutils.WifiEnums.SSID_KEY], softap_info)) + frequency = softap_info['frequency'] + if frequency > 0: + break + time.sleep(1) # frequency not updated yet, try again after a delay + return hostapd_constants.CHANNEL_MAP[frequency] def configure_ap(self, channel_2g=None, channel_5g=None): diff --git a/acts_tests/tests/google/wifi/WifiSoftApPerformanceTest.py b/acts_tests/tests/google/wifi/WifiSoftApPerformanceTest.py index 489ab61b66..375ae937f9 100644 --- a/acts_tests/tests/google/wifi/WifiSoftApPerformanceTest.py +++ b/acts_tests/tests/google/wifi/WifiSoftApPerformanceTest.py @@ -25,6 +25,7 @@ from acts.metrics.loggers.blackbox import BlackboxMappedMetricLogger from acts.test_utils.wifi import ota_sniffer from acts.test_utils.wifi import wifi_test_utils as wutils from acts.test_utils.wifi import wifi_performance_test_utils as wputils +from acts.test_utils.wifi import wifi_retail_ap as retail_ap from WifiRvrTest import WifiRvrTest AccessPointTuple = collections.namedtuple(('AccessPointTuple'), @@ -35,7 +36,15 @@ class WifiSoftApRvrTest(WifiRvrTest): def __init__(self, controllers): base_test.BaseTestClass.__init__(self, controllers) self.tests = ('test_rvr_TCP_DL_2GHz', 'test_rvr_TCP_UL_2GHz', - 'test_rvr_TCP_DL_5GHz', 'test_rvr_TCP_UL_5GHz') + 'test_rvr_TCP_DL_5GHz', 'test_rvr_TCP_UL_5GHz', + 'test_rvr_TCP_DL_2GHz_backhaul_2GHz', + 'test_rvr_TCP_UL_2GHz_backhaul_2GHz', + 'test_rvr_TCP_DL_5GHz_backhaul_2GHz', + 'test_rvr_TCP_UL_5GHz_backhaul_2GHz', + 'test_rvr_TCP_DL_2GHz_backhaul_5GHz', + 'test_rvr_TCP_UL_2GHz_backhaul_5GHz', + 'test_rvr_TCP_DL_5GHz_backhaul_5GHz', + 'test_rvr_TCP_UL_5GHz_backhaul_5GHz') self.testcase_metric_logger = ( BlackboxMappedMetricLogger.for_test_case()) self.testclass_metric_logger = ( @@ -48,10 +57,14 @@ class WifiSoftApRvrTest(WifiRvrTest): This function initializes hardwares and compiles parameters that are common to all tests in this class. """ - self.dut = self.android_devices[-1] - req_params = ['sap_test_params', 'testbed_params'] + req_params = [ + 'sap_test_params', 'testbed_params', 'RetailAccessPoints', + 'ap_networks' + ] opt_params = ['golden_files_list', 'OTASniffer'] self.unpack_userparams(req_params, opt_params) + self.access_points = retail_ap.create(self.RetailAccessPoints) + self.access_point = self.access_points[0] self.testclass_params = self.sap_test_params self.num_atten = self.attenuators[0].instrument.num_atten self.iperf_server = ipf.create([{ @@ -94,6 +107,8 @@ class WifiSoftApRvrTest(WifiRvrTest): for dev in self.android_devices: wutils.wifi_toggle_state(dev, False) self.process_testclass_results() + # Teardown AP and release it's lockfile + self.access_point.teardown() def teardown_test(self): self.iperf_server.stop() @@ -109,23 +124,45 @@ class WifiSoftApRvrTest(WifiRvrTest): 'wpa_cli status | grep freq').split('=')[1] info['channel'] = wutils.WifiEnums.freq_to_channel[int( info['frequency'])] + info['mode'] = 'VHT20' if info['channel'] < 13 else 'VHT80' return info - def setup_sap_rvr_test(self, testcase_params): + def setup_aps(self, testcase_params): + for network in testcase_params['ap_networks']: + self.log.info('Setting AP {} {} interface on channel {}'.format( + network['ap_id'], network['interface_id'], network['channel'])) + self.access_points[network['ap_id']].set_channel( + network['interface_id'], network['channel']) + + def setup_duts(self, testcase_params): """Function that gets devices ready for the test. Args: testcase_params: dict containing test-specific parameters """ + self.ap_dut = self.android_devices[0] + self.sta_dut = self.android_devices[1] for dev in self.android_devices: if not wputils.health_check(dev, 20): asserts.skip('DUT health check failed. Skipping test.') # Reset WiFi on all devices for dev in self.android_devices: - self.dut.go_to_sleep() + dev.go_to_sleep() wutils.reset_wifi(dev) wutils.set_wifi_country_code(dev, wutils.WifiEnums.CountryCode.US) + for network in testcase_params['ap_networks']: + for connected_dut in network['connected_dut']: + self.log.info("Connecting DUT {} to {}".format( + connected_dut, self.ap_networks[network['ap_id']][ + network['interface_id']])) + wutils.wifi_connect(self.android_devices[connected_dut], + self.ap_networks[network['ap_id']][ + network['interface_id']], + num_of_tries=5, + check_connectivity=True) + + def setup_sap_connection(self, testcase_params): # Setup Soft AP sap_config = wutils.create_softap_config() self.log.info('SoftAP Config: {}'.format(sap_config)) @@ -133,31 +170,39 @@ class WifiSoftApRvrTest(WifiRvrTest): sap_config[wutils.WifiEnums.SSID_KEY], sap_config[wutils.WifiEnums.PWD_KEY], testcase_params['sap_band_enum']) - # Set attenuator to 0 dB - for attenuator in self.attenuators: - attenuator.set_atten(0, strict=False) # Connect DUT to Network testcase_params['test_network'] = { 'SSID': sap_config[wutils.WifiEnums.SSID_KEY], 'password': sap_config[wutils.WifiEnums.PWD_KEY] } - wutils.wifi_connect(self.android_devices[1], + wutils.wifi_connect(self.sta_dut, testcase_params['test_network'], num_of_tries=5, check_connectivity=False) # Compile meta data - self.access_point = AccessPointTuple(sap_config) - testcase_params['connection_info'] = self.get_sap_connection_info() - testcase_params['channel'] = testcase_params['connection_info'][ - 'channel'] - testcase_params['test_network']['channel'] = testcase_params[ - 'connection_info']['channel'] - if testcase_params['channel'] < 13: - testcase_params['mode'] = 'VHT20' - else: - testcase_params['mode'] = 'VHT80' - testcase_params['iperf_server_address'] = testcase_params[ - 'connection_info']['ap_ip_address'] + #self.access_point = AccessPointTuple(sap_config) + sap_info = self.get_sap_connection_info() + testcase_params['channel'] = sap_info['channel'] + testcase_params['mode'] = sap_info['mode'] + testcase_params['iperf_server_address'] = sap_info['ap_ip_address'] + + def setup_sap_rvr_test(self, testcase_params): + """Function that gets devices ready for the test. + + Args: + testcase_params: dict containing test-specific parameters + """ + # Configure DUTs + self.setup_aps(testcase_params) + # Set attenuator to 0 dB + for attenuator in self.attenuators: + attenuator.set_atten(0, strict=False) + # Configure DUTs + self.setup_duts(testcase_params) + # Setup sap connection + self.setup_sap_connection(testcase_params) + # Set DUT to monitor RSSI and LLStats on + self.monitored_dut = self.sta_dut def compile_test_params(self, testcase_params): """Function that completes all test params based on the test name. @@ -186,6 +231,40 @@ class WifiSoftApRvrTest(WifiRvrTest): reverse_direction=0, traffic_type=testcase_params['traffic_type']) testcase_params['use_client_output'] = False + + # Compile AP and infrastructure connection parameters + ap_networks = [] + if testcase_params['dut_connected'][0]: + band = testcase_params['dut_connected'][0].split('_')[0] + ap_networks.append({ + 'ap_id': 0, + 'interface_id': band if band == '2G' else band + '_1', + 'band': band, + 'channel': 1 if band == '2G' else 36, + 'connected_dut': [0] + }) + + if testcase_params['dut_connected'][1]: + if testcase_params['dut_connected'][0] == testcase_params[ + 'dut_connected'][1]: + # if connected to same network, add it to the above + ap_networks[0]['connected_dut'].append(1) + else: + band = testcase_params['dut_connected'][1].split('_')[0] + if not testcase_params['dut_connected'][0]: + # if it's the only dut connected, assign it to ap 0 + ap_id = 0 + else: + ap_id = 1 + ap_networks.append({ + 'ap_id': ap_id, + 'interface_id': band if band == '2G' else band + '_1', + 'band': band, + 'channel': 11 if band == '2G' else 149, + 'connected_dut': [1] + }) + testcase_params['ap_networks'] = ap_networks + return testcase_params def _test_sap_rvr(self, testcase_params): @@ -209,7 +288,8 @@ class WifiSoftApRvrTest(WifiRvrTest): sap_band='2GHz', sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, traffic_type='TCP', - traffic_direction='DL') + traffic_direction='DL', + dut_connected=[False, False]) self._test_sap_rvr(testcase_params) def test_rvr_TCP_UL_2GHz(self): @@ -217,7 +297,8 @@ class WifiSoftApRvrTest(WifiRvrTest): sap_band='2GHz', sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, traffic_type='TCP', - traffic_direction='UL') + traffic_direction='UL', + dut_connected=[False, False]) self._test_sap_rvr(testcase_params) def test_rvr_TCP_DL_5GHz(self): @@ -225,7 +306,8 @@ class WifiSoftApRvrTest(WifiRvrTest): sap_band='5GHz', sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, traffic_type='TCP', - traffic_direction='DL') + traffic_direction='DL', + dut_connected=[False, False]) self._test_sap_rvr(testcase_params) def test_rvr_TCP_UL_5GHz(self): @@ -233,5 +315,78 @@ class WifiSoftApRvrTest(WifiRvrTest): sap_band='5GHz', sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, traffic_type='TCP', - traffic_direction='UL') + traffic_direction='UL', + dut_connected=[False, False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_DL_2GHz_backhaul_2GHz(self): + testcase_params = collections.OrderedDict( + sap_band='2GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, + traffic_type='TCP', + traffic_direction='DL', + dut_connected=['2G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_UL_2GHz_backhaul_2GHz(self): + testcase_params = collections.OrderedDict( + sap_band='2GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, + traffic_type='TCP', + traffic_direction='UL', + dut_connected=['2G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_DL_5GHz_backhaul_2GHz(self): + testcase_params = collections.OrderedDict( + sap_band='5GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, + traffic_type='TCP', + traffic_direction='DL', + dut_connected=['2G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_UL_5GHz_backhaul_2GHz(self): + testcase_params = collections.OrderedDict( + sap_band='5GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, + traffic_type='TCP', + traffic_direction='UL', + dut_connected=['2G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_DL_2GHz_backhaul_5GHz(self): + testcase_params = collections.OrderedDict( + sap_band='2GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, + traffic_type='TCP', + traffic_direction='DL', + dut_connected=['5G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_UL_2GHz_backhaul_5GHz(self): + testcase_params = collections.OrderedDict( + sap_band='2GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_2G, + traffic_type='TCP', + traffic_direction='UL', + dut_connected=['5G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_DL_5GHz_backhaul_5GHz(self): + testcase_params = collections.OrderedDict( + sap_band='5GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, + traffic_type='TCP', + traffic_direction='DL', + dut_connected=['5G_1', False]) + self._test_sap_rvr(testcase_params) + + def test_rvr_TCP_UL_5GHz_backhaul_5GHz(self): + testcase_params = collections.OrderedDict( + sap_band='5GHz', + sap_band_enum=wutils.WifiEnums.WIFI_CONFIG_APBAND_5G, + traffic_type='TCP', + traffic_direction='UL', + dut_connected=['5G_1', False]) self._test_sap_rvr(testcase_params) diff --git a/acts_tests/tests/google/wifi/WifiSoftApTest.py b/acts_tests/tests/google/wifi/WifiSoftApTest.py index de14eb3938..8faf1c5672 100644 --- a/acts_tests/tests/google/wifi/WifiSoftApTest.py +++ b/acts_tests/tests/google/wifi/WifiSoftApTest.py @@ -33,6 +33,8 @@ from acts.test_utils.wifi import wifi_constants from acts.test_utils.wifi import wifi_test_utils as wutils from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest +WifiEnums = wutils.WifiEnums + class WifiSoftApTest(WifiBaseTest): def setup_class(self): @@ -80,9 +82,11 @@ class WifiSoftApTest(WifiBaseTest): self.android_devices[2].droid.wifiEnableVerboseLogging(1) asserts.assert_equal(self.android_devices[2].droid.wifiGetVerboseLoggingLevel(), 1, "Failed to enable WiFi verbose logging on the client dut.") + self.dut_client_2 = self.android_devices[2] def teardown_class(self): - wutils.stop_wifi_tethering(self.dut) + if self.dut.droid.wifiIsApEnabled(): + wutils.stop_wifi_tethering(self.dut) wutils.reset_wifi(self.dut) wutils.reset_wifi(self.dut_client) if "AccessPoint" in self.user_params: @@ -499,7 +503,7 @@ class WifiSoftApTest(WifiBaseTest): 6. Unregister second softap callback 7. Force second client connect to hotspot (if supported) 8. Turn off hotspot - 9. Verify second softap callback doesn't respond after unresister + 9. Verify second softap callback doesn't respond after unregister """ config = wutils.start_softap_and_verify(self, WIFI_CONFIG_APBAND_AUTO) # Register callback after softap enabled to avoid unnecessary callback @@ -620,6 +624,265 @@ class WifiSoftApTest(WifiBaseTest): "SoftAp is not reported as running") self.dut.droid.unregisterSoftApCallback(callbackId) + @test_tracker_info(uuid="3a10c7fd-cd8d-4d46-9d12-88a68640e060") + def test_softap_auto_shut_off_with_customized_timeout(self): + """Test for softap auto shut off + 1. Turn on hotspot + 2. Register softap callback + 3. Backup original shutdown timeout value + 4. Set up test_shutdown_timeout_value + 5. Let client connect to the hotspot + 6. Start wait test_shutdown_timeout_value * 1.1 seconds + 7. Check hotspot doesn't shut off + 8. Let client disconnect to the hotspot + 9. Start wait test_shutdown_timeout_value seconds + 10. Check hotspot auto shut off + """ + # Backup config + original_softap_config = self.dut.droid.wifiGetApConfiguration() + # This config only included SSID and Password which used for connection + # only. + config = wutils.start_softap_and_verify(self, WIFI_CONFIG_APBAND_AUTO) + + # Get current configuration to use for update configuration + current_softap_config = self.dut.droid.wifiGetApConfiguration() + # Register callback after softap enabled to avoid unnecessary callback + # impact the test + callbackId = self.dut.droid.registerSoftApCallback() + # Verify clients will update immediately after register callback + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 0) + wutils.wait_for_expected_softap_state(self.dut, callbackId, + wifi_constants.WIFI_AP_ENABLED_STATE) + + # Setup shutdown timeout value + test_shutdown_timeout_value_s = 10 + wutils.save_wifi_soft_ap_config(self.dut, current_softap_config, + shutdown_timeout_millis=test_shutdown_timeout_value_s * 1000) + # Force DUTs connect to Network + wutils.wifi_connect(self.dut_client, config, check_connectivity=False) + wutils.wait_for_expected_number_of_softap_clients( + self.dut, callbackId, 1) + + self.dut.log.info("Start waiting %s seconds with 1 clients ", + test_shutdown_timeout_value_s * 1.1) + time.sleep(test_shutdown_timeout_value_s * 1.1) + + # When client connected, softap should keep as enabled + asserts.assert_true(self.dut.droid.wifiIsApEnabled(), + "SoftAp is not reported as running") + + wutils.wifi_toggle_state(self.dut_client, False) + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 0) + self.dut.log.info("Start waiting %s seconds with 0 client", + test_shutdown_timeout_value_s * 1.1) + time.sleep(test_shutdown_timeout_value_s * 1.1) + # Softap should stop since no client connected + # doesn't disconnect before softap stop + wutils.wait_for_expected_softap_state(self.dut, callbackId, + wifi_constants.WIFI_AP_DISABLING_STATE) + wutils.wait_for_expected_softap_state(self.dut, callbackId, + wifi_constants.WIFI_AP_DISABLED_STATE) + asserts.assert_false(self.dut.droid.wifiIsApEnabled(), + "SoftAp is not reported as running") + self.dut.droid.unregisterSoftApCallback(callbackId) + + # Restore config + wutils.save_wifi_soft_ap_config(self.dut, original_softap_config) + + @test_tracker_info(uuid="a9444699-f0d3-4ac3-922b-05e9d4f67968") + def test_softap_configuration_update(self): + """Test for softap configuration update + 1. Get current softap configuration + 2. Update to Open Security configuration + 3. Update to WPA2_PSK configuration + 4. Restore the configuration + """ + # Backup config + original_softap_config = self.dut.droid.wifiGetApConfiguration() + wutils.save_wifi_soft_ap_config(self.dut, {"SSID":"ACTS_TEST"}, + band=WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G, hidden=False, + security=WifiEnums.SoftApSecurityType.OPEN, password="", + channel=11, max_clients=0, shutdown_timeout_enable=False, + shutdown_timeout_millis=0, client_control_enable=True, + allowedList=[], blockedList=[]) + + wutils.save_wifi_soft_ap_config(self.dut, {"SSID":"ACTS_TEST"}, + band=WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G_5G, hidden=True, + security=WifiEnums.SoftApSecurityType.WPA2, password="12345678", + channel=0, max_clients=1, shutdown_timeout_enable=True, + shutdown_timeout_millis=10000, client_control_enable=False, + allowedList=["aa:bb:cc:dd:ee:ff"], blockedList=["11:22:33:44:55:66"]) + + # Restore config + wutils.save_wifi_soft_ap_config(self.dut, original_softap_config) + + @test_tracker_info(uuid="8a5d81fa-649c-4679-a823-5cef50828a94") + def test_softap_client_control(self): + """Test Client Control feature + 1. Check SoftApCapability to make sure feature is supported + 2. Backup config + 3. Setup configuration which used to start softap + 4. Register callback after softap enabled + 5. Trigger client connect to softap + 6. Verify blocking event + 7. Add client into allowed list + 8. Verify client connected + 9. Restore Config + """ + # Register callback to check capability first + callbackId = self.dut.droid.registerSoftApCallback() + # Check capability first to make sure DUT support this test. + capabilityEventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( + callbackId) + wifi_constants.SOFTAP_CAPABILITY_CHANGED + capability = self.dut.ed.pop_event(capabilityEventStr, 10) + asserts.skip_if(not capability['data'][wifi_constants + .SOFTAP_CAPABILITY_FEATURE_CLIENT_CONTROL], + "Client control isn't supported, ignore test") + + # Unregister callback before start test to avoid + # unnecessary callback impact the test + self.dut.droid.unregisterSoftApCallback(callbackId) + + # start the test + + # Backup config + original_softap_config = self.dut.droid.wifiGetApConfiguration() + # Setup configuration which used to start softap + wutils.save_wifi_soft_ap_config(self.dut, {"SSID":"ACTS_TEST"}, + band=WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G_5G, hidden=False, + security=WifiEnums.SoftApSecurityType.WPA2, password="12345678", + client_control_enable=True) + + wutils.start_wifi_tethering_saved_config(self.dut) + current_softap_config = self.dut.droid.wifiGetApConfiguration() + # Register callback after softap enabled to avoid unnecessary callback + # impact the test + callbackId = self.dut.droid.registerSoftApCallback() + + # Verify clients will update immediately after register callback + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 0) + wutils.wait_for_expected_softap_state(self.dut, callbackId, + wifi_constants.WIFI_AP_ENABLED_STATE) + + # Trigger client connection + self.dut_client.droid.wifiConnectByConfig(current_softap_config) + + eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( + callbackId) + wifi_constants.SOFTAP_BLOCKING_CLIENT_CONNECTING + blockedClient = self.dut.ed.pop_event(eventStr, 10) + asserts.assert_equal(blockedClient['data'][wifi_constants. + SOFTAP_BLOCKING_CLIENT_REASON_KEY], + wifi_constants.SAP_CLIENT_BLOCK_REASON_CODE_BLOCKED_BY_USER, + "Blocked reason code doesn't match") + + # Update configuration, add client into allowed list + wutils.save_wifi_soft_ap_config(self.dut, current_softap_config, + allowedList=[blockedClient['data'][wifi_constants. + SOFTAP_BLOCKING_CLIENT_WIFICLIENT_KEY]]) + + # Wait configuration updated + time.sleep(3) + # Trigger connection again + self.dut_client.droid.wifiConnectByConfig(current_softap_config) + + # Verify client connected + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 1) + + # Restore config + wutils.save_wifi_soft_ap_config(self.dut, original_softap_config) + + # Unregister callback + self.dut.droid.unregisterSoftApCallback(callbackId) + + @test_tracker_info(uuid="d0b61b58-fa2b-4ced-bc52-3366cb826e79") + def test_softap_max_client_setting(self): + """Test Client Control feature + 1. Check device number and capability to make sure feature is supported + 2. Backup config + 3. Setup configuration which used to start softap + 4. Register callback after softap enabled + 5. Trigger client connect to softap + 6. Verify blocking event + 7. Extend max client setting + 8. Verify client connected + 9. Restore Config + """ + asserts.skip_if(len(self.android_devices) < 3, + "Device less than 3, skip the test.") + # Register callback to check capability first + callbackId = self.dut.droid.registerSoftApCallback() + # Check capability first to make sure DUT support this test. + capabilityEventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( + callbackId) + wifi_constants.SOFTAP_CAPABILITY_CHANGED + capability = self.dut.ed.pop_event(capabilityEventStr, 10) + asserts.skip_if(not capability['data'][wifi_constants + .SOFTAP_CAPABILITY_FEATURE_CLIENT_CONTROL], + "Client control isn't supported, ignore test") + + # Unregister callback before start test to avoid + # unnecessary callback impact the test + self.dut.droid.unregisterSoftApCallback(callbackId) + + # Backup config + original_softap_config = self.dut.droid.wifiGetApConfiguration() + # Setup configuration which used to start softap + wutils.save_wifi_soft_ap_config(self.dut, {"SSID":"ACTS_TEST"}, + band=WifiEnums.WIFI_CONFIG_SOFTAP_BAND_2G_5G, hidden=False, + security=WifiEnums.SoftApSecurityType.WPA2, password="12345678", + max_clients=1) + + wutils.start_wifi_tethering_saved_config(self.dut) + current_softap_config = self.dut.droid.wifiGetApConfiguration() + # Register callback again after softap enabled to avoid + # unnecessary callback impact the test + callbackId = self.dut.droid.registerSoftApCallback() + + # Verify clients will update immediately after register calliback + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 0) + wutils.wait_for_expected_softap_state(self.dut, callbackId, + wifi_constants.WIFI_AP_ENABLED_STATE) + + # Trigger client connection + self.dut_client.droid.wifiConnectByConfig(current_softap_config) + self.dut_client_2.droid.wifiConnectByConfig(current_softap_config) + # Wait client connect + time.sleep(3) + + # Verify one client connected and one blocked due to max client + eventStr = wifi_constants.SOFTAP_CALLBACK_EVENT + str( + callbackId) + wifi_constants.SOFTAP_BLOCKING_CLIENT_CONNECTING + blockedClient = self.dut.ed.pop_event(eventStr, 10) + asserts.assert_equal(blockedClient['data'][wifi_constants. + SOFTAP_BLOCKING_CLIENT_REASON_KEY], + wifi_constants.SAP_CLIENT_BLOCK_REASON_CODE_NO_MORE_STAS, + "Blocked reason code doesn't match") + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 1) + + # Update configuration, extend client to 2 + wutils.save_wifi_soft_ap_config(self.dut, current_softap_config, + max_clients=2) + + # Wait configuration updated + time.sleep(3) + # Trigger connection again + self.dut_client_2.droid.wifiConnectByConfig(current_softap_config) + # Wait client connect + time.sleep(3) + # Verify client connected + wutils.wait_for_expected_number_of_softap_clients(self.dut, + callbackId, 2) + + # Restore config + wutils.save_wifi_soft_ap_config(self.dut, original_softap_config) + + # Unregister callback + self.dut.droid.unregisterSoftApCallback(callbackId) """ Tests End """ diff --git a/acts_tests/tests/google/wifi/WifiStaApConcurrencyStressTest.py b/acts_tests/tests/google/wifi/WifiStaApConcurrencyStressTest.py index 6dda5ddae5..f84c06c21e 100755 --- a/acts_tests/tests/google/wifi/WifiStaApConcurrencyStressTest.py +++ b/acts_tests/tests/google/wifi/WifiStaApConcurrencyStressTest.py @@ -59,76 +59,38 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): "test_stress_softap_5G_wifi_connection_2G_with_location_scan_on") def setup_class(self): - self.dut = self.android_devices[0] - self.dut_client = self.android_devices[1] - wutils.wifi_test_device_init(self.dut) - wutils.wifi_test_device_init(self.dut_client) - # Do a simple version of init - mainly just sync the time and enable - # verbose logging. This test will fail if the DUT has a sim and cell - # data is disabled. We would also like to test with phones in less - # constrained states (or add variations where we specifically - # constrain). - utils.require_sl4a((self.dut, self.dut_client)) - utils.sync_device_time(self.dut) - utils.sync_device_time(self.dut_client) - # Set country code explicitly to "US". - wutils.set_wifi_country_code(self.dut, wutils.WifiEnums.CountryCode.US) - wutils.set_wifi_country_code(self.dut_client, wutils.WifiEnums.CountryCode.US) - # Enable verbose logging on the duts - self.dut.droid.wifiEnableVerboseLogging(1) - asserts.assert_equal(self.dut.droid.wifiGetVerboseLoggingLevel(), 1, - "Failed to enable WiFi verbose logging on the softap dut.") - self.dut_client.droid.wifiEnableVerboseLogging(1) - asserts.assert_equal(self.dut_client.droid.wifiGetVerboseLoggingLevel(), 1, - "Failed to enable WiFi verbose logging on the client dut.") - - req_params = ["AccessPoint", "dbs_supported_models", "stress_count"] - opt_param = ["iperf_server_address"] - self.unpack_userparams( - req_param_names=req_params, opt_param_names=opt_param) - - if self.dut.model not in self.dbs_supported_models: - asserts.skip( - ("Device %s does not support dual interfaces.") - % self.dut.model) - - if "iperf_server_address" in self.user_params: - self.iperf_server = self.iperf_servers[0] - if hasattr(self, 'iperf_server'): - self.iperf_server.start() - - # Set the client wifi state to on before the test begins. - wutils.wifi_toggle_state(self.dut_client, True) - - # Init extra devices - if len(self.android_devices) > 2: - wutils.wifi_test_device_init(self.android_devices[2]) - utils.sync_device_time(self.android_devices[2]) - wutils.set_wifi_country_code(self.android_devices[2], wutils.WifiEnums.CountryCode.US) - self.android_devices[2].droid.wifiEnableVerboseLogging(1) - asserts.assert_equal(self.android_devices[2].droid.wifiGetVerboseLoggingLevel(), 1, - "Failed to enable WiFi verbose logging on the client dut.") + super().setup_class() + opt_param = ["stress_count"] + self.unpack_userparams(opt_param_names=opt_param) """Helper Functions""" + def connect_to_wifi_network_and_verify(self, params): + """Connection logic for open and psk wifi networks. + Args: + params: A tuple of network info and AndroidDevice object. + """ + network, ad = params + SSID = network[WifiEnums.SSID_KEY] + wutils.reset_wifi(ad) + wutils.connect_to_wifi_network(ad, network) + if len(self.android_devices) > 2: + wutils.reset_wifi(self.android_devices[2]) + wutils.connect_to_wifi_network(self.android_devices[2], network) def verify_wifi_full_on_off(self, network, softap_config): wutils.wifi_toggle_state(self.dut, True) self.connect_to_wifi_network_and_verify((network, self.dut)) - self.run_iperf_client((network, self.dut)) - self.run_iperf_client((softap_config, self.dut_client)) if len(self.android_devices) > 2: self.log.info("Testbed has extra android devices, do more validation") - self.verify_traffic_between_ap_clients( + self.verify_traffic_between_dut_clients( self.dut, self.android_devices[2]) wutils.wifi_toggle_state(self.dut, False) def verify_softap_full_on_off(self, network, softap_band): softap_config = self.start_softap_and_verify(softap_band) - self.run_iperf_client((network, self.dut)) - self.run_iperf_client((softap_config, self.dut_client)) if len(self.android_devices) > 2: self.log.info("Testbed has extra android devices, do more validation") - self.verify_traffic_between_softap_clients( + self.verify_traffic_between_dut_clients( self.dut_client, self.android_devices[2]) wutils.reset_wifi(self.dut_client) if len(self.android_devices) > 2: @@ -142,12 +104,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_2g=WIFI_NETWORK_AP_CHANNEL_2G) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_2g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_2g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_2g, WIFI_CONFIG_APBAND_2G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_2g, WIFI_CONFIG_APBAND_2G) @test_tracker_info(uuid="03362d54-a624-4fb8-ad97-7abb9e6f655c") def test_stress_wifi_connection_5G_softap_5G(self): @@ -155,12 +115,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_5g=WIFI_NETWORK_AP_CHANNEL_5G) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_5g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_5g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_5g, WIFI_CONFIG_APBAND_5G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_5g, WIFI_CONFIG_APBAND_5G) @test_tracker_info(uuid="fdda4ff2-38d5-4398-9a59-c7cee407a2b3") def test_stress_wifi_connection_5G_DFS_softap_5G(self): @@ -168,12 +126,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_5g=WIFI_NETWORK_AP_CHANNEL_5G_DFS) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_5g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_5g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_5g, WIFI_CONFIG_APBAND_5G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_5g, WIFI_CONFIG_APBAND_5G) @test_tracker_info(uuid="b3621721-7714-43eb-8438-b578164b9194") def test_stress_wifi_connection_5G_softap_2G(self): @@ -181,12 +137,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_5g=WIFI_NETWORK_AP_CHANNEL_5G) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_5g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_5g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_5g, WIFI_CONFIG_APBAND_2G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_5g, WIFI_CONFIG_APBAND_2G) @test_tracker_info(uuid="bde1443f-f912-408e-b01a-537548dd023c") def test_stress_wifi_connection_5G_DFS_softap_2G(self): @@ -194,11 +148,9 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_5g=WIFI_NETWORK_AP_CHANNEL_5G_DFS) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_5g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_5g, self.dut)) for count in range(self.stress_count): - self.verify_softap_full_on_off(self.wpapsk_5g, WIFI_CONFIG_APBAND_2G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_5g, WIFI_CONFIG_APBAND_2G) @test_tracker_info(uuid="2b6a891a-e0d6-4660-abf6-579099ce6924") def test_stress_wifi_connection_2G_softap_5G(self): @@ -206,12 +158,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): """ self.configure_ap(channel_2g=WIFI_NETWORK_AP_CHANNEL_2G) wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_2g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_2g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_2g, WIFI_CONFIG_APBAND_5G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_2g, WIFI_CONFIG_APBAND_5G) @test_tracker_info(uuid="f28abf22-9df0-4500-b342-6682ca305e60") def test_stress_wifi_connection_5G_softap_2G_with_location_scan_on(self): @@ -221,12 +171,10 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): self.configure_ap(channel_5g=WIFI_NETWORK_AP_CHANNEL_5G) self.turn_location_on_and_scan_toggle_on() wutils.wifi_toggle_state(self.dut, True) - self.connect_to_wifi_network_and_verify((self.wpapsk_5g, self.dut)) + self.connect_to_wifi_network_and_verify((self.open_5g, self.dut)) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_softap_full_on_off(self.wpapsk_5g, WIFI_CONFIG_APBAND_2G) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_softap_full_on_off(self.open_5g, WIFI_CONFIG_APBAND_2G) @test_tracker_info(uuid="0edb1500-6c60-442e-9268-a2ad9ee2b55c") def test_stress_softap_2G_wifi_connection_2G(self): @@ -237,9 +185,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_2G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_2g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_2g, softap_config) @test_tracker_info(uuid="162a6679-edd5-4daa-9f25-75d79cf4bb4a") def test_stress_softap_5G_wifi_connection_5G(self): @@ -250,9 +196,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_5G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_5g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_5g, softap_config) @test_tracker_info(uuid="ee98f2dd-c4f9-4f48-ab59-f577267760d5") def test_stress_softap_5G_wifi_connection_5G_DFS(self): @@ -263,9 +207,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_5G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_5g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_5g, softap_config) @test_tracker_info(uuid="b50750b5-d5b9-4687-b9e7-9fb15f54b428") def test_stress_softap_5G_wifi_connection_2G(self): @@ -276,9 +218,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_5G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_2g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_2g, softap_config) @test_tracker_info(uuid="9a2865db-8e4b-4339-9999-000ce9b6970b") def test_stress_softap_2G_wifi_connection_5G(self): @@ -289,9 +229,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_2G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_5g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_5g, softap_config) @test_tracker_info(uuid="add6609d-91d6-4b89-94c5-0ad8b941e3d1") def test_stress_softap_2G_wifi_connection_5G_DFS(self): @@ -302,9 +240,7 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_2G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_5g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_5g, softap_config) @test_tracker_info(uuid="ee42afb6-99d0-4330-933f-d4dd8c3626c6") def test_stress_softap_5G_wifi_connection_2G_with_location_scan_on(self): @@ -317,6 +253,4 @@ class WifiStaApConcurrencyStressTest(WifiStaApConcurrencyTest): WIFI_CONFIG_APBAND_5G, check_connectivity=False) for count in range(self.stress_count): self.log.info("Iteration %d", count+1) - self.verify_wifi_full_on_off(self.wpapsk_2g, softap_config) - raise signals.TestPass(details="", extras={"Iterations":"%d" % - self.stress_count, "Pass":"%d" %(count+1)}) + self.verify_wifi_full_on_off(self.open_2g, softap_config) diff --git a/acts_tests/tests/google/wifi/WifiTetheringTest.py b/acts_tests/tests/google/wifi/WifiTetheringTest.py index d5d197a0a6..b1c92cc8f7 100644 --- a/acts_tests/tests/google/wifi/WifiTetheringTest.py +++ b/acts_tests/tests/google/wifi/WifiTetheringTest.py @@ -49,7 +49,7 @@ class WifiTetheringTest(base_test.BaseTestClass): self.unpack_userparams(req_params) self.network = {"SSID": "hotspot_%s" % utils.rand_ascii_str(6), "password": "pass_%s" % utils.rand_ascii_str(6)} - self.new_ssid = "wifi_tethering_test2" + self.new_ssid = "hs_%s" % utils.rand_ascii_str(6) self.tcpdump_pid=[] nutils.verify_lte_data_and_tethering_supported(self.hotspot_device) @@ -59,10 +59,12 @@ class WifiTetheringTest(base_test.BaseTestClass): def setup_test(self): for ad in self.android_devices: self.tcpdump_pid.append(nutils.start_tcpdump(ad, self.test_name)) + self.tethered_devices[0].droid.telephonyToggleDataConnection(False) def teardown_test(self): if self.hotspot_device.droid.wifiIsApEnabled(): wutils.stop_wifi_tethering(self.hotspot_device) + self.tethered_devices[0].droid.telephonyToggleDataConnection(True) for ad, pid in zip(self.android_devices, self.tcpdump_pid): nutils.stop_tcpdump(ad, pid, self.test_name) self.tcpdump_pid = [] @@ -444,38 +446,30 @@ class WifiTetheringTest(base_test.BaseTestClass): wutils.stop_wifi_tethering(self.hotspot_device) @test_tracker_info(uuid="7edfb220-37f8-42ea-8d7c-39712fbe9be5") - def test_wifi_tethering_2ghz_ping_hotspot_interfaces(self): + def test_wifi_tethering_wpapsk_network_2g(self): """ Steps: - 1. Start wifi hotspot with 2ghz band - 2. Connect tethered device to hotspot device - 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4 - and IPv6 interfaces on hotspot device from tethered device + 1. Start wifi tethering with wpapsk network 2G band + 2. Connect tethered device to the SSID + 3. Verify internet connectivity """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) - self._start_wifi_tethering(WIFI_CONFIG_APBAND_2G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - result = self._ping_hotspot_interfaces_from_tethered_device( - self.tethered_devices[0]) - wutils.stop_wifi_tethering(self.hotspot_device) - return result + self._start_wifi_tethering() + wutils.connect_to_wifi_network(self.tethered_devices[0], + self.network, + check_connectivity=True) @test_tracker_info(uuid="17e450f4-795f-4e67-adab-984940dffedc") - def test_wifi_tethering_5ghz_ping_hotspot_interfaces(self): + def test_wifi_tethering_wpapsk_network_5g(self): """ Steps: - 1. Start wifi hotspot with 5ghz band - 2. Connect tethered device to hotspot device - 3. Ping 'wlan0' and 'rmnet_data' interface's IPv4 - and IPv6 interfaces on hotspot device from tethered device + 1. Start wifi tethering with wpapsk network 5G band + 2. Connect tethered device to the SSID + 3. Verify internet connectivity """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) self._start_wifi_tethering(WIFI_CONFIG_APBAND_5G) - wutils.wifi_connect(self.tethered_devices[0], self.network) - result = self._ping_hotspot_interfaces_from_tethered_device( - self.tethered_devices[0]) - wutils.stop_wifi_tethering(self.hotspot_device) - return result + wutils.connect_to_wifi_network(self.tethered_devices[0], + self.network, + check_connectivity=True) @test_tracker_info(uuid="2bc344cb-0277-4f06-b6cc-65b3972086ed") def test_change_wifi_hotspot_ssid_when_hotspot_enabled(self): @@ -488,7 +482,6 @@ class WifiTetheringTest(base_test.BaseTestClass): 5. Restart tethering and verify that the tethered device is able to connect to the new SSID """ - wutils.toggle_wifi_off_and_on(self.hotspot_device) dut = self.hotspot_device # start tethering and verify the wifi ap configuration settings @@ -498,12 +491,12 @@ class WifiTetheringTest(base_test.BaseTestClass): wifi_ap[wutils.WifiEnums.SSID_KEY] == \ self.network[wutils.WifiEnums.SSID_KEY], "Configured wifi hotspot SSID did not match with the expected SSID") - wutils.wifi_connect(self.tethered_devices[0], self.network) + wutils.connect_to_wifi_network(self.tethered_devices[0], self.network) # update the wifi ap configuration with new ssid config = {wutils.WifiEnums.SSID_KEY: self.new_ssid} config[wutils.WifiEnums.PWD_KEY] = self.network[wutils.WifiEnums.PWD_KEY] - config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G + config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_2G self._save_wifi_softap_configuration(dut, config) # start wifi tethering with new wifi ap configuration @@ -514,8 +507,7 @@ class WifiTetheringTest(base_test.BaseTestClass): new_network = {wutils.WifiEnums.SSID_KEY: self.new_ssid, wutils.WifiEnums.PWD_KEY: \ self.network[wutils.WifiEnums.PWD_KEY]} - wutils.wifi_connect(self.tethered_devices[0], new_network) - wutils.stop_wifi_tethering(self.hotspot_device) + wutils.connect_to_wifi_network(self.tethered_devices[0], new_network) @test_tracker_info(uuid="4cf7ab26-ca2d-46f6-9d3f-a935c7e04c97") def test_wifi_tethering_open_network_2g(self): @@ -526,11 +518,17 @@ class WifiTetheringTest(base_test.BaseTestClass): 2. Connect tethered device to the SSID 3. Verify internet connectivity """ + open_network = { + wutils.WifiEnums.SSID_KEY: "hs_2g_%s" % utils.rand_ascii_str(6) + } wutils.start_wifi_tethering( - self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY], - None, WIFI_CONFIG_APBAND_2G) - wutils.wifi_connect(self.tethered_devices[0], self.open_network) - wutils.stop_wifi_tethering(self.hotspot_device) + self.hotspot_device, + open_network[wutils.WifiEnums.SSID_KEY], + None, + WIFI_CONFIG_APBAND_2G) + wutils.connect_to_wifi_network(self.tethered_devices[0], + open_network, + check_connectivity=True) @test_tracker_info(uuid="f407049b-1324-40ea-a8d1-f90587933310") def test_wifi_tethering_open_network_5g(self): @@ -541,11 +539,17 @@ class WifiTetheringTest(base_test.BaseTestClass): 2. Connect tethered device to the SSID 3. Verify internet connectivity """ + open_network = { + wutils.WifiEnums.SSID_KEY: "hs_5g_%s" % utils.rand_ascii_str(6) + } wutils.start_wifi_tethering( - self.hotspot_device, self.open_network[wutils.WifiEnums.SSID_KEY], - None, WIFI_CONFIG_APBAND_5G) - wutils.wifi_connect(self.tethered_devices[0], self.open_network) - wutils.stop_wifi_tethering(self.hotspot_device) + self.hotspot_device, + open_network[wutils.WifiEnums.SSID_KEY], + None, + WIFI_CONFIG_APBAND_5G) + wutils.connect_to_wifi_network(self.tethered_devices[0], + open_network, + check_connectivity=True) @test_tracker_info(uuid="d964f2e6-0acb-417c-ada9-eb9fc5a470e4") def test_wifi_tethering_open_network_2g_stress(self): @@ -561,7 +565,7 @@ class WifiTetheringTest(base_test.BaseTestClass): # save open network wifi ap configuration with 2G band config = {wutils.WifiEnums.SSID_KEY: self.open_network[wutils.WifiEnums.SSID_KEY]} - config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_2G + config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_2G self._save_wifi_softap_configuration(self.hotspot_device, config) # turn on/off wifi hotspot, connect device @@ -585,7 +589,7 @@ class WifiTetheringTest(base_test.BaseTestClass): # save open network wifi ap configuration with 5G band config = {wutils.WifiEnums.SSID_KEY: self.open_network[wutils.WifiEnums.SSID_KEY]} - config[wutils.WifiEnums.APBAND_KEY] = WIFI_CONFIG_APBAND_5G + config[wutils.WifiEnums.AP_BAND_KEY] = WIFI_CONFIG_APBAND_5G self._save_wifi_softap_configuration(self.hotspot_device, config) # turn on/off wifi hotspot, connect device diff --git a/acts_tests/tests/google/wifi/WifiThroughputStabilityTest.py b/acts_tests/tests/google/wifi/WifiThroughputStabilityTest.py index 7e2c3ef38a..af2bb76595 100644 --- a/acts_tests/tests/google/wifi/WifiThroughputStabilityTest.py +++ b/acts_tests/tests/google/wifi/WifiThroughputStabilityTest.py @@ -400,6 +400,16 @@ class WifiThroughputStabilityTest(base_test.BaseTestClass): testcase_params['channel']) testcase_params['test_network'] = self.main_network[band] + if testcase_params['traffic_type'] == 'TCP': + testcase_params['iperf_socket_size'] = self.testclass_params.get( + 'tcp_socket_size', None) + testcase_params['iperf_processes'] = self.testclass_params.get( + 'tcp_processes', 1) + elif testcase_params['traffic_type'] == 'UDP': + testcase_params['iperf_socket_size'] = self.testclass_params.get( + 'udp_socket_size', None) + testcase_params['iperf_processes'] = self.testclass_params.get( + 'udp_processes', 1) if (testcase_params['traffic_direction'] == 'DL' and not isinstance(self.iperf_server, ipf.IPerfServerOverAdb) ) or (testcase_params['traffic_direction'] == 'UL' @@ -407,13 +417,17 @@ class WifiThroughputStabilityTest(base_test.BaseTestClass): testcase_params['iperf_args'] = wputils.get_iperf_arg_string( duration=self.testclass_params['iperf_duration'], reverse_direction=1, - traffic_type=testcase_params['traffic_type']) + traffic_type=testcase_params['traffic_type'], + socket_size=testcase_params['iperf_socket_size'], + num_processes=testcase_params['iperf_processes']) testcase_params['use_client_output'] = True else: testcase_params['iperf_args'] = wputils.get_iperf_arg_string( duration=self.testclass_params['iperf_duration'], reverse_direction=0, - traffic_type=testcase_params['traffic_type']) + traffic_type=testcase_params['traffic_type'], + socket_size=testcase_params['iperf_socket_size'], + num_processes=testcase_params['iperf_processes']) testcase_params['use_client_output'] = False return testcase_params diff --git a/acts_tests/tests/google/wifi/WifiWakeTest.py b/acts_tests/tests/google/wifi/WifiWakeTest.py index 13c6b2dc0b..7e4645242e 100644 --- a/acts_tests/tests/google/wifi/WifiWakeTest.py +++ b/acts_tests/tests/google/wifi/WifiWakeTest.py @@ -24,10 +24,14 @@ from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest import acts.test_utils.wifi.wifi_test_utils as wutils import acts.utils +WifiEnums = wutils.WifiEnums +SSID = WifiEnums.SSID_KEY CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT = 5 +SCANS_REQUIRED_TO_FIND_SSID = 5 LAST_DISCONNECT_TIMEOUT_MILLIS = 5000 LAST_DISCONNECT_TIMEOUT_SEC = LAST_DISCONNECT_TIMEOUT_MILLIS / 1000 PRESCAN_DELAY_SEC = 5 +WIFI_TOGGLE_DELAY_SEC = 3 class WifiWakeTest(WifiBaseTest): @@ -109,7 +113,15 @@ class WifiWakeTest(WifiBaseTest): self.dut.take_bug_report(test_name, begin_time) self.dut.cat_adb_log(test_name, begin_time) - def do_location_scan(self, num_times=1): + def find_ssid_in_scan_results(self, scan_results_batches, ssid): + scan_results_batch = scan_results_batches[0] + scan_results = scan_results_batch["ScanResults"] + for scan_result in scan_results: + if ssid == scan_result["SSID"]: + return True + return False + + def do_location_scan(self, num_times=1, ssid_to_find=None): scan_settings = { "band": wutils.WifiEnums.WIFI_BAND_BOTH, "periodInMs": 0, @@ -142,6 +154,10 @@ class WifiWakeTest(WifiBaseTest): event = self.dut.ed.pop_event(event_name, wait_time) self.log.debug("Event received: %s", event) result_received += 1 + scan_results_batches = event["data"]["Results"] + if ssid_to_find and self.find_ssid_in_scan_results( + scan_results_batches, ssid_to_find): + return except queue.Empty as error: asserts.assert_true( result_received >= 1, @@ -187,15 +203,17 @@ class WifiWakeTest(WifiBaseTest): self.do_location_scan(CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT + 2) self.ap_a_on() - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_a[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") - @test_tracker_info(uuid="") + @test_tracker_info(uuid="3cecd1c5-54bc-44a2-86f7-ad84625bf094") def test_reconnect_wifi_network_suggestion(self): """Tests that Wifi Wake re-enables Wifi for app provided suggestion.""" - self.dut.log.info("Adding network suggestions"); + self.dut.log.info("Adding network suggestions") asserts.assert_true( self.dut.droid.wifiAddNetworkSuggestions([self.ap_a]), "Failed to add suggestions") @@ -203,15 +221,23 @@ class WifiWakeTest(WifiBaseTest): self.dut.droid.wifiAddNetworkSuggestions([self.ap_b]), "Failed to add suggestions") # Enable suggestions by the app. - self.dut.log.debug("Enabling suggestions from test"); + self.dut.log.debug("Enabling suggestions from test") self.dut.adb.shell("cmd wifi network-suggestions-set-user-approved" + " " + SL4A_APK_NAME + " yes") # Ensure network is seen in scan results & auto-connected to. self.do_location_scan(2) wutils.wait_for_connect(self.dut) + current_network = self.dut.droid.wifiGetConnectionInfo() self.dut.ed.clear_all_events() - self.ap_a_off() - self.ap_b_off() + if current_network[SSID] == self.ap_a[SSID]: + # connected to AP A, so turn AP B off first to prevent the + # device from immediately reconnecting to AP B + self.ap_b_off() + self.ap_a_off() + else: + self.ap_a_off() + self.ap_b_off() + wutils.wait_for_disconnect(self.dut) self.log.info("Wifi Disconnected") time.sleep(LAST_DISCONNECT_TIMEOUT_SEC * 1.2) @@ -220,7 +246,9 @@ class WifiWakeTest(WifiBaseTest): self.do_location_scan(CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT + 2) self.ap_a_on() - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_a[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") @@ -240,7 +268,9 @@ class WifiWakeTest(WifiBaseTest): # evict AP A from Wakeup Lock self.do_location_scan(CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT + 2) self.ap_a_on() - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_a[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") @@ -282,7 +312,9 @@ class WifiWakeTest(WifiBaseTest): time.sleep(PRESCAN_DELAY_SEC) self.do_location_scan(CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT + 2) self.ap_a_on() - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_a[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") @@ -322,7 +354,9 @@ class WifiWakeTest(WifiBaseTest): self.ap_b_off() self.do_location_scan(CONSECUTIVE_MISSED_SCANS_REQUIRED_TO_EVICT + 2) self.ap_a_on() - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_a[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") @@ -350,14 +384,11 @@ class WifiWakeTest(WifiBaseTest): self.ap_a_atten.set_atten(30) self.ap_b_atten.set_atten(0) - self.do_location_scan() + self.do_location_scan( + SCANS_REQUIRED_TO_FIND_SSID, self.ap_b[wutils.WifiEnums.SSID_KEY]) + time.sleep(WIFI_TOGGLE_DELAY_SEC) asserts.assert_true( self.dut.droid.wifiCheckState(), "Expect Wifi Wake to enable Wifi, but Wifi is disabled.") expected_ssid = self.ap_b[wutils.WifiEnums.SSID_KEY] - actual_ssid = self.dut.droid.wifiGetConnectionInfo()[ - wutils.WifiEnums.SSID_KEY] - asserts.assert_equal( - expected_ssid, actual_ssid, - ("Expected to connect to SSID '{}', but actually connected to " - "'{}' instead.").format(expected_ssid, actual_ssid)) + wutils.wait_for_connect(self.dut, expected_ssid) diff --git a/acts_tests/tests/google/wifi/WifiWpa3OweTest.py b/acts_tests/tests/google/wifi/WifiWpa3OweTest.py index fbe939c216..ab0f23db2b 100644 --- a/acts_tests/tests/google/wifi/WifiWpa3OweTest.py +++ b/acts_tests/tests/google/wifi/WifiWpa3OweTest.py @@ -100,4 +100,23 @@ class WifiWpa3OweTest(WifiBaseTest): def test_connect_to_wpa3_personal_5g(self): wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, self.wpa3_personal_5g[WifiEnums.SSID_KEY]) - wutils.connect_to_wifi_network(self.dut, self.owe_5g) + wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_5g) + + @test_tracker_info(uuid="a8fb46be-3487-4dc8-a393-5af992b27f45") + def test_connect_to_wpa3_personal_reconnection(self): + """ This is to catch auth reject which is caused by PMKSA cache. + Steps: + ------------------------------ + 1. Connect STA to WPA3 AP + 2. Turn off the WiFi or connect to a different AP + 3. Turn on the WiFi or connect back to WPA3 AP. + 4. Initial connect request fails + Second connect request from framework succeeds. + """ + wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, + self.wpa3_personal_2g[WifiEnums.SSID_KEY]) + wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) + wutils.toggle_wifi_off_and_on(self.dut) + wutils.start_wifi_connection_scan_and_ensure_network_found(self.dut, + self.wpa3_personal_2g[WifiEnums.SSID_KEY]) + wutils.connect_to_wifi_network(self.dut, self.wpa3_personal_2g) diff --git a/acts_tests/tests/google/wifi/aware/README.md b/acts_tests/tests/google/wifi/aware/README.md index 6b969141ab..11a8296394 100644 --- a/acts_tests/tests/google/wifi/aware/README.md +++ b/acts_tests/tests/google/wifi/aware/README.md @@ -33,7 +33,7 @@ group sub-directories contains a file with the same name as that of the directory which lists all tests in the directory. E.g. to execute all functional tests execute: -`act.py -c <config> -tf ./tools/test/connectivity/acts_tests/tests/google/wifi/aware/functional/functional` +`act.py -c <config> -tf ./tools/test/connectivity/acts/tests/google/wifi/aware/functional/functional` ## Test Configurations The test configurations, the `<config>` in the commands above, are stored in diff --git a/acts_tests/tests/google/wifi/aware/config/wifi_aware.json b/acts_tests/tests/google/wifi/aware/config/wifi_aware.json index f1bd907ff1..97323fc6fa 100644 --- a/acts_tests/tests/google/wifi/aware/config/wifi_aware.json +++ b/acts_tests/tests/google/wifi/aware/config/wifi_aware.json @@ -9,7 +9,7 @@ } ], "logpath": "~/logs", - "testpaths": ["./tools/test/connectivity/acts_tests/tests/google/wifi"], + "testpaths": ["./tools/test/connectivity/acts/tests/google/wifi"], "adb_logcat_param": "-b all", "aware_default_power_mode": "INTERACTIVE" } diff --git a/acts_tests/tests/google/wifi/aware/config/wifi_aware_non_interactive.json b/acts_tests/tests/google/wifi/aware/config/wifi_aware_non_interactive.json index 391775689f..f2e6e79b53 100644 --- a/acts_tests/tests/google/wifi/aware/config/wifi_aware_non_interactive.json +++ b/acts_tests/tests/google/wifi/aware/config/wifi_aware_non_interactive.json @@ -9,7 +9,7 @@ } ], "logpath": "~/logs", - "testpaths": ["./tools/test/connectivity/acts_tests/tests/google/wifi"], + "testpaths": ["./tools/test/connectivity/acts/tests/google/wifi"], "adb_logcat_param": "-b all", "aware_default_power_mode": "NON_INTERACTIVE" } diff --git a/acts_tests/tests/google/wifi/aware/functional/DataPathTest.py b/acts_tests/tests/google/wifi/aware/functional/DataPathTest.py index 3f68376831..b8ac693c47 100644 --- a/acts_tests/tests/google/wifi/aware/functional/DataPathTest.py +++ b/acts_tests/tests/google/wifi/aware/functional/DataPathTest.py @@ -20,6 +20,7 @@ from acts import asserts from acts.test_decorators import test_tracker_info from acts.test_utils.net import connectivity_const as cconsts from acts.test_utils.wifi import wifi_test_utils as wutils +from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest from acts.test_utils.wifi.aware import aware_const as aconsts from acts.test_utils.wifi.aware import aware_test_utils as autils from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest @@ -596,15 +597,22 @@ class DataPathTest(AwareBaseTest): # Initiator & Responder: # - expect unavailable on the Initiator party if the - # Initiator or Responder has a bad ID - # - but a Responder will keep waiting ... + # Initiator and Responder with mac or encryption mismatch + # - For responder: + # - If mac mismatch, responder will keep waiting ... + # - If encryption mismatch, responder expect unavailable autils.wait_for_event_with_keys( init_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) time.sleep(autils.EVENT_NDP_TIMEOUT) - autils.fail_on_event_with_keys( - resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, - (cconsts.NETWORK_CB_KEY_ID, init_req_key)) + if init_mismatch_mac or resp_mismatch_mac: + autils.fail_on_event_with_keys( + resp_dut, cconsts.EVENT_NETWORK_CALLBACK, 0, + (cconsts.NETWORK_CB_KEY_ID, resp_req_key)) + else: + autils.wait_for_event_with_keys( + resp_dut, cconsts.EVENT_NETWORK_CALLBACK, autils.EVENT_NDP_TIMEOUT, + (cconsts.NETWORK_CB_KEY_EVENT, cconsts.NETWORK_CB_UNAVAILABLE)) # clean-up resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key) @@ -656,6 +664,7 @@ class DataPathTest(AwareBaseTest): ####################################### @test_tracker_info(uuid="fa30bedc-d1de-4440-bf25-ec00d10555af") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_open_specific(self): """Data-path: in-band, unsolicited/passive, open encryption, specific peer @@ -668,6 +677,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_open_any(self): """Data-path: in-band, unsolicited/passive, open encryption, any peer @@ -680,6 +690,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=False) @test_tracker_info(uuid="93b2a23d-8579-448a-936c-7812929464cf") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_passphrase_specific(self): """Data-path: in-band, unsolicited/passive, passphrase, specific peer @@ -692,6 +703,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="1736126f-a0ff-4712-acc4-f89b4eef5716") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_passphrase_any(self): """Data-path: in-band, unsolicited/passive, passphrase, any peer @@ -704,6 +716,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=False) @test_tracker_info(uuid="b9353d5b-3f77-46bf-bfd9-65d56a7c939a") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_pmk_specific(self): """Data-path: in-band, unsolicited/passive, PMK, specific peer @@ -716,6 +729,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="06f3b2ab-4a10-4398-83a4-6a23851b1662") + @WifiBaseTest.wifi_test_wrap def test_ib_unsolicited_passive_pmk_any(self): """Data-path: in-band, unsolicited/passive, PMK, any peer @@ -728,6 +742,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=False) @test_tracker_info(uuid="0ed7d8b3-a69e-46ba-aeb7-13e507ecf290") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_open_specific(self): """Data-path: in-band, solicited/active, open encryption, specific peer @@ -740,6 +755,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="c7ba6d28-5ef6-45d9-95d5-583ad6d981f3") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_open_any(self): """Data-path: in-band, solicited/active, open encryption, any peer @@ -752,6 +768,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=False) @test_tracker_info(uuid="388cea99-0e2e-49ea-b00e-f3e56b6236e5") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_passphrase_specific(self): """Data-path: in-band, solicited/active, passphrase, specific peer @@ -764,6 +781,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="fcd3e28a-5eab-4169-8a0c-dc7204dcdc13") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_passphrase_any(self): """Data-path: in-band, solicited/active, passphrase, any peer @@ -776,6 +794,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=False) @test_tracker_info(uuid="9d4eaad7-ba53-4a06-8ce0-e308daea3309") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_pmk_specific(self): """Data-path: in-band, solicited/active, PMK, specific peer @@ -788,6 +807,7 @@ class DataPathTest(AwareBaseTest): use_peer_id=True) @test_tracker_info(uuid="129d850e-c312-4137-a67b-05ae95fe66cc") + @WifiBaseTest.wifi_test_wrap def test_ib_solicited_active_pmk_any(self): """Data-path: in-band, solicited/active, PMK, any peer @@ -819,6 +839,7 @@ class DataPathTest(AwareBaseTest): ####################################### @test_tracker_info(uuid="e855dd81-45c8-4bb2-a204-7687c48ff843") + @WifiBaseTest.wifi_test_wrap def test_ib_extra_pub_same_unsolicited_passive_open_specific(self): """Data-path: in-band, unsolicited/passive, open encryption, specific peer. @@ -835,7 +856,8 @@ class DataPathTest(AwareBaseTest): pub_on_both=True, pub_on_both_same=True) - @test_tracker_info(uuid="57fc9d53-32ae-470f-a8b1-2fe37893687d") + @test_tracker_info(uuid="228ea657-82e6-44bc-8369-a2c719a5e252") + @WifiBaseTest.wifi_test_wrap def test_ib_extra_pub_same_unsolicited_passive_open_any(self): """Data-path: in-band, unsolicited/passive, open encryption, any peer. @@ -853,6 +875,7 @@ class DataPathTest(AwareBaseTest): pub_on_both_same=True) @test_tracker_info(uuid="7a32f439-d745-4716-a75e-b54109aaaf82") + @WifiBaseTest.wifi_test_wrap def test_ib_extra_pub_diff_unsolicited_passive_open_specific(self): """Data-path: in-band, unsolicited/passive, open encryption, specific peer. @@ -870,6 +893,7 @@ class DataPathTest(AwareBaseTest): pub_on_both_same=False) @test_tracker_info(uuid="a14ddc66-88fd-4b49-ab37-225533867c63") + @WifiBaseTest.wifi_test_wrap def test_ib_extra_pub_diff_unsolicited_passive_open_any(self): """Data-path: in-band, unsolicited/passive, open encryption, any peer. @@ -903,6 +927,7 @@ class DataPathTest(AwareBaseTest): ####################################### @test_tracker_info(uuid="7db17d8c-1dce-4084-b695-215bbcfe7d41") + @WifiBaseTest.wifi_test_wrap def test_oob_open_specific(self): """Data-path: out-of-band, open encryption, specific peer @@ -912,6 +937,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_OPEN, use_peer_id=True) @test_tracker_info(uuid="ad416d89-cb95-4a07-8d29-ee213117450b") + @WifiBaseTest.wifi_test_wrap def test_oob_open_any(self): """Data-path: out-of-band, open encryption, any peer @@ -921,6 +947,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_OPEN, use_peer_id=False) @test_tracker_info(uuid="74937a3a-d524-43e2-8979-4449271cab52") + @WifiBaseTest.wifi_test_wrap def test_oob_passphrase_specific(self): """Data-path: out-of-band, passphrase, specific peer @@ -930,6 +957,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=True) @test_tracker_info(uuid="afcbdc7e-d3a9-465b-b1da-ce2e42e3941e") + @WifiBaseTest.wifi_test_wrap def test_oob_passphrase_any(self): """Data-path: out-of-band, passphrase, any peer @@ -939,6 +967,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_PASSPHRASE, use_peer_id=False) @test_tracker_info(uuid="0d095031-160a-4537-aab5-41b6ad5d55f8") + @WifiBaseTest.wifi_test_wrap def test_oob_pmk_specific(self): """Data-path: out-of-band, PMK, specific peer @@ -948,6 +977,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_PMK, use_peer_id=True) @test_tracker_info(uuid="e45477bd-66cc-4eb7-88dd-4518c8aa2a74") + @WifiBaseTest.wifi_test_wrap def test_oob_pmk_any(self): """Data-path: out-of-band, PMK, any peer @@ -957,6 +987,7 @@ class DataPathTest(AwareBaseTest): encr_type=self.ENCR_TYPE_PMK, use_peer_id=False) @test_tracker_info(uuid="dd464f24-b404-4eea-955c-d10c9e8adefc") + @WifiBaseTest.wifi_test_wrap def test_oob_ib_coex_open_specific(self): """Data-path: out-of-band, open encryption, specific peer - in-band coex: set up a concurrent discovery session to verify no impact. The session @@ -970,6 +1001,7 @@ class DataPathTest(AwareBaseTest): setup_discovery_sessions=True) @test_tracker_info(uuid="088fcd3a-b015-4179-a9a5-91f782b03e3b") + @WifiBaseTest.wifi_test_wrap def test_oob_ib_coex_open_any(self): """Data-path: out-of-band, open encryption, any peer - in-band coex: set up a concurrent discovery session to verify no impact. The session @@ -985,6 +1017,7 @@ class DataPathTest(AwareBaseTest): ############################################################## @test_tracker_info(uuid="1c2c9805-dc1e-43b5-a1b8-315e8c9a4337") + @WifiBaseTest.wifi_test_wrap def test_passphrase_min(self): """Data-path: minimum passphrase length @@ -998,6 +1031,7 @@ class DataPathTest(AwareBaseTest): passphrase_to_use=self.PASSPHRASE_MIN) @test_tracker_info(uuid="e696e2b9-87a9-4521-b337-61b9efaa2057") + @WifiBaseTest.wifi_test_wrap def test_passphrase_max(self): """Data-path: maximum passphrase length @@ -1011,30 +1045,35 @@ class DataPathTest(AwareBaseTest): passphrase_to_use=self.PASSPHRASE_MAX) @test_tracker_info(uuid="533cd44c-ff30-4283-ac28-f71fd7b4f02d") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_publisher_peer_id(self): """Data-path: failure when publisher peer ID is mismatched""" self.run_mismatched_ib_data_path_test( pub_mismatch=True, sub_mismatch=False) @test_tracker_info(uuid="682f275e-722a-4f8b-85e7-0dcea9d25532") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_subscriber_peer_id(self): """Data-path: failure when subscriber peer ID is mismatched""" self.run_mismatched_ib_data_path_test( pub_mismatch=False, sub_mismatch=True) @test_tracker_info(uuid="7fa82796-7fc9-4d9e-bbbb-84b751788943") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_init_mac(self): """Data-path: failure when Initiator MAC address mismatch""" self.run_mismatched_oob_data_path_test( init_mismatch_mac=True, resp_mismatch_mac=False) @test_tracker_info(uuid="edeae959-4644-44f9-8d41-bdeb5216954e") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_resp_mac(self): """Data-path: failure when Responder MAC address mismatch""" self.run_mismatched_oob_data_path_test( init_mismatch_mac=False, resp_mismatch_mac=True) @test_tracker_info(uuid="91f46949-c47f-49f9-a90f-6fae699613a7") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_passphrase(self): """Data-path: failure when passphrases mismatch""" self.run_mismatched_oob_data_path_test( @@ -1042,6 +1081,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_PASSPHRASE) @test_tracker_info(uuid="01c49c2e-dc92-4a27-bb47-c4fc67617c23") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_pmk(self): """Data-path: failure when PMK mismatch""" self.run_mismatched_oob_data_path_test( @@ -1049,6 +1089,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_PMK) @test_tracker_info(uuid="4d651797-5fbb-408e-a4b6-a6e1944136da") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_open_passphrase(self): """Data-path: failure when initiator is open, and responder passphrase""" self.run_mismatched_oob_data_path_test( @@ -1056,6 +1097,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_PASSPHRASE) @test_tracker_info(uuid="1ae697f4-5987-4187-aeef-1e22d07d4a7c") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_open_pmk(self): """Data-path: failure when initiator is open, and responder PMK""" self.run_mismatched_oob_data_path_test( @@ -1063,6 +1105,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_PMK) @test_tracker_info(uuid="f027b1cc-0e7a-4075-b880-5e64b288afbd") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_pmk_passphrase(self): """Data-path: failure when initiator is pmk, and responder passphrase""" self.run_mismatched_oob_data_path_test( @@ -1070,6 +1113,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_PASSPHRASE) @test_tracker_info(uuid="0819bbd4-72ae-49c4-bd46-5448db2b0a06") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_passphrase_open(self): """Data-path: failure when initiator is passphrase, and responder open""" self.run_mismatched_oob_data_path_test( @@ -1077,6 +1121,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_OPEN) @test_tracker_info(uuid="7ef24f62-8e6b-4732-88a3-80a43584dda4") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_pmk_open(self): """Data-path: failure when initiator is PMK, and responder open""" self.run_mismatched_oob_data_path_test( @@ -1084,6 +1129,7 @@ class DataPathTest(AwareBaseTest): resp_encr_type=self.ENCR_TYPE_OPEN) @test_tracker_info(uuid="7b9c9efc-1c06-465e-8a5e-d6a22ac1da97") + @WifiBaseTest.wifi_test_wrap def test_negative_mismatch_passphrase_pmk(self): """Data-path: failure when initiator is passphrase, and responder pmk""" self.run_mismatched_oob_data_path_test( @@ -1132,6 +1178,7 @@ class DataPathTest(AwareBaseTest): "Network specifier leak!") @test_tracker_info(uuid="2e325e2b-d552-4890-b470-20b40284395d") + @WifiBaseTest.wifi_test_wrap def test_multiple_identical_networks(self): """Validate that creating multiple networks between 2 devices, each network with identical configuration is supported over a single NDP. @@ -1272,6 +1319,8 @@ class DataPathTest(AwareBaseTest): for init_req_key in init_req_keys: init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) + @test_tracker_info(uuid="34cf12e8-5df6-49bd-b384-e9935d89a5b7") + @WifiBaseTest.wifi_test_wrap def test_identical_network_from_both_sides(self): """Validate that requesting two identical NDPs (Open) each being initiated from a different side, results in the same/single NDP. @@ -1587,6 +1636,7 @@ class DataPathTest(AwareBaseTest): dut1.droid.connectivityUnregisterNetworkCallback(dut1_req_key) @test_tracker_info(uuid="2d728163-11cc-46ba-a973-c8e1e71397fc") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_open_passphrase(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one open, one using passphrase). The result should use two @@ -1594,6 +1644,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([None, self.PASSPHRASE]) @test_tracker_info(uuid="5f2c32aa-20b2-41f0-8b1e-d0b68df73ada") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_open_pmk(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one open, one using pmk). The result should use two @@ -1601,6 +1652,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([None, self.PMK]) @test_tracker_info(uuid="34467659-bcfb-40cd-ba25-7e50560fca63") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_passphrase_pmk(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one using passphrase, one using pmk). The result should use @@ -1608,6 +1660,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([self.PASSPHRASE, self.PMK]) @test_tracker_info(uuid="d9194ce6-45b6-41b1-9cc8-ada79968966d") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_passphrases(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (using different passphrases). The result should use two @@ -1615,6 +1668,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([self.PASSPHRASE, self.PASSPHRASE2]) @test_tracker_info(uuid="879df795-62d2-40d4-a862-bd46d8f7e67f") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_pmks(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (using different PMKS). The result should use two different @@ -1622,6 +1676,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([self.PMK, self.PMK2]) @test_tracker_info(uuid="397d380a-8e41-466e-9ccb-cf8f413d83ba") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_open_passphrase_flip(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one open, one using passphrase). The result should use two @@ -1632,6 +1687,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([None, self.PASSPHRASE], flip_init_resp=True) @test_tracker_info(uuid="b3a4300b-1514-4cb8-a814-9c2baa449700") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_open_pmk_flip(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one open, one using pmk). The result should use two @@ -1642,6 +1698,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([None, self.PMK], flip_init_resp=True) @test_tracker_info(uuid="0bfea9e4-e57d-417f-8db4-245741e9bbd5") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_passphrase_pmk_flip(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (one using passphrase, one using pmk). The result should use @@ -1652,6 +1709,7 @@ class DataPathTest(AwareBaseTest): self.run_multiple_ndi([self.PASSPHRASE, self.PMK], flip_init_resp=True) @test_tracker_info(uuid="74023483-5417-431b-a362-991ad4a03ab8") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_passphrases_flip(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (using different passphrases). The result should use two @@ -1663,6 +1721,7 @@ class DataPathTest(AwareBaseTest): [self.PASSPHRASE, self.PASSPHRASE2], flip_init_resp=True) @test_tracker_info(uuid="873b2d91-28a1-403f-ae9c-d756bb2f59ee") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndi_pmks_flip(self): """Verify that between 2 DUTs can create 2 NDPs with different security configuration (using different PMKS). The result should use two different @@ -1675,6 +1734,7 @@ class DataPathTest(AwareBaseTest): ####################################### @test_tracker_info(uuid="2f10a9df-7fbd-490d-a238-3523f47ab54c") + @WifiBaseTest.wifi_test_wrap def test_ib_responder_any_usage(self): """Verify that configuring an in-band (Aware discovery) Responder to receive an NDP request from any peer is not permitted by current API level. Override @@ -1703,6 +1763,7 @@ class DataPathTest(AwareBaseTest): expect_failure=True) @test_tracker_info(uuid="5889cd41-0a72-4b7b-ab82-5b9168b9b5b8") + @WifiBaseTest.wifi_test_wrap def test_oob_responder_any_usage(self): """Verify that configuring an out-of-band (Aware discovery) Responder to receive an NDP request from any peer is not permitted by current API level. @@ -1766,6 +1827,7 @@ class DataPathTest(AwareBaseTest): init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) @test_tracker_info(uuid="eff53739-35c5-47a6-81f0-d70b51d89c3b") + @WifiBaseTest.wifi_test_wrap def test_multiple_regulator_domains_ib_us_jp(self): """Verify data-path setup across multiple regulator domains. @@ -1778,6 +1840,7 @@ class DataPathTest(AwareBaseTest): resp_domain=wutils.WifiEnums.CountryCode.JAPAN) @test_tracker_info(uuid="19af47cc-3204-40ef-b50f-14cf7b89cf4a") + @WifiBaseTest.wifi_test_wrap def test_multiple_regulator_domains_ib_jp_us(self): """Verify data-path setup across multiple regulator domains. @@ -1790,6 +1853,7 @@ class DataPathTest(AwareBaseTest): resp_domain=wutils.WifiEnums.CountryCode.US) @test_tracker_info(uuid="65285ab3-977f-4dbd-b663-d5a02f4fc663") + @WifiBaseTest.wifi_test_wrap def test_multiple_regulator_domains_oob_us_jp(self): """Verify data-path setup across multiple regulator domains. @@ -1802,6 +1866,7 @@ class DataPathTest(AwareBaseTest): resp_domain=wutils.WifiEnums.CountryCode.JAPAN) @test_tracker_info(uuid="8a417e24-aaf6-44b9-a089-a07c3ba8d954") + @WifiBaseTest.wifi_test_wrap def test_multiple_regulator_domains_oob_jp_us(self): """Verify data-path setup across multiple regulator domains. @@ -2056,6 +2121,7 @@ class DataPathTest(AwareBaseTest): init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key) @test_tracker_info(uuid="d8a0839d-4ba0-43f2-af93-3cf1382f9f16") + @WifiBaseTest.wifi_test_wrap def test_identical_ndps_mix_ib_oob_ib_first_same_polarity(self): """Validate that a single NDP is created for multiple identical requests which are issued through either in-band (ib) or out-of-band (oob) APIs. @@ -2067,6 +2133,7 @@ class DataPathTest(AwareBaseTest): same_request=True, ib_first=True, inits_on_same_dut=True) @test_tracker_info(uuid="70bbb811-0bed-4a19-96b3-f2446e777c8a") + @WifiBaseTest.wifi_test_wrap def test_identical_ndps_mix_ib_oob_oob_first_same_polarity(self): """Validate that a single NDP is created for multiple identical requests which are issued through either in-band (ib) or out-of-band (oob) APIs. @@ -2078,6 +2145,7 @@ class DataPathTest(AwareBaseTest): same_request=True, ib_first=False, inits_on_same_dut=True) @test_tracker_info(uuid="d9796da5-f96a-4a51-be0f-89d6f5bfe3ad") + @WifiBaseTest.wifi_test_wrap def test_identical_ndps_mix_ib_oob_ib_first_diff_polarity(self): """Validate that a single NDP is created for multiple identical requests which are issued through either in-band (ib) or out-of-band (oob) APIs. @@ -2088,7 +2156,8 @@ class DataPathTest(AwareBaseTest): self.run_mix_ib_oob( same_request=True, ib_first=True, inits_on_same_dut=False) - @test_tracker_info(uuid="72b16cbf-53ad-4f98-8dcf-a8cc5fa812e3") + @test_tracker_info(uuid="48b9005b-7851-4222-b41c-1fcbefbc704d") + @WifiBaseTest.wifi_test_wrap def test_identical_ndps_mix_ib_oob_oob_first_diff_polarity(self): """Validate that a single NDP is created for multiple identical requests which are issued through either in-band (ib) or out-of-band (oob) APIs. @@ -2100,6 +2169,7 @@ class DataPathTest(AwareBaseTest): same_request=True, ib_first=False, inits_on_same_dut=False) @test_tracker_info(uuid="51f9581e-c5ee-48a7-84d2-adff4876c3d7") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndis_mix_ib_oob_ib_first_same_polarity(self): """Validate that multiple NDIs are created for NDPs which are requested with different security configurations. Use a mix of in-band and out-of-band APIs @@ -2112,6 +2182,7 @@ class DataPathTest(AwareBaseTest): same_request=False, ib_first=True, inits_on_same_dut=True) @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndis_mix_ib_oob_oob_first_same_polarity(self): """Validate that multiple NDIs are created for NDPs which are requested with different security configurations. Use a mix of in-band and out-of-band APIs @@ -2124,6 +2195,7 @@ class DataPathTest(AwareBaseTest): same_request=False, ib_first=False, inits_on_same_dut=True) @test_tracker_info(uuid="b1e3070e-4d38-4b31-862d-39b82e0f2853") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndis_mix_ib_oob_ib_first_diff_polarity(self): """Validate that multiple NDIs are created for NDPs which are requested with different security configurations. Use a mix of in-band and out-of-band APIs @@ -2136,6 +2208,7 @@ class DataPathTest(AwareBaseTest): same_request=False, ib_first=True, inits_on_same_dut=False) @test_tracker_info(uuid="596caadf-028e-494b-bbce-8304ccec2cbb") + @WifiBaseTest.wifi_test_wrap def test_multiple_ndis_mix_ib_oob_oob_first_diff_polarity(self): """Validate that multiple NDIs are created for NDPs which are requested with different security configurations. Use a mix of in-band and out-of-band APIs @@ -2149,6 +2222,7 @@ class DataPathTest(AwareBaseTest): ######################################################################## + @test_tracker_info(uuid="5ec10bf9-bfda-4093-8344-7ccc7764737e") def test_ndp_loop(self): """Validate that can create a loop (chain) of N NDPs between N devices, where N >= 3, e.g. @@ -2159,8 +2233,8 @@ class DataPathTest(AwareBaseTest): The NDPs are all OPEN (no encryption). """ - asserts.assert_true( - len(self.android_devices) >= 3, + asserts.skip_if( + len(self.android_devices) < 3, 'A minimum of 3 devices is needed to run the test, have %d' % len( self.android_devices)) diff --git a/acts_tests/tests/google/wifi/aware/functional/DiscoveryTest.py b/acts_tests/tests/google/wifi/aware/functional/DiscoveryTest.py index 5f01c80eb7..31255afa04 100644 --- a/acts_tests/tests/google/wifi/aware/functional/DiscoveryTest.py +++ b/acts_tests/tests/google/wifi/aware/functional/DiscoveryTest.py @@ -22,6 +22,7 @@ from acts.test_decorators import test_tracker_info from acts.test_utils.wifi.aware import aware_const as aconsts from acts.test_utils.wifi.aware import aware_test_utils as autils from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest +from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest class DiscoveryTest(AwareBaseTest): @@ -561,6 +562,7 @@ class DiscoveryTest(AwareBaseTest): ####################################### @test_tracker_info(uuid="954ebbde-ed2b-4f04-9e68-88239187d69d") + @WifiBaseTest.wifi_test_wrap def test_positive_unsolicited_passive_typical(self): """Functional test case / Discovery test cases / positive test case: - Solicited publish + passive subscribe @@ -1068,3 +1070,194 @@ class DiscoveryTest(AwareBaseTest): s_config=autils.create_discovery_config( sub_service_name, aconsts.SUBSCRIBE_TYPE_PASSIVE), device_startup_offset=self.device_startup_offset) + + ########################################################## + + def exchange_messages(self, p_dut, p_disc_id, s_dut, s_disc_id, peer_id_on_sub, session_name): + """ + Exchange message between Publisher and Subscriber on target discovery session + + Args: + p_dut: Publisher device + p_disc_id: Publish discovery session id + s_dut: Subscriber device + s_disc_id: Subscribe discovery session id + peer_id_on_sub: Peer ID of the Publisher as seen on the Subscriber + session_name: dictionary of discovery session name base on role("pub" or "sub") + {role: {disc_id: name}} + """ + msg_template = "Hello {} from {} !" + + # Message send from Subscriber to Publisher + s_to_p_msg = msg_template.format(session_name["pub"][p_disc_id], + session_name["sub"][s_disc_id]) + s_dut.droid.wifiAwareSendMessage(s_disc_id, + peer_id_on_sub, + self.get_next_msg_id(), + s_to_p_msg, + self.msg_retx_count) + autils.wait_for_event(s_dut, + autils.decorate_event(aconsts.SESSION_CB_ON_MESSAGE_SENT, s_disc_id)) + event = autils.wait_for_event(p_dut, + autils.decorate_event(aconsts.SESSION_CB_ON_MESSAGE_RECEIVED, + p_disc_id)) + asserts.assert_equal( + event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], s_to_p_msg, + "Message on service %s from Subscriber to Publisher " + "not received correctly" % session_name["pub"][p_disc_id]) + peer_id_on_pub = event["data"][aconsts.SESSION_CB_KEY_PEER_ID] + + # Message send from Publisher to Subscriber + p_to_s_msg = msg_template.format(session_name["sub"][s_disc_id], + session_name["pub"][p_disc_id]) + p_dut.droid.wifiAwareSendMessage(p_disc_id, + peer_id_on_pub, + self.get_next_msg_id(), p_to_s_msg, + self.msg_retx_count) + autils.wait_for_event( + p_dut, autils.decorate_event(aconsts.SESSION_CB_ON_MESSAGE_SENT, p_disc_id)) + event = autils.wait_for_event(s_dut, + autils.decorate_event(aconsts.SESSION_CB_ON_MESSAGE_RECEIVED, + s_disc_id)) + asserts.assert_equal( + event["data"][aconsts.SESSION_CB_KEY_MESSAGE_AS_STRING], p_to_s_msg, + "Message on service %s from Publisher to Subscriber" + "not received correctly" % session_name["sub"][s_disc_id]) + + def run_multiple_concurrent_services_same_name_diff_ssi(self, type_x, type_y): + """Validate same service name with multiple service specific info on publisher + and subscriber can see all service + + - p_dut running Publish X and Y + - s_dut running subscribe A and B + - subscribe A find X and Y + - subscribe B find X and Y + + Message exchanges: + - A to X and X to A + - B to X and X to B + - A to Y and Y to A + - B to Y and Y to B + + Note: test requires that publisher device support 2 publish sessions concurrently, + and subscriber device support 2 subscribe sessions concurrently. + The test will be skipped if the devices are not capable. + + Args: + type_x, type_y: A list of [ptype, stype] of the publish and subscribe + types for services X and Y respectively. + """ + p_dut = self.android_devices[0] + s_dut = self.android_devices[1] + + asserts.skip_if( + p_dut.aware_capabilities[aconsts.CAP_MAX_PUBLISHES] < 2 + or s_dut.aware_capabilities[aconsts.CAP_MAX_SUBSCRIBES] < 2, + "Devices do not support 2 publish sessions or 2 subscribe sessions") + + SERVICE_NAME = "ServiceName" + X_SERVICE_SSI = "ServiceSpecificInfoXXX" + Y_SERVICE_SSI = "ServiceSpecificInfoYYY" + use_id = True + + # attach and wait for confirmation + p_id = p_dut.droid.wifiAwareAttach(False, None, use_id) + autils.wait_for_event(p_dut, autils.decorate_event(aconsts.EVENT_CB_ON_ATTACHED, p_id)) + time.sleep(self.device_startup_offset) + s_id = s_dut.droid.wifiAwareAttach(False, None, use_id) + autils.wait_for_event(s_dut, autils.decorate_event(aconsts.EVENT_CB_ON_ATTACHED, s_id)) + + # Publisher: start publishing both X & Y services and wait for confirmations + p_disc_id_x = p_dut.droid.wifiAwarePublish( + p_id, autils.create_discovery_config(SERVICE_NAME, type_x[0], X_SERVICE_SSI), use_id) + event = autils.wait_for_event(p_dut, + autils.decorate_event( + aconsts.SESSION_CB_ON_PUBLISH_STARTED, p_disc_id_x)) + + p_disc_id_y = p_dut.droid.wifiAwarePublish( + p_id, autils.create_discovery_config(SERVICE_NAME, type_x[0], Y_SERVICE_SSI), use_id) + event = autils.wait_for_event(p_dut, + autils.decorate_event( + aconsts.SESSION_CB_ON_PUBLISH_STARTED, p_disc_id_y)) + + # Subscriber: start subscribe session A + s_disc_id_a = s_dut.droid.wifiAwareSubscribe( + s_id, autils.create_discovery_config(SERVICE_NAME, type_x[1]), use_id) + autils.wait_for_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED, s_disc_id_a)) + + # Subscriber: start subscribe session B + s_disc_id_b = s_dut.droid.wifiAwareSubscribe( + p_id, autils.create_discovery_config(SERVICE_NAME, type_y[1]), use_id) + autils.wait_for_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SUBSCRIBE_STARTED, s_disc_id_b)) + + session_name = {"pub": {p_disc_id_x: "X", p_disc_id_y: "Y"}, + "sub": {s_disc_id_a: "A", s_disc_id_b: "B"}} + + # Subscriber: subscribe session A & B wait for service discovery + # Number of results on each session should be exactly 2 + results_a = {} + for i in range(2): + event = autils.wait_for_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SERVICE_DISCOVERED, s_disc_id_a)) + results_a[ + bytes(event["data"][ + aconsts.SESSION_CB_KEY_SERVICE_SPECIFIC_INFO]).decode('utf-8')] = event + autils.fail_on_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SERVICE_DISCOVERED, s_disc_id_a)) + + results_b = {} + for i in range(2): + event = autils.wait_for_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SERVICE_DISCOVERED, s_disc_id_b)) + results_b[ + bytes(event["data"][ + aconsts.SESSION_CB_KEY_SERVICE_SPECIFIC_INFO]).decode('utf-8')] = event + autils.fail_on_event(s_dut, autils.decorate_event( + aconsts.SESSION_CB_ON_SERVICE_DISCOVERED, s_disc_id_b)) + + s_a_peer_id_for_p_x = results_a[X_SERVICE_SSI]["data"][aconsts.SESSION_CB_KEY_PEER_ID] + s_a_peer_id_for_p_y = results_a[Y_SERVICE_SSI]["data"][aconsts.SESSION_CB_KEY_PEER_ID] + s_b_peer_id_for_p_x = results_b[X_SERVICE_SSI]["data"][aconsts.SESSION_CB_KEY_PEER_ID] + s_b_peer_id_for_p_y = results_b[Y_SERVICE_SSI]["data"][aconsts.SESSION_CB_KEY_PEER_ID] + + # Message exchange between Publisher and Subscribe + self.exchange_messages(p_dut, p_disc_id_x, + s_dut, s_disc_id_a, s_a_peer_id_for_p_x, session_name) + + self.exchange_messages(p_dut, p_disc_id_x, + s_dut, s_disc_id_b, s_b_peer_id_for_p_x, session_name) + + self.exchange_messages(p_dut, p_disc_id_y, + s_dut, s_disc_id_a, s_a_peer_id_for_p_y, session_name) + + self.exchange_messages(p_dut, p_disc_id_y, + s_dut, s_disc_id_b, s_b_peer_id_for_p_y, session_name) + + # Check no more messages + time.sleep(autils.EVENT_TIMEOUT) + autils.verify_no_more_events(p_dut, timeout=0) + autils.verify_no_more_events(s_dut, timeout=0) + + ########################################################## + + @test_tracker_info(uuid="78d89d63-1cbc-47f6-a8fc-74057fea655e") + def test_multiple_concurrent_services_diff_ssi_unsolicited_passive(self): + """Multi service test on same service name but different Service Specific Info + - Unsolicited publish + - Passive subscribe + """ + self.run_multiple_concurrent_services_same_name_diff_ssi( + type_x=[aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE], + type_y=[aconsts.PUBLISH_TYPE_UNSOLICITED, aconsts.SUBSCRIBE_TYPE_PASSIVE]) + + @test_tracker_info(uuid="5d349491-48e4-4ca1-a8af-7afb44e7bcbc") + def test_multiple_concurrent_services_diff_ssi_solicited_active(self): + """Multi service test on same service name but different Service Specific Info + - Solicited publish + - Active subscribe + """ + self.run_multiple_concurrent_services_same_name_diff_ssi( + type_x=[aconsts.PUBLISH_TYPE_SOLICITED, aconsts.SUBSCRIBE_TYPE_ACTIVE], + type_y=[aconsts.PUBLISH_TYPE_SOLICITED, aconsts.SUBSCRIBE_TYPE_ACTIVE]) diff --git a/acts_tests/tests/google/wifi/aware/functional/MacRandomNoLeakageTest.py b/acts_tests/tests/google/wifi/aware/functional/MacRandomNoLeakageTest.py index 074ca48826..3898832026 100644 --- a/acts_tests/tests/google/wifi/aware/functional/MacRandomNoLeakageTest.py +++ b/acts_tests/tests/google/wifi/aware/functional/MacRandomNoLeakageTest.py @@ -70,12 +70,13 @@ class MacRandomNoLeakageTest(AwareBaseTest, WifiBaseTest): pcaps = pcap_5g + pcap_2g # Verify factory MAC is not leaked in both 2G and 5G pcaps - for mac in factory_mac_addresses: - wutils.verify_mac_not_found_in_pcap(mac, pcaps) + ads = [self.android_devices[0], self.android_devices[1]] + for i, mac in enumerate(factory_mac_addresses): + wutils.verify_mac_not_found_in_pcap(ads[i], mac, pcaps) # Verify random MACs are being used and in pcaps - for mac in mac_addresses: - wutils.verify_mac_is_found_in_pcap(mac, pcaps) + for i, mac in enumerate(mac_addresses): + wutils.verify_mac_is_found_in_pcap(ads[i], mac, pcaps) def transfer_mac_format(self, mac): """add ':' to mac String, and transfer to lower case diff --git a/acts_tests/tests/google/wifi/aware/functional/MessageTest.py b/acts_tests/tests/google/wifi/aware/functional/MessageTest.py index 9bfb932b31..040f4e4615 100644 --- a/acts_tests/tests/google/wifi/aware/functional/MessageTest.py +++ b/acts_tests/tests/google/wifi/aware/functional/MessageTest.py @@ -19,6 +19,7 @@ import time from acts import asserts from acts.test_decorators import test_tracker_info +from acts.test_utils.wifi.WifiBaseTest import WifiBaseTest from acts.test_utils.wifi.aware import aware_const as aconsts from acts.test_utils.wifi.aware import aware_test_utils as autils from acts.test_utils.wifi.aware.AwareBaseTest import AwareBaseTest @@ -407,6 +408,7 @@ class MessageTest(AwareBaseTest): ############################################################################ @test_tracker_info(uuid="a8cd0512-b279-425f-93cf-949ddba22c7a") + @WifiBaseTest.wifi_test_wrap def test_message_no_queue_min(self): """Functional / Message / No queue - Minimal payload size (None or "") @@ -421,6 +423,7 @@ class MessageTest(AwareBaseTest): self.run_message_no_queue(self.PAYLOAD_SIZE_TYPICAL) @test_tracker_info(uuid="c984860c-b62d-4d9b-8bce-4d894ea3bfbe") + @WifiBaseTest.wifi_test_wrap def test_message_no_queue_max(self): """Functional / Message / No queue - Max payload size (based on device capabilities) diff --git a/acts_tests/tests/google/wifi/aware/functional/NonConcurrencyTest.py b/acts_tests/tests/google/wifi/aware/functional/NonConcurrencyTest.py index f0286f25a3..51f4caedd4 100644 --- a/acts_tests/tests/google/wifi/aware/functional/NonConcurrencyTest.py +++ b/acts_tests/tests/google/wifi/aware/functional/NonConcurrencyTest.py @@ -14,9 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from acts import asserts import queue +import time + +from acts import asserts from acts import utils +from acts.test_decorators import test_tracker_info from acts.test_utils.wifi import wifi_test_utils as wutils from acts.test_utils.wifi import wifi_constants as wconsts from acts.test_utils.wifi.aware import aware_const as aconsts @@ -40,10 +43,13 @@ class NonConcurrencyTest(AwareBaseTest): AwareBaseTest.teardown_test(self) for ad in self.android_devices: ad.droid.wifiP2pClose() + ad.droid.connectivityStopTethering(0) def run_aware_then_incompat_service(self, is_p2p): """Run test to validate that a running Aware session terminates when an Aware-incompatible service is started. + P2P: has same priority, will bring down Aware, then Aware will become available again. + SoftAp: has higher priority, will bring down Aware, Aware will keep unavailable. Args: is_p2p: True for p2p, False for SoftAP @@ -54,6 +60,8 @@ class NonConcurrencyTest(AwareBaseTest): id = dut.droid.wifiAwareAttach() autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) + time.sleep(EVENT_TIMEOUT) + # start other service if is_p2p: dut.droid.wifiP2pInitialize() @@ -63,40 +71,68 @@ class NonConcurrencyTest(AwareBaseTest): # expect an announcement about Aware non-availability autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) - # local clean-up - if not is_p2p: + if is_p2p: + # P2P has same priority, aware will be available + autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) + else: + # SoftAp has higher priority, aware will keep unavailable + autils.fail_on_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) + # local clean-up wutils.stop_wifi_tethering(dut) def run_incompat_service_then_aware(self, is_p2p): - """Validate that if an Aware-incompatible service is already up then any - Aware operation fails""" + """Validate that if an Aware-incompatible service is already up then try to start Aware. + P2P: has same priority, Aware can bring it down. + SoftAp: has higher priority, Aware will be unavailable, any Aware operation will fail. + + Args: + is_p2p: True for p2p, False for SoftAP + """ dut = self.android_devices[0] # start other service if is_p2p: dut.droid.wifiP2pInitialize() + # expect no announcement about Aware non-availability + autils.fail_on_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) else: wutils.start_wifi_tethering(dut, self.TETHER_SSID, password=None) + # expect an announcement about Aware non-availability + autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) - # expect an announcement about Aware non-availability - autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_NOT_AVAILABLE) + # Change Wifi state and location mode to check if aware became available. + wutils.wifi_toggle_state(dut, False) + utils.set_location_service(dut, False) + wutils.wifi_toggle_state(dut, True) + utils.set_location_service(dut, True) - # try starting anyway (expect failure) - dut.droid.wifiAwareAttach() - autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACH_FAILED) + if is_p2p: + # P2P has same priority, aware will be available + autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) + asserts.assert_true(dut.droid.wifiIsAwareAvailable(), "Aware should be available") + else: + # SoftAp has higher priority, aware will keep unavailable + autils.fail_on_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) + asserts.assert_false(dut.droid.wifiIsAwareAvailable(), + "Aware is available (it shouldn't be)") - # stop other service + dut.droid.wifiAwareAttach() if is_p2p: - dut.droid.wifiP2pClose() + # P2P has same priority, Aware attach should success. + autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) else: + # SoftAp has higher priority, Aware attach should fail. + autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACH_FAILED) + + if not is_p2p: wutils.stop_wifi_tethering(dut) - # expect an announcement about Aware availability - autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) + # expect an announcement about Aware availability + autils.wait_for_event(dut, aconsts.BROADCAST_WIFI_AWARE_AVAILABLE) - # try starting Aware - dut.droid.wifiAwareAttach() - autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) + # try starting Aware + dut.droid.wifiAwareAttach() + autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) def run_aware_then_connect_to_new_ap(self): """Validate interaction of Wi-Fi Aware and infra (STA) association with randomized MAC @@ -133,6 +169,7 @@ class NonConcurrencyTest(AwareBaseTest): p_id = dut.droid.wifiAwareAttach() autils.wait_for_event(dut, aconsts.EVENT_CB_ON_ATTACHED) + wutils.start_wifi_connection_scan_and_ensure_network_found(dut, ap_ssid) wutils.wifi_connect(dut, config, check_connectivity=False) autils.wait_for_event(dut, wconsts.WIFI_STATE_CHANGED) @@ -162,23 +199,31 @@ class NonConcurrencyTest(AwareBaseTest): ########################################################################## + @test_tracker_info(uuid="b7c84cbe-d744-440a-9279-a0133e88e8cb") def test_run_p2p_then_aware(self): """Validate that if p2p is already up then any Aware operation fails""" self.run_incompat_service_then_aware(is_p2p=True) + @test_tracker_info(uuid="1e7b3a6d-575d-4911-80bb-6fcf1157ee9f") def test_run_aware_then_p2p(self): """Validate that a running Aware session terminates when p2p is started""" self.run_aware_then_incompat_service(is_p2p=True) + @test_tracker_info(uuid="82a0bd98-3022-4831-ac9e-d81f58c742d2") def test_run_softap_then_aware(self): """Validate that if SoftAp is already up then any Aware operation fails""" + asserts.skip_if( + self.android_devices[0].model not in self.dbs_supported_models, + "Device %s doesn't support STA+AP." % self.android_devices[0].model) self.run_incompat_service_then_aware(is_p2p=False) + @test_tracker_info(uuid="0da7661e-8ac2-4f68-b6d3-b3f612369d03") def test_run_aware_then_softap(self): """Validate that a running Aware session terminates when softAp is started""" self.run_aware_then_incompat_service(is_p2p=False) + @test_tracker_info(uuid="2ac27ac6-8010-4d05-b892-00242420b075") def test_run_aware_then_connect_new_ap(self): """Validate connect new ap during Aware session""" self.run_aware_then_connect_to_new_ap() diff --git a/acts_tests/tests/google/wifi/aware/performance/ThroughputTest.py b/acts_tests/tests/google/wifi/aware/performance/ThroughputTest.py index a90734d7d7..2dab2760a9 100644 --- a/acts_tests/tests/google/wifi/aware/performance/ThroughputTest.py +++ b/acts_tests/tests/google/wifi/aware/performance/ThroughputTest.py @@ -406,3 +406,35 @@ class ThroughputTest(AwareBaseTest): [self.PASSPHRASE, self.PASSPHRASE2], results=results) asserts.explicit_pass( "test_iperf_max_ndi_aware_only_passphrases passes", extras=results) + + def run_test_traffic_latency_single_ndp_ib_aware_only_open(self): + """Measure IPv6 traffic latency performance(ping) on NDP between 2 devices. + Security config is open. + """ + p_dut = self.android_devices[0] + p_dut.pretty_name = "publisher" + s_dut = self.android_devices[1] + s_dut.pretty_name = "subscriber" + ndp_info = autils.create_ib_ndp(p_dut, + s_dut, + autils.create_discovery_config( + self.SERVICE_NAME, aconsts.PUBLISH_TYPE_UNSOLICITED), + autils.create_discovery_config( + self.SERVICE_NAME, aconsts.SUBSCRIBE_TYPE_PASSIVE), + self.device_startup_offset) + p_req_key = ndp_info[0] + s_req_key = ndp_info[1] + p_aware_if = ndp_info[2] + s_aware_if = ndp_info[3] + p_ipv6 = ndp_info[4] + s_ipv6 = ndp_info[5] + self.log.info("Interface names: P=%s, S=%s", p_aware_if, s_aware_if) + self.log.info("Interface addresses (IPv6): P=%s, S=%s", p_ipv6, s_ipv6) + self.log.info("Start ping %s from %s", s_ipv6, p_ipv6) + latency_result = autils.run_ping6(p_dut, s_ipv6) + self.log.info("The latency results are %s", latency_result) + + def test_traffic_latency_single_ndp_ib_aware_only_open(self): + """Test IPv6 traffic latency performance on NDP with security config is open. + """ + self.run_test_traffic_latency_single_ndp_ib_aware_only_open() diff --git a/acts_tests/tests/google/wifi/aware/stress/MessagesStressTest.py b/acts_tests/tests/google/wifi/aware/stress/MessagesStressTest.py index fbe95d4df5..153a81fde9 100644 --- a/acts_tests/tests/google/wifi/aware/stress/MessagesStressTest.py +++ b/acts_tests/tests/google/wifi/aware/stress/MessagesStressTest.py @@ -30,10 +30,18 @@ KEY_RX_COUNT = "rx_count" class MessagesStressTest(AwareBaseTest): """Set of stress tests for Wi-Fi Aware L2 (layer 2) message exchanges.""" + # Number of the message queue depth per Uid from framework + MESSAGE_QUEUE_DEPTH_PER_UID = 50 # Number of iterations in the stress test (number of messages) + # Should be larger than MESSAGE_QUEUE_DEPTH_PER_UID NUM_ITERATIONS = 100 + # Number of message to send per round to avoid exceed message queue depth limit + # Should be less than or equal to 1/2 of MESSAGE_QUEUE_DEPTH_PER_UID + NUM_PER_ROUND = 20 + NUM_ROUNDS = 5 + # Maximum permitted percentage of messages which fail to be transmitted # correctly MAX_TX_FAILURE_PERCENTAGE = 2 @@ -172,39 +180,166 @@ class MessagesStressTest(AwareBaseTest): if data[KEY_TX_OK_COUNT] > 0: results["tx_count_success"] = results["tx_count_success"] + 1 if data[KEY_TX_OK_COUNT] > 1: - results["tx_count_duplicate_success"] = ( - results["tx_count_duplicate_success"] + 1) + results["tx_count_duplicate_success"] += 1 if data[KEY_TX_FAIL_COUNT] > 0: - results["tx_count_fail"] = results["tx_count_fail"] + 1 + results["tx_count_fail"] += 1 if data[KEY_TX_FAIL_COUNT] > 1: - results[ - "tx_count_duplicate_fail"] = results["tx_count_duplicate_fail"] + 1 + results["tx_count_duplicate_fail"] += 1 if (data[KEY_TX_OK_COUNT] == 0 and data[KEY_TX_FAIL_COUNT] == 0 and data[KEY_ID] != -1): - results["tx_count_neither"] = results["tx_count_neither"] + 1 + results["tx_count_neither"] += 1 if data[KEY_TX_OK_COUNT] > 0 and data[KEY_RX_COUNT] == 0: - results["tx_count_tx_ok_but_no_rx"] = ( - results["tx_count_tx_ok_but_no_rx"] + 1) + results["tx_count_tx_ok_but_no_rx"] += 1 if data[KEY_RX_COUNT] > 0: - results["rx_count"] = results["rx_count"] + 1 + results["rx_count"] += 1 if data[KEY_RX_COUNT] > 1: - results[ - "rx_count_duplicate"] = results["rx_count_duplicate"] + 1 + results["rx_count_duplicate"] += 1 if data[KEY_RX_COUNT] > 0 and data[KEY_TX_OK_COUNT] == 0: - results["rx_count_no_ok_tx_indication"] = ( - results["rx_count_no_ok_tx_indication"] + 1) + results["rx_count_no_ok_tx_indication"] += 1 if data[KEY_RX_COUNT] > 0 and data[KEY_TX_FAIL_COUNT] > 0: - results["rx_count_fail_tx_indication"] = ( - results["rx_count_fail_tx_indication"] + 1) + results["rx_count_fail_tx_indication"] += 1 if data[KEY_RX_COUNT] > 0 and data[KEY_ID] == -1: - results[ - "rx_count_no_tx_message"] = results["rx_count_no_tx_message"] + 1 + results["rx_count_no_tx_message"] += 1 ####################################################################### @test_tracker_info(uuid="e88c060f-4ca7-41c1-935a-d3d62878ec0b") - def test_stress_message(self): - """Stress test for bi-directional message transmission and reception.""" + def test_stress_message_no_throttling(self): + """Stress test for bi-directional message transmission and reception no throttling""" + p_dut = self.android_devices[0] + s_dut = self.android_devices[1] + + # Start up a discovery session + discovery_data = autils.create_discovery_pair( + p_dut, + s_dut, + p_config=autils.create_discovery_config( + self.SERVICE_NAME, aconsts.PUBLISH_TYPE_UNSOLICITED), + s_config=autils.create_discovery_config( + self.SERVICE_NAME, aconsts.SUBSCRIBE_TYPE_PASSIVE), + device_startup_offset=self.device_startup_offset, + msg_id=self.get_next_msg_id()) + p_id = discovery_data[0] + s_id = discovery_data[1] + p_disc_id = discovery_data[2] + s_disc_id = discovery_data[3] + peer_id_on_sub = discovery_data[4] + peer_id_on_pub = discovery_data[5] + + # Store information on Tx & Rx messages + messages_by_msg = {} # keyed by message text + # {text -> {id, tx_ok_count, tx_fail_count, rx_count}} + messages_by_id = {} # keyed by message ID {id -> text} + iterations = 0 + p_tx_ok_count_total = 0 + p_tx_fail_count_total = 0 + p_tx_unknown_id_total = 0 + s_tx_ok_count_total = 0 + s_tx_fail_count_total = 0 + s_tx_unknown_id_total = 0 + + # First round will fill up the message queue + num_of_messages_this_round = self.MESSAGE_QUEUE_DEPTH_PER_UID + + # send messages (one in each direction) in rounds to avoid exceed the queue limit + for j in range(self.NUM_ROUNDS): + for k in range(num_of_messages_this_round): + msg_p2s = "Message Publisher -> Subscriber #%d" % iterations + next_msg_id = self.get_next_msg_id() + self.init_info(msg_p2s, next_msg_id, messages_by_msg, + messages_by_id) + p_dut.droid.wifiAwareSendMessage(p_disc_id, peer_id_on_pub, + next_msg_id, msg_p2s, 0) + + msg_s2p = "Message Subscriber -> Publisher #%d" % iterations + next_msg_id = self.get_next_msg_id() + self.init_info(msg_s2p, next_msg_id, messages_by_msg, + messages_by_id) + s_dut.droid.wifiAwareSendMessage(s_disc_id, peer_id_on_sub, + next_msg_id, msg_s2p, 0) + iterations += 1 + + # wait for message tx confirmation + (p_tx_ok_count, p_tx_fail_count, p_tx_unknown_id) = self.wait_for_tx_events( + p_dut, self.NUM_PER_ROUND, messages_by_msg, messages_by_id) + p_tx_ok_count_total += p_tx_ok_count + p_tx_fail_count_total += p_tx_fail_count + p_tx_unknown_id_total += p_tx_unknown_id + (s_tx_ok_count, s_tx_fail_count, s_tx_unknown_id) = self.wait_for_tx_events( + s_dut, self.NUM_PER_ROUND, messages_by_msg, messages_by_id) + s_tx_ok_count_total += s_tx_ok_count + s_tx_fail_count_total += s_tx_fail_count + s_tx_unknown_id_total += s_tx_unknown_id + + num_of_messages_this_round = self.NUM_PER_ROUND + + # wait for the rest message tx confirmation + p_tx_total = p_tx_ok_count_total + p_tx_fail_count_total + p_tx_unknown_id_total + s_tx_total = s_tx_ok_count_total + s_tx_fail_count_total + s_tx_unknown_id_total + (p_tx_ok_count, p_tx_fail_count, p_tx_unknown_id) = self.wait_for_tx_events( + p_dut, iterations - p_tx_total, messages_by_msg, messages_by_id) + (s_tx_ok_count, s_tx_fail_count, s_tx_unknown_id) = self.wait_for_tx_events( + s_dut, iterations - s_tx_total, messages_by_msg, messages_by_id) + p_tx_ok_count_total += p_tx_ok_count + p_tx_fail_count_total += p_tx_fail_count + p_tx_unknown_id_total += p_tx_unknown_id + s_tx_ok_count_total += s_tx_ok_count + s_tx_fail_count_total += s_tx_fail_count + s_tx_unknown_id_total += s_tx_unknown_id + self.log.info( + "Transmission done: pub=%d, sub=%d transmitted successfully", + p_tx_ok_count_total, s_tx_ok_count_total) + + # wait for message rx confirmation (giving it the total number of messages + # transmitted rather than just those transmitted correctly since sometimes + # the Tx doesn't get that information correctly. I.e. a message the Tx + # thought was not transmitted correctly is actually received - missing ACK? + # bug?) + self.wait_for_rx_events(p_dut, iterations, messages_by_msg) + self.wait_for_rx_events(s_dut, iterations, messages_by_msg) + + # analyze results + results = {} + results["tx_count"] = 2 * iterations + results["tx_unknown_ids"] = p_tx_unknown_id_total + s_tx_unknown_id_total + self.analyze_results(results, messages_by_msg) + + # clear errors + asserts.assert_equal(results["tx_unknown_ids"], 0, + "Message ID corruption", results) + asserts.assert_equal(results["tx_count_neither"], 0, + "Tx message with no success or fail indication", + results) + asserts.assert_equal(results["tx_count_duplicate_fail"], 0, + "Duplicate Tx fail messages", results) + asserts.assert_equal(results["tx_count_duplicate_success"], 0, + "Duplicate Tx success messages", results) + asserts.assert_equal(results["rx_count_no_tx_message"], 0, + "Rx message which wasn't sent - message corruption?", results) + asserts.assert_equal(results["tx_count_tx_ok_but_no_rx"], 0, + "Tx got ACK but Rx didn't get message", results) + + # possibly ok - but flag since most frequently a bug + asserts.assert_equal(results["rx_count_no_ok_tx_indication"], 0, + "Message received but Tx didn't get ACK", results) + asserts.assert_equal(results["rx_count_fail_tx_indication"], 0, + "Message received but Tx didn't get ACK", results) + + # permissible failures based on thresholds + asserts.assert_true( + results["tx_count_fail"] <= + (self.MAX_TX_FAILURE_PERCENTAGE * iterations * 2 / 100), + "Number of Tx failures exceeds threshold", extras=results) + asserts.assert_true( + results["rx_count_duplicate"] <= + (self.MAX_DUPLICATE_RX_PERCENTAGE * iterations * 2 / 100), + "Number of duplicate Rx exceeds threshold", extras=results) + + asserts.explicit_pass("test_stress_message_no_throttling done", extras=results) + + @test_tracker_info(uuid="546b0c6f-3071-4330-8e23-842ecbd07018") + def test_stress_message_throttling(self): + """Stress test for bi-directional message transmission and reception with throttling""" p_dut = self.android_devices[0] s_dut = self.android_devices[1] @@ -295,14 +430,16 @@ class MessagesStressTest(AwareBaseTest): # permissible failures based on thresholds asserts.assert_true( - results["tx_count_fail"] <= - (self.MAX_TX_FAILURE_PERCENTAGE * self.NUM_ITERATIONS / 100), - "Number of Tx failures exceeds threshold", - extras=results) - asserts.assert_true( results["rx_count_duplicate"] <= - (self.MAX_DUPLICATE_RX_PERCENTAGE * self.NUM_ITERATIONS / 100), - "Number of duplicate Rx exceeds threshold", - extras=results) + (self.MAX_DUPLICATE_RX_PERCENTAGE * results["tx_count_success"] / 100), + "Number of duplicate Rx exceeds threshold", extras=results) + + # check working status message queue limit per UID + asserts.assert_true( + results["tx_count_success"] >= self.MESSAGE_QUEUE_DEPTH_PER_UID * 2, + "Number of messages did not reach uid message queue limit", extras=results) + asserts.assert_true( + results["tx_count_success"] < self.NUM_ITERATIONS * 2, + "Seems uid message queue limit is not working, Tx all message", extras=results) - asserts.explicit_pass("test_stress_message done", extras=results) + asserts.explicit_pass("test_stress_message_throttling done", extras=results) diff --git a/acts_tests/tests/google/wifi/example_config_iot.json b/acts_tests/tests/google/wifi/example_config_iot.json index 133cbe3625..42b0be7531 100644 --- a/acts_tests/tests/google/wifi/example_config_iot.json +++ b/acts_tests/tests/google/wifi/example_config_iot.json @@ -14,7 +14,7 @@ ], "logpath": "/tmp/ACTS_logs", "testpaths": [ - "<path to acts root>/tools/test/connectivity/acts_tests/tests/google/wifi" + "<path to acts root>/tools/test/connectivity/acts/tests/google/wifi" ], "iot_networks": [ { diff --git a/acts_tests/tests/google/wifi/example_connectivity_performance_ap_sta.json b/acts_tests/tests/google/wifi/example_connectivity_performance_ap_sta.json index 6ec05017a5..234df4a52b 100644 --- a/acts_tests/tests/google/wifi/example_connectivity_performance_ap_sta.json +++ b/acts_tests/tests/google/wifi/example_connectivity_performance_ap_sta.json @@ -85,5 +85,5 @@ "rtt_std_deviation_threshold": 5 }, "logpath": "<path to logs>", - "testpaths": ["<path to ACTS root folder>/tools/test/connectivity/acts_tests/tests/google/wifi"] + "testpaths": ["<path to ACTS root folder>/tools/test/connectivity/acts/tests/google/wifi"] } diff --git a/acts_tests/tests/google/wifi/p2p/config/wifi_p2p.json b/acts_tests/tests/google/wifi/p2p/config/wifi_p2p.json index 9a8c841ed6..31af5313af 100644 --- a/acts_tests/tests/google/wifi/p2p/config/wifi_p2p.json +++ b/acts_tests/tests/google/wifi/p2p/config/wifi_p2p.json @@ -8,7 +8,8 @@ "AndroidDevice": "*" } ], + "skip_read_factory_mac": 1, "logpath": "~/logs", - "testpaths": ["./tools/test/connectivity/acts_tests/tests/google/wifi/p2p"], + "testpaths": ["./tools/test/connectivity/acts/tests/google/wifi/p2p"], "adb_logcat_param": "-b all" } diff --git a/acts_tests/tests/google/wifi/p2p/config/wifi_p2p_group.json b/acts_tests/tests/google/wifi/p2p/config/wifi_p2p_group.json index e4f7d8b3a7..5ca412d404 100644 --- a/acts_tests/tests/google/wifi/p2p/config/wifi_p2p_group.json +++ b/acts_tests/tests/google/wifi/p2p/config/wifi_p2p_group.json @@ -8,10 +8,11 @@ "AndroidDevice": "*" } ], + "skip_read_factory_mac": 1, "network_name": "DIRECT-xy-Hello", "passphrase": "P2pWorld1234", "group_band": "2", "logpath": "~/logs", - "testpaths": ["./tools/test/connectivity/acts_tests/tests/google/wifi/p2p"], + "testpaths": ["./tools/test/connectivity/acts/tests/google/wifi/p2p"], "adb_logcat_param": "-b all" } diff --git a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pGroupTest.py b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pGroupTest.py index 165391fe35..dd27f210c9 100644 --- a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pGroupTest.py +++ b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pGroupTest.py @@ -30,13 +30,13 @@ WPS_PBC = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC WPS_DISPLAY = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_DISPLAY WPS_KEYPAD = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_KEYPAD + class WifiP2pGroupTest(WifiP2pBaseTest): """Tests for APIs in Android's WifiP2pManager class. Test Bed Requirement: * At least two Android devices """ - def __init__(self, controllers): WifiP2pBaseTest.__init__(self, controllers) @@ -76,10 +76,15 @@ class WifiP2pGroupTest(WifiP2pBaseTest): gc_dut = self.dut2 # Create a group wp2putils.p2p_create_group(go_dut) - go_dut.ed.pop_event(p2pconsts.CONNECTED_EVENT, p2pconsts.DEFAULT_TIMEOUT) + go_dut.ed.pop_event(p2pconsts.CONNECTED_EVENT, + p2pconsts.DEFAULT_TIMEOUT) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) # Request the connection - wp2putils.p2p_connect(gc_dut, go_dut, False, wps_type, True) + wp2putils.p2p_connect(gc_dut, + go_dut, + False, + wps_type, + p2p_connect_type=p2pconsts.P2P_CONNECT_JOIN) go_ip = wp2putils.p2p_go_ip(gc_dut) wp2putils.p2p_connection_ping_test(gc_dut, go_ip) @@ -88,7 +93,6 @@ class WifiP2pGroupTest(WifiP2pBaseTest): wp2putils.check_disconnect(gc_dut) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - """Test Cases""" @test_tracker_info(uuid="c41f8293-5225-430d-917e-c294ddff7c2a") def test_p2p_group_join_via_pbc(self): @@ -114,15 +118,13 @@ class WifiP2pGroupTest(WifiP2pBaseTest): go_dut = self.dut1 gc_dut = self.dut2 # Create a group - wp2putils.p2p_create_group_with_config(go_dut, - self.network_name, + wp2putils.p2p_create_group_with_config(go_dut, self.network_name, self.passphrase, self.group_band) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) # Request the connection. Since config is known, this is reconnection. - wp2putils.p2p_connect_with_config(gc_dut, go_dut, - self.network_name, self.passphrase, - self.group_band) + wp2putils.p2p_connect_with_config(gc_dut, go_dut, self.network_name, + self.passphrase, self.group_band) go_ip = wp2putils.p2p_go_ip(gc_dut) wp2putils.p2p_connection_ping_test(gc_dut, go_ip) diff --git a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pLocalServiceTest.py b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pLocalServiceTest.py index baa21847b8..b043eb9f13 100644 --- a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pLocalServiceTest.py +++ b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pLocalServiceTest.py @@ -21,6 +21,7 @@ from acts.test_utils.wifi.p2p.WifiP2pBaseTest import WifiP2pBaseTest from acts.test_utils.wifi.p2p import wifi_p2p_test_utils as wp2putils from acts.test_utils.wifi.p2p import wifi_p2p_const as p2pconsts + class WifiP2pLocalServiceTest(WifiP2pBaseTest): """Tests for APIs in Android's WifiP2pManager and p2p local service class. @@ -28,7 +29,6 @@ class WifiP2pLocalServiceTest(WifiP2pBaseTest): * At least two Android devices * 3 Android devices for WifiP2pMultiPeersTest.py """ - def __init__(self, controllers): WifiP2pBaseTest.__init__(self, controllers) @@ -46,19 +46,20 @@ class WifiP2pLocalServiceTest(WifiP2pBaseTest): Note: Step 2 - Step 5 should reference function requestServiceAndCheckResult """ self.log.info("Add local Upnp Service") - wp2putils.createP2pLocalService(self.dut1, p2pconsts.P2P_LOCAL_SERVICE_UPNP) + wp2putils.createP2pLocalService(self.dut1, + p2pconsts.P2P_LOCAL_SERVICE_UPNP) - wp2putils.requestServiceAndCheckResult(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP, - None, None) + wp2putils.requestServiceAndCheckResult( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_UPNP, None, None) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - wp2putils.requestServiceAndCheckResult(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP, - "ssdp:all", None) + wp2putils.requestServiceAndCheckResult( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_UPNP, "ssdp:all", None) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - wp2putils.requestServiceAndCheckResult(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_UPNP, - "upnp:rootdevice", None) + wp2putils.requestServiceAndCheckResult( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_UPNP, "upnp:rootdevice", None) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) """Test Cases""" @@ -75,21 +76,23 @@ class WifiP2pLocalServiceTest(WifiP2pBaseTest): Note: Step 2 - Step 5 should reference function requestServiceAndCheckResult """ self.log.info("Add local bonjour service to %s" % (self.dut1.name)) - wp2putils.createP2pLocalService(self.dut1, p2pconsts.P2P_LOCAL_SERVICE_IPP) - wp2putils.createP2pLocalService(self.dut1, p2pconsts.P2P_LOCAL_SERVICE_AFP) + wp2putils.createP2pLocalService(self.dut1, + p2pconsts.P2P_LOCAL_SERVICE_IPP) + wp2putils.createP2pLocalService(self.dut1, + p2pconsts.P2P_LOCAL_SERVICE_AFP) - wp2putils.requestServiceAndCheckResultWithRetry(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_BONJOUR, - None, None) + wp2putils.requestServiceAndCheckResultWithRetry( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_BONJOUR, None, None) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - wp2putils.requestServiceAndCheckResultWithRetry(self.dut1,self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_BONJOUR, - "_ipp._tcp", None) + wp2putils.requestServiceAndCheckResultWithRetry( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_BONJOUR, "_ipp._tcp", None) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - wp2putils.requestServiceAndCheckResultWithRetry(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_BONJOUR, - "_ipp._tcp", "MyPrinter") + wp2putils.requestServiceAndCheckResultWithRetry( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_BONJOUR, "_ipp._tcp", "MyPrinter") time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) - wp2putils.requestServiceAndCheckResultWithRetry(self.dut1, self.dut2, - wp2putils.WifiP2PEnums.WifiP2pServiceInfo.WIFI_P2P_SERVICE_TYPE_BONJOUR, - "_afpovertcp._tcp", "Example") + wp2putils.requestServiceAndCheckResultWithRetry( + self.dut1, self.dut2, wp2putils.WifiP2PEnums.WifiP2pServiceInfo. + WIFI_P2P_SERVICE_TYPE_BONJOUR, "_afpovertcp._tcp", "Example") diff --git a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pManagerTest.py b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pManagerTest.py index 1f5a8628bd..6bda400dd6 100644 --- a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pManagerTest.py +++ b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pManagerTest.py @@ -30,6 +30,7 @@ WPS_PBC = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_PBC WPS_DISPLAY = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_DISPLAY WPS_KEYPAD = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_KEYPAD + class WifiP2pManagerTest(WifiP2pBaseTest): """Tests for APIs in Android's WifiP2pManager class. @@ -37,7 +38,6 @@ class WifiP2pManagerTest(WifiP2pBaseTest): * At least two Android devices * 3 Android devices for WifiP2pMultiPeersTest.py """ - def __init__(self, controllers): WifiP2pBaseTest.__init__(self, controllers) @@ -100,7 +100,8 @@ class WifiP2pManagerTest(WifiP2pBaseTest): gc_dut.ed.clear_all_events() wp2putils.p2p_connect(gc_dut, go_dut, True, WPS_PBC) wp2putils.p2p_disconnect(gc_dut) - wp2putils.check_disconnect(go_dut) + wp2putils.check_disconnect( + go_dut, timeout=p2pconsts.DEFAULT_GROUP_CLIENT_LOST_TIME) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) @test_tracker_info(uuid="12bbe73a-5a6c-4307-9797-c77c7efdc4b5") @@ -150,7 +151,8 @@ class WifiP2pManagerTest(WifiP2pBaseTest): gc_dut.ed.clear_all_events() wp2putils.p2p_connect(gc_dut, go_dut, True, WPS_DISPLAY) wp2putils.p2p_disconnect(gc_dut) - wp2putils.check_disconnect(go_dut) + wp2putils.check_disconnect( + go_dut, timeout=p2pconsts.DEFAULT_GROUP_CLIENT_LOST_TIME) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) @test_tracker_info(uuid="efe88f57-5a08-4195-9592-2f6945a9d18a") @@ -200,5 +202,6 @@ class WifiP2pManagerTest(WifiP2pBaseTest): gc_dut.ed.clear_all_events() wp2putils.p2p_connect(gc_dut, go_dut, True, WPS_KEYPAD) wp2putils.p2p_disconnect(gc_dut) - wp2putils.check_disconnect(go_dut) + wp2putils.check_disconnect( + go_dut, timeout=p2pconsts.DEFAULT_GROUP_CLIENT_LOST_TIME) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) diff --git a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py index 310eab2b50..2db52730d5 100644 --- a/acts_tests/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py +++ b/acts_tests/tests/google/wifi/p2p/functional/WifiP2pSnifferTest.py @@ -17,6 +17,7 @@ import acts.test_utils.wifi.wifi_test_utils as wutils import acts.utils import time +import re from acts import asserts from acts import utils @@ -33,6 +34,7 @@ WPS_DISPLAY = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_DISPLAY WPS_KEYPAD = wp2putils.WifiP2PEnums.WpsInfo.WIFI_WPS_INFO_KEYPAD DEFAULT_TIMEOUT = 10 + class WifiP2pSnifferTest(WifiP2pBaseTest): """Tests factory MAC is not leaked for p2p discovery and associated cases. @@ -40,7 +42,6 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): * At least two Android devices * An access point as sniffer """ - def __init__(self, controllers): WifiP2pBaseTest.__init__(self, controllers) @@ -52,11 +53,12 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): def setup_test(self): super(WifiP2pSnifferTest, self).setup_test() - self.pcap_procs = wutils.start_pcap( - self.packet_capture, '2g', self.test_name) + self.pcap_procs = wutils.start_pcap(self.packet_capture, '2g', + self.test_name) def teardown_test(self): - self.verify_mac_no_leakage() + if self.pcap_procs: + wutils.stop_pcap(self.packet_capture, self.pcap_procs, False) super(WifiP2pSnifferTest, self).teardown_test() def configure_packet_capture(self): @@ -73,12 +75,13 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): # Verify factory MAC is not leaked in 2G pcaps pcap_fname = '%s_%s.pcap' % (self.pcap_procs[BAND_2G][1], BAND_2G.upper()) + self.pcap_procs = None packets = rdpcap(pcap_fname) - wutils.verify_mac_not_found_in_pcap(self.dut1_mac, packets) - wutils.verify_mac_not_found_in_pcap(self.dut2_mac, packets) + wutils.verify_mac_not_found_in_pcap(self.dut1, self.dut1_mac, packets) + wutils.verify_mac_not_found_in_pcap(self.dut2, self.dut2_mac, packets) """Test Cases""" - @test_tracker_info(uuid=" d04e62dc-e1ef-4cea-86e6-39f0dd08fb6b") + @test_tracker_info(uuid="d04e62dc-e1ef-4cea-86e6-39f0dd08fb6b") def test_p2p_discovery_sniffer(self): """Verify the p2p discovery functionality Steps: @@ -88,6 +91,7 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): self.log.info("Device discovery") wp2putils.find_p2p_device(self.dut1, self.dut2) wp2putils.find_p2p_device(self.dut2, self.dut1) + self.verify_mac_no_leakage() @test_tracker_info(uuid="6a02be84-912d-4b5b-8dfa-fd80d2554c55") def test_p2p_connect_via_pbc_and_ping_and_reconnect_sniffer(self): @@ -138,3 +142,6 @@ class WifiP2pSnifferTest(WifiP2pBaseTest): wp2putils.p2p_disconnect(gc_dut) wp2putils.check_disconnect(go_dut) time.sleep(p2pconsts.DEFAULT_FUNCTION_SWITCH_TIME) + + # teardown + self.verify_mac_no_leakage() diff --git a/acts_tests/tests/google/wifi/rtt/config/wifi_rtt.json b/acts_tests/tests/google/wifi/rtt/config/wifi_rtt.json index 1870fe97f2..315beacc26 100644 --- a/acts_tests/tests/google/wifi/rtt/config/wifi_rtt.json +++ b/acts_tests/tests/google/wifi/rtt/config/wifi_rtt.json @@ -9,7 +9,7 @@ } ], "logpath": "~/logs", - "testpaths": ["./tools/test/connectivity/acts_tests/tests/google/wifi"], + "testpaths": ["./tools/test/connectivity/acts/tests/google/wifi"], "adb_logcat_param": "-b all", "aware_default_power_mode": "INTERACTIVE", "lci_reference": [], diff --git a/acts_tests/tests/google/wifi/rtt/functional/AwareDiscoveryWithRangingTest.py b/acts_tests/tests/google/wifi/rtt/functional/AwareDiscoveryWithRangingTest.py index e19993db13..da0ba4be86 100644 --- a/acts_tests/tests/google/wifi/rtt/functional/AwareDiscoveryWithRangingTest.py +++ b/acts_tests/tests/google/wifi/rtt/functional/AwareDiscoveryWithRangingTest.py @@ -1044,7 +1044,7 @@ class AwareDiscoveryWithRangingTest(AwareBaseTest, RttBaseTest): s_config=None, # no updates expect_discovery=False) - @test_tracker_info(uuid="ec6ca57b-f115-4516-813a-4572b930c8d3") + @test_tracker_info(uuid="3938a3dc-8032-4096-b184-b528e4564b5e") def test_ranged_updated_discovery_solicited_active_multi_step(self): """Verify discovery with ranging operation with updated configuration: - Unsolicited Publish/Passive Subscribe diff --git a/acts_tests/tests/sample/SampleTest.py b/acts_tests/tests/sample/SampleTest.py index d21e3044ed..eb4481175f 100755 --- a/acts_tests/tests/sample/SampleTest.py +++ b/acts_tests/tests/sample/SampleTest.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python3.4 +#!/usr/bin/env python3 # -# Copyright 2016 - The Android Open Source Project +# Copyright 2020 - The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,14 +13,21 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - from acts.base_test import BaseTestClass class SampleTest(BaseTestClass): - def __init__(self, controllers): - BaseTestClass.__init__(self, controllers) - self.tests = ("test_make_toast", ) + def setup_class(self): + self.log.info('Called when the test class is started.') + + def teardown_class(self): + self.log.info('Called when the test class has finished.') + + def setup_test(self): + self.log.info('Called before each test case starts.') + + def teardown_test(self): + self.log.info('Called after each test case completes.') """Tests""" |