Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +38 −2 Original line number Diff line number Diff line Loading @@ -548,6 +548,12 @@ public class AdapterServiceTest { verify(nativeInterface).disable(); adapter.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); TestUtils.syncHandler(looper, AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler TestUtils.syncHandler(looper, -1); } verifyStateChange(callback, STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(adapter.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -640,6 +646,12 @@ public class AdapterServiceTest { assertThat(mAdapterService.getBluetoothGatt()).isNull(); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } syncHandler(MESSAGE_PROFILE_SERVICE_STATE_CHANGED); syncHandler(MESSAGE_PROFILE_SERVICE_UNREGISTERED); Loading Loading @@ -674,6 +686,12 @@ public class AdapterServiceTest { mLooper.moveTimeForward(120_000); // Skip time so the timeout fires syncHandler(AdapterState.BLE_STOP_TIMEOUT); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -723,12 +741,18 @@ public class AdapterServiceTest { assertThat(mAdapterService.getBluetoothGatt()).isNull(); mAdapterService.stopBle(); TestUtils.syncHandler(mLooper, AdapterState.BLE_TURN_OFF); syncHandler(AdapterState.BLE_TURN_OFF); verifyStateChange(callback, STATE_BLE_ON, STATE_BLE_TURNING_OFF); verify(mNativeInterface).disable(); mAdapterService.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); TestUtils.syncHandler(mLooper, AdapterState.BLE_STOPPED); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(callback, STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -875,6 +899,12 @@ public class AdapterServiceTest { // TODO(b/280518177): The only timeout to fire here should be the BREDR mLooper.moveTimeForward(120_000); // Skip time so the timeout fires syncHandler(AdapterState.BLE_STOP_TIMEOUT); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -918,6 +948,12 @@ public class AdapterServiceTest { mAdapterService.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +38 −2 Original line number Diff line number Diff line Loading @@ -548,6 +548,12 @@ public class AdapterServiceTest { verify(nativeInterface).disable(); adapter.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); TestUtils.syncHandler(looper, AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler TestUtils.syncHandler(looper, -1); } verifyStateChange(callback, STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(adapter.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -640,6 +646,12 @@ public class AdapterServiceTest { assertThat(mAdapterService.getBluetoothGatt()).isNull(); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } syncHandler(MESSAGE_PROFILE_SERVICE_STATE_CHANGED); syncHandler(MESSAGE_PROFILE_SERVICE_UNREGISTERED); Loading Loading @@ -674,6 +686,12 @@ public class AdapterServiceTest { mLooper.moveTimeForward(120_000); // Skip time so the timeout fires syncHandler(AdapterState.BLE_STOP_TIMEOUT); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -723,12 +741,18 @@ public class AdapterServiceTest { assertThat(mAdapterService.getBluetoothGatt()).isNull(); mAdapterService.stopBle(); TestUtils.syncHandler(mLooper, AdapterState.BLE_TURN_OFF); syncHandler(AdapterState.BLE_TURN_OFF); verifyStateChange(callback, STATE_BLE_ON, STATE_BLE_TURNING_OFF); verify(mNativeInterface).disable(); mAdapterService.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); TestUtils.syncHandler(mLooper, AdapterState.BLE_STOPPED); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(callback, STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -875,6 +899,12 @@ public class AdapterServiceTest { // TODO(b/280518177): The only timeout to fire here should be the BREDR mLooper.moveTimeForward(120_000); // Skip time so the timeout fires syncHandler(AdapterState.BLE_STOP_TIMEOUT); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading Loading @@ -918,6 +948,12 @@ public class AdapterServiceTest { mAdapterService.stateChangeCallback(AbstractionLayer.BT_STATE_OFF); syncHandler(AdapterState.BLE_STOPPED); if (Flags.explicitKillFromSystemServer()) { // When reaching the OFF state, the cleanup is called that will destroy the state // machine of the adapterService. Destroying state machine send a -1 event on the // handler syncHandler(-1); } verifyStateChange(STATE_BLE_TURNING_OFF, STATE_OFF); assertThat(mAdapterService.getState()).isEqualTo(STATE_OFF); Loading