Commit 676a19bd authored by bsheedy's avatar bsheedy Committed by Commit Bot

Fix NFC test not working in WebappActivity

Fixes the issue of CCT/WAA NFC tests getting stuck in the DOFF flow.
This was somehow caused by the webpage listening for vrdisplayactivate,
but not actually presenting with it.

Also adds a sleep at the end of the test to prevent a possible race
condition with VrCore's 2 second NFC debounce timeout.

Bug: 787878
Change-Id: Ic5f16258cfa94ce3fac63781c1e225b8b2749f4e
Reviewed-on: https://chromium-review.googlesource.com/791938
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519499}
parent 11852d9e
...@@ -13,6 +13,8 @@ import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V ...@@ -13,6 +13,8 @@ import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
import android.app.Activity; import android.app.Activity;
import android.os.Build; import android.os.Build;
import android.os.SystemClock;
import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import org.junit.Assert; import org.junit.Assert;
...@@ -114,13 +116,12 @@ public class WebVrTransitionTest { ...@@ -114,13 +116,12 @@ public class WebVrTransitionTest {
/** /**
* Tests that scanning the Daydream View NFC tag on supported devices fires the * Tests that scanning the Daydream View NFC tag on supported devices fires the
* vrdisplayactivate event. * vrdisplayactivate event and the event allows presentation without a user gesture.
*/ */
@Test @Test
@MediumTest @LargeTest
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM) @Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
@VrActivityRestriction({VrActivityRestriction.SupportedActivity.CTA, @VrActivityRestriction({VrActivityRestriction.SupportedActivity.ALL})
VrActivityRestriction.SupportedActivity.CCT})
public void testNfcFiresVrdisplayactivate() throws InterruptedException { public void testNfcFiresVrdisplayactivate() throws InterruptedException {
mVrTestFramework.loadUrlAndAwaitInitialization( mVrTestFramework.loadUrlAndAwaitInitialization(
VrTestFramework.getHtmlTestFile("test_nfc_fires_vrdisplayactivate"), VrTestFramework.getHtmlTestFile("test_nfc_fires_vrdisplayactivate"),
...@@ -130,6 +131,11 @@ public class WebVrTransitionTest { ...@@ -130,6 +131,11 @@ public class WebVrTransitionTest {
NfcSimUtils.simNfcScan(mVrTestRule.getActivity()); NfcSimUtils.simNfcScan(mVrTestRule.getActivity());
VrTestFramework.waitOnJavaScriptStep(mVrTestFramework.getFirstTabWebContents()); VrTestFramework.waitOnJavaScriptStep(mVrTestFramework.getFirstTabWebContents());
VrTestFramework.endTest(mVrTestFramework.getFirstTabWebContents()); VrTestFramework.endTest(mVrTestFramework.getFirstTabWebContents());
// VrCore has a 2000 ms debounce timeout on NFC scans. When run multiple times in different
// activities, it is possible for a latter test to be run in the 2 seconds after the
// previous test's NFC scan, causing it to fail flakily. So, wait 2 seconds to ensure that
// can't happen.
SystemClock.sleep(2000);
} }
/** /**
......
...@@ -11,10 +11,20 @@ vrdisplayactivate event ...@@ -11,10 +11,20 @@ vrdisplayactivate event
<canvas id="webgl-canvas"></canvas> <canvas id="webgl-canvas"></canvas>
<script src="../../../../../../third_party/WebKit/LayoutTests/resources/testharness.js"></script> <script src="../../../../../../third_party/WebKit/LayoutTests/resources/testharness.js"></script>
<script src="../resources/webvr_e2e.js"></script> <script src="../resources/webvr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script>
<script> <script>
var t = async_test("NFC scan fires the vrdisplayactivate event"); var t = async_test("NFC scan fires the vrdisplayactivate event");
function addListener() { function addListener() {
window.addEventListener("vrdisplayactivate", () => {t.done();}, false); window.addEventListener("vrdisplayactivate", () => {
vrDisplay.requestPresent([{source: webglCanvas}]).then( () => {
// Do nothing
}, (err) => {
t.step( () => {
assert_unreached(
"Was unable to present with vrdisplayactivate: " + err);
});
}).then( () => {t.done()});
}, false);
} }
// NFC scan triggered after page loaded and listener added // NFC scan triggered after page loaded and listener added
</script> </script>
......
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