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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/fullscreen/FullscreenManagerTest.java

Issue 1209243003: Changed the constraints for hiding the top controls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Used pollForUIThreadCriteria instead of pollForCriteria in the test code Created 5 years, 5 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 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
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
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());
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
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.pollForUIThreadCriteria(new Criteria() {
528 @Override
529 public boolean isSatisfied() {
530 ContentViewCore contentViewCore = tab.getContentViewCore();
531 return !contentViewCore.isFocusedNodeEditable();
532 }
533 });
534 }
535
488 @Override 536 @Override
489 protected void startMainActivityWithURL(String url) throws InterruptedExcept ion { 537 protected void startMainActivityWithURL(String url) throws InterruptedExcept ion {
490 super.startMainActivityWithURL(url); 538 super.startMainActivityWithURL(url);
491 final Tab tab = getActivity().getActivityTab(); 539 final Tab tab = getActivity().getActivityTab();
492 ThreadUtils.runOnUiThread(new Runnable() { 540 ThreadUtils.runOnUiThread(new Runnable() {
493 @Override 541 @Override
494 public void run() { 542 public void run() {
495 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest(); 543 ChromeTab.fromTab(tab).processEnableFullscreenRunnableForTest();
496 } 544 }
497 }); 545 });
498 } 546 }
499 547
500 @Override 548 @Override
501 public void startMainActivity() throws InterruptedException { 549 public void startMainActivity() throws InterruptedException {
502 // Each test will start itself with the appropriate test page. 550 // Each test will start itself with the appropriate test page.
503 } 551 }
504 } 552 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698