Commit 3be3f56d authored by bsheedy's avatar bsheedy Committed by Commit Bot

Deflake VR fling scrolling test on older devices

Adds in retries to the VR fling scrolling test to help combat flakiness
on older/slower devices. The previous version of the test was stable on
newer devices such as the Pixel 2, but was flaking on the Pixel XLs used
by the bots due to scroll jank.

Bug: 923093
Change-Id: I218b09c4ae827149541eda0c735a8121b16dd970
Reviewed-on: https://chromium-review.googlesource.com/c/1448530Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628509}
parent ceb92979
...@@ -11,6 +11,8 @@ import static org.chromium.chrome.browser.vr.XrTestFramework.POLL_TIMEOUT_SHORT_ ...@@ -11,6 +11,8 @@ import static org.chromium.chrome.browser.vr.XrTestFramework.POLL_TIMEOUT_SHORT_
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_VIEWER_DAYDREAM_OR_STANDALONE; import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_VIEWER_DAYDREAM_OR_STANDALONE;
import android.graphics.PointF; import android.graphics.PointF;
import android.os.Build;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.View; import android.view.View;
...@@ -187,7 +189,7 @@ public class VrBrowserControllerInputTest { ...@@ -187,7 +189,7 @@ public class VrBrowserControllerInputTest {
* scroll of the same speed scrolls further. * scroll of the same speed scrolls further.
*/ */
@Test @Test
@MediumTest @LargeTest
public void testControllerFlingScrolling() throws InterruptedException { public void testControllerFlingScrolling() throws InterruptedException {
mVrTestRule.loadUrl( mVrTestRule.loadUrl(
VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_controller_scrolling"), VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_controller_scrolling"),
...@@ -203,82 +205,117 @@ public class VrBrowserControllerInputTest { ...@@ -203,82 +205,117 @@ public class VrBrowserControllerInputTest {
return coord.getScrollXPixInt(); return coord.getScrollXPixInt();
}; };
// Scrolling can be inconsistent on older/slower devices. So, try each direction up to
// 3 times to try to work around flakiness. Only enable this on problematic devices (
// currently first generation Pixel devices).
int numAttempts = 1;
if (Build.DEVICE.equals("marlin") || Build.DEVICE.equals("sailfish")) {
numAttempts = 3;
}
final int diffMultiplier = 2;
int startPoint;
int nonFlingEndpoint;
int nonFlingDistance;
boolean succeeded = false;
// Test fling scrolling down. // Test fling scrolling down.
for (int i = 0; i < numAttempts; ++i) {
startPoint = coord.getScrollYPixInt();
// Perform a fast non-fling scroll and record how far it causes the page to scroll. // Perform a fast non-fling scroll and record how far it causes the page to scroll.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.DOWN); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.DOWN);
waitForScrollQuiescence(getYCoord); waitForScrollQuiescence(getYCoord);
final AtomicInteger endScrollPoint = new AtomicInteger(coord.getScrollYPixInt()); nonFlingEndpoint = coord.getScrollYPixInt();
nonFlingDistance = nonFlingEndpoint - startPoint;
// Perform a fling scroll and check that it goes sufficiently further than the non-fling
// scroll.
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.DOWN); NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.DOWN);
// Check that we scroll further than we did with the non-fling scroll. This should be a very
// violent fling, so we expect the fling to go much further than the non-fling case.
// Choose 3 times as far since it's high enough to demonstrate that the fling is actually
// working properly, but not high enough to run into flakiness issues.
final int diffMultiplier = 3;
CriteriaHelper.pollInstrumentationThread(
()
-> {
return coord.getScrollYPixInt() - endScrollPoint.get()
> diffMultiplier * endScrollPoint.get();
},
"Controller failed to fling scroll down", POLL_TIMEOUT_SHORT_MS,
POLL_CHECK_INTERVAL_LONG_MS);
// Scroll the page all the way to the bottom so we can test the fling up.
waitForScrollQuiescence(getYCoord); waitForScrollQuiescence(getYCoord);
if (coord.getScrollYPixInt() - nonFlingEndpoint >= diffMultiplier * nonFlingDistance) {
succeeded = true;
break;
}
// Reset to the top of the page to try again.
mVrBrowserTestFramework.runJavaScriptOrFail( mVrBrowserTestFramework.runJavaScriptOrFail(
"window.scrollTo(0, document.documentElement.scrollHeight)", POLL_TIMEOUT_SHORT_MS); "window.scrollTo(0, 0)", POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getYCoord); waitForScrollQuiescence(getYCoord);
final AtomicInteger startScrollPoint = new AtomicInteger(coord.getScrollYPixInt()); }
Assert.assertTrue(
"Fling scroll down was unable to go sufficiently further than non-fling scroll",
succeeded);
succeeded = false;
// Test fling scrolling up. // Test fling scrolling up.
for (int i = 0; i < numAttempts; ++i) {
// Ensure we're at the bottom of the page.
mVrBrowserTestFramework.runJavaScriptOrFail(
"window.scrollTo(0, document.documentElement.scrollHeight)",
POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getYCoord);
startPoint = coord.getScrollYPixInt();
// Perform the actual test.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.UP); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.UP);
waitForScrollQuiescence(getYCoord); waitForScrollQuiescence(getYCoord);
endScrollPoint.set(coord.getScrollYPixInt()); nonFlingEndpoint = coord.getScrollYPixInt();
nonFlingDistance = startPoint - nonFlingEndpoint;
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.UP); NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.UP);
CriteriaHelper.pollInstrumentationThread( waitForScrollQuiescence(getYCoord);
() if (nonFlingEndpoint - coord.getScrollYPixInt() >= diffMultiplier * nonFlingDistance) {
-> { succeeded = true;
return endScrollPoint.get() - coord.getScrollYPixInt() break;
> diffMultiplier * (startScrollPoint.get() - endScrollPoint.get()); }
}, }
"Controller failed to fling scroll up", POLL_TIMEOUT_SHORT_MS, Assert.assertTrue(
POLL_CHECK_INTERVAL_LONG_MS); "Fling scroll up was unable to go sufficiently further than non-fling scroll",
succeeded);
succeeded = false;
// Test fling scrolling right. // Test fling scrolling right.
waitForScrollQuiescence(getYCoord); for (int i = 0; i < numAttempts; ++i) {
startPoint = coord.getScrollXPixInt();
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.RIGHT); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.RIGHT);
waitForScrollQuiescence(getXCoord); waitForScrollQuiescence(getXCoord);
endScrollPoint.set(coord.getScrollXPixInt()); nonFlingEndpoint = coord.getScrollXPixInt();
nonFlingDistance = nonFlingEndpoint - startPoint;
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.RIGHT); NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.RIGHT);
CriteriaHelper.pollInstrumentationThread( waitForScrollQuiescence(getXCoord);
() if (coord.getScrollXPixInt() - nonFlingEndpoint >= diffMultiplier * nonFlingDistance) {
-> { succeeded = true;
return coord.getScrollXPixInt() - endScrollPoint.get() break;
> diffMultiplier * endScrollPoint.get(); }
}, // Reset to the left side to try again
"Controller failed to fling scroll right", POLL_TIMEOUT_SHORT_MS,
POLL_CHECK_INTERVAL_LONG_MS);
// Scroll the page all the way to the right.
waitForScrollQuiescence(getYCoord);
mVrBrowserTestFramework.runJavaScriptOrFail( mVrBrowserTestFramework.runJavaScriptOrFail(
"window.scrollTo(document.documentElement.scrollWidth, 0)", POLL_TIMEOUT_SHORT_MS); "window.scrollTo(0, 0)", POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getXCoord); waitForScrollQuiescence(getXCoord);
startScrollPoint.set(coord.getScrollXPixInt()); }
Assert.assertTrue(
"Fling scroll right was unable to go sufficiently further than non-fling scroll",
succeeded);
succeeded = false;
// Test fling scrolling left. // Test fling scrolling left.
for (int i = 0; i < numAttempts; ++i) {
// Ensure we're on the right side of the page.
mVrBrowserTestFramework.runJavaScriptOrFail(
"window.scrollTo(document.documentElement.scrollWidth, 0)",
POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getXCoord);
startPoint = coord.getScrollXPixInt();
// Perform the actual test.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.LEFT); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.LEFT);
waitForScrollQuiescence(getXCoord); waitForScrollQuiescence(getXCoord);
endScrollPoint.set(coord.getScrollXPixInt()); nonFlingEndpoint = coord.getScrollXPixInt();
nonFlingDistance = startPoint - nonFlingEndpoint;
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.LEFT); NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.LEFT);
CriteriaHelper.pollInstrumentationThread( waitForScrollQuiescence(getXCoord);
() if (nonFlingEndpoint - coord.getScrollXPixInt() >= diffMultiplier * nonFlingDistance) {
-> { succeeded = true;
return endScrollPoint.get() - coord.getScrollXPixInt() break;
> diffMultiplier * (startScrollPoint.get() - endScrollPoint.get()); }
}, }
"Controller failed to fling scroll left", POLL_TIMEOUT_SHORT_MS, Assert.assertTrue(
POLL_CHECK_INTERVAL_LONG_MS); "Fling scroll left was unable to go sufficiently further than non-fling scroll",
succeeded);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment