Commit 71fa6ab0 authored by Brian Sheedy's avatar Brian Sheedy Committed by Commit Bot

Refactor + Cleanup XR Browser Tests

Does the following refactoring/cleanup in the XR browser tests:

1. Standardizes the naming of test classes.
2. Switches any easily-ported OpenVR tests to run with both OpenVR and
   WMR runtimes.
3. Deduplicates some code DirectX adapter enumeration code.
4. Ensures that WMR tests always create a test hook before the test
   starts, to avoid issues with the real Mixed Reality Portal starting
   up if it's installed and a test hook is otherwise not needed for a
   test.
5. Documenation clarification.

Bug: 926048
Change-Id: I2af46b3aa103f5b8d80c676154af451e93384a89
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633316
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664467}
parent d8078ce7
......@@ -20,7 +20,7 @@ std::string CheckDirectX_11_1() {
return "DirectX 11.1 required, but not on Windows";
#else
int32_t adapter_index;
GetD3D11_1Adapter(&adapter_index);
GetD3D11_1AdapterIndex(&adapter_index);
if (adapter_index == -1) {
return "DirectX 11.1 required, but no suitable device found";
}
......
......@@ -63,4 +63,12 @@
void MULTI_CLASS_RUNNER_NAME_(test_name)::ActuallyRunTestOnMainThread( \
base_class* t)
// Helper macro to cut down on duplicate code since most uses of
// IN_PROC_MULTI_CLASS_BROWSER_TEST_F2 are passed the same OpenVR and WMR
// classes and the same base class
#define WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(test_name) \
IN_PROC_MULTI_CLASS_BROWSER_TEST_F2(WebXrVrOpenVrBrowserTest, \
WebXrVrWmrBrowserTest, \
WebXrVrBrowserTestBase, test_name)
#endif // CHROME_BROWSER_VR_TEST_MULTI_CLASS_BROWSER_TEST_H_
......@@ -41,9 +41,9 @@ class WebVrBrowserTestBase : public WebXrVrBrowserTestBase {
};
// Test class with OpenVR support disabled.
class WebVrBrowserTestOpenVrDisabled : public WebVrBrowserTestBase {
class WebVrRuntimelessBrowserTest : public WebVrBrowserTestBase {
public:
WebVrBrowserTestOpenVrDisabled() {
WebVrRuntimelessBrowserTest() {
append_switches_.push_back(switches::kEnableWebVR);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
......@@ -55,9 +55,9 @@ class WebVrBrowserTestOpenVrDisabled : public WebVrBrowserTestBase {
// OpenVR feature only defined on Windows.
#ifdef OS_WIN
// Test class with standard features enabled: WebVR and OpenVR support.
class WebVrBrowserTestStandard : public WebVrBrowserTestBase {
class WebVrOpenVrBrowserTest : public WebVrBrowserTestBase {
public:
WebVrBrowserTestStandard() {
WebVrOpenVrBrowserTest() {
append_switches_.push_back(switches::kEnableWebVR);
enable_features_.push_back(features::kOpenVR);
......@@ -70,9 +70,9 @@ class WebVrBrowserTestStandard : public WebVrBrowserTestBase {
};
// Test class with WebVR disabled.
class WebVrBrowserTestWebVrDisabled : public WebVrBrowserTestBase {
class WebVrOpenVrBrowserTestWebVrDisabled : public WebVrBrowserTestBase {
public:
WebVrBrowserTestWebVrDisabled() {
WebVrOpenVrBrowserTestWebVrDisabled() {
enable_features_.push_back(features::kOpenVR);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
......
......@@ -62,7 +62,16 @@ XrBrowserTestBase::RuntimeType WebXrVrOpenVrBrowserTestBase::GetRuntimeType()
return XrBrowserTestBase::RuntimeType::RUNTIME_OPENVR;
}
XrBrowserTestBase::RuntimeType WebXrVrWMRBrowserTestBase::GetRuntimeType()
WebXrVrWmrBrowserTestBase::WebXrVrWmrBrowserTestBase() {}
WebXrVrWmrBrowserTestBase::~WebXrVrWmrBrowserTestBase() = default;
void WebXrVrWmrBrowserTestBase::PreRunTestOnMainThread() {
dummy_hook_ = std::make_unique<MockXRDeviceHookBase>();
WebXrVrBrowserTestBase::PreRunTestOnMainThread();
}
XrBrowserTestBase::RuntimeType WebXrVrWmrBrowserTestBase::GetRuntimeType()
const {
return XrBrowserTestBase::RuntimeType::RUNTIME_WMR;
}
......
......@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "chrome/browser/vr/test/conditional_skipping.h"
#include "chrome/browser/vr/test/mock_xr_device_hook_base.h"
#include "chrome/browser/vr/test/webxr_browser_test.h"
#include "chrome/browser/vr/test/xr_browser_test.h"
#include "chrome/common/chrome_features.h"
......@@ -22,9 +23,10 @@
namespace vr {
// WebXR for VR-specific test base class.
// WebXR for VR-specific test base class without any particular runtime.
class WebXrVrBrowserTestBase : public WebXrBrowserTestBase {
public:
WebXrVrBrowserTestBase() { enable_features_.push_back(features::kWebXr); }
void EnterSessionWithUserGesture(content::WebContents* web_contents) override;
void EnterSessionWithUserGestureOrFail(
content::WebContents* web_contents) override;
......@@ -45,11 +47,9 @@ class WebXrVrBrowserTestBase : public WebXrBrowserTestBase {
};
// Test class with OpenVR disabled.
class WebXrVrBrowserTestOpenVrDisabled : public WebXrVrBrowserTestBase {
class WebXrVrRuntimelessBrowserTest : public WebXrVrBrowserTestBase {
public:
WebXrVrBrowserTestOpenVrDisabled() {
enable_features_.push_back(features::kWebXr);
WebXrVrRuntimelessBrowserTest() {
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
#endif
......@@ -58,18 +58,14 @@ class WebXrVrBrowserTestOpenVrDisabled : public WebXrVrBrowserTestBase {
// WebXrOrientationSensorDevice is only defined when the enable_vr flag is set.
#if BUILDFLAG(ENABLE_VR)
class WebXrVrBrowserTestSensorless : public WebXrVrBrowserTestBase {
class WebXrVrRuntimelessBrowserTestSensorless
: public WebXrVrRuntimelessBrowserTest {
public:
WebXrVrBrowserTestSensorless() {
enable_features_.push_back(features::kWebXr);
WebXrVrRuntimelessBrowserTestSensorless() {
disable_features_.push_back(device::kWebXrOrientationSensorDevice);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
#endif
}
};
#endif
#endif // BUILDFLAG(ENABLE_VR)
// OpenVR and WMR feature only defined on Windows.
#ifdef OS_WIN
......@@ -78,46 +74,61 @@ class WebXrVrOpenVrBrowserTestBase : public WebXrVrBrowserTestBase {
public:
WebXrVrOpenVrBrowserTestBase() {
enable_features_.push_back(features::kOpenVR);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
#endif
}
XrBrowserTestBase::RuntimeType GetRuntimeType() const override;
};
// WMR-specific subclass of WebXrVrBrowserTestBase.
class WebXrVrWMRBrowserTestBase : public WebXrVrBrowserTestBase {
class WebXrVrWmrBrowserTestBase : public WebXrVrBrowserTestBase {
public:
WebXrVrWmrBrowserTestBase();
~WebXrVrWmrBrowserTestBase() override;
void PreRunTestOnMainThread() override;
// WMR enabled by default, so no need to add anything in the constructor.
XrBrowserTestBase::RuntimeType GetRuntimeType() const override;
private:
// We create this before the test starts so that a test hook is always
// registered, and thus the mock WMR wrappers are always used in tests. If a
// test needs to actually use the test hook for input, then the one the test
// creates will simply be registered over this one.
std::unique_ptr<MockXRDeviceHookBase> dummy_hook_;
};
// Test class with standard features enabled: WebXR and OpenVR.
class WebXrVrBrowserTestStandard : public WebXrVrOpenVrBrowserTestBase {
class WebXrVrOpenVrBrowserTest : public WebXrVrOpenVrBrowserTestBase {
public:
WebXrVrBrowserTestStandard() {
enable_features_.push_back(features::kWebXr);
WebXrVrOpenVrBrowserTest() {
// We know at this point that we're going to be running with both OpenVR and
// WebXR enabled, so enforce the DirectX 11.1 requirement.
runtime_requirements_.push_back(XrTestRequirement::DIRECTX_11_1);
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
#endif
}
};
class WebXrVrBrowserTestWMR : public WebXrVrWMRBrowserTestBase {
class WebXrVrWmrBrowserTest : public WebXrVrWmrBrowserTestBase {
public:
WebXrVrBrowserTestWMR() {
WebXrVrWmrBrowserTest() {
// WMR already enabled by default.
enable_features_.push_back(features::kWebXr);
runtime_requirements_.push_back(XrTestRequirement::DIRECTX_11_1);
}
};
// Test class with WebXR disabled.
class WebXrVrBrowserTestWebXrDisabled : public WebXrVrOpenVrBrowserTestBase {
// Test classes with WebXR disabled.
class WebXrVrOpenVrBrowserTestWebXrDisabled
: public WebXrVrOpenVrBrowserTestBase {
public:
WebXrVrBrowserTestWebXrDisabled() {
#if BUILDFLAG(ENABLE_WINDOWS_MR)
disable_features_.push_back(features::kWindowsMixedReality);
#endif
WebXrVrOpenVrBrowserTestWebXrDisabled() {
disable_features_.push_back(features::kWebXr);
}
};
class WebXrVrWmrBrowserTestWebXrDisabled : public WebXrVrWmrBrowserTestBase {
public:
WebXrVrWmrBrowserTestWebXrDisabled() {
disable_features_.push_back(features::kWebXr);
}
};
#endif // OS_WIN
......
......@@ -90,9 +90,35 @@ These macros help cut down on boilerplate code, but if you need either:
2. Different test logic in the implementation depending on the provided class
You should consider using the standard IN_PROC_BROWSER_TEST_F macros instead.
Small snippets of runtime-specific code are acceptable, but if it affects
readability significantly, the tests should probably remain separate.
Most tests simply use the standard `WebXrVrOpenVrBrowserTest` and
`WebXrVrWmrBrowserTest` classes. In this case, you can instead use the
`WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F` macro, which only needs to take the test
name, further cutting down on boilerplate code.
[multi class macros]: https://chromium.googlesource.com/chromium/src/+/master/chrome/browser/vr/test/multi_class_browser_test.h
## Test Class Names
The test classes that are used to provide feature and runtime-specific setup and
functions are named in the following order:
1. Feature
2. Runtime
3. "BrowserTest"
4. Optional Descriptor/special flags
For example, `WebXrVrOpenVrBrowserTest` is meant for testing the WebXR for VR
feature using the OpenVR runtime with standard flags enabled, i.e. the flags
required for using WebXR and the OpenVR runtime with other runtimes disabled.
`WebXrVrRuntimelessBrowserTestSensorless` on the other hand would be for
testing WebVR for VR without any runtimes and with the orientation sensor
device explicitly disabled.
In general, classes ending in "Base" should not be used directly.
## Controller and Head Input
The XR browser tests provide a way to plumb controller and headset data (e.g.
......
......@@ -232,7 +232,9 @@ void TestPresentationPosesImpl(WebXrVrBrowserTestBase* t,
t->EndTest();
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard, TestPresentationPoses) {
// TODO(https://crbug.com/926048): Port to WMR as well. Submitted frame data
// is not yet provided back to the test when using WMR.
IN_PROC_BROWSER_TEST_F(WebXrVrOpenVrBrowserTest, TestPresentationPoses) {
TestPresentationPosesImpl(this, "test_webxr_poses");
}
......
......@@ -8,6 +8,7 @@
#include "base/bind_helpers.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/vr/test/multi_class_browser_test.h"
#include "chrome/browser/vr/test/ui_utils.h"
#include "chrome/browser/vr/test/webxr_vr_browser_test.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
......@@ -53,7 +54,7 @@ std::vector<TestContentSettings> ExtractFrom(
}
void SetMultipleContentSetting(
WebXrVrBrowserTestStandard* t,
WebXrVrBrowserTestBase* t,
const std::vector<TestContentSettings>& test_settings) {
HostContentSettingsMap* host_content_settings_map =
HostContentSettingsMapFactory::GetForProfile(Profile::FromBrowserContext(
......@@ -66,7 +67,7 @@ void SetMultipleContentSetting(
}
void LoadGenericPageChangeDefaultPermissionAndEnterVr(
WebXrVrBrowserTestStandard* t,
WebXrVrBrowserTestBase* t,
const std::vector<TestContentSettings>& test_settings) {
t->LoadUrlAndAwaitInitialization(
t->GetEmbeddedServerUrlForHtmlTestFile("generic_webxr_page"));
......@@ -77,7 +78,7 @@ void LoadGenericPageChangeDefaultPermissionAndEnterVr(
// Tests that indicators are displayed in the headset when a device becomes
// in-use.
void TestIndicatorOnAccessForContentType(
WebXrVrBrowserTestStandard* t,
WebXrVrBrowserTestBase* t,
ContentSettingsType content_setting_type,
const std::string& script,
UserFriendlyElementName element_name) {
......@@ -101,7 +102,7 @@ void TestIndicatorOnAccessForContentType(
// Tests indicators on entering immersive session.
void TestForInitialIndicatorForContentType(
WebXrVrBrowserTestStandard* t,
WebXrVrBrowserTestBase* t,
const std::vector<TestIndicatorSetting>& test_indicator_settings) {
DCHECK(!test_indicator_settings.empty());
// Enter VR while the content setting is CONTENT_SETTING_ASK to suppress
......@@ -121,61 +122,56 @@ void TestForInitialIndicatorForContentType(
} // namespace
// Tests for indicators when they become in-use
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard, TestLocationInUseIndicator) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestLocationInUseIndicator) {
// Asking for location seems to work without any hardware/machine specific
// enabling/capability (unlike microphone, camera). Hence, this test.
TestIndicatorOnAccessForContentType(
this, CONTENT_SETTINGS_TYPE_GEOLOCATION,
t, CONTENT_SETTINGS_TYPE_GEOLOCATION,
"navigator.geolocation.getCurrentPosition( ()=>{}, ()=>{} )",
UserFriendlyElementName::kWebXrLocationPermissionIndicator);
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
DISABLED_TestMicrophoneInUseIndicator) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(DISABLED_TestMicrophoneInUseIndicator) {
TestIndicatorOnAccessForContentType(
this, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
t, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC,
"navigator.getUserMedia( {audio : true}, ()=>{}, ()=>{} )",
UserFriendlyElementName::kWebXrAudioIndicator);
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
DISABLED_TestCameraInUseIndicator) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(DISABLED_TestCameraInUseIndicator) {
TestIndicatorOnAccessForContentType(
this, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
t, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA,
"navigator.getUserMedia( {video : true}, ()=>{}, ()=>{} )",
UserFriendlyElementName::kWebXrVideoPermissionIndicator);
}
// Single indicator tests on entering immersive session
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestLocationIndicatorWhenPermissionInitiallyAllowed) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestLocationIndicatorWhenPermissionInitiallyAllowed) {
TestForInitialIndicatorForContentType(
this,
{{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true}});
t, {{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true}});
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestLocationIndicatorWhenPermissionInitiallyBlocked) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestLocationIndicatorWhenPermissionInitiallyBlocked) {
TestForInitialIndicatorForContentType(
this,
{{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false}});
t, {{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_BLOCK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false}});
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestLocationIndicatorWhenUserAskedToPrompt) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestLocationIndicatorWhenUserAskedToPrompt) {
TestForInitialIndicatorForContentType(
this,
{{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ASK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false}});
t, {{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ASK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false}});
}
// Indicator combination tests on entering immersive session
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestMultipleInitialIndicators_NoDevicesAllowed) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestMultipleInitialIndicators_NoDevicesAllowed) {
TestForInitialIndicatorForContentType(
this,
t,
{
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ASK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false},
......@@ -186,10 +182,10 @@ IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
});
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestMultipleInitialIndicators_OneDeviceAllowed) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestMultipleInitialIndicators_OneDeviceAllowed) {
TestForInitialIndicatorForContentType(
this,
t,
{
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ASK,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, false},
......@@ -200,32 +196,30 @@ IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
});
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestMultipleInitialIndicators_TwoDevicesAllowed) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestMultipleInitialIndicators_TwoDevicesAllowed) {
TestForInitialIndicatorForContentType(
this,
{
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_BLOCK,
UserFriendlyElementName::kWebXrAudioIndicator, false},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrVideoPermissionIndicator, true},
});
t, {
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_BLOCK,
UserFriendlyElementName::kWebXrAudioIndicator, false},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrVideoPermissionIndicator, true},
});
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestMultipleInitialIndicators_ThreeDevicesAllowed) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestMultipleInitialIndicators_ThreeDevicesAllowed) {
TestForInitialIndicatorForContentType(
this,
{
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrAudioIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrVideoPermissionIndicator, true},
});
t, {
{CONTENT_SETTINGS_TYPE_GEOLOCATION, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrLocationPermissionIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrAudioIndicator, true},
{CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, CONTENT_SETTING_ALLOW,
UserFriendlyElementName::kWebXrVideoPermissionIndicator, true},
});
}
} // namespace vr
......@@ -11,9 +11,10 @@
namespace vr {
// TODO(https://crbug.com/926048): Figure out why/fix the WMR version of this
// causes the real Mixed Reality Portal to open if it's installed.
// Tests that we can recover from a crash/disconnect on the DeviceService
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestDeviceServiceDisconnect) {
IN_PROC_BROWSER_TEST_F(WebXrVrOpenVrBrowserTest, TestDeviceServiceDisconnect) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("test_isolated_device_service_disconnect"));
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind_helpers.h"
#include "chrome/browser/vr/test/multi_class_browser_test.h"
#include "chrome/browser/vr/test/ui_utils.h"
#include "chrome/browser/vr/test/webxr_vr_browser_test.h"
#include "chrome/browser/vr/ui_test_input.h"
......@@ -12,7 +13,12 @@
namespace vr {
void InSessionPermissionNotificationCommon(WebXrVrBrowserTestStandard* t) {
// Tests that permission requests that occur when in an immersive session cause
// a notification to appear telling the user that a permission request is
// visible in the browser and that closing the browser while this is still
// displayed does not cause any issues.
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestInSessionPermissionNotificationCloseWhileVisible) {
// We need to use a local server for permission requests to not hit a DCHECK.
t->LoadUrlAndAwaitInitialization(
t->GetEmbeddedServerUrlForHtmlTestFile("generic_webxr_page"));
......@@ -29,15 +35,6 @@ void InSessionPermissionNotificationCommon(WebXrVrBrowserTestStandard* t) {
true /* visible */, base::DoNothing::Once());
}
// Tests that permission requests that occur when in an immersive session cause
// a notification to appear telling the user that a permission request is
// visible in the browser and that closing the browser while this is still
// displayed does not cause any issues.
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestInSessionPermissionNotificationCloseWhileVisible) {
InSessionPermissionNotificationCommon(this);
}
// TODO(https://crbug.com/920697): Add tests verifying the notification
// disappears when the permission is accepted/denied once we can query element
// visibility at any time using PermissionRequestManagerTestApi.
......
......@@ -87,10 +87,12 @@ void TestPresentationPixelsImpl(WebXrVrBrowserTestBase* t,
<< "Alpha channel of submitted color does not match expectation";
}
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestStandard, TestPresentationPixels) {
IN_PROC_BROWSER_TEST_F(WebVrOpenVrBrowserTest, TestPresentationPixels) {
TestPresentationPixelsImpl(this, "test_webvr_pixels");
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard, TestPresentationPixels) {
// TODO(https://crbug.com/926048): Port to WMR once the frame data is properly
// piped back to the test.
IN_PROC_BROWSER_TEST_F(WebXrVrOpenVrBrowserTest, TestPresentationPixels) {
TestPresentationPixelsImpl(this, "test_webxr_pixels");
}
......
......@@ -12,7 +12,7 @@ namespace vr {
// Tests that WebXR can still get an inline identity reference space when there
// are no runtimes available.
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestOpenVrDisabled,
IN_PROC_BROWSER_TEST_F(WebXrVrRuntimelessBrowserTest,
TestInlineIdentityAlwaysAvailable) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("test_inline_viewer_available"));
......@@ -21,7 +21,8 @@ IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestOpenVrDisabled,
}
#if BUILDFLAG(ENABLE_VR)
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestSensorless, TestSensorlessRejections) {
IN_PROC_BROWSER_TEST_F(WebXrVrRuntimelessBrowserTestSensorless,
TestSensorlessRejections) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("test_local_floor_reference_space_rejects"));
WaitOnJavaScriptStep();
......
......@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/vr/test/multi_class_browser_test.h"
#include "chrome/browser/vr/test/webvr_browser_test.h"
#include "chrome/browser/vr/test/webxr_vr_browser_test.h"
#include "url/gurl.h"
......@@ -27,11 +28,11 @@ void TestPoseDataUnfocusedTabImpl(WebXrVrBrowserTestBase* t,
t->EndTest(first_tab_web_contents);
}
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestStandard, TestPoseDataUnfocusedTab) {
IN_PROC_BROWSER_TEST_F(WebVrOpenVrBrowserTest, TestPoseDataUnfocusedTab) {
TestPoseDataUnfocusedTabImpl(this, "test_pose_data_unfocused_tab");
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard, TestPoseDataUnfocusedTab) {
TestPoseDataUnfocusedTabImpl(this, "webxr_test_pose_data_unfocused_tab");
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestPoseDataUnfocusedTab) {
TestPoseDataUnfocusedTabImpl(t, "webxr_test_pose_data_unfocused_tab");
}
} // namespace vr
......@@ -5,6 +5,7 @@
#include "chrome/browser/vr/test/webvr_browser_test.h"
#include "build/build_config.h"
#include "chrome/browser/vr/test/multi_class_browser_test.h"
#include "chrome/browser/vr/test/webxr_vr_browser_test.h"
#include "content/public/test/browser_test_utils.h"
......@@ -25,8 +26,8 @@ void TestApiDisabledWithoutFlagSetImpl(WebXrVrBrowserTestBase* t,
}
// Tests that WebVR does not return any devices if OpenVR support is disabled.
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestOpenVrDisabled,
TestWebVrNoDevicesWithoutOpenVr) {
IN_PROC_BROWSER_TEST_F(WebVrRuntimelessBrowserTest,
TestWebVrNoDevicesWithoutRuntime) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("generic_webvr_page"));
EXPECT_FALSE(XrDeviceFound())
......@@ -34,9 +35,10 @@ IN_PROC_BROWSER_TEST_F(WebVrBrowserTestOpenVrDisabled,
AssertNoJavaScriptErrors();
}
// Tests that WebXR does not return any devices if OpenVR support is disabled.
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestOpenVrDisabled,
TestWebXrNoDevicesWithoutOpenVr) {
// Tests that WebXR does not return any devices if all runtime support is
// disabled.
IN_PROC_BROWSER_TEST_F(WebXrVrRuntimelessBrowserTest,
TestWebXrNoDevicesWithoutRuntime) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("test_webxr_does_not_return_device"));
WaitOnJavaScriptStep();
......@@ -46,25 +48,26 @@ IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestOpenVrDisabled,
// Windows-specific tests.
#ifdef OS_WIN
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestWebVrDisabled,
IN_PROC_BROWSER_TEST_F(WebVrOpenVrBrowserTestWebVrDisabled,
TestWebVrDisabledWithoutFlagSet) {
TestApiDisabledWithoutFlagSetImpl(this,
"test_webvr_disabled_without_flag_set");
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestWebXrDisabled,
TestWebXrDisabledWithoutFlagSet) {
TestApiDisabledWithoutFlagSetImpl(this,
"test_webxr_disabled_without_flag_set");
IN_PROC_MULTI_CLASS_BROWSER_TEST_F2(WebXrVrOpenVrBrowserTestWebXrDisabled,
WebXrVrWmrBrowserTestWebXrDisabled,
WebXrVrBrowserTestBase,
TestWebXrDisabledWithoutFlagSet) {
TestApiDisabledWithoutFlagSetImpl(t, "test_webxr_disabled_without_flag_set");
}
// Tests that window.requestAnimationFrame continues to fire when we have a
// non-immersive WebXR session.
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestWindowRafFiresDuringNonImmersiveSession) {
LoadUrlAndAwaitInitialization(GetFileUrlForHtmlTestFile(
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(
TestWindowRafFiresDuringNonImmersiveSession) {
t->LoadUrlAndAwaitInitialization(t->GetFileUrlForHtmlTestFile(
"test_window_raf_fires_during_non_immersive_session"));
WaitOnJavaScriptStep();
EndTest();
t->WaitOnJavaScriptStep();
t->EndTest();
}
// Tests that a successful requestPresent or requestSession call enters
......@@ -76,11 +79,11 @@ void TestPresentationEntryImpl(WebXrVrBrowserTestBase* t,
t->AssertNoJavaScriptErrors();
}
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestStandard, TestRequestPresentEntersVr) {
IN_PROC_BROWSER_TEST_F(WebVrOpenVrBrowserTest, TestRequestPresentEntersVr) {
TestPresentationEntryImpl(this, "generic_webvr_page");
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard, TestRequestSessionEntersVr) {
TestPresentationEntryImpl(this, "generic_webxr_page");
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestRequestSessionEntersVr) {
TestPresentationEntryImpl(t, "generic_webxr_page");
}
// Tests that window.requestAnimationFrame continues to fire while in
......@@ -96,29 +99,27 @@ void TestWindowRafFiresWhilePresentingImpl(WebXrVrBrowserTestBase* t,
t->EndTest();
}
IN_PROC_BROWSER_TEST_F(WebVrBrowserTestStandard,
IN_PROC_BROWSER_TEST_F(WebVrOpenVrBrowserTest,
TestWindowRafFiresWhilePresenting) {
TestWindowRafFiresWhilePresentingImpl(
this, "test_window_raf_fires_while_presenting");
}
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestWindowRafFiresWhilePresenting) {
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestWindowRafFiresWhilePresenting) {
TestWindowRafFiresWhilePresentingImpl(
this, "webxr_test_window_raf_fires_while_presenting");
t, "webxr_test_window_raf_fires_while_presenting");
}
// Tests that non-immersive sessions stop receiving rAFs during an immersive
// session, but resume once the immersive session ends.
IN_PROC_BROWSER_TEST_F(WebXrVrBrowserTestStandard,
TestNonImmersiveStopsDuringImmersive) {
LoadUrlAndAwaitInitialization(
GetFileUrlForHtmlTestFile("test_non_immersive_stops_during_immersive"));
ExecuteStepAndWait("stepBeforeImmersive()");
EnterSessionWithUserGestureOrFail();
ExecuteStepAndWait("stepDuringImmersive()");
EndSessionOrFail();
ExecuteStepAndWait("stepAfterImmersive()");
EndTest();
WEBXR_VR_ALL_RUNTIMES_BROWSER_TEST_F(TestNonImmersiveStopsDuringImmersive) {
t->LoadUrlAndAwaitInitialization(t->GetFileUrlForHtmlTestFile(
"test_non_immersive_stops_during_immersive"));
t->ExecuteStepAndWait("stepBeforeImmersive()");
t->EnterSessionWithUserGestureOrFail();
t->ExecuteStepAndWait("stepDuringImmersive()");
t->EndSessionOrFail();
t->ExecuteStepAndWait("stepAfterImmersive()");
t->EndTest();
}
#endif // OS_WIN
......
......@@ -141,6 +141,8 @@ if (enable_vr) {
"windows/geometry_shader.h",
"windows/vertex_shader.h",
]
deps += [ ":directx_helpers" ]
}
if (is_win && enable_windows_mr) {
......@@ -266,7 +268,6 @@ if (enable_vr) {
if (is_win) {
static_library("directx_helpers") {
testonly = true
sources = [
"windows/d3d11_device_helpers.cc",
"windows/d3d11_device_helpers.h",
......
......@@ -419,7 +419,7 @@ void TestVRSystem::GetRecommendedRenderTargetSize(uint32_t* width,
}
void TestVRSystem::GetDXGIOutputInfo(int32_t* adapter_index) {
GetD3D11_1Adapter(adapter_index);
GetD3D11_1AdapterIndex(adapter_index);
}
void TestVRSystem::GetProjectionRaw(EVREye eye,
......
......@@ -12,14 +12,13 @@
namespace vr {
void GetD3D11_1Adapter(int32_t* adapter_index) {
void GetD3D11_1Adapter(int32_t* adapter_index, IDXGIAdapter** adapter) {
// Enumerate devices until we find one that supports 11.1.
*adapter_index = -1;
Microsoft::WRL::ComPtr<IDXGIFactory1> dxgi_factory;
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter;
bool success = SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory)));
DCHECK(success);
for (int i = 0; SUCCEEDED(dxgi_factory->EnumAdapters(i, &adapter)); ++i) {
for (int i = 0; SUCCEEDED(dxgi_factory->EnumAdapters(i, adapter)); ++i) {
D3D_FEATURE_LEVEL feature_levels[] = {D3D_FEATURE_LEVEL_11_1};
UINT flags = 0;
D3D_FEATURE_LEVEL feature_level_out = D3D_FEATURE_LEVEL_11_1;
......@@ -27,7 +26,7 @@ void GetD3D11_1Adapter(int32_t* adapter_index) {
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3d11_device_context;
if (SUCCEEDED(D3D11CreateDevice(
adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, NULL, flags, feature_levels,
*adapter, D3D_DRIVER_TYPE_UNKNOWN, NULL, flags, feature_levels,
base::size(feature_levels), D3D11_SDK_VERSION, &d3d11_device,
&feature_level_out, &d3d11_device_context))) {
*adapter_index = i;
......@@ -36,4 +35,9 @@ void GetD3D11_1Adapter(int32_t* adapter_index) {
}
}
void GetD3D11_1AdapterIndex(int32_t* adapter_index) {
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter;
GetD3D11_1Adapter(adapter_index, &adapter);
}
} // namespace vr
......@@ -5,11 +5,14 @@
#ifndef DEVICE_VR_WINDOWS_D3D11_DEVICE_HELPERS_H_
#define DEVICE_VR_WINDOWS_D3D11_DEVICE_HELPERS_H_
#include <dxgi.h>
#include <wrl.h>
#include <cstdint>
namespace vr {
void GetD3D11_1Adapter(int32_t* adapter_index);
void GetD3D11_1Adapter(int32_t* adapter_index, IDXGIAdapter** adapter);
void GetD3D11_1AdapterIndex(int32_t* adapter_index);
} // namespace vr
......
......@@ -11,6 +11,7 @@
#include "base/stl_util.h"
#include "device/vr/windows/d3d11_device_helpers.h"
#include "device/vr/windows_mixed_reality/wrappers/test/mock_wmr_holographic_frame.h"
namespace device {
......@@ -23,37 +24,15 @@ ABI::Windows::Graphics::Holographic::HolographicAdapterId
MockWMRHolographicSpace::PrimaryAdapterId() {
ABI::Windows::Graphics::Holographic::HolographicAdapterId ret;
// This is currently duplicated from the mock OpenVR implementation. It can
// be de-duped once https://crrev.com/c/1575030, which moves the DX11.1
// helper code into a standalone library.
// Enumerate devices until we find one that supports 11.1.
int32_t adapter_index = -1;
Microsoft::WRL::ComPtr<IDXGIFactory1> dxgi_factory;
Microsoft::WRL::ComPtr<IDXGIAdapter> adapter;
bool success = SUCCEEDED(CreateDXGIFactory1(IID_PPV_ARGS(&dxgi_factory)));
DCHECK(success);
for (int i = 0; SUCCEEDED(dxgi_factory->EnumAdapters(i, &adapter)); ++i) {
D3D_FEATURE_LEVEL feature_levels[] = {D3D_FEATURE_LEVEL_11_1};
UINT flags = 0;
D3D_FEATURE_LEVEL feature_level_out = D3D_FEATURE_LEVEL_11_1;
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> d3d11_device_context;
if (SUCCEEDED(D3D11CreateDevice(
adapter.Get(), D3D_DRIVER_TYPE_UNKNOWN, NULL, flags, feature_levels,
base::size(feature_levels), D3D11_SDK_VERSION, &d3d11_device,
&feature_level_out, &d3d11_device_context))) {
adapter_index = i;
break;
}
}
vr::GetD3D11_1Adapter(&adapter_index, &adapter);
if (adapter_index == -1)
return ret;
DXGI_ADAPTER_DESC description;
success = SUCCEEDED(adapter->GetDesc(&description));
if (!success) {
if (!SUCCEEDED(adapter->GetDesc(&description))) {
return ret;
}
......
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