OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.fullscreen; | 5 package org.chromium.chrome.browser.fullscreen; |
6 | 6 |
7 import android.graphics.Rect; | 7 import android.graphics.Rect; |
8 import android.graphics.Region; | 8 import android.graphics.Region; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.os.SystemClock; | 10 import android.os.SystemClock; |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 import java.util.concurrent.Callable; | 37 import java.util.concurrent.Callable; |
38 import java.util.concurrent.ExecutionException; | 38 import java.util.concurrent.ExecutionException; |
39 import java.util.concurrent.atomic.AtomicInteger; | 39 import java.util.concurrent.atomic.AtomicInteger; |
40 | 40 |
41 /** | 41 /** |
42 * Test suite for verifying the behavior of various fullscreen actions. | 42 * Test suite for verifying the behavior of various fullscreen actions. |
43 */ | 43 */ |
44 public class FullscreenManagerTest extends ChromeTabbedActivityTestBase { | 44 public class FullscreenManagerTest extends ChromeTabbedActivityTestBase { |
45 | 45 |
46 private static final String LONG_HTML_WITH_AUTO_FOCUS_INPUT_TEST_PAGE = | |
47 UrlUtils.encodeHtmlDataUri("<html>" | |
48 + "<body style='height:10000px;'>" | |
49 + "<p>The text input is focused automatically on load." | |
50 + " The top controls should not hide when page is scrolled.< /p><br/>" | |
51 + "<input id=\"input_text\" type=\"text\" autofocus/>" | |
52 + "</body>" | |
53 + "</html>"); | |
54 | |
46 private static final String LONG_HTML_TEST_PAGE = UrlUtils.encodeHtmlDataUri ( | 55 private static final String LONG_HTML_TEST_PAGE = UrlUtils.encodeHtmlDataUri ( |
47 "<html><body style='height:10000px;'></body></html>"); | 56 "<html><body style='height:10000px;'></body></html>"); |
48 private static final String LONG_FULLSCREEN_API_HTML_TEST_PAGE = UrlUtils.en codeHtmlDataUri( | 57 private static final String LONG_FULLSCREEN_API_HTML_TEST_PAGE = UrlUtils.en codeHtmlDataUri( |
49 "<html>" | 58 "<html>" |
50 + "<head>" | 59 + "<head>" |
51 + " <meta name=\"viewport\" " | 60 + " <meta name=\"viewport\" " |
52 + " content=\"width=device-width, initial-scale=1.0, maximum-scal e=1.0\" />" | 61 + " content=\"width=device-width, initial-scale=1.0, maximum-scal e=1.0\" />" |
53 + " <script>" | 62 + " <script>" |
54 + " function toggleFullScreen() {" | 63 + " function toggleFullScreen() {" |
55 + " if (document.webkitIsFullScreen) {" | 64 + " if (document.webkitIsFullScreen) {" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 322 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
314 @Override | 323 @Override |
315 public void run() { | 324 public void run() { |
316 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest(); | 325 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest(); |
317 } | 326 } |
318 }); | 327 }); |
319 | 328 |
320 scrollTopControls(false); | 329 scrollTopControls(false); |
321 } | 330 } |
322 | 331 |
332 @LargeTest | |
333 @Feature({"Fullscreen"}) | |
334 public void testTopControlsShownWhenInputIsFocused() | |
335 throws InterruptedException, ExecutionException { | |
336 startMainActivityWithURL(LONG_HTML_WITH_AUTO_FOCUS_INPUT_TEST_PAGE); | |
337 | |
338 ChromeFullscreenManager fullscreenManager = getActivity().getFullscreenM anager(); | |
339 assertEquals(fullscreenManager.getControlOffset(), 0f); | |
340 | |
341 fullscreenManager.setAnimationDurationsForTest(1, 1); | |
342 | |
343 int topControlsHeight = fullscreenManager.getTopControlsHeight(); | |
344 float dragX = 50f; | |
345 float dragStartY = topControlsHeight * 3; | |
346 float dragEndY = dragStartY - topControlsHeight * 2; | |
347 long downTime = SystemClock.uptimeMillis(); | |
348 dragStart(dragX, dragStartY, downTime); | |
349 dragTo(dragX, dragX, dragStartY, dragEndY, 100, downTime); | |
350 dragEnd(dragX, dragEndY, downTime); | |
351 assertTrue(waitForNoBrowserTopControlsOffset()); | |
352 assertEquals(fullscreenManager.getControlOffset(), 0f); | |
353 | |
354 Tab tab = getActivity().getActivityTab(); | |
355 singleClickView(tab.getView()); | |
Ted C
2015/07/07 16:46:33
This line "could" end up causing issues if the cli
| |
356 waitForEditableNodeToLoseFocus(tab); | |
357 scrollTopControls(false); | |
358 scrollTopControls(true); | |
359 } | |
360 | |
323 private void scrollTopControls(boolean show) throws InterruptedException, Ex ecutionException { | 361 private void scrollTopControls(boolean show) throws InterruptedException, Ex ecutionException { |
324 ChromeFullscreenManager fullscreenManager = getActivity().getFullscreenM anager(); | 362 ChromeFullscreenManager fullscreenManager = getActivity().getFullscreenM anager(); |
325 int topControlsHeight = fullscreenManager.getTopControlsHeight(); | 363 int topControlsHeight = fullscreenManager.getTopControlsHeight(); |
326 | 364 |
327 waitForPageToBeScrollable(getActivity().getActivityTab()); | 365 waitForPageToBeScrollable(getActivity().getActivityTab()); |
328 | 366 |
329 float dragX = 50f; | 367 float dragX = 50f; |
330 // Use a larger scroll range than the height of the top controls to ensu re we overcome | 368 // Use a larger scroll range than the height of the top controls to ensu re we overcome |
331 // the delay in a scroll start being sent. | 369 // the delay in a scroll start being sent. |
332 float dragStartY = topControlsHeight * 3; | 370 float dragStartY = topControlsHeight * 3; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
478 } | 516 } |
479 }).get(); | 517 }).get(); |
480 } catch (Exception e) { | 518 } catch (Exception e) { |
481 fail(e.getMessage()); | 519 fail(e.getMessage()); |
482 return false; | 520 return false; |
483 } | 521 } |
484 } | 522 } |
485 }); | 523 }); |
486 } | 524 } |
487 | 525 |
526 private boolean waitForEditableNodeToLoseFocus(final Tab tab) throws Interru ptedException { | |
527 return CriteriaHelper.pollForCriteria(new Criteria() { | |
Ted C
2015/07/07 16:46:33
use pollForUIThreadCriteria here instead. then yo
raghu
2015/07/07 22:24:15
Acknowledged.
Would you like me to do it for all t
Ted C
2015/07/07 22:26:50
Nah, just this one. The other ones should be done
| |
528 @Override | |
529 public boolean isSatisfied() { | |
530 try { | |
531 return ThreadUtils.runOnUiThread(new Callable<Boolean>() { | |
532 @Override | |
533 public Boolean call() throws Exception { | |
534 ContentViewCore contentViewCore = tab.getContentView Core(); | |
535 return !contentViewCore.isFocusedNodeEditable(); | |
536 } | |
537 }).get(); | |
538 } catch (Exception e) { | |
539 fail(e.getMessage()); | |
540 return false; | |
541 } | |
542 } | |
543 }); | |
544 } | |
545 | |
488 @Override | 546 @Override |
489 protected void startMainActivityWithURL(String url) throws InterruptedExcept ion { | 547 protected void startMainActivityWithURL(String url) throws InterruptedExcept ion { |
490 super.startMainActivityWithURL(url); | 548 super.startMainActivityWithURL(url); |
491 final Tab tab = getActivity().getActivityTab(); | 549 final Tab tab = getActivity().getActivityTab(); |
492 ThreadUtils.runOnUiThread(new Runnable() { | 550 ThreadUtils.runOnUiThread(new Runnable() { |
493 @Override | 551 @Override |
494 public void run() { | 552 public void run() { |
495 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest(); | 553 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest(); |
496 } | 554 } |
497 }); | 555 }); |
498 } | 556 } |
499 | 557 |
500 @Override | 558 @Override |
501 public void startMainActivity() throws InterruptedException { | 559 public void startMainActivity() throws InterruptedException { |
502 // Each test will start itself with the appropriate test page. | 560 // Each test will start itself with the appropriate test page. |
503 } | 561 } |
504 } | 562 } |
OLD | NEW |