Commit d2bb1544 authored by bsheedy's avatar bsheedy Committed by Commit bot

Add WebVR device capability e2e test

Tests that the device capabilities reported by WebVR match expectations,
although currently all tested devices have the same expectations.

Automates one of our manual test cases.

BUG=702700

Review-Url: https://codereview.chromium.org/2794383002
Cr-Commit-Position: refs/heads/master@{#462934}
parent 58eb768a
...@@ -12,6 +12,7 @@ import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V ...@@ -12,6 +12,7 @@ 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_VIEWER_NON_DAYDREAM;
import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_WEBVR_SUPPORTED; import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_WEBVR_SUPPORTED;
import android.os.Build;
import android.support.test.filters.LargeTest; import android.support.test.filters.LargeTest;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
...@@ -327,7 +328,7 @@ public class WebVrTest extends ChromeTabbedActivityTestBase { ...@@ -327,7 +328,7 @@ public class WebVrTest extends ChromeTabbedActivityTestBase {
mockChecker.setMockReturnValue(checkerReturnValue); mockChecker.setMockReturnValue(checkerReturnValue);
VrShellDelegate.getInstanceForTesting().overrideVrCoreVersionCheckerForTesting(mockChecker); VrShellDelegate.getInstanceForTesting().overrideVrCoreVersionCheckerForTesting(mockChecker);
String testName = "generic_webvr_page"; String testName = "generic_webvr_page";
loadUrl(getHtmlTestFile(testName), 10); loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
String displayFound = "VRDisplay Found"; String displayFound = "VRDisplay Found";
String barPresent = "InfoBar present"; String barPresent = "InfoBar present";
if (checkerReturnValue == VrCoreVersionChecker.VR_READY) { if (checkerReturnValue == VrCoreVersionChecker.VR_READY) {
...@@ -406,4 +407,17 @@ public class WebVrTest extends ChromeTabbedActivityTestBase { ...@@ -406,4 +407,17 @@ public class WebVrTest extends ChromeTabbedActivityTestBase {
public void testInfoBarNotPresentWhenVrServicesNotSupported() throws InterruptedException { public void testInfoBarNotPresentWhenVrServicesNotSupported() throws InterruptedException {
infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED); infoBarTestHelper(VrCoreVersionChecker.VR_NOT_SUPPORTED);
} }
/**
* Tests that the reported WebVR capabilities match expectations on the
* devices the WebVR tests are run on continuously.
*/
@MediumTest
public void testDeviceCapabilitiesMatchExpectations() throws InterruptedException {
String testName = "test_device_capabilities_match_expectations";
loadUrl(getHtmlTestFile(testName), PAGE_LOAD_TIMEOUT_S);
assertTrue("VRDisplayFound", vrDisplayFound(mWebContents));
executeStepAndWait("stepCheckDeviceCapabilities('" + Build.DEVICE + "')", mWebContents);
endTest(mWebContents);
}
} }
<!doctype html>
<!--
Tests that the reported device capabilities match expectations.
-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="../resources/webvr_e2e.css">
</head>
<body>
<canvas id="webgl-canvas"></canvas>
<script src="../../../../../../third_party/WebKit/LayoutTests/resources/testharness.js"></script>
<script src="../resources/webvr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script>
<script>
// All the current test devices have the same expectations, but that will
// change with additional device support, especially desktop.
var android_expectation = {
"isPresenting": false,
"capabilities": {
"hasPosition": false,
"hasExternalDisplay": false,
"canPresent": true,
"maxLayers": 1,
},
}
var expectations = {
"angler": android_expectation, // Nexus 6P
"bullhead": android_expectation, // Nexus 5X
"hammerhead": android_expectation, // Nexus 5
"marlin": android_expectation, // Pixel XL
"sailfish": android_expectation, // Pixel
}
var t = async_test("Device capabilities match expectations");
function stepCheckDeviceCapabilities(device) {
if (!(device in expectations)) {
t.step_func_done( () => {
assert_unreached("Given device " + device + " not in expectations");
})();
return;
}
let expectation = expectations[device];
t.step_func_done( () => {
assert_equals(vrDisplay["isPresenting"], expectation["isPresenting"]);
for (var capability in expectation["capabilities"]) {
assert_equals(vrDisplay["capabilities"][capability],
expectation["capabilities"][capability],
capability);
}
})();
}
</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