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

Commit cef77050 authored by Hyundo Moon's avatar Hyundo Moon Committed by Gerrit Code Review
Browse files

Merge "OPP: Fix failing OPP Activity tests" into main

parents 7d1ad2fc 6073dcd4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.mock;

import android.content.Context;
import android.content.Intent;
import android.sysprop.BluetoothProperties;

import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.action.ViewActions;
@@ -39,6 +40,7 @@ import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -55,6 +57,8 @@ public class BluetoothOppBtEnableActivityTest {

    @Before
    public void setUp() throws Exception {
        Assume.assumeTrue(BluetoothProperties.isProfileOppEnabled().orElse(false));

        mTargetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        mIntent = new Intent();
        mIntent.setClass(mTargetContext, BluetoothOppBtEnableActivity.class);
@@ -64,6 +68,9 @@ public class BluetoothOppBtEnableActivityTest {

    @After
    public void tearDown() throws Exception {
        if (!BluetoothProperties.isProfileOppEnabled().orElse(false)) {
            return;
        }
        TestUtils.tearDownUiTest();
        Intents.release();
    }
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.bluetooth.BluetoothAdapter;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.sysprop.BluetoothProperties;
import android.view.KeyEvent;

import androidx.lifecycle.Lifecycle;
@@ -42,6 +43,7 @@ import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -73,6 +75,8 @@ public class BluetoothOppBtEnablingActivityTest {

    @Before
    public void setUp() throws Exception {
        Assume.assumeTrue(BluetoothProperties.isProfileOppEnabled().orElse(false));

        mBluetoothMethodProxy = Mockito.spy(BluetoothMethodProxy.getInstance());
        BluetoothMethodProxy.setInstanceForTesting(mBluetoothMethodProxy);

+7 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
import android.net.Uri;
import android.sysprop.BluetoothProperties;

import androidx.lifecycle.Lifecycle;
import androidx.test.core.app.ActivityScenario;
@@ -50,6 +51,7 @@ import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -81,6 +83,8 @@ public class BluetoothOppLauncherActivityTest {

    @Before
    public void setUp() throws Exception {
        Assume.assumeTrue(BluetoothProperties.isProfileOppEnabled().orElse(false));

        mTargetContext = spy(new ContextWrapper(
                ApplicationProvider.getApplicationContext()));
        mMethodProxy = spy(BluetoothMethodProxy.getInstance());
@@ -97,6 +101,9 @@ public class BluetoothOppLauncherActivityTest {

    @After
    public void tearDown() throws Exception {
        if (!BluetoothProperties.isProfileOppEnabled().orElse(false)) {
            return;
        }
        TestUtils.tearDownUiTest();
        BluetoothMethodProxy.setInstanceForTesting(null);
        BluetoothOppManager.setInstance(null);
+6 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.platform.test.flag.junit.SetFlagsRule;
import android.sysprop.BluetoothProperties;

import androidx.test.core.app.ActivityScenario;
import androidx.test.espresso.intent.Intents;
@@ -56,6 +57,7 @@ import com.android.bluetooth.flags.Flags;
import com.google.common.base.Objects;

import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -106,6 +108,8 @@ public class BluetoothOppReceiverTest {
    @Ignore("b/262201478")
    @Test
    public void onReceive_withActionDeviceSelected_callsStartTransfer() {
        Assume.assumeTrue(BluetoothProperties.isProfileOppEnabled().orElse(false));

        BluetoothOppManager bluetoothOppManager = spy(BluetoothOppManager.getInstance(mContext));
        BluetoothOppManager.setInstance(bluetoothOppManager);
        String address = "AA:BB:CC:DD:EE:FF";
@@ -116,8 +120,6 @@ public class BluetoothOppReceiverTest {
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);

        try {
            BluetoothOppTestUtils.enableActivity(
                    BluetoothOppBtEnableActivity.class, true, mContext);
            ActivityScenario<BluetoothOppBtEnableActivity> activityScenario =
                    ActivityScenario.launch(BluetoothOppBtEnableActivity.class);
            activityScenario.onActivity(
@@ -337,6 +339,8 @@ public class BluetoothOppReceiverTest {

    @Test
    public void onReceive_withActionTransferComplete_noBroadcastSent() throws Exception {
        Assume.assumeTrue(BluetoothProperties.isProfileOppEnabled().orElse(false));

        List<BluetoothOppTestUtils.CursorMockData> cursorMockDataList;
        Cursor cursor = mock(Cursor.class);
        int idValue = 1234;