Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/VideoFullscreenOrientationLockTest.java

Issue 2847523002: Android: Remove GetApplicationContext part 4 (Closed)
Patch Set: Rebase and fix build Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 @Before 128 @Before
129 public void setUp() throws Exception { 129 public void setUp() throws Exception {
130 mActivityTestRule.launchContentShellWithUrlSync(TEST_URL); 130 mActivityTestRule.launchContentShellWithUrlSync(TEST_URL);
131 } 131 }
132 132
133 @Test 133 @Test
134 @MediumTest 134 @MediumTest
135 @Feature({"VideoFullscreenOrientationLock"}) 135 @Feature({"VideoFullscreenOrientationLock"})
136 public void testEnterExitFullscreenWithControlsButton() throws Exception { 136 public void testEnterExitFullscreenWithControlsButton() throws Exception {
137 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/. 137 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/.
138 if (DeviceFormFactor.isTablet(mActivityTestRule.getActivity())) { 138 if (DeviceFormFactor.isTablet()) {
139 return; 139 return;
140 } 140 }
141 141
142 // Start playback to guarantee it's properly loaded. 142 // Start playback to guarantee it's properly loaded.
143 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID)); 143 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID));
144 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID); 144 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID);
145 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID); 145 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID);
146 146
147 // Simulate click on fullscreen button. 147 // Simulate click on fullscreen button.
148 Assert.assertTrue(clickFullscreenButton()); 148 Assert.assertTrue(clickFullscreenButton());
(...skipping 10 matching lines...) Expand all
159 Assert.assertTrue(clickFullscreenButton()); 159 Assert.assertTrue(clickFullscreenButton());
160 waitForContentsFullscreenState(false); 160 waitForContentsFullscreenState(false);
161 waitUntilUnlocked(); 161 waitUntilUnlocked();
162 } 162 }
163 163
164 @Test 164 @Test
165 @MediumTest 165 @MediumTest
166 @Feature({"VideoFullscreenOrientationLock"}) 166 @Feature({"VideoFullscreenOrientationLock"})
167 public void testEnterExitFullscreenWithAPI() throws Exception { 167 public void testEnterExitFullscreenWithAPI() throws Exception {
168 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/. 168 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/.
169 if (DeviceFormFactor.isTablet(mActivityTestRule.getActivity())) { 169 if (DeviceFormFactor.isTablet()) {
170 return; 170 return;
171 } 171 }
172 172
173 // Start playback to guarantee it's properly loaded. 173 // Start playback to guarantee it's properly loaded.
174 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID)); 174 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID));
175 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID); 175 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID);
176 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID); 176 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID);
177 177
178 // Trigger requestFullscreen() via a click on a button. 178 // Trigger requestFullscreen() via a click on a button.
179 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen")); 179 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen"));
180 waitForContentsFullscreenState(true); 180 waitForContentsFullscreenState(true);
181 181
182 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise. 182 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise.
183 waitUntilLockedToLandscape(); 183 waitUntilLockedToLandscape();
184 184
185 // Leave fullscreen from API. 185 // Leave fullscreen from API.
186 DOMUtils.exitFullscreen(mActivityTestRule.getWebContents()); 186 DOMUtils.exitFullscreen(mActivityTestRule.getWebContents());
187 waitForContentsFullscreenState(false); 187 waitForContentsFullscreenState(false);
188 waitUntilUnlocked(); 188 waitUntilUnlocked();
189 } 189 }
190 190
191 @Test 191 @Test
192 @MediumTest 192 @MediumTest
193 @Feature({"VideoFullscreenOrientationLock"}) 193 @Feature({"VideoFullscreenOrientationLock"})
194 public void testExitFullscreenByRemovingVideo() throws Exception { 194 public void testExitFullscreenByRemovingVideo() throws Exception {
195 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/. 195 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/.
196 if (DeviceFormFactor.isTablet(mActivityTestRule.getActivity())) { 196 if (DeviceFormFactor.isTablet()) {
197 return; 197 return;
198 } 198 }
199 199
200 // Start playback to guarantee it's properly loaded. 200 // Start playback to guarantee it's properly loaded.
201 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID)); 201 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID));
202 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID); 202 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID);
203 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID); 203 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID);
204 204
205 // Trigger requestFullscreen() via a click on a button. 205 // Trigger requestFullscreen() via a click on a button.
206 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen")); 206 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen"));
207 waitForContentsFullscreenState(true); 207 waitForContentsFullscreenState(true);
208 208
209 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise. 209 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise.
210 waitUntilLockedToLandscape(); 210 waitUntilLockedToLandscape();
211 211
212 // Leave fullscreen by removing video element from page. 212 // Leave fullscreen by removing video element from page.
213 JavaScriptUtils.executeJavaScriptAndWaitForResult( 213 JavaScriptUtils.executeJavaScriptAndWaitForResult(
214 mActivityTestRule.getWebContents(), "document.body.innerHTML = ' ';"); 214 mActivityTestRule.getWebContents(), "document.body.innerHTML = ' ';");
215 waitForContentsFullscreenState(false); 215 waitForContentsFullscreenState(false);
216 waitUntilUnlocked(); 216 waitUntilUnlocked();
217 } 217 }
218 218
219 @Test 219 @Test
220 @MediumTest 220 @MediumTest
221 @Feature({"VideoFullscreenOrientationLock"}) 221 @Feature({"VideoFullscreenOrientationLock"})
222 public void testExitFullscreenWithNavigation() throws Exception { 222 public void testExitFullscreenWithNavigation() throws Exception {
223 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/. 223 // TODO(johnme): Use RESTRICTION_TYPE_PHONE once crbug.com/673917 moves it out of chrome/.
224 if (DeviceFormFactor.isTablet(mActivityTestRule.getActivity())) { 224 if (DeviceFormFactor.isTablet()) {
225 return; 225 return;
226 } 226 }
227 227
228 // Start playback to guarantee it's properly loaded. 228 // Start playback to guarantee it's properly loaded.
229 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID)); 229 Assert.assertTrue(DOMUtils.isMediaPaused(mActivityTestRule.getWebContent s(), VIDEO_ID));
230 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID); 230 DOMUtils.playMedia(mActivityTestRule.getWebContents(), VIDEO_ID);
231 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID); 231 DOMUtils.waitForMediaPlay(mActivityTestRule.getWebContents(), VIDEO_ID);
232 232
233 // Trigger requestFullscreen() via a click on a button. 233 // Trigger requestFullscreen() via a click on a button.
234 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen")); 234 Assert.assertTrue(DOMUtils.clickNode(mActivityTestRule.getContentViewCor e(), "fullscreen"));
235 waitForContentsFullscreenState(true); 235 waitForContentsFullscreenState(true);
236 236
237 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise. 237 // Should be locked to landscape now, `waitUntilLockedToLandscape` will throw otherwise.
238 waitUntilLockedToLandscape(); 238 waitUntilLockedToLandscape();
239 239
240 // Leave fullscreen by navigating page. 240 // Leave fullscreen by navigating page.
241 JavaScriptUtils.executeJavaScriptAndWaitForResult( 241 JavaScriptUtils.executeJavaScriptAndWaitForResult(
242 mActivityTestRule.getWebContents(), "location.reload();"); 242 mActivityTestRule.getWebContents(), "location.reload();");
243 waitForContentsFullscreenState(false); 243 waitForContentsFullscreenState(false);
244 waitUntilUnlocked(); 244 waitUntilUnlocked();
245 } 245 }
246 } 246 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698