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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.pm.ActivityInfo; | 7 import android.content.pm.ActivityInfo; |
8 import android.graphics.Rect; | 8 import android.graphics.Rect; |
9 import android.support.test.InstrumentationRegistry; | 9 import android.support.test.InstrumentationRegistry; |
10 import android.support.test.filters.MediumTest; | 10 import android.support.test.filters.MediumTest; |
11 | 11 |
12 import org.junit.Assert; | 12 import org.junit.Assert; |
13 import org.junit.Before; | 13 import org.junit.Before; |
14 import org.junit.Rule; | 14 import org.junit.Rule; |
15 import org.junit.Test; | 15 import org.junit.Test; |
16 import org.junit.runner.RunWith; | 16 import org.junit.runner.RunWith; |
17 | 17 |
18 import org.chromium.base.test.util.CommandLineFlags; | 18 import org.chromium.base.test.util.CommandLineFlags; |
19 import org.chromium.base.test.util.Feature; | 19 import org.chromium.base.test.util.Feature; |
20 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; | 20 import org.chromium.content.browser.test.ContentJUnit4ClassRunner; |
21 import org.chromium.content.browser.test.util.Criteria; | 21 import org.chromium.content.browser.test.util.Criteria; |
22 import org.chromium.content.browser.test.util.CriteriaHelper; | 22 import org.chromium.content.browser.test.util.CriteriaHelper; |
23 import org.chromium.content.browser.test.util.DOMUtils; | 23 import org.chromium.content.browser.test.util.DOMUtils; |
24 import org.chromium.content.browser.test.util.JavaScriptUtils; | 24 import org.chromium.content.browser.test.util.JavaScriptUtils; |
25 import org.chromium.content.browser.test.util.UiUtils; | 25 import org.chromium.content.browser.test.util.UiUtils; |
26 import org.chromium.content.common.ContentSwitches; | 26 import org.chromium.content.common.ContentSwitches; |
27 import org.chromium.content_shell_apk.ContentShellActivityTestRule; | 27 import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
28 import org.chromium.media.MediaSwitches; | |
29 import org.chromium.ui.base.DeviceFormFactor; | 28 import org.chromium.ui.base.DeviceFormFactor; |
30 | 29 |
31 import java.util.concurrent.Callable; | 30 import java.util.concurrent.Callable; |
32 import java.util.concurrent.TimeoutException; | 31 import java.util.concurrent.TimeoutException; |
33 | 32 |
34 /** | 33 /** |
35 * Integration tests for the feature that auto locks the orientation when a vide
o goes fullscreen. | 34 * Integration tests for the feature that auto locks the orientation when a vide
o goes fullscreen. |
36 * See also chrome layer org.chromium.chrome.browser.VideoFullscreenOrientationL
ockChromeTest | 35 * See also chrome layer org.chromium.chrome.browser.VideoFullscreenOrientationL
ockChromeTest |
37 ContentSwitches.ENABLE_TEST_INTENTS */ | 36 ContentSwitches.ENABLE_TEST_INTENTS */ |
38 @RunWith(ContentJUnit4ClassRunner.class) | 37 @RunWith(ContentJUnit4ClassRunner.class) |
39 @CommandLineFlags.Add({"enable-features=VideoFullscreenOrientationLock", | 38 @CommandLineFlags.Add({"enable-features=VideoFullscreenOrientationLock", |
40 MediaSwitches.IGNORE_AUTOPLAY_RESTRICTIONS_FOR_TESTS, ContentSwitches.EN
ABLE_TEST_INTENTS}) | 39 ContentSwitches.DISABLE_GESTURE_REQUIREMENT_FOR_MEDIA_PLAYBACK, |
| 40 ContentSwitches.ENABLE_TEST_INTENTS}) |
41 public class VideoFullscreenOrientationLockTest { | 41 public class VideoFullscreenOrientationLockTest { |
42 @Rule | 42 @Rule |
43 public ContentShellActivityTestRule mActivityTestRule = new ContentShellActi
vityTestRule(); | 43 public ContentShellActivityTestRule mActivityTestRule = new ContentShellActi
vityTestRule(); |
44 | 44 |
45 private static final String TEST_URL = "content/test/data/media/video-player
.html"; | 45 private static final String TEST_URL = "content/test/data/media/video-player
.html"; |
46 private static final String VIDEO_ID = "video"; | 46 private static final String VIDEO_ID = "video"; |
47 | 47 |
48 private void waitForContentsFullscreenState(boolean fullscreenValue) { | 48 private void waitForContentsFullscreenState(boolean fullscreenValue) { |
49 CriteriaHelper.pollInstrumentationThread( | 49 CriteriaHelper.pollInstrumentationThread( |
50 Criteria.equals(fullscreenValue, new Callable<Boolean>() { | 50 Criteria.equals(fullscreenValue, new Callable<Boolean>() { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Should be locked to landscape now, `waitUntilLockedToLandscape` will
throw otherwise. | 234 // Should be locked to landscape now, `waitUntilLockedToLandscape` will
throw otherwise. |
235 waitUntilLockedToLandscape(); | 235 waitUntilLockedToLandscape(); |
236 | 236 |
237 // Leave fullscreen by navigating page. | 237 // Leave fullscreen by navigating page. |
238 JavaScriptUtils.executeJavaScriptAndWaitForResult( | 238 JavaScriptUtils.executeJavaScriptAndWaitForResult( |
239 mActivityTestRule.getWebContents(), "location.reload();"); | 239 mActivityTestRule.getWebContents(), "location.reload();"); |
240 waitForContentsFullscreenState(false); | 240 waitForContentsFullscreenState(false); |
241 waitUntilUnlocked(); | 241 waitUntilUnlocked(); |
242 } | 242 } |
243 } | 243 } |
OLD | NEW |