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

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

Merge "Fix flaky widget tapl tests" into sc-dev

parents ce9134c9 8c8d99f9
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import com.android.launcher3.Insettable;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.model.WidgetItem;
@@ -649,7 +650,8 @@ public class WidgetsFullSheet extends BaseWidgetSheet
    }

    private boolean hasSeenEducationTip() {
        return mLauncher.getSharedPrefs().getBoolean(WIDGETS_EDUCATION_TIP_SEEN, false);
        return mLauncher.getSharedPrefs().getBoolean(WIDGETS_EDUCATION_TIP_SEEN, false)
                || Utilities.IS_RUNNING_IN_TEST_HARNESS;
    }

    /** A holder class for holding adapters & their corresponding recycler view. */
+7 −2
Original line number Diff line number Diff line
@@ -169,12 +169,16 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
                "widgets_table");

        boolean hasHeaderExpanded = false;
        int scrollDistance = 0;
        for (int i = 0; i < SCROLL_ATTEMPTS; i++) {
            UiObject2 fullWidgetsPicker = verifyActiveContainer();

            UiObject2 header = mLauncher.waitForObjectInContainer(fullWidgetsPicker,
                    headerSelector);
            int headerHeight = header.getVisibleBounds().height();
            // If a header is barely visible in the bottom edge of the screen, its height could be
            // too small for a scroll gesture. Since all header should have roughly the same height,
            // let's pick the max height we have seen so far.
            scrollDistance = Math.max(scrollDistance, header.getVisibleBounds().height());

            // Look for a header that has the test app name.
            UiObject2 headerTitle = mLauncher.findObjectInContainer(fullWidgetsPicker,
@@ -196,7 +200,8 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
                    return widgetsContainer;
                }
            }
            mLauncher.scrollDownByDistance(fullWidgetsPicker, headerHeight);
            log("Finding test widget package - scroll with distance: " + scrollDistance);
            mLauncher.scrollDownByDistance(fullWidgetsPicker, scrollDistance);
        }

        return null;