| Index: chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrUtils.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrUtils.java b/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrUtils.java
|
| index e16076eb898dfad009c338a980925dbc38c3a1bd..d63fa8529d6537fcb23f8211d6dbb24b6a53ab1c 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrUtils.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/vr_shell/VrUtils.java
|
| @@ -22,6 +22,7 @@ import org.chromium.content.browser.test.util.CriteriaHelper;
|
| import java.nio.ByteBuffer;
|
| import java.nio.ByteOrder;
|
| import java.util.concurrent.Callable;
|
| +import java.util.concurrent.atomic.AtomicReference;
|
|
|
| /**
|
| * Class containing static functions and constants that are useful for VR
|
| @@ -48,6 +49,23 @@ public class VrUtils {
|
| private static final int RESERVED = 456;
|
|
|
| /**
|
| + * Gets the VrShellDelegate instance on the UI thread, as otherwise the
|
| + * Choreographer obtained in VrShellDelegate's constructor is for the instrumentation
|
| + * thread instead of the UI thread.
|
| + * @return The browser's current VrShellDelegate instance
|
| + */
|
| + public static VrShellDelegate getVrShellDelegateInstance() {
|
| + final AtomicReference<VrShellDelegate> delegate = new AtomicReference<VrShellDelegate>();
|
| + ThreadUtils.runOnUiThreadBlocking(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + delegate.set(VrShellDelegate.getInstanceForTesting());
|
| + }
|
| + });
|
| + return delegate.get();
|
| + }
|
| +
|
| + /**
|
| * Forces the browser into VR mode via a VrShellDelegate call.
|
| */
|
| public static void forceEnterVr() {
|
|
|