Commit edcb4e68 authored by Tibor Goldschwendt's avatar Tibor Goldschwendt Committed by Commit Bot

[vr] Fix Java unit tests interacting with VR if VR is disabled

This should fix the x86 downstream bots that are currently blocking
Canary release.

Bug: 864924
Change-Id: I0929373233e58897f91536a5e60813bf3db5e2f7
Reviewed-on: https://chromium-review.googlesource.com/1142126Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Tibor Goldschwendt <tiborg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576092}
parent 7be271d7
...@@ -35,4 +35,6 @@ public interface VrDelegate { ...@@ -35,4 +35,6 @@ public interface VrDelegate {
void maybeHandleVrIntentPreNative(ChromeActivity activity, Intent intent); void maybeHandleVrIntentPreNative(ChromeActivity activity, Intent intent);
void setVrModeEnabled(Activity activity, boolean enabled); void setVrModeEnabled(Activity activity, boolean enabled);
boolean bootsToVr(); boolean bootsToVr();
boolean isDaydreamReadyDevice();
boolean isDaydreamCurrentViewer();
} }
...@@ -112,6 +112,16 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -112,6 +112,16 @@ import org.chromium.chrome.browser.ChromeActivity;
return false; return false;
} }
@Override
public boolean isDaydreamReadyDevice() {
return false;
}
@Override
public boolean isDaydreamCurrentViewer() {
return false;
}
@Override @Override
public boolean isVrIntent(Intent intent) { public boolean isVrIntent(Intent intent) {
return false; return false;
......
...@@ -133,6 +133,16 @@ import org.chromium.chrome.browser.ChromeActivity; ...@@ -133,6 +133,16 @@ import org.chromium.chrome.browser.ChromeActivity;
return VrShellDelegate.bootsToVr(); return VrShellDelegate.bootsToVr();
} }
@Override
public boolean isDaydreamReadyDevice() {
return VrShellDelegate.isDaydreamReadyDevice();
}
@Override
public boolean isDaydreamCurrentViewer() {
return VrShellDelegate.isDaydreamCurrentViewer();
}
@Override @Override
public boolean isVrIntent(Intent intent) { public boolean isVrIntent(Intent intent) {
return VrIntentUtils.isVrIntent(intent); return VrIntentUtils.isVrIntent(intent);
......
...@@ -684,6 +684,11 @@ public class VrShellDelegate ...@@ -684,6 +684,11 @@ public class VrShellDelegate
return getVrClassesWrapper() != null && getVrClassesWrapper().isDaydreamReadyDevice(); return getVrClassesWrapper() != null && getVrClassesWrapper().isDaydreamReadyDevice();
} }
public static boolean isDaydreamCurrentViewer() {
if (sInstance != null) return sInstance.isDaydreamCurrentViewerInternal();
return getVrDaydreamApi().isDaydreamCurrentViewer();
}
/** /**
* @return A helper class for creating VR-specific classes that may not be available at compile * @return A helper class for creating VR-specific classes that may not be available at compile
* time. * time.
...@@ -797,11 +802,6 @@ public class VrShellDelegate ...@@ -797,11 +802,6 @@ public class VrShellDelegate
return isVrBrowsingSupported(activity) && vrSupportLevel == VrSupportLevel.VR_DAYDREAM; return isVrBrowsingSupported(activity) && vrSupportLevel == VrSupportLevel.VR_DAYDREAM;
} }
/* package */ static boolean isDaydreamCurrentViewer() {
if (sInstance != null) return sInstance.isDaydreamCurrentViewerInternal();
return getVrDaydreamApi().isDaydreamCurrentViewer();
}
/* package */ static boolean isInVrSession() { /* package */ static boolean isInVrSession() {
return getVrClassesWrapper() != null && getVrClassesWrapper().isInVrSession(); return getVrClassesWrapper() != null && getVrClassesWrapper().isInVrSession();
} }
......
...@@ -20,8 +20,7 @@ import org.chromium.base.test.BaseTestResult.PreTestHook; ...@@ -20,8 +20,7 @@ import org.chromium.base.test.BaseTestResult.PreTestHook;
import org.chromium.base.test.util.RestrictionSkipCheck; import org.chromium.base.test.util.RestrictionSkipCheck;
import org.chromium.base.test.util.SkipCheck; import org.chromium.base.test.util.SkipCheck;
import org.chromium.chrome.browser.ChromeVersionInfo; import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.vr.VrDaydreamApi; import org.chromium.chrome.browser.vr.VrModuleProvider;
import org.chromium.chrome.browser.vr.VrShellDelegate;
import org.chromium.chrome.test.util.ChromeRestriction; import org.chromium.chrome.test.util.ChromeRestriction;
import org.chromium.chrome.test.util.browser.ChromeModernDesign; import org.chromium.chrome.test.util.browser.ChromeModernDesign;
import org.chromium.chrome.test.util.browser.Features; import org.chromium.chrome.test.util.browser.Features;
...@@ -68,19 +67,19 @@ public class ChromeJUnit4ClassRunner extends ContentJUnit4ClassRunner { ...@@ -68,19 +67,19 @@ public class ChromeJUnit4ClassRunner extends ContentJUnit4ClassRunner {
} }
private boolean isDaydreamReady() { private boolean isDaydreamReady() {
return VrShellDelegate.isDaydreamReadyDevice(); return VrModuleProvider.getDelegate().isDaydreamReadyDevice();
} }
private boolean isDaydreamViewPaired() { private boolean isDaydreamViewPaired() {
final VrDaydreamApi daydreamApi = VrShellDelegate.getVrDaydreamApi(); if (!isDaydreamReady()) {
if (daydreamApi == null) {
return false; return false;
} }
// isDaydreamCurrentViewer() creates a concrete instance of DaydreamApi, // isDaydreamCurrentViewer() creates a concrete instance of DaydreamApi,
// which can only be done on the main thread // which can only be done on the main thread
try { try {
return ThreadUtils.runOnUiThreadBlocking(daydreamApi::isDaydreamCurrentViewer); return ThreadUtils.runOnUiThreadBlocking(
VrModuleProvider.getDelegate()::isDaydreamCurrentViewer);
} catch (CancellationException | ExecutionException | IllegalArgumentException e) { } catch (CancellationException | ExecutionException | IllegalArgumentException e) {
return false; return false;
} }
......
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