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

Commit f56efc01 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Adding debug tracing for Device.wait"

parents 9e86e3b8 ed86cb19
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ public class FallbackRecentsTest {
        OverviewTask task = overview.getCurrentTask();
        assertNotNull("overview.getCurrentTask() returned null (1)", task);
        assertNotNull("OverviewTask.open returned null", task.open());
        assertTrue("Test activity didn't open from Overview", mDevice.wait(Until.hasObject(
        assertTrue("Test activity didn't open from Overview", TestHelpers.wait(Until.hasObject(
                By.pkg(getAppPackageName()).text("TestActivity2")),
                DEFAULT_UI_TIMEOUT));

@@ -236,7 +236,7 @@ public class FallbackRecentsTest {

        // Test dismissing all tasks.
        pressHomeAndGoToOverview().dismissAllTasks();
        assertTrue("Fallback Launcher not visible", mDevice.wait(Until.hasObject(By.pkg(
        assertTrue("Fallback Launcher not visible", TestHelpers.wait(Until.hasObject(By.pkg(
                mOtherLauncherActivity.packageName)), WAIT_TIME_MS));
    }

+2 −3
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public abstract class AbstractLauncherUiTest {
    @Before
    public void setUp() throws Exception {
        Assert.assertTrue("Keyguard is visible",
                mDevice.wait(
                TestHelpers.wait(
                        Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000));

        final String launcherPackageName = mDevice.getLauncherPackageName();
@@ -477,8 +477,7 @@ public abstract class AbstractLauncherUiTest {
        }
        getInstrumentation().getTargetContext().startActivity(intent);
        assertTrue("App didn't start: " + selector,
                UiDevice.getInstance(getInstrumentation())
                        .wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT));
                TestHelpers.wait(Until.hasObject(selector), DEFAULT_UI_TIMEOUT));
    }

    public static ActivityInfo resolveSystemAppInfo(String category) {
+1 −2
Original line number Diff line number Diff line
@@ -68,8 +68,7 @@ abstract class Launchable {

        mLauncher.assertTrue(
                "App didn't start: " + label,
                mLauncher.getDevice().wait(Until.hasObject(selector),
                        LauncherInstrumentation.WAIT_TIME_MS));
                TestHelpers.wait(Until.hasObject(selector), LauncherInstrumentation.WAIT_TIME_MS));
        return new Background(mLauncher);
    }

+1 −1
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ public final class LauncherInstrumentation {

    @NonNull
    UiObject2 waitForAndroidObject(String resId) {
        final UiObject2 object = mDevice.wait(
        final UiObject2 object = TestHelpers.wait(
                Until.findObject(By.res(ANDROID_PACKAGE, resId)), WAIT_TIME_MS);
        assertNotNull("Can't find a android object with id: " + resId, object);
        return object;
+14 −0
Original line number Diff line number Diff line
@@ -27,6 +27,11 @@ import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.os.DropBoxManager;
import android.os.SystemClock;
import android.util.Log;

import androidx.test.uiautomator.SearchCondition;
import androidx.test.uiautomator.UiDevice;

import org.junit.Assert;

@@ -35,6 +40,7 @@ import java.util.List;

public class TestHelpers {

    private static final String TAG = "Tapl";
    private static Boolean sIsInLauncherProcess;

    public static boolean isInLauncherProcess() {
@@ -154,4 +160,12 @@ public class TestHelpers {
            return null;
        }
    }

    public static <R> R wait(SearchCondition<R> condition, long timeout) {
        Log.d(TAG,
                "TestHelpers.wait, condition=" + timeout + ", time=" + SystemClock.uptimeMillis());
        final R result = UiDevice.getInstance(getInstrumentation()).wait(condition, timeout);
        Log.d(TAG, "TestHelpers.wait, result=" + result + ", time=" + SystemClock.uptimeMillis());
        return result;
    }
}