OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.toolbar; |
| 6 |
| 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_TABLET; |
| 8 |
| 9 import android.test.suitebuilder.annotation.MediumTest; |
| 10 |
| 11 import com.google.android.apps.chrome.R; |
| 12 |
| 13 import org.chromium.base.test.util.Feature; |
| 14 import org.chromium.base.test.util.Restriction; |
| 15 import org.chromium.chrome.browser.ChromeActivity; |
| 16 import org.chromium.chrome.browser.omnibox.UrlBar; |
| 17 import org.chromium.chrome.browser.widget.findinpage.FindToolbar; |
| 18 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 19 import org.chromium.chrome.test.util.MenuUtils; |
| 20 import org.chromium.chrome.test.util.OmniboxTestUtils; |
| 21 import org.chromium.content.browser.test.util.Criteria; |
| 22 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 23 |
| 24 /** |
| 25 * Tests for toolbar manager behavior. |
| 26 */ |
| 27 public class ToolbarTest extends ChromeActivityTestCaseBase<ChromeActivity> { |
| 28 |
| 29 public ToolbarTest() { |
| 30 super(ChromeActivity.class); |
| 31 } |
| 32 |
| 33 @Override |
| 34 public void startMainActivity() throws InterruptedException { |
| 35 startMainActivityOnBlankPage(); |
| 36 } |
| 37 |
| 38 private void findInPageFromMenu() throws InterruptedException { |
| 39 MenuUtils.invokeCustomMenuActionSync(getInstrumentation(), |
| 40 getActivity(), R.id.find_in_page_id); |
| 41 |
| 42 waitForFindInPageVisibility(true); |
| 43 } |
| 44 |
| 45 private void waitForFindInPageVisibility(final boolean visible) throws Inter
ruptedException { |
| 46 assertTrue(CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
| 47 @Override |
| 48 public boolean isSatisfied() { |
| 49 FindToolbar findToolbar = (FindToolbar) getActivity().findViewBy
Id( |
| 50 R.id.find_toolbar); |
| 51 |
| 52 boolean isVisible = findToolbar != null && findToolbar.isShown()
; |
| 53 return (visible == isVisible) && !findToolbar.isAnimating(); |
| 54 } |
| 55 })); |
| 56 } |
| 57 |
| 58 @MediumTest |
| 59 @Restriction(RESTRICTION_TYPE_TABLET) |
| 60 @Feature({"Omnibox"}) |
| 61 public void testFindInPageDismissedOnOmniboxFocus() throws InterruptedExcept
ion { |
| 62 findInPageFromMenu(); |
| 63 |
| 64 UrlBar urlBar = (UrlBar) getActivity().findViewById(R.id.url_bar); |
| 65 OmniboxTestUtils.toggleUrlBarFocus(urlBar, true); |
| 66 OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true); |
| 67 |
| 68 waitForFindInPageVisibility(false); |
| 69 } |
| 70 |
| 71 } |
OLD | NEW |