| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.vr_shell; | 5 package org.chromium.chrome.browser.vr_shell; |
| 6 | 6 |
| 7 import static org.chromium.chrome.browser.vr_shell.VrTestRule.PAGE_LOAD_TIMEOUT_
S; |
| 7 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_CHECK_INTERVAL_L
ONG_MS; | 8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_CHECK_INTERVAL_L
ONG_MS; |
| 8 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_LONG_MS; | 9 import static org.chromium.chrome.browser.vr_shell.VrUtils.POLL_TIMEOUT_LONG_MS; |
| 9 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_D
EVICE_DAYDREAM; | 10 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_D
EVICE_DAYDREAM; |
| 10 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_D
EVICE_NON_DAYDREAM; | 11 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_D
EVICE_NON_DAYDREAM; |
| 11 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_DAYDREAM; | 12 import static org.chromium.chrome.test.util.ChromeRestriction.RESTRICTION_TYPE_V
IEWER_DAYDREAM; |
| 12 | 13 |
| 13 import android.content.pm.ActivityInfo; | 14 import android.support.test.InstrumentationRegistry; |
| 14 import android.support.test.filters.MediumTest; | 15 import android.support.test.filters.MediumTest; |
| 15 import android.support.test.filters.SmallTest; | 16 import android.support.test.filters.SmallTest; |
| 16 import android.view.ViewGroup; | 17 import android.view.ViewGroup; |
| 17 | 18 |
| 19 import org.junit.Assert; |
| 20 import org.junit.Before; |
| 21 import org.junit.Rule; |
| 22 import org.junit.Test; |
| 23 import org.junit.runner.RunWith; |
| 24 |
| 18 import org.chromium.base.ThreadUtils; | 25 import org.chromium.base.ThreadUtils; |
| 19 import org.chromium.base.test.util.CommandLineFlags; | 26 import org.chromium.base.test.util.CommandLineFlags; |
| 20 import org.chromium.base.test.util.Feature; | |
| 21 import org.chromium.base.test.util.Restriction; | 27 import org.chromium.base.test.util.Restriction; |
| 22 import org.chromium.base.test.util.RetryOnFailure; | 28 import org.chromium.base.test.util.RetryOnFailure; |
| 23 import org.chromium.chrome.R; | 29 import org.chromium.chrome.R; |
| 30 import org.chromium.chrome.browser.ChromeSwitches; |
| 24 import org.chromium.chrome.browser.compositor.CompositorViewHolder; | 31 import org.chromium.chrome.browser.compositor.CompositorViewHolder; |
| 25 import org.chromium.chrome.browser.tabmodel.TabModelSelector; | 32 import org.chromium.chrome.browser.tabmodel.TabModelSelector; |
| 26 import org.chromium.chrome.test.util.RenderUtils.ViewRenderer; | 33 import org.chromium.chrome.test.ChromeActivityTestRule; |
| 34 import org.chromium.chrome.test.ChromeJUnit4ClassRunner; |
| 35 import org.chromium.chrome.test.ChromeTabbedActivityTestRule; |
| 27 import org.chromium.content.browser.ContentViewCore; | 36 import org.chromium.content.browser.ContentViewCore; |
| 28 import org.chromium.content.browser.test.util.Criteria; | 37 import org.chromium.content.browser.test.util.Criteria; |
| 29 import org.chromium.content.browser.test.util.CriteriaHelper; | 38 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 30 | 39 |
| 31 import java.io.IOException; | |
| 32 import java.util.concurrent.Callable; | 40 import java.util.concurrent.Callable; |
| 33 import java.util.concurrent.TimeoutException; | 41 import java.util.concurrent.TimeoutException; |
| 34 import java.util.concurrent.atomic.AtomicReference; | 42 import java.util.concurrent.atomic.AtomicReference; |
| 35 | 43 |
| 36 /** | 44 /** |
| 37 * End-to-end tests for VR browsing, aka "VR Shell". This may require | 45 * End-to-end tests for VR browsing, aka "VR Shell". This may require |
| 38 * interacting with WebVR in addition to the VR browser, so inherit from | 46 * interacting with WebVR in addition to the VR browser, so inherit from |
| 39 * VrTestBase for the WebVR test framework. | 47 * VrTestBase for the WebVR test framework. |
| 40 */ | 48 */ |
| 41 @CommandLineFlags.Add("enable-features=VrShell") | 49 @RunWith(ChromeJUnit4ClassRunner.class) |
| 42 public class VrShellTest extends VrTestBase { | 50 |
| 43 private static final String GOLDEN_DIR = | 51 @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, |
| 44 "chrome/test/data/android/render_tests"; | 52 ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG, "enable-features
=VrShell"}) |
| 53 public class VrShellTest { |
| 54 @Rule |
| 55 public ChromeTabbedActivityTestRule mActivityTestRule = new ChromeTabbedActi
vityTestRule(); |
| 45 | 56 |
| 46 private VrShellDelegate mDelegate; | 57 private VrShellDelegate mDelegate; |
| 47 private ViewRenderer mViewRenderer; | |
| 48 | 58 |
| 49 @Override | 59 @Before |
| 50 protected void setUp() throws Exception { | 60 public void setUp() throws Exception { |
| 51 super.setUp(); | 61 mActivityTestRule.startMainActivityOnBlankPage(); |
| 52 mDelegate = VrUtils.getVrShellDelegateInstance(); | 62 mDelegate = VrUtils.getVrShellDelegateInstance(); |
| 53 } | 63 } |
| 54 | 64 |
| 55 @Override | |
| 56 public void startMainActivity() throws InterruptedException { | |
| 57 startMainActivityOnBlankPage(); | |
| 58 mViewRenderer = new ViewRenderer(getActivity(), | |
| 59 GOLDEN_DIR, this.getClass().getSimpleName()); | |
| 60 } | |
| 61 | |
| 62 private void enterExitVrMode(boolean supported) { | 65 private void enterExitVrMode(boolean supported) { |
| 63 MockVrDaydreamApi mockApi = new MockVrDaydreamApi(); | 66 MockVrDaydreamApi mockApi = new MockVrDaydreamApi(); |
| 64 if (!supported) { | 67 if (!supported) { |
| 65 mDelegate.overrideDaydreamApiForTesting(mockApi); | 68 mDelegate.overrideDaydreamApiForTesting(mockApi); |
| 66 } | 69 } |
| 67 VrUtils.forceEnterVr(); | 70 VrUtils.forceEnterVr(); |
| 68 if (supported) { | 71 if (supported) { |
| 69 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); | 72 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); |
| 70 assertTrue(VrShellDelegate.isInVr()); | 73 Assert.assertTrue(VrShellDelegate.isInVr()); |
| 71 } else { | 74 } else { |
| 72 assertFalse(mockApi.getLaunchInVrCalled()); | 75 Assert.assertFalse(mockApi.getLaunchInVrCalled()); |
| 73 assertFalse(VrShellDelegate.isInVr()); | 76 Assert.assertFalse(VrShellDelegate.isInVr()); |
| 74 } | 77 } |
| 75 VrUtils.forceExitVr(mDelegate); | 78 VrUtils.forceExitVr(mDelegate); |
| 76 assertFalse(VrShellDelegate.isInVr()); | 79 Assert.assertFalse(VrShellDelegate.isInVr()); |
| 77 } | |
| 78 | |
| 79 private void enterExitVrModeImage(boolean supported) throws IOException { | |
| 80 int prevOrientation = getActivity().getRequestedOrientation(); | |
| 81 getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LA
NDSCAPE); | |
| 82 getInstrumentation().waitForIdleSync(); | |
| 83 mViewRenderer.renderAndCompare( | |
| 84 getActivity().getWindow().getDecorView().getRootView(), | |
| 85 "blank_page"); | |
| 86 | |
| 87 VrUtils.forceEnterVr(); | |
| 88 // Currently, screenshots only show the static UI overlay, not the | |
| 89 // actual content. Thus, 1:1 pixel checking is reliable until a | |
| 90 // way to take screenshots of VR content is added, in which case | |
| 91 // % similarity or some other method will need to be used. We're | |
| 92 // assuming that if the UI overlay is visible, then the device has | |
| 93 // successfully entered VR mode. | |
| 94 if (supported) { | |
| 95 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); | |
| 96 mViewRenderer.renderAndCompare( | |
| 97 getActivity().getWindow().getDecorView().getRootView(), | |
| 98 "vr_entered"); | |
| 99 } else { | |
| 100 // TODO(bsheedy): Find a good way to wait before taking a screenshot | |
| 101 // when running on an unsupported device | |
| 102 mViewRenderer.renderAndCompare( | |
| 103 getActivity().getWindow().getDecorView().getRootView(), | |
| 104 "blank_page"); | |
| 105 } | |
| 106 | |
| 107 VrUtils.forceExitVr(mDelegate); | |
| 108 getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LA
NDSCAPE); | |
| 109 getInstrumentation().waitForIdleSync(); | |
| 110 mViewRenderer.renderAndCompare( | |
| 111 getActivity().getWindow().getDecorView().getRootView(), | |
| 112 "blank_page"); | |
| 113 | |
| 114 getActivity().setRequestedOrientation(prevOrientation); | |
| 115 } | 80 } |
| 116 | 81 |
| 117 private void enterVrModeNfc(boolean supported) { | 82 private void enterVrModeNfc(boolean supported) { |
| 118 getInstrumentation().waitForIdleSync(); | 83 InstrumentationRegistry.getInstrumentation().waitForIdleSync(); |
| 119 VrUtils.simNfc(getActivity()); | 84 VrUtils.simNfc(mActivityTestRule.getActivity()); |
| 120 if (supported) { | 85 if (supported) { |
| 121 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); | 86 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); |
| 122 assertTrue(VrShellDelegate.isInVr()); | 87 Assert.assertTrue(VrShellDelegate.isInVr()); |
| 123 } else { | 88 } else { |
| 124 assertFalse(VrShellDelegate.isInVr()); | 89 Assert.assertFalse(VrShellDelegate.isInVr()); |
| 125 } | 90 } |
| 126 VrUtils.forceExitVr(mDelegate); | 91 VrUtils.forceExitVr(mDelegate); |
| 127 // TODO(bsheedy): Figure out why NFC tests cause the next test to fail | 92 // TODO(bsheedy): Figure out why NFC tests cause the next test to fail |
| 128 // to enter VR unless we sleep for some amount of time after exiting VR | 93 // to enter VR unless we sleep for some amount of time after exiting VR |
| 129 // in the NFC test | 94 // in the NFC test |
| 130 } | 95 } |
| 131 | 96 |
| 132 /** | 97 /** |
| 133 * Verifies that browser successfully enters VR mode when Daydream headset | 98 * Verifies that browser successfully enters VR mode when Daydream headset |
| 134 * NFC tag is scanned on a Daydream-ready device. Requires that the phone | 99 * NFC tag is scanned on a Daydream-ready device. Requires that the phone |
| 135 * is unlocked. | 100 * is unlocked. |
| 136 */ | 101 */ |
| 102 @Test |
| 137 @Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYD
REAM}) | 103 @Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYD
REAM}) |
| 138 @MediumTest | 104 @MediumTest |
| 139 public void testSimNfcSupported() { | 105 public void testSimNfcSupported() { |
| 140 enterVrModeNfc(true); | 106 enterVrModeNfc(true); |
| 141 } | 107 } |
| 142 | 108 |
| 143 /** | 109 /** |
| 144 * Verifies that the browser does not enter VR mode on Non-Daydream-ready | 110 * Verifies that the browser does not enter VR mode on Non-Daydream-ready |
| 145 * devices when the Daydream headset NFC tag is scanned. | 111 * devices when the Daydream headset NFC tag is scanned. |
| 146 */ | 112 */ |
| 113 @Test |
| 147 @Restriction(RESTRICTION_TYPE_DEVICE_NON_DAYDREAM) | 114 @Restriction(RESTRICTION_TYPE_DEVICE_NON_DAYDREAM) |
| 148 @SmallTest | 115 @SmallTest |
| 149 public void testSimNfcUnsupported() { | 116 public void testSimNfcUnsupported() { |
| 150 enterVrModeNfc(false); | 117 enterVrModeNfc(false); |
| 151 } | 118 } |
| 152 | 119 |
| 153 /** | 120 /** |
| 154 * Verifies that browser successfully enters and exits VR mode when told to | 121 * Verifies that browser successfully enters and exits VR mode when told to |
| 155 * on Daydream-ready devices. Requires that the phone is unlocked. | 122 * on Daydream-ready devices. Requires that the phone is unlocked. |
| 156 */ | 123 */ |
| 124 @Test |
| 157 @Restriction(RESTRICTION_TYPE_DEVICE_DAYDREAM) | 125 @Restriction(RESTRICTION_TYPE_DEVICE_DAYDREAM) |
| 158 @SmallTest | 126 @SmallTest |
| 159 public void testEnterExitVrModeSupported() { | 127 public void testEnterExitVrModeSupported() { |
| 160 enterExitVrMode(true); | 128 enterExitVrMode(true); |
| 161 } | 129 } |
| 162 | 130 |
| 163 /** | 131 /** |
| 164 * Verifies that browser does not enter VR mode on Non-Daydream-ready device
s. | 132 * Verifies that browser does not enter VR mode on Non-Daydream-ready device
s. |
| 165 */ | 133 */ |
| 134 @Test |
| 166 @Restriction(RESTRICTION_TYPE_DEVICE_NON_DAYDREAM) | 135 @Restriction(RESTRICTION_TYPE_DEVICE_NON_DAYDREAM) |
| 167 @SmallTest | 136 @SmallTest |
| 168 public void testEnterExitVrModeUnsupported() { | 137 public void testEnterExitVrModeUnsupported() { |
| 169 enterExitVrMode(false); | 138 enterExitVrMode(false); |
| 170 } | 139 } |
| 171 | 140 |
| 172 /** | 141 /** |
| 173 * Verifies that browser successfully enters and exits VR mode when told to | |
| 174 * on Daydream-ready devices via a screendiffing check. | |
| 175 * Requires that the phone is unlocked. | |
| 176 */ | |
| 177 @Restriction(RESTRICTION_TYPE_DEVICE_DAYDREAM) | |
| 178 @Feature("RenderTest") | |
| 179 @MediumTest | |
| 180 public void testEnterExitVrModeSupportedImage() throws IOException { | |
| 181 enterExitVrModeImage(true); | |
| 182 } | |
| 183 | |
| 184 /** | |
| 185 * Verifies that browser does not enter VR mode on Non-Daydream-ready device
s | |
| 186 * via a screendiffing check. Requires that the phone is unlocked. | |
| 187 */ | |
| 188 @Restriction(RESTRICTION_TYPE_DEVICE_NON_DAYDREAM) | |
| 189 @Feature("RenderTest") | |
| 190 @MediumTest | |
| 191 public void testEnterExitVrModeUnsupportedImage() throws IOException { | |
| 192 enterExitVrModeImage(false); | |
| 193 } | |
| 194 | |
| 195 /** | |
| 196 * Verifies that swiping up/down on the Daydream controller's touchpad scrol
ls | 142 * Verifies that swiping up/down on the Daydream controller's touchpad scrol
ls |
| 197 * the webpage while in the VR browser. | 143 * the webpage while in the VR browser. |
| 198 */ | 144 */ |
| 145 @Test |
| 199 @Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYD
REAM}) | 146 @Restriction({RESTRICTION_TYPE_DEVICE_DAYDREAM, RESTRICTION_TYPE_VIEWER_DAYD
REAM}) |
| 200 @MediumTest | 147 @MediumTest |
| 201 public void testControllerScrolling() throws InterruptedException { | 148 public void testControllerScrolling() throws InterruptedException { |
| 202 // Load page in VR and make sure the controller is pointed at the conten
t quad | 149 // Load page in VR and make sure the controller is pointed at the conten
t quad |
| 203 loadUrl("chrome://credits", PAGE_LOAD_TIMEOUT_S); | 150 mActivityTestRule.loadUrl("chrome://credits", PAGE_LOAD_TIMEOUT_S); |
| 204 VrUtils.forceEnterVr(); | 151 VrUtils.forceEnterVr(); |
| 205 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); | 152 VrUtils.waitForVrSupported(POLL_TIMEOUT_LONG_MS); |
| 206 EmulatedVrController controller = new EmulatedVrController(getActivity()
); | 153 EmulatedVrController controller = new EmulatedVrController(mActivityTest
Rule.getActivity()); |
| 207 final ContentViewCore cvc = getActivity().getActivityTab().getActiveCont
entViewCore(); | 154 final ContentViewCore cvc = |
| 155 mActivityTestRule.getActivity().getActivityTab().getActiveConten
tViewCore(); |
| 208 controller.recenterView(); | 156 controller.recenterView(); |
| 209 | 157 |
| 210 // Wait for the page to be scrollable | 158 // Wait for the page to be scrollable |
| 211 CriteriaHelper.pollUiThread(new Criteria() { | 159 CriteriaHelper.pollUiThread(new Criteria() { |
| 212 @Override | 160 @Override |
| 213 public boolean isSatisfied() { | 161 public boolean isSatisfied() { |
| 214 return cvc.computeVerticalScrollRange() > cvc.getContainerView()
.getHeight(); | 162 return cvc.computeVerticalScrollRange() > cvc.getContainerView()
.getHeight(); |
| 215 } | 163 } |
| 216 }, POLL_TIMEOUT_LONG_MS, POLL_CHECK_INTERVAL_LONG_MS); | 164 }, POLL_TIMEOUT_LONG_MS, POLL_CHECK_INTERVAL_LONG_MS); |
| 217 | 165 |
| 218 // Test that scrolling down works | 166 // Test that scrolling down works |
| 219 int startScrollY = cvc.getNativeScrollYForTest(); | 167 int startScrollY = cvc.getNativeScrollYForTest(); |
| 220 // Arbitrary, but valid values to scroll smoothly | 168 // Arbitrary, but valid values to scroll smoothly |
| 221 int scrollSteps = 20; | 169 int scrollSteps = 20; |
| 222 int scrollSpeed = 60; | 170 int scrollSpeed = 60; |
| 223 controller.scrollDown(scrollSteps, scrollSpeed); | 171 controller.scrollDown(scrollSteps, scrollSpeed); |
| 224 int endScrollY = cvc.getNativeScrollYForTest(); | 172 int endScrollY = cvc.getNativeScrollYForTest(); |
| 225 assertTrue("Controller was able to scroll down", startScrollY < endScrol
lY); | 173 Assert.assertTrue("Controller was able to scroll down", startScrollY < e
ndScrollY); |
| 226 | 174 |
| 227 // Test that scrolling up works | 175 // Test that scrolling up works |
| 228 startScrollY = endScrollY; | 176 startScrollY = endScrollY; |
| 229 controller.scrollUp(scrollSteps, scrollSpeed); | 177 controller.scrollUp(scrollSteps, scrollSpeed); |
| 230 endScrollY = cvc.getNativeScrollYForTest(); | 178 endScrollY = cvc.getNativeScrollYForTest(); |
| 231 assertTrue("Controller was able to scroll up", startScrollY > endScrollY
); | 179 Assert.assertTrue("Controller was able to scroll up", startScrollY > end
ScrollY); |
| 232 } | 180 } |
| 233 | 181 |
| 234 /** | 182 /** |
| 235 * Verify that resizing the CompositorViewHolder does not cause the current
tab to resize while | 183 * Verify that resizing the CompositorViewHolder does not cause the current
tab to resize while |
| 236 * the CompositorViewHolder is detached from the TabModelSelector. See crbug
.com/680240. | 184 * the CompositorViewHolder is detached from the TabModelSelector. See crbug
.com/680240. |
| 237 * @throws InterruptedException | 185 * @throws InterruptedException |
| 238 * @throws TimeoutException | 186 * @throws TimeoutException |
| 239 */ | 187 */ |
| 188 @Test |
| 240 @SmallTest | 189 @SmallTest |
| 241 @RetryOnFailure | 190 @RetryOnFailure |
| 242 public void testResizeWithCompositorViewHolderDetached() | 191 public void testResizeWithCompositorViewHolderDetached() |
| 243 throws InterruptedException, TimeoutException { | 192 throws InterruptedException, TimeoutException { |
| 244 final AtomicReference<TabModelSelector> selector = new AtomicReference<>
(); | 193 final AtomicReference<TabModelSelector> selector = new AtomicReference<>
(); |
| 245 final AtomicReference<Integer> oldWidth = new AtomicReference<>(); | 194 final AtomicReference<Integer> oldWidth = new AtomicReference<>(); |
| 246 final int testWidth = 123; | 195 final int testWidth = 123; |
| 247 final ContentViewCore cvc = getActivity().getActivityTab().getActiveCont
entViewCore(); | 196 final ContentViewCore cvc = |
| 197 mActivityTestRule.getActivity().getActivityTab().getActiveConten
tViewCore(); |
| 248 | 198 |
| 249 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 199 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 250 @Override | 200 @Override |
| 251 public void run() { | 201 public void run() { |
| 252 CompositorViewHolder compositorViewHolder = (CompositorViewHolde
r) | 202 CompositorViewHolder compositorViewHolder = |
| 253 getActivity().findViewById(R.id.compositor_view_holder); | 203 (CompositorViewHolder) mActivityTestRule.getActivity().f
indViewById( |
| 204 R.id.compositor_view_holder); |
| 254 selector.set(compositorViewHolder.detachForVr()); | 205 selector.set(compositorViewHolder.detachForVr()); |
| 255 oldWidth.set(cvc.getViewportWidthPix()); | 206 oldWidth.set(cvc.getViewportWidthPix()); |
| 256 | 207 |
| 257 ViewGroup.LayoutParams layoutParams = compositorViewHolder.getLa
youtParams(); | 208 ViewGroup.LayoutParams layoutParams = compositorViewHolder.getLa
youtParams(); |
| 258 layoutParams.width = testWidth; | 209 layoutParams.width = testWidth; |
| 259 layoutParams.height = 456; | 210 layoutParams.height = 456; |
| 260 compositorViewHolder.requestLayout(); | 211 compositorViewHolder.requestLayout(); |
| 261 } | 212 } |
| 262 }); | 213 }); |
| 263 CriteriaHelper.pollUiThread(Criteria.equals(testWidth, new Callable<Inte
ger>() { | 214 CriteriaHelper.pollUiThread(Criteria.equals(testWidth, new Callable<Inte
ger>() { |
| 264 @Override | 215 @Override |
| 265 public Integer call() { | 216 public Integer call() { |
| 266 return getActivity().findViewById(R.id.compositor_view_holder).g
etMeasuredWidth(); | 217 return mActivityTestRule.getActivity() |
| 218 .findViewById(R.id.compositor_view_holder) |
| 219 .getMeasuredWidth(); |
| 267 } | 220 } |
| 268 })); | 221 })); |
| 269 | 222 |
| 270 assertEquals("Viewport width should not have changed when resizing a det
ached " | 223 Assert.assertEquals("Viewport width should not have changed when resizin
g a detached " |
| 271 + "CompositorViewHolder", | 224 + "CompositorViewHolder", |
| 272 cvc.getViewportWidthPix(), | 225 cvc.getViewportWidthPix(), oldWidth.get().intValue()); |
| 273 oldWidth.get().intValue()); | |
| 274 | 226 |
| 275 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 227 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 276 @Override | 228 @Override |
| 277 public void run() { | 229 public void run() { |
| 278 CompositorViewHolder compositorViewHolder = (CompositorViewHolde
r) getActivity() | 230 CompositorViewHolder compositorViewHolder = |
| 279 .findViewById(R.id.compositor_view_holder); | 231 (CompositorViewHolder) mActivityTestRule.getActivity().f
indViewById( |
| 232 R.id.compositor_view_holder); |
| 280 compositorViewHolder.onExitVr(selector.get()); | 233 compositorViewHolder.onExitVr(selector.get()); |
| 281 } | 234 } |
| 282 }); | 235 }); |
| 283 | 236 |
| 284 CriteriaHelper.pollUiThread(Criteria.equals(testWidth, new Callable<Inte
ger>() { | 237 CriteriaHelper.pollUiThread(Criteria.equals(testWidth, new Callable<Inte
ger>() { |
| 285 @Override | 238 @Override |
| 286 public Integer call() { | 239 public Integer call() { |
| 287 return cvc.getViewportWidthPix(); | 240 return cvc.getViewportWidthPix(); |
| 288 } | 241 } |
| 289 })); | 242 })); |
| 290 } | 243 } |
| 291 } | 244 } |
| OLD | NEW |