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

Commit b795ce83 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Fix Bluetooth Activity Tests Screen off error"

parents ce04c6b1 81127d88
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.service.media.MediaBrowserService;

import androidx.test.InstrumentationRegistry;
import androidx.test.rule.ServiceTestRule;
import androidx.test.uiautomator.UiDevice;

import com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService;
import com.android.bluetooth.btservice.AdapterService;
@@ -380,6 +381,13 @@ public class TestUtils {
        return intent;
    }

    public static void wakeUpAndDismissKeyGuard() throws Exception {
        final UiDevice device = UiDevice.getInstance(
                androidx.test.platform.app.InstrumentationRegistry.getInstrumentation());
        device.wakeUp();
        device.executeShellCommand("wm dismiss-keyguard");
    }

    /**
     * Helper class used to run synchronously a runnable action on a looper.
     */
+3 −2
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Assume;
@@ -53,8 +54,9 @@ public class BluetoothMapSettingsTest {
    ActivityScenario<BluetoothMapSettings> mActivityScenario;

    @Before
    public void setUp() {
    public void setUp() throws Exception {
        enableActivity(true);
        TestUtils.wakeUpAndDismissKeyGuard();
        mIntent = new Intent();
        mIntent.setClass(mTargetContext, BluetoothMapSettings.class);
        mActivityScenario = ActivityScenario.launch(mIntent);
@@ -70,7 +72,6 @@ public class BluetoothMapSettingsTest {
        enableActivity(false);
    }

    @Ignore("b/277596416")
    @Test
    public void initialize() throws Exception {
        onView(withId(R.id.bluetooth_map_settings_list_view)).check(matches(isDisplayed()));
+2 −1
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import androidx.test.espresso.intent.Intents;
import androidx.test.platform.app.InstrumentationRegistry;

import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Before;
@@ -56,7 +57,7 @@ public class BluetoothOppBtEnableActivityTest {
        mIntent.setClass(mTargetContext, BluetoothOppBtEnableActivity.class);
        Intents.init();
        BluetoothOppTestUtils.enableOppActivities(true, mTargetContext);
        BluetoothOppTestUtils.wakeUpAndDismissKeyGuard();
        TestUtils.wakeUpAndDismissKeyGuard();
    }

    @After
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Before;
@@ -74,7 +75,7 @@ public class BluetoothOppBtEnablingActivityTest {

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

    @After
+2 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import androidx.test.runner.AndroidJUnit4;

import com.android.bluetooth.BluetoothMethodProxy;
import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;

import org.junit.After;
import org.junit.Before;
@@ -85,7 +86,7 @@ public class BluetoothOppLauncherActivityTest {
        mIntent.setClass(mTargetContext, BluetoothOppLauncherActivity.class);

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

        BluetoothOppManager.setInstance(mBluetoothOppManager);
        Intents.init();
Loading