OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.content.Intent; | 7 import android.content.Intent; |
8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.support.test.filters.MediumTest; | 10 import android.support.test.filters.MediumTest; |
11 import android.view.KeyEvent; | 11 import android.view.KeyEvent; |
12 | 12 |
13 import org.chromium.base.test.util.CommandLineFlags; | 13 import org.chromium.base.test.util.CommandLineFlags; |
14 import org.chromium.base.test.util.Feature; | 14 import org.chromium.base.test.util.Feature; |
| 15 import org.chromium.base.test.util.RetryOnFailure; |
15 import org.chromium.base.test.util.UrlUtils; | 16 import org.chromium.base.test.util.UrlUtils; |
16 import org.chromium.chrome.browser.download.DownloadUtils; | 17 import org.chromium.chrome.browser.download.DownloadUtils; |
17 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; | 18 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; |
18 import org.chromium.content.browser.test.util.Criteria; | 19 import org.chromium.content.browser.test.util.Criteria; |
19 import org.chromium.content.browser.test.util.CriteriaHelper; | 20 import org.chromium.content.browser.test.util.CriteriaHelper; |
20 import org.chromium.content.browser.test.util.DOMUtils; | 21 import org.chromium.content.browser.test.util.DOMUtils; |
21 import org.chromium.content.browser.test.util.JavaScriptUtils; | 22 import org.chromium.content.browser.test.util.JavaScriptUtils; |
22 import org.chromium.content_public.browser.WebContents; | 23 import org.chromium.content_public.browser.WebContents; |
23 import org.chromium.media.MediaSwitches; | 24 import org.chromium.media.MediaSwitches; |
24 import org.chromium.ui.base.DeviceFormFactor; | 25 import org.chromium.ui.base.DeviceFormFactor; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 }); | 92 }); |
92 } | 93 } |
93 | 94 |
94 @Override | 95 @Override |
95 public void startMainActivity() throws InterruptedException { | 96 public void startMainActivity() throws InterruptedException { |
96 startMainActivityWithURL(UrlUtils.getIsolatedTestFileUrl(TEST_URL)); | 97 startMainActivityWithURL(UrlUtils.getIsolatedTestFileUrl(TEST_URL)); |
97 } | 98 } |
98 | 99 |
99 @MediumTest | 100 @MediumTest |
100 @Feature({"VideoFullscreenOrientationLock"}) | 101 @Feature({"VideoFullscreenOrientationLock"}) |
| 102 @RetryOnFailure // The final waitForContentsFullscreenState(false) is flaky
- crbug.com/711005. |
101 public void testUnlockWithDownloadViewerActivity() throws Exception { | 103 public void testUnlockWithDownloadViewerActivity() throws Exception { |
102 if (DeviceFormFactor.isTablet(getInstrumentation().getContext())) return
; | 104 if (DeviceFormFactor.isTablet(getInstrumentation().getContext())) return
; |
103 | 105 |
104 // Start playback to guarantee it's properly loaded. | 106 // Start playback to guarantee it's properly loaded. |
105 assertTrue(DOMUtils.isMediaPaused(getWebContents(), VIDEO_ID)); | 107 assertTrue(DOMUtils.isMediaPaused(getWebContents(), VIDEO_ID)); |
106 DOMUtils.playMedia(getWebContents(), VIDEO_ID); | 108 DOMUtils.playMedia(getWebContents(), VIDEO_ID); |
107 DOMUtils.waitForMediaPlay(getWebContents(), VIDEO_ID); | 109 DOMUtils.waitForMediaPlay(getWebContents(), VIDEO_ID); |
108 | 110 |
109 // Trigger requestFullscreen() via a click on a button. | 111 // Trigger requestFullscreen() via a click on a button. |
110 assertTrue(DOMUtils.clickNode(getActivity().getCurrentContentViewCore(),
"fullscreen")); | 112 assertTrue(DOMUtils.clickNode(getActivity().getCurrentContentViewCore(),
"fullscreen")); |
111 waitForContentsFullscreenState(true); | 113 waitForContentsFullscreenState(true); |
112 | 114 |
113 // Should be locked to landscape now, `waitUntilLockedToLandscape` will
throw otherwise. | 115 // Should be locked to landscape now, `waitUntilLockedToLandscape` will
throw otherwise. |
114 waitUntilLockedToLandscape(); | 116 waitUntilLockedToLandscape(); |
115 | 117 |
116 // Orientation lock should be disabled when download viewer activity is
started. | 118 // Orientation lock should be disabled when download viewer activity is
started. |
117 Uri fileUri = Uri.parse(UrlUtils.getIsolatedTestFileUrl(VIDEO_URL)); | 119 Uri fileUri = Uri.parse(UrlUtils.getIsolatedTestFileUrl(VIDEO_URL)); |
118 String mimeType = "video/mp4"; | 120 String mimeType = "video/mp4"; |
119 Intent intent = | 121 Intent intent = |
120 DownloadUtils.getMediaViewerIntentForDownloadItem(fileUri, fileU
ri, mimeType); | 122 DownloadUtils.getMediaViewerIntentForDownloadItem(fileUri, fileU
ri, mimeType); |
121 IntentHandler.startActivityForTrustedIntent(intent); | 123 IntentHandler.startActivityForTrustedIntent(intent); |
122 waitUntilUnlocked(); | 124 waitUntilUnlocked(); |
123 | 125 |
124 // Sometimes the web page doesn't transition out of fullscreen until we
exit the download | 126 // Sometimes the web page doesn't transition out of fullscreen until we
exit the download |
125 // activity and return to the web page. | 127 // activity and return to the web page. |
126 sendKeys(KeyEvent.KEYCODE_BACK); | 128 sendKeys(KeyEvent.KEYCODE_BACK); |
127 waitForContentsFullscreenState(false); | 129 waitForContentsFullscreenState(false); |
128 } | 130 } |
129 } | 131 } |
OLD | NEW |