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

Commit ae36c6a8 authored by Hugh Chen's avatar Hugh Chen Committed by Android (Google) Code Review
Browse files

Merge "Fix Broken test: Package: com.android.settingslib.bluetooth"

parents 3302a5be 988b2900
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -169,18 +169,6 @@ public class BluetoothEventManager {
        }
    }

    @VisibleForTesting
    void registerIntentReceiver() {
        mContext.registerReceiverAsUser(mBroadcastReceiver, mUserHandle, mAdapterIntentFilter,
                null, mReceiverHandler);
    }

    @VisibleForTesting
    void registerProfileIntentReceiverForTest() {
        mContext.registerReceiverAsUser(mProfileBroadcastReceiver, mUserHandle,
                mProfileIntentFilter, null, mReceiverHandler);
    }

    @VisibleForTesting
    void addProfileHandler(String action, Handler handler) {
        mHandlerMap.put(action, handler);
+0 −11
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@ public class BluetoothEventManagerTest {
    @Test
    public void intentWithExtraState_audioStateChangedShouldDispatchToRegisterCallback() {
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED);

        mContext.sendBroadcast(mIntent);
@@ -143,7 +142,6 @@ public class BluetoothEventManagerTest {
    @Test
    public void intentWithExtraState_phoneStateChangedShouldDispatchToRegisterCallback() {
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);

        mContext.sendBroadcast(mIntent);
@@ -169,7 +167,6 @@ public class BluetoothEventManagerTest {
    @Test
    public void dispatchAclConnectionStateChanged_aclDisconnected_shouldDispatchCallback() {
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

@@ -182,7 +179,6 @@ public class BluetoothEventManagerTest {
    @Test
    public void dispatchAclConnectionStateChanged_aclConnected_shouldDispatchCallback() {
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

@@ -196,7 +192,6 @@ public class BluetoothEventManagerTest {
    public void dispatchAclConnectionStateChanged_aclDisconnected_shouldNotCallbackSubDevice() {
        when(mCachedDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

@@ -210,7 +205,6 @@ public class BluetoothEventManagerTest {
    public void dispatchAclConnectionStateChanged_aclConnected_shouldNotCallbackSubDevice() {
        when(mCachedDeviceManager.isSubDevice(mBluetoothDevice)).thenReturn(true);
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

@@ -224,7 +218,6 @@ public class BluetoothEventManagerTest {
    public void dispatchAclConnectionStateChanged_findDeviceReturnNull_shouldNotDispatchCallback() {
        when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(null);
        mBluetoothEventManager.registerCallback(mBluetoothCallback);
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);

@@ -361,7 +354,6 @@ public class BluetoothEventManagerTest {

    @Test
    public void showUnbondMessage_reasonAuthTimeout_showCorrectedErrorCode() {
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);
        mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
@@ -377,7 +369,6 @@ public class BluetoothEventManagerTest {

    @Test
    public void showUnbondMessage_reasonRemoteDeviceDown_showCorrectedErrorCode() {
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);
        mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
@@ -394,7 +385,6 @@ public class BluetoothEventManagerTest {

    @Test
    public void showUnbondMessage_reasonAuthRejected_showCorrectedErrorCode() {
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);
        mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
@@ -410,7 +400,6 @@ public class BluetoothEventManagerTest {

    @Test
    public void showUnbondMessage_reasonAuthFailed_showCorrectedErrorCode() {
        mBluetoothEventManager.registerIntentReceiver();
        mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED);
        mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice);
        mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE);
+0 −7
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.os.ParcelUuid;
import com.android.settingslib.testutils.shadow.ShadowBluetoothAdapter;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -85,7 +84,6 @@ public class LocalBluetoothProfileManagerTest {
        when(mCachedBluetoothDevice.getDevice()).thenReturn(mDevice);
        mProfileManager = new LocalBluetoothProfileManager(mContext, mLocalBluetoothAdapter,
                mDeviceManager, mEventManager);
        mEventManager.registerProfileIntentReceiverForTest();
    }

    /**
@@ -152,7 +150,6 @@ public class LocalBluetoothProfileManagerTest {
     * profile connection state changed callback
     */
    @Test
    @Ignore
    public void stateChangedHandler_receiveA2dpConnectionStateChanged_shouldDispatchCallback() {
        mShadowBluetoothAdapter.setSupportedProfiles(generateList(
                new int[] {BluetoothProfile.A2DP}));
@@ -174,7 +171,6 @@ public class LocalBluetoothProfileManagerTest {
     * profile connection state changed callback
     */
    @Test
    @Ignore
    public void stateChangedHandler_receiveHeadsetConnectionStateChanged_shouldDispatchCallback() {
        mShadowBluetoothAdapter.setSupportedProfiles(generateList(
                new int[] {BluetoothProfile.HEADSET}));
@@ -196,7 +192,6 @@ public class LocalBluetoothProfileManagerTest {
     * CachedBluetoothDeviceManager method
     */
    @Test
    @Ignore
    public void stateChangedHandler_receiveHAPConnectionStateChanged_shouldDispatchDeviceManager() {
        mShadowBluetoothAdapter.setSupportedProfiles(generateList(
                new int[] {BluetoothProfile.HEARING_AID}));
@@ -219,7 +214,6 @@ public class LocalBluetoothProfileManagerTest {
     * profile connection state changed callback
     */
    @Test
    @Ignore
    public void stateChangedHandler_receivePanConnectionStateChanged_shouldNotDispatchCallback() {
        mShadowBluetoothAdapter.setSupportedProfiles(generateList(
                new int[] {BluetoothProfile.PAN}));
@@ -261,7 +255,6 @@ public class LocalBluetoothProfileManagerTest {
     * handler and refresh CachedBluetoothDevice
     */
    @Test
    @Ignore
    public void stateChangedHandler_receivePanConnectionStateChangedWithProfile_shouldRefresh() {
        mShadowBluetoothAdapter.setSupportedProfiles(generateList(
                new int[] {BluetoothProfile.PAN}));