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

Commit fb099c7f authored by vadimt's avatar vadimt Committed by Vadim Tryshev
Browse files

Improving diagnostics when can't find a widget

Instead of "exceeded number of attempts" now printing that can't scroll
to widget.

Change-Id: Ia6f582e038d68fc35f152d94e592f60ef0bc2cf4
parent 7e3d07fc
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherState;
import com.android.launcher3.R;
import com.android.launcher3.util.ResourceBasedOverride;
import com.android.launcher3.widget.WidgetsFullSheet;

import java.util.concurrent.ExecutionException;
import java.util.function.Function;
@@ -92,6 +93,11 @@ public class TestInformationHandler implements ResourceBasedOverride {
                        l -> l.getAppsView().getActiveRecyclerView().getCurrentScrollY());
            }

            case TestProtocol.REQUEST_WIDGETS_SCROLL_Y: {
                return getLauncherUIProperty(Bundle::putInt,
                        l -> WidgetsFullSheet.getWidgetsView(l).getCurrentScrollY());
            }

            case TestProtocol.REQUEST_WINDOW_INSETS: {
                return getUIProperty(Bundle::putParcelable, a -> {
                    WindowInsets insets = a.getWindow()
+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public final class TestProtocol {
    public static final String REQUEST_UNFREEZE_APP_LIST = "unfreeze-app-list";
    public static final String REQUEST_APP_LIST_FREEZE_FLAGS = "app-list-freeze-flags";
    public static final String REQUEST_APPS_LIST_SCROLL_Y = "apps-list-scroll-y";
    public static final String REQUEST_WIDGETS_SCROLL_Y = "widgets-scroll-y";
    public static final String REQUEST_WINDOW_INSETS = "window-insets";
    public static final String REQUEST_PID = "pid";
    public static final String REQUEST_TOTAL_PSS_KB = "total_pss";
+13 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.Until;

import com.android.launcher3.tapl.LauncherInstrumentation.GestureScope;
import com.android.launcher3.testing.TestProtocol;

import java.util.Collection;

@@ -90,6 +91,12 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
        return LauncherInstrumentation.ContainerType.WIDGETS;
    }

    private int getWidgetsScroll() {
        return mLauncher.getTestInfo(
                TestProtocol.REQUEST_WIDGETS_SCROLL_Y)
                .getInt(TestProtocol.TEST_INFO_RESPONSE_FIELD);
    }

    public Widget getWidget(String labelText) {
        try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck();
             LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
@@ -136,7 +143,13 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
                }

                mLauncher.assertTrue("Too many attempts", ++i <= 40);
                final int scroll = getWidgetsScroll();
                mLauncher.scrollToLastVisibleRow(widgetsContainer, cells, 0);
                final int newScroll = getWidgetsScroll();
                mLauncher.assertTrue(
                        "Scrolled in a wrong direction in Widgets: from " + scroll + " to "
                                + newScroll, newScroll >= scroll);
                mLauncher.assertTrue("Unable to scroll to the widget", newScroll != scroll);
            }
        }
    }