Commit b40132aa authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add VR Browser fling scroll test

Adds a test to ensure that quickly scrolling on the Daydream
controller's touchpad in the VR Browser results in a fling scroll.

Also refactors some related test code to reduce duplication between test
cases.

Bug: 762213
Change-Id: I6a041a6051c9bfc0648c90b04a8a44b06261ae9d
Reviewed-on: https://chromium-review.googlesource.com/874615
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541947}
parent 8b319633
...@@ -112,31 +112,56 @@ public class EmulatedVrController { ...@@ -112,31 +112,56 @@ public class EmulatedVrController {
* @param steps the number of intermediate steps to send while scrolling * @param steps the number of intermediate steps to send while scrolling
* @param speed how long to wait between steps in the scroll, with higher * @param speed how long to wait between steps in the scroll, with higher
* numbers resulting in a faster scroll * numbers resulting in a faster scroll
* @param fling whether fling scrolling is allowed. Enabling this more closely emulates how a
* user will scroll, but is less precise, so only enable if you actually need it.
*/ */
public void scroll(ScrollDirection direction, int steps, int speed) { public void scroll(ScrollDirection direction, int steps, int speed, boolean fling) {
float startX, startY, endX, endY; float startX, startY, endX, endY;
// We need to perform the scroll over a shorter area of the touchpad in order for flinging
// to work properly.
// TODO(https://crbug.com/820281): Figure out why this is the case - not fling scrolling
// because we're using more of the touchpad doesn't make sense.
float offset = fling ? 0.5f : 0.1f;
startX = startY = endX = endY = 0.5f; startX = startY = endX = endY = 0.5f;
switch (direction) { switch (direction) {
case UP: case UP:
startY = 0.1f; startY = offset;
endY = 0.9f; endY = 0.9f;
break; break;
case DOWN: case DOWN:
startY = 0.9f; startY = 0.9f;
endY = 0.1f; endY = offset;
break; break;
case LEFT: case LEFT:
startX = 0.1f; startX = offset;
endX = 0.9f; endX = 0.9f;
break; break;
case RIGHT: case RIGHT:
startX = 0.9f; startX = 0.9f;
endX = 0.1f; endX = offset;
break; break;
default: default:
Assert.fail("Unknown scroll direction enum given"); Assert.fail("Unknown scroll direction enum given");
} }
performLinearTouchpadMovement(startX, startY, endX, endY, steps, speed); performLinearTouchpadMovement(startX, startY, endX, endY, steps, speed);
// There's technically nothing that prevents fling scrolling if fling is set to false, but
// we have yet to find any combination of steps and speed that results in a fling with the
// larger scroll area that setting fling to false uses. As an added precaution, assume that
// a fling occurred and cancel it immediately if we're not supposed to be flinging.
if (!fling) cancelFlingScroll();
}
/**
* Touches then releases the touchpad to cancel fling scroll.
*/
public void cancelFlingScroll() {
// Arbitrary amount of delay to both ensure that the touchpad press is properly registered
// and long enough that we don't accidentally trigger any functionality bound to quick
// touchpad taps if there is any.
int delay = 500;
long simulatedDelay = TimeUnit.MILLISECONDS.toNanos(delay);
long timestamp = mApi.touchEvent.startTouchSequence(0.5f, 0.5f, simulatedDelay, delay);
mApi.touchEvent.endTouchSequence(0.5f, 0.5f, timestamp, simulatedDelay, delay);
} }
/** /**
......
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