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

Commit 81127d88 authored by Hieu Dang's avatar Hieu Dang
Browse files

Fix Bluetooth Activity Tests Screen off error

Bug: 277596416
Bug: 277596797
Tag: #refactor
Test: atest BluetoothInstrumentationTests
Change-Id: Iecd55136b6cad94ec64160ee336f497677061196
parent 987b2ff9
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@ import android.service.media.MediaBrowserService;


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


import com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService;
import com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.AdapterService;
@@ -380,6 +381,13 @@ public class TestUtils {
        return intent;
        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.
     * Helper class used to run synchronously a runnable action on a looper.
     */
     */
+3 −2
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.runner.AndroidJUnit4;


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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