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();
}; };
// Test fling scrolling down. // Scrolling can be inconsistent on older/slower devices. So, try each direction up to
// Perform a fast non-fling scroll and record how far it causes the page to scroll. // 3 times to try to work around flakiness. Only enable this on problematic devices (
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.DOWN); // currently first generation Pixel devices).
waitForScrollQuiescence(getYCoord); int numAttempts = 1;
final AtomicInteger endScrollPoint = new AtomicInteger(coord.getScrollYPixInt()); if (Build.DEVICE.equals("marlin") || Build.DEVICE.equals("sailfish")) {
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.DOWN); numAttempts = 3;
// 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. final int diffMultiplier = 2;
// 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. int startPoint;
waitForScrollQuiescence(getYCoord); int nonFlingEndpoint;
mVrBrowserTestFramework.runJavaScriptOrFail( int nonFlingDistance;
"window.scrollTo(0, document.documentElement.scrollHeight)", POLL_TIMEOUT_SHORT_MS); boolean succeeded = false;
waitForScrollQuiescence(getYCoord);
final AtomicInteger startScrollPoint = new AtomicInteger(coord.getScrollYPixInt()); // 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.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.DOWN);
waitForScrollQuiescence(getYCoord);
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);
waitForScrollQuiescence(getYCoord);
if (coord.getScrollYPixInt() - nonFlingEndpoint >= diffMultiplier * nonFlingDistance) {
succeeded = true;
break;
}
// Reset to the top of the page to try again.
mVrBrowserTestFramework.runJavaScriptOrFail(
"window.scrollTo(0, 0)", POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getYCoord);
}
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.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.UP); for (int i = 0; i < numAttempts; ++i) {
waitForScrollQuiescence(getYCoord); // Ensure we're at the bottom of the page.
endScrollPoint.set(coord.getScrollYPixInt()); mVrBrowserTestFramework.runJavaScriptOrFail(
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.UP); "window.scrollTo(0, document.documentElement.scrollHeight)",
CriteriaHelper.pollInstrumentationThread( POLL_TIMEOUT_SHORT_MS);
() waitForScrollQuiescence(getYCoord);
-> { startPoint = coord.getScrollYPixInt();
return endScrollPoint.get() - coord.getScrollYPixInt() // Perform the actual test.
> diffMultiplier * (startScrollPoint.get() - endScrollPoint.get()); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.UP);
}, waitForScrollQuiescence(getYCoord);
"Controller failed to fling scroll up", POLL_TIMEOUT_SHORT_MS, nonFlingEndpoint = coord.getScrollYPixInt();
POLL_CHECK_INTERVAL_LONG_MS); nonFlingDistance = startPoint - nonFlingEndpoint;
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.UP);
waitForScrollQuiescence(getYCoord);
if (nonFlingEndpoint - coord.getScrollYPixInt() >= diffMultiplier * nonFlingDistance) {
succeeded = true;
break;
}
}
Assert.assertTrue(
"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) {
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.RIGHT); startPoint = coord.getScrollXPixInt();
waitForScrollQuiescence(getXCoord); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.RIGHT);
endScrollPoint.set(coord.getScrollXPixInt()); waitForScrollQuiescence(getXCoord);
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.RIGHT); nonFlingEndpoint = coord.getScrollXPixInt();
CriteriaHelper.pollInstrumentationThread( nonFlingDistance = nonFlingEndpoint - startPoint;
() NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.RIGHT);
-> { waitForScrollQuiescence(getXCoord);
return coord.getScrollXPixInt() - endScrollPoint.get() if (coord.getScrollXPixInt() - nonFlingEndpoint >= diffMultiplier * nonFlingDistance) {
> diffMultiplier * endScrollPoint.get(); succeeded = true;
}, break;
"Controller failed to fling scroll right", POLL_TIMEOUT_SHORT_MS, }
POLL_CHECK_INTERVAL_LONG_MS); // Reset to the left side to try again
mVrBrowserTestFramework.runJavaScriptOrFail(
// Scroll the page all the way to the right. "window.scrollTo(0, 0)", POLL_TIMEOUT_SHORT_MS);
waitForScrollQuiescence(getYCoord); waitForScrollQuiescence(getXCoord);
mVrBrowserTestFramework.runJavaScriptOrFail( }
"window.scrollTo(document.documentElement.scrollWidth, 0)", POLL_TIMEOUT_SHORT_MS); Assert.assertTrue(
waitForScrollQuiescence(getXCoord); "Fling scroll right was unable to go sufficiently further than non-fling scroll",
startScrollPoint.set(coord.getScrollXPixInt()); succeeded);
succeeded = false;
// Test fling scrolling left. // Test fling scrolling left.
NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.LEFT); for (int i = 0; i < numAttempts; ++i) {
waitForScrollQuiescence(getXCoord); // Ensure we're on the right side of the page.
endScrollPoint.set(coord.getScrollXPixInt()); mVrBrowserTestFramework.runJavaScriptOrFail(
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.LEFT); "window.scrollTo(document.documentElement.scrollWidth, 0)",
CriteriaHelper.pollInstrumentationThread( POLL_TIMEOUT_SHORT_MS);
() waitForScrollQuiescence(getXCoord);
-> { startPoint = coord.getScrollXPixInt();
return endScrollPoint.get() - coord.getScrollXPixInt() // Perform the actual test.
> diffMultiplier * (startScrollPoint.get() - endScrollPoint.get()); NativeUiUtils.scrollNonFlingFast(NativeUiUtils.ScrollDirection.LEFT);
}, waitForScrollQuiescence(getXCoord);
"Controller failed to fling scroll left", POLL_TIMEOUT_SHORT_MS, nonFlingEndpoint = coord.getScrollXPixInt();
POLL_CHECK_INTERVAL_LONG_MS); nonFlingDistance = startPoint - nonFlingEndpoint;
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.LEFT);
waitForScrollQuiescence(getXCoord);
if (nonFlingEndpoint - coord.getScrollXPixInt() >= diffMultiplier * nonFlingDistance) {
succeeded = true;
break;
}
}
Assert.assertTrue(
"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