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

Commit 13fd81f0 authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Fix companionManager test"

parents 1317ebca 12c3ea47
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ public class CompanionManager {
    private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter();
    private final Set<BluetoothDevice> mMetadataListeningDevices = new HashSet<>();

    CompanionManager(AdapterService service, ServiceFactory factory) {
    public CompanionManager(AdapterService service, ServiceFactory factory) {
        mAdapterService = service;
        mGattConnHighDefault = new int[] {
                service.getResources().getInteger(R.integer.gatt_high_priority_min_interval),
+3 −0
Original line number Diff line number Diff line
@@ -290,6 +290,9 @@ public class AdapterServiceTest {
                .thenReturn(mBluetoothManager);
        when(mMockContext.getSystemServiceName(BluetoothManager.class))
                .thenReturn(Context.BLUETOOTH_SERVICE);
        when(mMockContext.getSharedPreferences(anyString(), anyInt()))
                .thenReturn(InstrumentationRegistry.getTargetContext()
                        .getSharedPreferences("AdapterServiceTestPrefs", Context.MODE_PRIVATE));

        when(mMockContext.getAttributionSource()).thenReturn(mAttributionSource);
        doAnswer(invocation -> {
+13 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.content.AttributionSource;
import android.content.Context;
import android.content.res.Resources;
import android.os.Binder;
import android.os.ParcelUuid;
import android.os.RemoteException;
@@ -54,6 +55,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.CompanionManager;

import org.junit.After;
import org.junit.Assert;
@@ -102,10 +104,12 @@ public class GattServiceTest {
    private BluetoothAdapter mAdapter;
    private AttributionSource mAttributionSource;

    @Mock private Resources mResources;
    @Mock private AdapterService mAdapterService;
    @Mock private GattObjectsFactory mFactory;
    @Mock private GattNativeInterface mNativeInterface;
    private BluetoothDevice mCurrentDevice;
    private CompanionManager mBtCompanionManager;

    @Before
    public void setUp() throws Exception {
@@ -122,6 +126,15 @@ public class GattServiceTest {
        mAttributionSource = mAdapter.getAttributionSource();
        mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(REMOTE_DEVICE_ADDRESS);

        when(mAdapterService.getResources()).thenReturn(mResources);
        when(mResources.getInteger(anyInt())).thenReturn(0);
        when(mAdapterService.getSharedPreferences(anyString(), anyInt()))
                .thenReturn(InstrumentationRegistry.getTargetContext()
                        .getSharedPreferences("GattServiceTestPrefs", Context.MODE_PRIVATE));

        mBtCompanionManager = new CompanionManager(mAdapterService, null);
        doReturn(mBtCompanionManager).when(mAdapterService).getCompanionManager();

        TestUtils.startService(mServiceRule, GattService.class);
        mService = GattService.getGattService();
        Assert.assertNotNull(mService);