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 7e5797911605c7419a338e00258528b5395a13ea..60b48458b57916ffe332b67a420f16a0f9478673 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 |
@@ -15,10 +15,12 @@ import android.nfc.NfcAdapter; |
import org.chromium.base.ThreadUtils; |
import org.chromium.content.browser.test.util.Criteria; |
import org.chromium.content.browser.test.util.CriteriaHelper; |
+import org.chromium.content_public.browser.WebContents; |
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 |
@@ -122,4 +124,21 @@ public class VrUtils { |
} |
}), timeout, POLL_CHECK_INTERVAL_SHORT_MS); |
} |
+ |
+ /** |
+ * Tries to get the HTML UI WebContents from VrShell. |
+ * @param timeout The timeout for getting the WebContents in milliseconds |
+ * @return The WebContents for the HTML UI. |
+ */ |
+ public static WebContents getVrShellUiContents(final int timeout) { |
+ final AtomicReference<VrShellImpl> vrShell = new AtomicReference<VrShellImpl>(); |
+ CriteriaHelper.pollUiThread(Criteria.equals(true, new Callable<Boolean>() { |
+ @Override |
+ public Boolean call() { |
+ vrShell.set((VrShellImpl) VrShellDelegate.getVrShellForTesting()); |
+ return vrShell.get() != null && vrShell.get().getUiContentsForTesting() != null; |
+ } |
+ }), timeout, POLL_CHECK_INTERVAL_LONG_MS); |
+ return vrShell.get().getUiContentsForTesting(); |
+ } |
} |