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

Commit 45da9aff authored by Joseph Pirozzo's avatar Joseph Pirozzo
Browse files

Mock HFPClient Test Resources

Add a mock resource for testing hfp_clcc_poll_during_call.

Bug: 72132773
Test: runtest bluetooth -c
com.android.bluetooth.hfpclient.HeadsetClientStateMachineTest

Change-Id: I311758910688a663287d48ce7e9e7ce8a4de7dc1
parent 5c931787
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -11,12 +11,15 @@ import android.bluetooth.BluetoothHeadsetClientCall;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.media.AudioManager;
import android.os.HandlerThread;
import android.support.test.espresso.intent.matcher.IntentMatchers;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;

import com.android.bluetooth.R;

import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsInstanceOf;
import org.junit.After;
@@ -37,6 +40,8 @@ public class HeadsetClientStateMachineTest {
    private HeadsetClientStateMachine mHeadsetClientStateMachine;
    private BluetoothDevice mTestDevice;

    @Mock
    private Resources mMockHfpResources;
    @Mock
    private HeadsetClientService mHeadsetClientService;
    @Mock
@@ -52,6 +57,9 @@ public class HeadsetClientStateMachineTest {
        when(mAudioManager.getStreamMinVolume(anyInt())).thenReturn(1);
        when(mHeadsetClientService.getSystemService(Context.AUDIO_SERVICE)).thenReturn(
                mAudioManager);
        when(mHeadsetClientService.getResources()).thenReturn(mMockHfpResources);
        when(mMockHfpResources.getBoolean(R.bool.hfp_clcc_poll_during_call)).thenReturn(true);

        // This line must be called to make sure relevant objects are initialized properly
        mAdapter = BluetoothAdapter.getDefaultAdapter();
        // Get a device for testing