Commit b83c78ca authored by bsheedy's avatar bsheedy Committed by Commit Bot

Fix VrShellDelegate creation on Vega

Fixes VR tests failing on Vega due to the special TestVrShellDelegate
construction done via reflection on Vega devices not being updated
when the TestVrShellDelegate's constructor had an extra parameter added

TBR=mthiesse@chromium.org

Bug: 924696
Change-Id: Ib48f64609fad549a2af8078d376bab1601c1da13
Reviewed-on: https://chromium-review.googlesource.com/c/1431837
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625416}
parent 91433093
......@@ -89,6 +89,9 @@ public class VrModuleProvider implements ModuleInstallUi.FailureUiListener {
@VisibleForTesting
public static void setAlwaysUseFallbackDelegate(boolean useFallbackDelegate) {
// TODO(bsheedy): Change this to an "assert sDelegateProvider == null" once we change the
// restriction checking code to use the Daydream API directly so that a delegate provider
// doesn't get created during pre-test setup.
sDelegateProvider = null;
sAlwaysUseFallbackDelegate = useFallbackDelegate;
}
......
......@@ -22,18 +22,24 @@ import org.chromium.chrome.browser.vr.rules.VrModuleNotInstalled;
public class TestVrShellDelegate extends VrShellDelegate {
private Runnable mOnVSyncPausedCallback;
private static TestVrShellDelegate sInstance;
private static Description sTestDescription;
private boolean mDisableVrBrowsing;
private boolean mExpectingBroadcast;
private boolean mExpectingIntent;
private Boolean mAllow2dIntents;
public static void createTestVrShellDelegate(final ChromeActivity activity, Description desc) {
public static void createTestVrShellDelegate(final ChromeActivity activity) {
// Cannot make VrShellDelegate if we are faking that the VR module is not installed.
if (desc.getAnnotation(VrModuleNotInstalled.class) != null) return;
if (sTestDescription.getAnnotation(VrModuleNotInstalled.class) != null) return;
if (sInstance != null) return;
ThreadUtils.runOnUiThreadBlocking(() -> { sInstance = new TestVrShellDelegate(activity); });
}
// TODO(bsheedy): Maybe remove this and switch to setting a VrShellDelegateFactory instead.
public static void setDescription(Description desc) {
sTestDescription = desc;
}
public static TestVrShellDelegate getInstance() {
return sInstance;
}
......
......@@ -32,7 +32,7 @@ public class ChromeTabbedActivityVrTestRule
VrTestRuleUtils.evaluateVrTestRuleImpl(
base, desc, ChromeTabbedActivityVrTestRule.this, () -> {
startMainActivityOnBlankPage();
TestVrShellDelegate.createTestVrShellDelegate(getActivity(), desc);
TestVrShellDelegate.createTestVrShellDelegate(getActivity());
});
}
}, desc);
......
......@@ -35,7 +35,7 @@ public class CustomTabActivityVrTestRule extends CustomTabActivityTestRule imple
CustomTabsTestUtils.createMinimalCustomTabIntent(
InstrumentationRegistry.getTargetContext(),
"about:blank")));
TestVrShellDelegate.createTestVrShellDelegate(getActivity(), desc);
TestVrShellDelegate.createTestVrShellDelegate(getActivity());
});
}
}, desc);
......
......@@ -30,7 +30,7 @@ public class WebappActivityVrTestRule extends WebappActivityTestRule implements
VrTestRuleUtils.evaluateVrTestRuleImpl(
base, desc, WebappActivityVrTestRule.this, () -> {
startWebappActivity();
TestVrShellDelegate.createTestVrShellDelegate(getActivity(), desc);
TestVrShellDelegate.createTestVrShellDelegate(getActivity());
});
}
}, desc);
......
......@@ -63,6 +63,7 @@ public class VrTestRuleUtils extends XrTestRuleUtils {
if (desc.getAnnotation(VrModuleNotInstalled.class) != null) {
VrModuleProvider.setAlwaysUseFallbackDelegate(true);
}
TestVrShellDelegate.setDescription(desc);
VrTestRuleUtils.ensureNoVrActivitiesDisplayed();
HeadTrackingUtils.checkForAndApplyHeadTrackingModeAnnotation(rule, desc);
......
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