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

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

Merge "Fix BluetoothMapSettingsTest failure in some devices" into main

parents eb238cbb 2ff9d78a
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -25,14 +25,21 @@ import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
import static androidx.test.espresso.matcher.ViewMatchers.withId;

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

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

import androidx.test.core.app.ActivityScenario;
import androidx.test.filters.FlakyTest;
import androidx.test.filters.LargeTest;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.runner.AndroidJUnit4;
import androidx.test.uiautomator.By;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;

import com.android.bluetooth.R;
import com.android.bluetooth.TestUtils;
@@ -64,15 +71,23 @@ public class BluetoothMapSettingsTest {
    public void tearDown() throws Exception {
        TestUtils.tearDownUiTest();
        if (mActivityScenario != null) {
            // Workaround for b/159805732. Without this, test hangs for 45 seconds.
            Thread.sleep(1_000);
            mActivityScenario.close();
        }
        enableActivity(false);
    }

    @Test
    @FlakyTest
    public void initialize() throws Exception {
        UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());

        long timeoutMs = 5_000;
        String activityLabel = mTargetContext.getString(R.string.bluetooth_map_settings_title);
        UiObject2 object = device.wait(Until.findObject(By.text(activityLabel)), timeoutMs);
        assertThat(object).isNotNull();

        object.click();

        onView(withId(R.id.bluetooth_map_settings_list_view)).check(matches(isDisplayed()));
    }