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

Commit a6ea2539 authored by Hieu Dang's avatar Hieu Dang
Browse files

Unlock screen for OPP activity tests

Bug: 277596797
Tag: #refactor
Test: atest BluetoothInstrumentationTests
Change-Id: I74e26613d14ecf64a1888b4c4cb901a6d5db12e0
parent cb1d20f4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ java_defaults {
        "androidx.test.espresso.intents",
        "androidx.test.ext.truth",
        "androidx.test.rules",
        "androidx.test.uiautomator_uiautomator",
        "framework-bluetooth-pre-jarjar",
        "gson",
        "mockito-target",
+4 −6
Original line number Diff line number Diff line
@@ -16,10 +16,6 @@

package com.android.bluetooth.opp;

import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
import static android.content.pm.PackageManager.DONT_KILL_APP;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
@@ -31,7 +27,6 @@ import static androidx.test.espresso.matcher.ViewMatchers.withText;

import static org.mockito.Mockito.mock;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

@@ -46,19 +41,22 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;

import java.io.IOException;

public class BluetoothOppBtEnableActivityTest {

    Intent mIntent;
    Context mTargetContext;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mTargetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
        mIntent = new Intent();
        mIntent.setClass(mTargetContext, BluetoothOppBtEnableActivity.class);
        Intents.init();
        BluetoothOppTestUtils.enableOppActivities(true, mTargetContext);
        BluetoothOppTestUtils.wakeUpAndDismissKeyGuard();
    }

    @After
+4 −1
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;

import java.io.IOException;

@RunWith(AndroidJUnit4.class)
public class BluetoothOppBtEnablingActivityTest {
    @Spy
@@ -60,7 +62,7 @@ public class BluetoothOppBtEnablingActivityTest {
    int mRealTimeoutValue;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mBluetoothMethodProxy = Mockito.spy(BluetoothMethodProxy.getInstance());
        BluetoothMethodProxy.setInstanceForTesting(mBluetoothMethodProxy);
@@ -72,6 +74,7 @@ public class BluetoothOppBtEnablingActivityTest {

        mRealTimeoutValue = BluetoothOppBtEnablingActivity.sBtEnablingTimeoutMs;
        BluetoothOppTestUtils.enableOppActivities(true, mTargetContext);
        BluetoothOppTestUtils.wakeUpAndDismissKeyGuard();
    }

    @After
+4 −5
Original line number Diff line number Diff line
@@ -20,14 +20,10 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
import static android.content.pm.PackageManager.DONT_KILL_APP;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.click;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.intent.Intents.intended;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasAction;
import static androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent;
import static androidx.test.espresso.matcher.RootMatchers.isDialog;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withText;

import static com.google.common.truth.Truth.assertThat;
@@ -65,6 +61,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.io.File;
import java.io.IOException;

@MediumTest
@RunWith(AndroidJUnit4.class)
@@ -77,7 +74,7 @@ public class BluetoothOppLauncherActivityTest {
    BluetoothOppManager mBluetoothOppManager;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mTargetContext = spy(new ContextWrapper(
                ApplicationProvider.getApplicationContext()));
@@ -88,6 +85,8 @@ public class BluetoothOppLauncherActivityTest {
        mIntent.setClass(mTargetContext, BluetoothOppLauncherActivity.class);

        BluetoothOppTestUtils.enableOppActivities(true, mTargetContext);
        BluetoothOppTestUtils.wakeUpAndDismissKeyGuard();

        BluetoothOppManager.setInstance(mBluetoothOppManager);
        Intents.init();
    }
+3 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@@ -72,7 +73,7 @@ public class BluetoothOppReceiverTest {
    BluetoothOppReceiver mReceiver;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        mContext = spy(new ContextWrapper(
                InstrumentationRegistry.getInstrumentation().getTargetContext()));
@@ -85,6 +86,7 @@ public class BluetoothOppReceiverTest {
        Intents.init();

        BluetoothOppTestUtils.enableOppActivities(true, mContext);
        BluetoothOppTestUtils.wakeUpAndDismissKeyGuard();
    }

    @After
Loading