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

Commit 438d0afe authored by Jack He's avatar Jack He
Browse files

SL4A: Throw exception when test fails and clear paired devices

* Return False no longer makes the test fail in mobly
  we should raise exception instead
* Clear paired devices before tests so that they do not interfer with
  later tests

Bug: 232048916
Tag: #test
Test: gd/cert/run --sl4a_sl4a --clean
Merged-In: Id1e4cb30e28a13203848cb5c406ecb784fe2315c
Change-Id: Id1e4cb30e28a13203848cb5c406ecb784fe2315c
(cherry picked from commit 19d1d76c)
parent 2d7ead85
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