Removing magic constant 0.8f from AllApps
am: 7028b10c54
Change-Id: Ifb5c044f0297f2944efd348b6dff97e02ddbfb91
This commit is contained in:
@@ -90,6 +90,7 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
|||||||
final UiObject2 allAppsContainer = verifyActiveContainer();
|
final UiObject2 allAppsContainer = verifyActiveContainer();
|
||||||
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
|
final UiObject2 appListRecycler = mLauncher.waitForObjectInContainer(allAppsContainer,
|
||||||
"apps_list_view");
|
"apps_list_view");
|
||||||
|
final UiObject2 searchBox = getSearchBox(allAppsContainer);
|
||||||
allAppsContainer.setGestureMargins(
|
allAppsContainer.setGestureMargins(
|
||||||
0,
|
0,
|
||||||
getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
|
getSearchBox(allAppsContainer).getVisibleBounds().bottom + 1,
|
||||||
@@ -103,7 +104,11 @@ public class AllApps extends LauncherInstrumentation.VisibleContainer {
|
|||||||
int scroll = getScroll(allAppsContainer);
|
int scroll = getScroll(allAppsContainer);
|
||||||
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
|
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("scrolled")) {
|
||||||
while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
|
while (!hasClickableIcon(allAppsContainer, appListRecycler, appIconSelector)) {
|
||||||
mLauncher.scroll(allAppsContainer, Direction.DOWN, 0.8f, null, 50);
|
mLauncher.scrollToLastVisibleRow(
|
||||||
|
allAppsContainer,
|
||||||
|
mLauncher.getObjectsInContainer(allAppsContainer, "icon"),
|
||||||
|
searchBox.getVisibleBounds().bottom -
|
||||||
|
allAppsContainer.getVisibleBounds().top);
|
||||||
final int newScroll = getScroll(allAppsContainer);
|
final int newScroll = getScroll(allAppsContainer);
|
||||||
if (newScroll == scroll) break;
|
if (newScroll == scroll) break;
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ import androidx.test.uiautomator.UiDevice;
|
|||||||
import androidx.test.uiautomator.UiObject2;
|
import androidx.test.uiautomator.UiObject2;
|
||||||
import androidx.test.uiautomator.Until;
|
import androidx.test.uiautomator.Until;
|
||||||
|
|
||||||
|
import com.android.launcher3.ResourceUtils;
|
||||||
import com.android.launcher3.testing.TestProtocol;
|
import com.android.launcher3.testing.TestProtocol;
|
||||||
import com.android.systemui.shared.system.QuickStepContract;
|
import com.android.systemui.shared.system.QuickStepContract;
|
||||||
|
|
||||||
@@ -67,6 +68,8 @@ import org.junit.Assert;
|
|||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Deque;
|
import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -765,6 +768,36 @@ public final class LauncherInstrumentation {
|
|||||||
TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
|
TestProtocol.stateOrdinalToString(parcel.getInt(TestProtocol.STATE_FIELD)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int getBottomGestureSize() {
|
||||||
|
return ResourceUtils.getNavbarSize(
|
||||||
|
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, getResources()) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getBottomGestureMargin(UiObject2 container) {
|
||||||
|
return container.getVisibleBounds().bottom - getRealDisplaySize().y +
|
||||||
|
getBottomGestureSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollToLastVisibleRow(UiObject2 container, Collection<UiObject2> items, int topPadding) {
|
||||||
|
final UiObject2 lowestItem = Collections.max(items, (i1, i2) ->
|
||||||
|
Integer.compare(i1.getVisibleBounds().top, i2.getVisibleBounds().top));
|
||||||
|
|
||||||
|
final int gestureStart = lowestItem.getVisibleBounds().top + getTouchSlop();
|
||||||
|
final int distance = gestureStart - container.getVisibleBounds().top - topPadding;
|
||||||
|
final int bottomMargin = container.getVisibleBounds().height() - distance;
|
||||||
|
|
||||||
|
scroll(
|
||||||
|
container,
|
||||||
|
Direction.DOWN,
|
||||||
|
1f,
|
||||||
|
new Rect(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
Math.max(bottomMargin, getBottomGestureMargin(container))),
|
||||||
|
150);
|
||||||
|
}
|
||||||
|
|
||||||
void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
|
void scroll(UiObject2 container, Direction direction, float percent, Rect margins, int steps) {
|
||||||
final Rect rect = container.getVisibleBounds();
|
final Rect rect = container.getVisibleBounds();
|
||||||
if (margins != null) {
|
if (margins != null) {
|
||||||
|
|||||||
@@ -24,10 +24,7 @@ import androidx.test.uiautomator.BySelector;
|
|||||||
import androidx.test.uiautomator.Direction;
|
import androidx.test.uiautomator.Direction;
|
||||||
import androidx.test.uiautomator.UiObject2;
|
import androidx.test.uiautomator.UiObject2;
|
||||||
|
|
||||||
import com.android.launcher3.ResourceUtils;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All widgets container.
|
* All widgets container.
|
||||||
@@ -52,7 +49,7 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
|
|||||||
widgetsContainer,
|
widgetsContainer,
|
||||||
Direction.DOWN,
|
Direction.DOWN,
|
||||||
1f,
|
1f,
|
||||||
new Rect(0, 0, 0, getBottomGestureMargin(widgetsContainer)),
|
new Rect(0, 0, 0, mLauncher.getBottomGestureMargin(widgetsContainer)),
|
||||||
FLING_STEPS);
|
FLING_STEPS);
|
||||||
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {
|
try (LauncherInstrumentation.Closable c1 = mLauncher.addContextLayer("flung forward")) {
|
||||||
verifyActiveContainer();
|
verifyActiveContainer();
|
||||||
@@ -61,16 +58,6 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getBottomGestureMargin(UiObject2 widgetsContainer) {
|
|
||||||
return widgetsContainer.getVisibleBounds().bottom - mLauncher.getRealDisplaySize().y +
|
|
||||||
getBottomGestureSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getBottomGestureSize() {
|
|
||||||
return ResourceUtils.getNavbarSize(
|
|
||||||
ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE, mLauncher.getResources()) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flings backward (up) and waits the fling's end.
|
* Flings backward (up) and waits the fling's end.
|
||||||
*/
|
*/
|
||||||
@@ -117,29 +104,14 @@ public final class Widgets extends LauncherInstrumentation.VisibleContainer {
|
|||||||
"com.android.launcher3.widget.WidgetCell",
|
"com.android.launcher3.widget.WidgetCell",
|
||||||
widget.getClassName());
|
widget.getClassName());
|
||||||
|
|
||||||
if (widget.getVisibleBounds().bottom <= displaySize.y - getBottomGestureSize()) {
|
if (widget.getVisibleBounds().bottom <=
|
||||||
|
displaySize.y - mLauncher.getBottomGestureSize()) {
|
||||||
return new Widget(mLauncher, widget);
|
return new Widget(mLauncher, widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mLauncher.assertTrue("Too many attempts", ++i <= 40);
|
mLauncher.assertTrue("Too many attempts", ++i <= 40);
|
||||||
final UiObject2 lowestCell = Collections.max(cells, (c1, c2) ->
|
mLauncher.scrollToLastVisibleRow(widgetsContainer, cells, 0);
|
||||||
Integer.compare(c1.getVisibleBounds().top, c2.getVisibleBounds().top));
|
|
||||||
|
|
||||||
final int gestureStart = lowestCell.getVisibleBounds().top + mLauncher.getTouchSlop();
|
|
||||||
final int distance = gestureStart - widgetsContainer.getVisibleBounds().top;
|
|
||||||
final int bottomMargin = widgetsContainer.getVisibleBounds().height() - distance;
|
|
||||||
|
|
||||||
mLauncher.scroll(
|
|
||||||
widgetsContainer,
|
|
||||||
Direction.DOWN,
|
|
||||||
1f,
|
|
||||||
new Rect(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
Math.max(bottomMargin, getBottomGestureMargin(widgetsContainer))),
|
|
||||||
150);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user