Commit 12d7fecd authored by mdjones's avatar mdjones Committed by Commit bot

Revert of Make VR screen tap tests more stable (patchset #6 id:100001 of...

Revert of Make VR screen tap tests more stable (patchset #6 id:100001 of https://codereview.chromium.org/2768583002/ )

Reason for revert:
Breaking compile on several bots including Android x64 builder:
  symbol:   class OnDispatchTouchEventCallback
  location: class WebVrTest
../../chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/WebVrTest.java:269: error: cannot find symbol
        ((VrShellImpl) VrShellDelegate.getVrShellForTesting()

Original issue's description:
> Make VR screen tap tests more stable
>
> The single tap sent during the VR screen tap tests wasn't always
> getting registered since device response can be a bit slow during
> the VR transition. For the Cardboard case, wait on Javascript to say
> it received another click event. For the Daydream case, wait on VrShell
> saying its parent has consumed the event before checking.
> BUG=
>
> Review-Url: https://codereview.chromium.org/2768583002
> Cr-Commit-Position: refs/heads/master@{#460452}
> Committed: https://chromium.googlesource.com/chromium/src/+/3e2ce51e88f19f0cc5196284f580583ddd4dbd9a

TBR=dtrainor@chromium.org,tedchoc@chromium.org,mthiesse@chromium.org,bsheedy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review-Url: https://codereview.chromium.org/2782963002
Cr-Commit-Position: refs/heads/master@{#460490}
parent 0749ec24
......@@ -790,14 +790,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener
mVrDaydreamApi = api;
}
/**
* @return The VrShell for the VrShellDelegate instance
*/
@VisibleForTesting
public static VrShell getVrShellForTesting() {
return sInstance == null ? null : sInstance.mVrShell;
}
/**
* @return Pointer to the native VrShellDelegate object.
*/
......
......@@ -23,7 +23,6 @@ import com.google.vr.ndk.base.GvrLayout;
import org.chromium.base.CommandLine;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.ChromeActivity;
......@@ -119,8 +118,6 @@ public class VrShellImpl
private MotionEventSynthesizer mMotionEventSynthesizer;
private OnDispatchTouchEventCallback mOnDispatchTouchEventForTesting;
public VrShellImpl(
ChromeActivity activity, VrShellDelegate delegate, TabModelSelector tabModelSelector) {
super(activity);
......@@ -446,18 +443,11 @@ public class VrShellImpl
// Normally, touch event is dispatched to presentation view only if the phone is paired with
// a Cardboard viewer. This is annoying when we just want to quickly verify a Cardboard
// behavior. This allows us to trigger cardboard trigger event without pair to a Cardboard.
boolean cardboardTriggered = false;
if (CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_VR_SHELL_DEV)
&& event.getActionMasked() == MotionEvent.ACTION_DOWN) {
nativeOnTriggerEvent(mNativeVrShell);
cardboardTriggered = true;
}
boolean parentConsumed = super.dispatchTouchEvent(event);
if (mOnDispatchTouchEventForTesting != null) {
mOnDispatchTouchEventForTesting.onDispatchTouchEvent(
parentConsumed, cardboardTriggered);
}
return parentConsumed;
return super.dispatchTouchEvent(event);
}
@Override
......@@ -638,16 +628,6 @@ public class VrShellImpl
@Override
public void removeWindowAndroidChangedObserver(WindowAndroidChangedObserver observer) {}
/**
* Sets the runnable that will be run when VrShellImpl's dispatchTouchEvent
* is run and the parent consumed the event.
* @param runnable The Runnable that will be run
*/
@VisibleForTesting
public void setOnDispatchTouchEventForTesting(OnDispatchTouchEventCallback callback) {
mOnDispatchTouchEventForTesting = callback;
}
private native long nativeInit(WebContents uiWebContents, long nativeContentWindowAndroid,
long nativeUiWindowAndroid, boolean forWebVR, VrShellDelegate delegate, long gvrApi,
boolean reprojectedRendering);
......
......@@ -1210,7 +1210,6 @@ chrome_vr_java_sources = [
"java/src/org/chromium/chrome/browser/vr_shell/VrDaydreamApiImpl.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrShellImpl.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrWindowAndroid.java",
"javatests/src/org/chromium/chrome/browser/vr_shell/OnDispatchTouchEventCallback.java",
]
chrome_test_java_sources = [
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.vr_shell;
/**
* Callback used to execute code additional test code after VrShellImpl's
* dispatchTouchEvent() runs.
*/
public interface OnDispatchTouchEventCallback {
/**
* Runs some code that may need to know if the event was consumed
* by the parent and if a cardboard event was triggered.
*/
void onDispatchTouchEvent(boolean parentConsumed, boolean cardboardTriggered);
}
......@@ -12,8 +12,6 @@ import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_VIEWER_NON_DAYDREAM;
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_WEBVR_SUPPORTED;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest;
import org.chromium.base.Log;
......@@ -28,7 +26,6 @@ import org.chromium.content.browser.test.util.JavaScriptUtils;
import org.chromium.content_public.browser.WebContents;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
......@@ -255,7 +252,7 @@ public class WebVrTest extends ChromeTabbedActivityTestBase {
* Tests that screen touches are not registered when the viewer is a
* Daydream View.
*/
@LargeTest
@SmallTest
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
public void testScreenTapsNotRegisteredOnDaydream() throws InterruptedException {
String testName = "test_screen_taps_not_registered_on_daydream";
......@@ -263,22 +260,7 @@ public class WebVrTest extends ChromeTabbedActivityTestBase {
assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents);
enterVrTapAndWait(mWebContents);
// Wait on VrShellImpl to say that its parent consumed the touch event
// Set to 2 because there's an ACTION_DOWN followed by ACTION_UP
final CountDownLatch touchRegisteredLatch = new CountDownLatch(2);
((VrShellImpl) VrShellDelegate.getVrShellForTesting())
.setOnDispatchTouchEventForTesting(new OnDispatchTouchEventCallback() {
@Override
public void onDispatchTouchEvent(
boolean parentConsumed, boolean cardboardTriggered) {
if (!parentConsumed) fail("Parent did not consume event");
if (cardboardTriggered) fail("Cardboard event triggered");
touchRegisteredLatch.countDown();
}
});
enterVrTap();
assertTrue("VrShellImpl dispatched touches",
touchRegisteredLatch.await(POLL_TIMEOUT_SHORT_MS, TimeUnit.MILLISECONDS));
executeStepAndWait("stepVerifyNoAdditionalTaps()", mWebContents);
endTest(mWebContents);
}
......@@ -287,17 +269,16 @@ public class WebVrTest extends ChromeTabbedActivityTestBase {
* Tests that screen touches are still registered when the viewer is
* Cardboard.
*/
@MediumTest
@SmallTest
@Restriction(RESTRICTION_TYPE_VIEWER_NON_DAYDREAM)
public void testScreenTapsRegisteredOnCardboard() throws InterruptedException {
String testName = "test_screen_taps_registered_on_cardboard";
loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
assertTrue("VRDisplay found", vrDisplayFound(mWebContents));
executeStepAndWait("stepVerifyNoInitialTaps()", mWebContents);
// Tap and wait to enter VR
enterVrTapAndWait(mWebContents);
// Tap and wait for Javascript to receive it
enterVrTapAndWait(mWebContents);
enterVrTap();
executeStepAndWait("stepVerifyAdditionalTap()", mWebContents);
endTest(mWebContents);
}
......
......@@ -30,7 +30,7 @@ Daydream View
t.step_func_done( () => {
// We expect 1 tap from entering VR
assert_equals(numTaps, 1,
"Only one tap registered after two taps given");
"Only tap one tap registered after two taps given");
})();
}
......
......@@ -17,14 +17,7 @@ Cardboard
window.addEventListener("vrdisplaypresentchange",
() => {finishJavascriptStep();}, false);
var numTaps = 0;
webglCanvas.addEventListener("click",
() => {
numTaps++;
// Notify Java when we've received the tap after entering VR
if (numTaps == 2) {
t.done();
}
}, false);
webglCanvas.addEventListener("click", () => {numTaps++;}, false);
function stepVerifyNoInitialTaps() {
t.step( () => {
......@@ -32,6 +25,15 @@ Cardboard
});
finishJavascriptStep();
}
function stepVerifyAdditionalTap() {
t.step_func_done( () => {
// We expect 1 tap from entering VR + 1 additional one after
assert_equals(numTaps, 2,
"Two taps registered after two taps given");
})();
}
</script>
</body>
</html>
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