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

Commit 137f5b62 authored by vadimt's avatar vadimt
Browse files

Improve diags when system errors cause failing Launcher tests

Now, for example, we won't diagnose a locked phone as a
"home button not showing in 3-button mode", even though it's technically
correct.

Change-Id: Ibdfa0741af7ff8545a811f6702dda74dc6c31c2e
parent 43968167
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -175,7 +175,7 @@ public class FallbackRecentsTest {
            }
            result[0] = f.apply(activity);
            return true;
        }).get(), DEFAULT_UI_TIMEOUT);
        }).get(), DEFAULT_UI_TIMEOUT, mLauncher);
        return (T) result[0];
    }

@@ -196,7 +196,7 @@ public class FallbackRecentsTest {
        startAppFastAndWaitForRecentTask(resolveSystemApp(Intent.CATEGORY_APP_CALCULATOR));
        startTestActivity(2);
        Wait.atMost("Expected three apps in the task list",
                () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT);
                () -> mLauncher.getRecentTasks().size() >= 3, DEFAULT_ACTIVITY_TIMEOUT, mLauncher);

        BaseOverview overview = mLauncher.getBackground().switchToOverview();
        executeOnRecents(recents ->
@@ -255,7 +255,8 @@ public class FallbackRecentsTest {
    private void startAppFastAndWaitForRecentTask(String packageName) {
        startAppFast(packageName);
        Wait.atMost("Expected app in task list",
                () -> containsRecentTaskWithPackage(packageName), DEFAULT_ACTIVITY_TIMEOUT);
                () -> containsRecentTaskWithPackage(packageName), DEFAULT_ACTIVITY_TIMEOUT,
                mLauncher);
    }

    private boolean containsRecentTaskWithPackage(String packageName) {
+2 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class NavigationModeSwitchRule implements TestRule {
            Mode mode = description.getAnnotation(NavigationModeSwitch.class).mode();
            return new Statement() {
                private void assertTrue(String message, boolean condition) {
                    mLauncher.checkForAnomaly();
                    if (!condition) {
                        final AssertionError assertionError = new AssertionError(message);
                        FailureWatcher.onError(mLauncher.getDevice(), description, assertionError);
+3 −5
Original line number Diff line number Diff line
@@ -26,8 +26,6 @@ import static org.junit.Assert.assertTrue;

import static java.lang.System.exit;

import static androidx.test.InstrumentationRegistry.getInstrumentation;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -306,7 +304,7 @@ public abstract class AbstractLauncherUiTest {
    protected void waitForLauncherCondition(
            String message, Function<Launcher, Boolean> condition, long timeout) {
        if (!TestHelpers.isInLauncherProcess()) return;
        Wait.atMost(message, () -> getFromLauncher(condition), timeout);
        Wait.atMost(message, () -> getFromLauncher(condition), timeout, mLauncher);
    }

    // Cannot be used in TaplTests after injecting any gesture using Tapl because this can hide
@@ -319,7 +317,7 @@ public abstract class AbstractLauncherUiTest {
            final Object fromLauncher = getFromLauncher(f);
            output[0] = fromLauncher;
            return fromLauncher != null;
        }, timeout);
        }, timeout, mLauncher);
        return (T) output[0];
    }

@@ -333,7 +331,7 @@ public abstract class AbstractLauncherUiTest {
        Wait.atMost(message, () -> {
            testThreadAction.run();
            return getFromLauncher(condition);
        }, timeout);
        }, timeout, mLauncher);
    }

    protected LauncherActivityInfo getSettingsApp() {
+2 −2
Original line number Diff line number Diff line
@@ -103,12 +103,12 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {

        setResult(acceptConfig);
        if (acceptConfig) {
            Wait.atMost(null, new WidgetSearchCondition(), DEFAULT_ACTIVITY_TIMEOUT);
            Wait.atMost(null, new WidgetSearchCondition(), DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
            assertNotNull(mAppWidgetManager.getAppWidgetInfo(mWidgetId));
        } else {
            // Verify that the widget id is deleted.
            Wait.atMost(null, () -> mAppWidgetManager.getAppWidgetInfo(mWidgetId) == null,
                    DEFAULT_ACTIVITY_TIMEOUT);
                    DEFAULT_ACTIVITY_TIMEOUT, mLauncher);
        }
    }

+6 −4
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ import java.util.UUID;
@RunWith(AndroidJUnit4.class)
public class RequestPinItemTest extends AbstractLauncherUiTest {

    @Rule public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
    @Rule
    public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();

    private String mCallbackAction;
    private String mShortcutId;
@@ -169,7 +170,8 @@ public class RequestPinItemTest extends AbstractLauncherUiTest {

        // Go back to home
        mLauncher.pressHome();
        Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT);
        Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT,
                mLauncher);
    }

    /**
Loading