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

Commit 0d2828d4 authored by My Name's avatar My Name
Browse files

Fix BluetoothOppManagerTest

The URI that is used for test is only valid in the local test device.
Therefore the test passed locally even without mocking contentResolverInsert(). However, it should fail since there is no content for the URI in other devices.

This CL fixes the bug by making the contentResolverInsert() do nothing.

Bug: 260183711
Tag: #refactor
Test: atest BluetoothOppManagerTest
Change-Id: I0ba90c1236cd846db4fbf2abb233a9b679274657
(cherry picked from commit 3cc40f4e)
Merged-In: I0ba90c1236cd846db4fbf2abb233a9b679274657
parent f644c978
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@ import static com.android.bluetooth.opp.BluetoothOppManager.OPP_PREFERENCE_FILE;

import static com.google.common.truth.Truth.assertThat;

import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.nullable;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
@@ -43,7 +45,6 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;

import java.util.ArrayList;
import java.util.List;
@@ -51,8 +52,8 @@ import java.util.List;
@RunWith(AndroidJUnit4.class)
public class BluetoothOppManagerTest {
    Context mContext;
    @Spy
    BluetoothMethodProxy mCallProxy = BluetoothMethodProxy.getInstance();

    BluetoothMethodProxy mCallProxy;

    @Before
    public void setUp() {
@@ -60,7 +61,11 @@ public class BluetoothOppManagerTest {
        mContext = spy(new ContextWrapper(
                InstrumentationRegistry.getInstrumentation().getTargetContext()));

        mCallProxy = spy(BluetoothMethodProxy.getInstance());
        BluetoothMethodProxy.setInstanceForTesting(mCallProxy);

        doReturn(null).when(mCallProxy).contentResolverInsert(
                any(), eq(BluetoothShare.CONTENT_URI), any());
    }

    @After