Commit a3222340 authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Revert "Use mocked VR controller for scrolling"

This reverts commit 06b8660d.

Reason for revert: Hitting DCHECK: [FATAL:latency_tracker.cc(399)] Check failed: (event_timestamp - last_event_timestamp_).InMilliseconds() >= 0

Original change's description:
> Use mocked VR controller for scrolling
> 
> Switches all VR instrumentation tests for scrolling using the Daydream
> controller to use the Chrome-side controller mock instead of the
> VrCore-side emulation via intents. The latter has always been somewhat
> flaky, so this should help reduce VR test flakiness.
> 
> Bug: 902938
> Change-Id: I560cda2129357c49bdfa3d095836e6ebd1b23da8
> Reviewed-on: https://chromium-review.googlesource.com/c/1341061
> Reviewed-by: Christopher Grant <cjgrant@chromium.org>
> Reviewed-by: Ian Vollick <vollick@chromium.org>
> Commit-Queue: Ian Vollick <vollick@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#613107}

TBR=vollick@chromium.org,cjgrant@chromium.org,bsheedy@chromium.org

Change-Id: I40d8cf660d35a14ee4269010f5da749a2e91daad
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 902938
Reviewed-on: https://chromium-review.googlesource.com/c/1359311Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613272}
parent 242c217f
...@@ -55,6 +55,7 @@ public class VrBrowserControllerInputTest { ...@@ -55,6 +55,7 @@ public class VrBrowserControllerInputTest {
public ChromeTabbedActivityVrTestRule mVrTestRule = new ChromeTabbedActivityVrTestRule(); public ChromeTabbedActivityVrTestRule mVrTestRule = new ChromeTabbedActivityVrTestRule();
private VrBrowserTestFramework mVrBrowserTestFramework; private VrBrowserTestFramework mVrBrowserTestFramework;
private EmulatedVrController mController;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
...@@ -64,6 +65,8 @@ public class VrBrowserControllerInputTest { ...@@ -64,6 +65,8 @@ public class VrBrowserControllerInputTest {
mVrBrowserTestFramework = new VrBrowserTestFramework(mVrTestRule); mVrBrowserTestFramework = new VrBrowserTestFramework(mVrTestRule);
VrBrowserTransitionUtils.forceEnterVrBrowserOrFail(POLL_TIMEOUT_LONG_MS); VrBrowserTransitionUtils.forceEnterVrBrowserOrFail(POLL_TIMEOUT_LONG_MS);
mController = new EmulatedVrController(mVrTestRule.getActivity());
mController.recenterView();
} }
private void waitForPageToBeScrollable(final RenderCoordinates coord) { private void waitForPageToBeScrollable(final RenderCoordinates coord) {
...@@ -133,16 +136,6 @@ public class VrBrowserControllerInputTest { ...@@ -133,16 +136,6 @@ public class VrBrowserControllerInputTest {
testControllerScrollingImpl(url, waitScrollable, getYCoord, getXCoord); testControllerScrollingImpl(url, waitScrollable, getYCoord, getXCoord);
} }
private void waitForScrollQuiescence(final Callable<Integer> getCoord) {
final AtomicInteger lastCoord = new AtomicInteger(-1);
CriteriaHelper.pollInstrumentationThread(() -> {
Integer curCoord = getCoord.call();
if (curCoord.equals(lastCoord.get())) return true;
lastCoord.set(curCoord);
return false;
}, "Did not reach scroll quiescence", POLL_TIMEOUT_LONG_MS, POLL_CHECK_INTERVAL_LONG_MS);
}
private void testControllerScrollingImpl(String url, Runnable waitScrollable, private void testControllerScrollingImpl(String url, Runnable waitScrollable,
Callable<Integer> getYCoord, Callable<Integer> getXCoord) Callable<Integer> getYCoord, Callable<Integer> getXCoord)
throws InterruptedException, Exception { throws InterruptedException, Exception {
...@@ -151,33 +144,33 @@ public class VrBrowserControllerInputTest { ...@@ -151,33 +144,33 @@ public class VrBrowserControllerInputTest {
// Test that scrolling down works. // Test that scrolling down works.
int startScrollPoint = getYCoord.call().intValue(); int startScrollPoint = getYCoord.call().intValue();
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.DOWN); // Arbitrary, but valid values to scroll smoothly.
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL); int scrollSteps = 20;
waitForScrollQuiescence(getYCoord); int scrollSpeed = 60;
mController.scroll(EmulatedVrController.ScrollDirection.DOWN, scrollSteps, scrollSpeed);
// We need this second scroll down, otherwise the horizontal scrolling becomes flaky
// This actually seems to not be an issue in this test case anymore, but still occurs in
// the fling scroll test, so keep around here as an extra precaution.
// TODO(bsheedy): Figure out why this is the case.
mController.scroll(EmulatedVrController.ScrollDirection.DOWN, scrollSteps, scrollSpeed);
int endScrollPoint = getYCoord.call().intValue(); int endScrollPoint = getYCoord.call().intValue();
Assert.assertTrue("Controller failed to scroll down", startScrollPoint < endScrollPoint); Assert.assertTrue("Controller failed to scroll down", startScrollPoint < endScrollPoint);
// Test that scrolling up works. // Test that scrolling up works.
startScrollPoint = getYCoord.call().intValue(); startScrollPoint = endScrollPoint;
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.UP); mController.scroll(EmulatedVrController.ScrollDirection.UP, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL);
waitForScrollQuiescence(getYCoord);
endScrollPoint = getYCoord.call().intValue(); endScrollPoint = getYCoord.call().intValue();
Assert.assertTrue("Controller failed to scroll up", startScrollPoint > endScrollPoint); Assert.assertTrue("Controller failed to scroll up", startScrollPoint > endScrollPoint);
// Test that scrolling right works. // Test that scrolling right works.
startScrollPoint = getXCoord.call().intValue(); startScrollPoint = getXCoord.call().intValue();
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.RIGHT); mController.scroll(EmulatedVrController.ScrollDirection.RIGHT, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL);
waitForScrollQuiescence(getXCoord);
endScrollPoint = getXCoord.call().intValue(); endScrollPoint = getXCoord.call().intValue();
Assert.assertTrue("Controller failed to scroll right", startScrollPoint < endScrollPoint); Assert.assertTrue("Controller failed to scroll right", startScrollPoint < endScrollPoint);
// Test that scrolling left works. // Test that scrolling left works.
startScrollPoint = endScrollPoint; startScrollPoint = endScrollPoint;
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.LEFT); mController.scroll(EmulatedVrController.ScrollDirection.LEFT, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL);
waitForScrollQuiescence(getXCoord);
endScrollPoint = getXCoord.call().intValue(); endScrollPoint = getXCoord.call().intValue();
Assert.assertTrue("Controller failed to scroll left", startScrollPoint > endScrollPoint); Assert.assertTrue("Controller failed to scroll left", startScrollPoint > endScrollPoint);
} }
...@@ -196,41 +189,46 @@ public class VrBrowserControllerInputTest { ...@@ -196,41 +189,46 @@ public class VrBrowserControllerInputTest {
RenderCoordinates.fromWebContents(mVrTestRule.getWebContents()); RenderCoordinates.fromWebContents(mVrTestRule.getWebContents());
waitForPageToBeScrollable(coord); waitForPageToBeScrollable(coord);
// Arbitrary, but valid values to trigger fling scrolling.
int scrollSteps = 10;
int scrollSpeed = 10;
// Test fling scrolling down. // Test fling scrolling down.
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.DOWN); mController.scroll(EmulatedVrController.ScrollDirection.DOWN, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_FLING_SCROLL);
final AtomicInteger endScrollPoint = new AtomicInteger(coord.getScrollYPixInt()); final AtomicInteger endScrollPoint = new AtomicInteger(coord.getScrollYPixInt());
// Check that we continue to scroll past wherever we were even though we aren't touching // Check that we continue to scroll past wherever we were when we let go of the touchpad.
// the touchpad anymore.
CriteriaHelper.pollInstrumentationThread( CriteriaHelper.pollInstrumentationThread(
() ()
-> { return coord.getScrollYPixInt() > endScrollPoint.get(); }, -> { return coord.getScrollYPixInt() > endScrollPoint.get(); },
"Controller failed to fling scroll down", POLL_TIMEOUT_SHORT_MS, "Controller failed to fling scroll down", POLL_TIMEOUT_SHORT_MS,
POLL_CHECK_INTERVAL_LONG_MS); POLL_CHECK_INTERVAL_LONG_MS);
mController.cancelFlingScroll();
// Test fling scrolling up. // Test fling scrolling up.
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.UP); mController.scroll(EmulatedVrController.ScrollDirection.UP, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_FLING_SCROLL);
endScrollPoint.set(coord.getScrollYPixInt()); endScrollPoint.set(coord.getScrollYPixInt());
CriteriaHelper.pollInstrumentationThread( CriteriaHelper.pollInstrumentationThread(
() ()
-> { return coord.getScrollYPixInt() < endScrollPoint.get(); }, -> { return coord.getScrollYPixInt() < endScrollPoint.get(); },
"Controller failed to fling scroll up", POLL_TIMEOUT_SHORT_MS, "Controller failed to fling scroll up", POLL_TIMEOUT_SHORT_MS,
POLL_CHECK_INTERVAL_LONG_MS); POLL_CHECK_INTERVAL_LONG_MS);
mController.cancelFlingScroll();
// Horizontal scrolling becomes flaky if the scroll bar is at the top when we try to scroll
// horizontally, so scroll down a bit to ensure that isn't the case.
mController.scroll(EmulatedVrController.ScrollDirection.DOWN, 10, 60);
// Test fling scrolling right. // Test fling scrolling right.
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.RIGHT); mController.scroll(EmulatedVrController.ScrollDirection.RIGHT, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_FLING_SCROLL);
endScrollPoint.set(coord.getScrollXPixInt()); endScrollPoint.set(coord.getScrollXPixInt());
CriteriaHelper.pollInstrumentationThread( CriteriaHelper.pollInstrumentationThread(
() ()
-> { return coord.getScrollXPixInt() > endScrollPoint.get(); }, -> { return coord.getScrollXPixInt() > endScrollPoint.get(); },
"Controller failed to fling scroll right", POLL_TIMEOUT_SHORT_MS, "Controller failed to fling scroll right", POLL_TIMEOUT_SHORT_MS,
POLL_CHECK_INTERVAL_LONG_MS); POLL_CHECK_INTERVAL_LONG_MS);
mController.cancelFlingScroll();
// Test fling scrolling left. // Test fling scrolling left.
NativeUiUtils.scrollFling(NativeUiUtils.ScrollDirection.LEFT); mController.scroll(EmulatedVrController.ScrollDirection.LEFT, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_FLING_SCROLL);
endScrollPoint.set(coord.getScrollXPixInt()); endScrollPoint.set(coord.getScrollXPixInt());
CriteriaHelper.pollInstrumentationThread( CriteriaHelper.pollInstrumentationThread(
() ()
...@@ -250,7 +248,7 @@ public class VrBrowserControllerInputTest { ...@@ -250,7 +248,7 @@ public class VrBrowserControllerInputTest {
"test_controller_clicks_register_on_webpage"), "test_controller_clicks_register_on_webpage"),
PAGE_LOAD_TIMEOUT_S); PAGE_LOAD_TIMEOUT_S);
NativeUiUtils.clickElement(UserFriendlyElementName.CONTENT_QUAD, new PointF()); mController.performControllerClick();
ChromeTabUtils.waitForTabPageLoaded(mVrTestRule.getActivity().getActivityTab(), ChromeTabUtils.waitForTabPageLoaded(mVrTestRule.getActivity().getActivityTab(),
VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_navigation_2d_page")); VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_navigation_2d_page"));
} }
...@@ -266,7 +264,7 @@ public class VrBrowserControllerInputTest { ...@@ -266,7 +264,7 @@ public class VrBrowserControllerInputTest {
public void testControllerClicksRegisterOnIframe() throws InterruptedException { public void testControllerClicksRegisterOnIframe() throws InterruptedException {
mVrTestRule.loadUrl( mVrTestRule.loadUrl(
VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_iframe_clicks_outer")); VrBrowserTestFramework.getFileUrlForHtmlTestFile("test_iframe_clicks_outer"));
NativeUiUtils.clickElement(UserFriendlyElementName.CONTENT_QUAD, new PointF()); mController.performControllerClick();
// Wait until the iframe's current location matches the URL of the page that gets navigated // Wait until the iframe's current location matches the URL of the page that gets navigated
// to on click. // to on click.
mVrBrowserTestFramework.pollJavaScriptBooleanInFrameOrFail("window.location.href == '" mVrBrowserTestFramework.pollJavaScriptBooleanInFrameOrFail("window.location.href == '"
...@@ -313,15 +311,16 @@ public class VrBrowserControllerInputTest { ...@@ -313,15 +311,16 @@ public class VrBrowserControllerInputTest {
// Test that scrolling down works // Test that scrolling down works
int startScrollPoint = recyclerView.computeVerticalScrollOffset(); int startScrollPoint = recyclerView.computeVerticalScrollOffset();
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.DOWN); // Arbitrary, but valid values to scroll smoothly
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL); int scrollSteps = 20;
int scrollSpeed = 60;
mController.scroll(EmulatedVrController.ScrollDirection.DOWN, scrollSteps, scrollSpeed);
int endScrollPoint = recyclerView.computeVerticalScrollOffset(); int endScrollPoint = recyclerView.computeVerticalScrollOffset();
Assert.assertTrue("Controller failed to scroll down", startScrollPoint < endScrollPoint); Assert.assertTrue("Controller failed to scroll down", startScrollPoint < endScrollPoint);
// Test that scrolling up works // Test that scrolling up works
startScrollPoint = endScrollPoint; startScrollPoint = endScrollPoint;
NativeUiUtils.scrollNonFling(NativeUiUtils.ScrollDirection.UP); mController.scroll(EmulatedVrController.ScrollDirection.UP, scrollSteps, scrollSpeed);
NativeUiUtils.waitNumFrames(NativeUiUtils.NUM_FRAMES_NON_FLING_SCROLL);
endScrollPoint = recyclerView.computeVerticalScrollOffset(); endScrollPoint = recyclerView.computeVerticalScrollOffset();
Assert.assertTrue("Controller failed to scroll up", startScrollPoint > endScrollPoint); Assert.assertTrue("Controller failed to scroll up", startScrollPoint > endScrollPoint);
} }
......
...@@ -8,7 +8,6 @@ import static org.chromium.chrome.browser.vr.XrTestFramework.POLL_TIMEOUT_SHORT_ ...@@ -8,7 +8,6 @@ import static org.chromium.chrome.browser.vr.XrTestFramework.POLL_TIMEOUT_SHORT_
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.support.annotation.IntDef;
import android.view.Choreographer; import android.view.Choreographer;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -32,8 +31,6 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper; ...@@ -32,8 +31,6 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.DOMUtils; import org.chromium.content_public.browser.test.util.DOMUtils;
import java.io.File; import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
...@@ -42,33 +39,11 @@ import java.util.concurrent.TimeoutException; ...@@ -42,33 +39,11 @@ import java.util.concurrent.TimeoutException;
* omnibox or back button. * omnibox or back button.
*/ */
public class NativeUiUtils { public class NativeUiUtils {
@IntDef({ScrollDirection.UP, ScrollDirection.DOWN, ScrollDirection.LEFT, ScrollDirection.RIGHT})
@Retention(RetentionPolicy.SOURCE)
public @interface ScrollDirection {
int UP = 0;
int DOWN = 1;
int LEFT = 2;
int RIGHT = 3;
}
// How many frames to wait after entering text in the omnibox before we can assume that // How many frames to wait after entering text in the omnibox before we can assume that
// suggestions are updated. This should only be used if the workaround of inputting text and // suggestions are updated. This should only be used if the workaround of inputting text and
// waiting for the suggestion box to appear doesn't work, e.g. if you need to input text, wait // waiting for the suggestion box to appear doesn't work, e.g. if you need to input text, wait
// for autocomplete, then input more text before committing. 20 is arbitrary, but stable. // for autocomplete, then input more text before committing. 20 is arbitrary, but stable.
public static final int NUM_FRAMES_FOR_SUGGESTION_UPDATE = 20; public static final int NUM_FRAMES_FOR_SUGGESTION_UPDATE = 20;
// Arbitrary number of interpolated steps to perform within a scroll to consistently trigger
// either fling or non-fling scrolling.
public static final int NUM_STEPS_NON_FLING_SCROLL = 60;
public static final int NUM_STEPS_FLING_SCROLL = 6;
// Number of frames to wait after queueing a non-fling scroll before we can be sure that all the
// scroll actions have been processed. The +2 comes from scrolls always having a touch down and
// up action with NUM_STEPS_*_SCROLL additional actions in between.
public static final int NUM_FRAMES_NON_FLING_SCROLL = NUM_STEPS_NON_FLING_SCROLL + 2;
// The number of frames after queueing a fling scroll before we can be sure that all the scroll
// actions have been processed AND we should still be scrolling due to the fling. The 10 is
// arbitrary, but 1/6 of a second is a reasonable amount of time to wait and still expect to be
// flinging, and is stable.
public static final int NUM_FRAMES_FLING_SCROLL = NUM_STEPS_FLING_SCROLL + 2 + 10;
public static final String FRAME_BUFFER_SUFFIX_WEB_XR_OVERLAY = "_WebXrOverlay"; public static final String FRAME_BUFFER_SUFFIX_WEB_XR_OVERLAY = "_WebXrOverlay";
public static final String FRAME_BUFFER_SUFFIX_WEB_XR_CONTENT = "_WebXrContent"; public static final String FRAME_BUFFER_SUFFIX_WEB_XR_CONTENT = "_WebXrContent";
public static final String FRAME_BUFFER_SUFFIX_BROWSER_UI = "_BrowserUi"; public static final String FRAME_BUFFER_SUFFIX_BROWSER_UI = "_BrowserUi";
...@@ -186,51 +161,6 @@ public class NativeUiUtils { ...@@ -186,51 +161,6 @@ public class NativeUiUtils {
}); });
} }
/**
* Helper function for performing a non-fling scroll.
*
* @param direction the ScrollDirection to scroll in.
*/
public static void scrollNonFling(@ScrollDirection int direction) throws InterruptedException {
scroll(directionToStartPoint(direction), directionToEndPoint(direction),
NUM_STEPS_NON_FLING_SCROLL);
}
/**
* Helper function for performing a fling scroll.
*
* @param direction the ScrollDirection to scroll in.
*/
public static void scrollFling(@ScrollDirection int direction) throws InterruptedException {
scroll(directionToStartPoint(direction), directionToEndPoint(direction),
NUM_STEPS_FLING_SCROLL);
}
/**
* Perform a touchpad drag to scroll.
*
* @param start the position on the touchpad to start the drag.
* @param end the position on the touchpad to end the drag.
* @param numSteps the number of steps to interpolate between the two points, one step per
* frame.
*/
public static void scroll(PointF start, PointF end, int numSteps) throws InterruptedException {
PointF stepIncrement =
new PointF((end.x - start.x) / numSteps, (end.y - start.y) / numSteps);
PointF currentPosition = new PointF(start.x, start.y);
TestVrShellDelegate.getInstance().performControllerActionForTesting(
UserFriendlyElementName.NONE /* unused */, VrControllerTestAction.TOUCH_DOWN,
currentPosition);
for (int i = 0; i < numSteps; ++i) {
currentPosition.offset(stepIncrement.x, stepIncrement.y);
TestVrShellDelegate.getInstance().performControllerActionForTesting(
UserFriendlyElementName.NONE /* unused */, VrControllerTestAction.TOUCH_DOWN,
currentPosition);
}
TestVrShellDelegate.getInstance().performControllerActionForTesting(
UserFriendlyElementName.NONE /* unused */, VrControllerTestAction.TOUCH_UP, end);
}
/** /**
* Inputs the given text as if done via the VR keyboard. * Inputs the given text as if done via the VR keyboard.
* *
...@@ -549,30 +479,4 @@ public class NativeUiUtils { ...@@ -549,30 +479,4 @@ public class NativeUiUtils {
return "Unknown result"; return "Unknown result";
} }
} }
private static PointF directionToStartPoint(@ScrollDirection int direction) {
switch (direction) {
case ScrollDirection.UP:
return new PointF(0.5f, 0.05f);
case ScrollDirection.DOWN:
return new PointF(0.5f, 0.95f);
case ScrollDirection.LEFT:
return new PointF(0.05f, 0.5f);
default:
return new PointF(0.95f, 0.5f);
}
}
private static PointF directionToEndPoint(@ScrollDirection int direction) {
switch (direction) {
case ScrollDirection.UP:
return new PointF(0.5f, 0.95f);
case ScrollDirection.DOWN:
return new PointF(0.5f, 0.05f);
case ScrollDirection.LEFT:
return new PointF(0.95f, 0.5f);
default:
return new PointF(0.05f, 0.5f);
}
}
} }
...@@ -43,8 +43,8 @@ class AndroidUiGestureTarget { ...@@ -43,8 +43,8 @@ class AndroidUiGestureTarget {
int64_t time_ms, int64_t time_ms,
int delay_ms); int delay_ms);
float scroll_x_ = 0.0f; int scroll_x_ = 0;
float scroll_y_ = 0.0f; int scroll_y_ = 0;
float scale_factor_; float scale_factor_;
float scroll_ratio_; float scroll_ratio_;
int touch_slop_; int touch_slop_;
......
...@@ -81,8 +81,13 @@ void InputDelegateForTesting::QueueControllerActionForTesting( ...@@ -81,8 +81,13 @@ void InputDelegateForTesting::QueueControllerActionForTesting(
break; break;
case VrControllerTestAction::kMove: case VrControllerTestAction::kMove:
// Use whatever the last button state is. // Use whatever the last button state is.
controller_model.touchpad_button_state = if (!IsQueueEmpty()) {
GetMostRecentModel().touchpad_button_state; controller_model.touchpad_button_state =
controller_model_queue_.back().touchpad_button_state;
} else {
controller_model.touchpad_button_state =
cached_controller_model_.touchpad_button_state;
}
controller_model_queue_.push(controller_model); controller_model_queue_.push(controller_model);
break; break;
case VrControllerTestAction::kAppDown: case VrControllerTestAction::kAppDown:
...@@ -93,22 +98,6 @@ void InputDelegateForTesting::QueueControllerActionForTesting( ...@@ -93,22 +98,6 @@ void InputDelegateForTesting::QueueControllerActionForTesting(
controller_model.app_button_state = ControllerModel::ButtonState::kUp; controller_model.app_button_state = ControllerModel::ButtonState::kUp;
controller_model_queue_.push(controller_model); controller_model_queue_.push(controller_model);
break; break;
case VrControllerTestAction::kTouchDown:
// Use whatever the most recent direction is and interpret the provided
// point as the point on the touchpad.
controller_model.laser_direction = GetMostRecentModel().laser_direction;
SetOriginAndTransform(&controller_model);
controller_model.touching_touchpad = true;
controller_model.touchpad_touch_position = controller_input.position;
controller_model_queue_.push(controller_model);
break;
case VrControllerTestAction::kTouchUp:
controller_model.laser_direction = GetMostRecentModel().laser_direction;
SetOriginAndTransform(&controller_model);
controller_model.touching_touchpad = false;
controller_model.touchpad_touch_position = controller_input.position;
controller_model_queue_.push(controller_model);
break;
default: default:
NOTREACHED() << "Given unsupported controller action"; NOTREACHED() << "Given unsupported controller action";
} }
...@@ -158,10 +147,4 @@ void InputDelegateForTesting::OnResume() {} ...@@ -158,10 +147,4 @@ void InputDelegateForTesting::OnResume() {}
void InputDelegateForTesting::OnPause() {} void InputDelegateForTesting::OnPause() {}
ControllerModel InputDelegateForTesting::GetMostRecentModel() {
if (!IsQueueEmpty())
return controller_model_queue_.back();
return cached_controller_model_;
}
} // namespace vr } // namespace vr
...@@ -38,8 +38,6 @@ class InputDelegateForTesting : public InputDelegate { ...@@ -38,8 +38,6 @@ class InputDelegateForTesting : public InputDelegate {
void OnPause() override; void OnPause() override;
private: private:
ControllerModel GetMostRecentModel();
UiInterface* ui_; UiInterface* ui_;
std::queue<ControllerModel> controller_model_queue_; std::queue<ControllerModel> controller_model_queue_;
ControllerModel cached_controller_model_; ControllerModel cached_controller_model_;
......
...@@ -8,7 +8,17 @@ namespace vr { ...@@ -8,7 +8,17 @@ namespace vr {
ControllerModel::ControllerModel() = default; ControllerModel::ControllerModel() = default;
ControllerModel::ControllerModel(const ControllerModel& other) = default; ControllerModel::ControllerModel(const ControllerModel& other)
: transform(other.transform),
laser_direction(other.laser_direction),
laser_origin(other.laser_origin),
touchpad_button_state(other.touchpad_button_state),
app_button_state(other.app_button_state),
home_button_state(other.home_button_state),
opacity(other.opacity),
resting_in_viewport(other.resting_in_viewport),
handedness(other.handedness),
battery_level(other.battery_level) {}
ControllerModel::~ControllerModel() = default; ControllerModel::~ControllerModel() = default;
......
...@@ -63,11 +63,11 @@ bool PlatformControllerForTesting::ButtonDownHappened( ...@@ -63,11 +63,11 @@ bool PlatformControllerForTesting::ButtonDownHappened(
} }
bool PlatformControllerForTesting::IsTouchingTrackpad() const { bool PlatformControllerForTesting::IsTouchingTrackpad() const {
return cur_model_->touching_touchpad; return false;
} }
gfx::PointF PlatformControllerForTesting::GetPositionInTrackpad() const { gfx::PointF PlatformControllerForTesting::GetPositionInTrackpad() const {
return cur_model_->touchpad_touch_position; return gfx::PointF();
} }
base::TimeTicks PlatformControllerForTesting::GetLastOrientationTimestamp() base::TimeTicks PlatformControllerForTesting::GetLastOrientationTimestamp()
......
...@@ -78,8 +78,6 @@ enum class VrControllerTestAction : int { ...@@ -78,8 +78,6 @@ enum class VrControllerTestAction : int {
kMove, kMove,
kAppDown, kAppDown,
kAppUp, kAppUp,
kTouchDown,
kTouchUp,
}; };
// These are used to specify what type of keyboard input should be performed // These are used to specify what type of keyboard input should be performed
......
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