Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce04101b authored by Jack He's avatar Jack He Committed by Automerger Merge Worker
Browse files

SL4A: Throw exception when test fails and clear paired devices am: 438d0afe

parents 3b95c294 438d0afe
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ from blueberry.tests.gd.cert.gd_device import MOBLY_CONTROLLER_CONFIG_NAME as GD
from blueberry.tests.gd_sl4a.lib.ble_lib import enable_bluetooth, disable_bluetooth, BleLib
from blueberry.facade import rootservice_pb2 as facade_rootservice
from blueberry.tests.gd.cert import gd_device
from blueberry.utils.bt_test_utils import clear_bonded_devices


class GdSl4aBaseTestClass(BaseTestClass):
@@ -90,9 +91,11 @@ class GdSl4aBaseTestClass(BaseTestClass):
        # Then enable Bluetooth
        enable_bluetooth(self.dut.sl4a, self.dut.ed)
        self.dut.sl4a.bluetoothDisableBLE()
        clear_bonded_devices(self.dut)
        return True

    def teardown_test(self):
        clear_bonded_devices(self.dut)
        # Make sure BLE is disabled and Bluetooth is disabled after test
        self.dut.sl4a.bluetoothDisableBLE()
        disable_bluetooth(self.dut.sl4a, self.dut.ed)
+98 −57

File changed.

Preview size limit exceeded, changes collapsed.

+1 −4
Original line number Diff line number Diff line
@@ -60,12 +60,9 @@ def setup_gatt_connection(central: AndroidDevice,
        close_gatt_client(central, bluetooth_gatt)
        raise GattTestUtilsError("Could not establish a connection to "
                                 "peripheral. Expected event: {}".format(expected_event))
    logging.info("Got connection event {}".format(event))
    if event['data']['State'] != GattConnectionState.STATE_CONNECTED:
        close_gatt_client(central, bluetooth_gatt)
        try:
            central.sl4a.gattClientClose(bluetooth_gatt)
        except Exception:
            logging.debug("Failed to close gatt client.")
        raise GattTestUtilsError("Could not establish a connection to "
                                 "peripheral. Event Details: {}".format(pprint.pformat(event)))
    return bluetooth_gatt, gatt_callback