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.contextualsearch; | 5 package org.chromium.chrome.browser.contextualsearch; |
6 | 6 |
7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; | 7 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_NON_LOW_E
ND_DEVICE; |
8 import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE; | |
9 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL
ING_INTERVAL; | 8 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL
ING_INTERVAL; |
10 | 9 |
11 import android.app.Activity; | 10 import android.app.Activity; |
12 import android.app.Instrumentation; | 11 import android.app.Instrumentation; |
13 import android.app.Instrumentation.ActivityMonitor; | 12 import android.app.Instrumentation.ActivityMonitor; |
14 import android.content.Context; | 13 import android.content.Context; |
15 import android.content.Intent; | 14 import android.content.Intent; |
16 import android.content.IntentFilter; | 15 import android.content.IntentFilter; |
17 import android.graphics.Point; | 16 import android.graphics.Point; |
18 import android.os.SystemClock; | 17 import android.os.SystemClock; |
(...skipping 21 matching lines...) Expand all Loading... |
40 import org.chromium.chrome.browser.contextualsearch.ContextualSearchFakeServer.F
akeSlowResolveSearch; | 39 import org.chromium.chrome.browser.contextualsearch.ContextualSearchFakeServer.F
akeSlowResolveSearch; |
41 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; | 40 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; |
42 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; | 41 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; |
43 import org.chromium.chrome.browser.omnibox.UrlBar; | 42 import org.chromium.chrome.browser.omnibox.UrlBar; |
44 import org.chromium.chrome.browser.tab.Tab; | 43 import org.chromium.chrome.browser.tab.Tab; |
45 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; | 44 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; |
46 import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; | 45 import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; |
47 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 46 import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
48 import org.chromium.chrome.browser.util.FeatureUtilities; | 47 import org.chromium.chrome.browser.util.FeatureUtilities; |
49 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 48 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 49 import org.chromium.chrome.test.util.ChromeRestriction; |
50 import org.chromium.chrome.test.util.ChromeTabUtils; | 50 import org.chromium.chrome.test.util.ChromeTabUtils; |
51 import org.chromium.chrome.test.util.FullscreenTestUtils; | 51 import org.chromium.chrome.test.util.FullscreenTestUtils; |
52 import org.chromium.chrome.test.util.OmniboxTestUtils; | 52 import org.chromium.chrome.test.util.OmniboxTestUtils; |
53 import org.chromium.chrome.test.util.TestHttpServerClient; | 53 import org.chromium.chrome.test.util.TestHttpServerClient; |
54 import org.chromium.components.navigation_interception.NavigationParams; | 54 import org.chromium.components.navigation_interception.NavigationParams; |
55 import org.chromium.content.browser.ContentViewCore; | 55 import org.chromium.content.browser.ContentViewCore; |
56 import org.chromium.content.browser.test.util.CallbackHelper; | 56 import org.chromium.content.browser.test.util.CallbackHelper; |
57 import org.chromium.content.browser.test.util.Criteria; | 57 import org.chromium.content.browser.test.util.Criteria; |
58 import org.chromium.content.browser.test.util.CriteriaHelper; | 58 import org.chromium.content.browser.test.util.CriteriaHelper; |
59 import org.chromium.content.browser.test.util.DOMUtils; | 59 import org.chromium.content.browser.test.util.DOMUtils; |
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1003 waitForPanelToPeek(); | 1003 waitForPanelToPeek(); |
1004 assertLoadedNoUrl(); | 1004 assertLoadedNoUrl(); |
1005 assertNoContentViewCore(); | 1005 assertNoContentViewCore(); |
1006 } | 1006 } |
1007 | 1007 |
1008 /** | 1008 /** |
1009 * Tests swiping the overlay open, after an initial tap that activates the p
eeking card. | 1009 * Tests swiping the overlay open, after an initial tap that activates the p
eeking card. |
1010 */ | 1010 */ |
1011 @SmallTest | 1011 @SmallTest |
1012 @Feature({"ContextualSearch"}) | 1012 @Feature({"ContextualSearch"}) |
1013 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1013 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1014 public void testSwipeExpand() throws InterruptedException, TimeoutException
{ | 1014 public void testSwipeExpand() throws InterruptedException, TimeoutException
{ |
1015 assertNoSearchesLoaded(); | 1015 assertNoSearchesLoaded(); |
1016 clickWordNode("intelligence"); | 1016 clickWordNode("intelligence"); |
1017 assertNoSearchesLoaded(); | 1017 assertNoSearchesLoaded(); |
1018 | 1018 |
1019 // Fake a search term resolution response. | 1019 // Fake a search term resolution response. |
1020 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", | 1020 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", |
1021 false); | 1021 false); |
1022 assertContainsParameters("Intelligence", "alternate-term"); | 1022 assertContainsParameters("Intelligence", "alternate-term"); |
1023 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 1023 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
1024 assertLoadedLowPriorityUrl(); | 1024 assertLoadedLowPriorityUrl(); |
1025 | 1025 |
1026 waitForPanelToPeek(); | 1026 waitForPanelToPeek(); |
1027 flingPanelUp(); | 1027 flingPanelUp(); |
1028 waitForPanelToExpand(); | 1028 waitForPanelToExpand(); |
1029 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 1029 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
1030 assertLoadedLowPriorityUrl(); | 1030 assertLoadedLowPriorityUrl(); |
1031 } | 1031 } |
1032 | 1032 |
1033 /** | 1033 /** |
1034 * Tests swiping the overlay open, after an initial long-press that activate
s the peeking card, | 1034 * Tests swiping the overlay open, after an initial long-press that activate
s the peeking card, |
1035 * followed by closing the panel. | 1035 * followed by closing the panel. |
1036 */ | 1036 */ |
1037 @SmallTest | 1037 @SmallTest |
1038 @Feature({"ContextualSearch"}) | 1038 @Feature({"ContextualSearch"}) |
1039 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1039 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1040 public void testLongPressSwipeExpand() throws InterruptedException, TimeoutE
xception { | 1040 public void testLongPressSwipeExpand() throws InterruptedException, TimeoutE
xception { |
1041 longPressNode("intelligence"); | 1041 longPressNode("intelligence"); |
1042 assertNoContentViewCore(); | 1042 assertNoContentViewCore(); |
1043 | 1043 |
1044 // TODO(pedrosimonetti): Long press does not resolve so we shouldn't be
faking one. | 1044 // TODO(pedrosimonetti): Long press does not resolve so we shouldn't be
faking one. |
1045 // Consider changing the fake server to create a fake response automatic
ally, | 1045 // Consider changing the fake server to create a fake response automatic
ally, |
1046 // when one is requested by the Manager. | 1046 // when one is requested by the Manager. |
1047 | 1047 |
1048 // Fake a search term resolution response. | 1048 // Fake a search term resolution response. |
1049 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", | 1049 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 PanelState initialState = mPanel.getPanelState(); | 1472 PanelState initialState = mPanel.getPanelState(); |
1473 clickNode("focusable"); | 1473 clickNode("focusable"); |
1474 assertPanelStillInState(initialState); | 1474 assertPanelStillInState(initialState); |
1475 } | 1475 } |
1476 | 1476 |
1477 /** | 1477 /** |
1478 * Tests that taps can be resolve-limited for decided users. | 1478 * Tests that taps can be resolve-limited for decided users. |
1479 */ | 1479 */ |
1480 @SmallTest | 1480 @SmallTest |
1481 @Feature({"ContextualSearch"}) | 1481 @Feature({"ContextualSearch"}) |
1482 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1482 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1483 public void testTapResolveLimitForDecided() throws InterruptedException, Tim
eoutException { | 1483 public void testTapResolveLimitForDecided() throws InterruptedException, Tim
eoutException { |
1484 mPolicy.setTapResolveLimitForDecidedForTesting(2); | 1484 mPolicy.setTapResolveLimitForDecidedForTesting(2); |
1485 clickToTriggerSearchTermResolution(); | 1485 clickToTriggerSearchTermResolution(); |
1486 assertSearchTermRequested(); | 1486 assertSearchTermRequested(); |
1487 clickToTriggerSearchTermResolution(); | 1487 clickToTriggerSearchTermResolution(); |
1488 assertSearchTermRequested(); | 1488 assertSearchTermRequested(); |
1489 // 3rd click should not resolve. | 1489 // 3rd click should not resolve. |
1490 clickToTriggerSearchTermResolution(); | 1490 clickToTriggerSearchTermResolution(); |
1491 assertSearchTermNotRequested(); | 1491 assertSearchTermNotRequested(); |
1492 | 1492 |
1493 // Expanding the panel should reset the limit. | 1493 // Expanding the panel should reset the limit. |
1494 clickToExpandAndClosePanel(); | 1494 clickToExpandAndClosePanel(); |
1495 | 1495 |
1496 // Click should resolve again. | 1496 // Click should resolve again. |
1497 clickToTriggerSearchTermResolution(); | 1497 clickToTriggerSearchTermResolution(); |
1498 assertSearchTermRequested(); | 1498 assertSearchTermRequested(); |
1499 } | 1499 } |
1500 | 1500 |
1501 /** | 1501 /** |
1502 * Tests that taps can be resolve-limited for undecided users. | 1502 * Tests that taps can be resolve-limited for undecided users. |
1503 */ | 1503 */ |
1504 @SmallTest | 1504 @SmallTest |
1505 @Feature({"ContextualSearch"}) | 1505 @Feature({"ContextualSearch"}) |
1506 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1506 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1507 public void testTapResolveLimitForUndecided() throws InterruptedException, T
imeoutException { | 1507 public void testTapResolveLimitForUndecided() throws InterruptedException, T
imeoutException { |
1508 mPolicy.setTapResolveLimitForUndecidedForTesting(2); | 1508 mPolicy.setTapResolveLimitForUndecidedForTesting(2); |
1509 mPolicy.overrideDecidedStateForTesting(false); | 1509 mPolicy.overrideDecidedStateForTesting(false); |
1510 | 1510 |
1511 clickToTriggerSearchTermResolution(); | 1511 clickToTriggerSearchTermResolution(); |
1512 assertSearchTermRequested(); | 1512 assertSearchTermRequested(); |
1513 clickToTriggerSearchTermResolution(); | 1513 clickToTriggerSearchTermResolution(); |
1514 assertSearchTermRequested(); | 1514 assertSearchTermRequested(); |
1515 // 3rd click should not resolve. | 1515 // 3rd click should not resolve. |
1516 clickToTriggerSearchTermResolution(); | 1516 clickToTriggerSearchTermResolution(); |
1517 assertSearchTermNotRequested(); | 1517 assertSearchTermNotRequested(); |
1518 | 1518 |
1519 // Expanding the panel should reset the limit. | 1519 // Expanding the panel should reset the limit. |
1520 clickToExpandAndClosePanel(); | 1520 clickToExpandAndClosePanel(); |
1521 | 1521 |
1522 // Click should resolve again. | 1522 // Click should resolve again. |
1523 clickToTriggerSearchTermResolution(); | 1523 clickToTriggerSearchTermResolution(); |
1524 assertSearchTermRequested(); | 1524 assertSearchTermRequested(); |
1525 } | 1525 } |
1526 | 1526 |
1527 /** | 1527 /** |
1528 * Tests that taps can be preload-limited for decided users. | 1528 * Tests that taps can be preload-limited for decided users. |
1529 */ | 1529 */ |
1530 @SmallTest | 1530 @SmallTest |
1531 @Feature({"ContextualSearch"}) | 1531 @Feature({"ContextualSearch"}) |
1532 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1532 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1533 public void testTapPrefetchLimitForDecided() throws InterruptedException, Ti
meoutException { | 1533 public void testTapPrefetchLimitForDecided() throws InterruptedException, Ti
meoutException { |
1534 mPolicy.setTapPrefetchLimitForDecidedForTesting(2); | 1534 mPolicy.setTapPrefetchLimitForDecidedForTesting(2); |
1535 clickToTriggerPrefetch(); | 1535 clickToTriggerPrefetch(); |
1536 assertLoadedLowPriorityUrl(); | 1536 assertLoadedLowPriorityUrl(); |
1537 clickToTriggerPrefetch(); | 1537 clickToTriggerPrefetch(); |
1538 assertLoadedLowPriorityUrl(); | 1538 assertLoadedLowPriorityUrl(); |
1539 // 3rd click should not preload. | 1539 // 3rd click should not preload. |
1540 clickToTriggerPrefetch(); | 1540 clickToTriggerPrefetch(); |
1541 assertLoadedNoUrl(); | 1541 assertLoadedNoUrl(); |
1542 | 1542 |
1543 // Expanding the panel should reset the limit. | 1543 // Expanding the panel should reset the limit. |
1544 clickToExpandAndClosePanel(); | 1544 clickToExpandAndClosePanel(); |
1545 | 1545 |
1546 // Click should preload again. | 1546 // Click should preload again. |
1547 clickToTriggerPrefetch(); | 1547 clickToTriggerPrefetch(); |
1548 assertLoadedLowPriorityUrl(); | 1548 assertLoadedLowPriorityUrl(); |
1549 } | 1549 } |
1550 | 1550 |
1551 /** | 1551 /** |
1552 * Tests that taps can be preload-limited for undecided users. | 1552 * Tests that taps can be preload-limited for undecided users. |
1553 */ | 1553 */ |
1554 @SmallTest | 1554 @SmallTest |
1555 @Feature({"ContextualSearch"}) | 1555 @Feature({"ContextualSearch"}) |
1556 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1556 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1557 public void testTapPrefetchLimitForUndecided() throws InterruptedException,
TimeoutException { | 1557 public void testTapPrefetchLimitForUndecided() throws InterruptedException,
TimeoutException { |
1558 mPolicy.setTapPrefetchLimitForUndecidedForTesting(2); | 1558 mPolicy.setTapPrefetchLimitForUndecidedForTesting(2); |
1559 mPolicy.overrideDecidedStateForTesting(false); | 1559 mPolicy.overrideDecidedStateForTesting(false); |
1560 | 1560 |
1561 clickToTriggerPrefetch(); | 1561 clickToTriggerPrefetch(); |
1562 assertLoadedLowPriorityUrl(); | 1562 assertLoadedLowPriorityUrl(); |
1563 clickToTriggerPrefetch(); | 1563 clickToTriggerPrefetch(); |
1564 assertLoadedLowPriorityUrl(); | 1564 assertLoadedLowPriorityUrl(); |
1565 // 3rd click should not preload. | 1565 // 3rd click should not preload. |
1566 clickToTriggerPrefetch(); | 1566 clickToTriggerPrefetch(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1693 return false; | 1693 return false; |
1694 } | 1694 } |
1695 }); | 1695 }); |
1696 } | 1696 } |
1697 | 1697 |
1698 /** | 1698 /** |
1699 * Tests that the App Menu gets suppressed when Search Panel is expanded. | 1699 * Tests that the App Menu gets suppressed when Search Panel is expanded. |
1700 */ | 1700 */ |
1701 @SmallTest | 1701 @SmallTest |
1702 @Feature({"ContextualSearch"}) | 1702 @Feature({"ContextualSearch"}) |
1703 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1703 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1704 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { | 1704 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { |
1705 clickWordNode("states"); | 1705 clickWordNode("states"); |
1706 tapPeekingBarToExpandAndAssert(); | 1706 tapPeekingBarToExpandAndAssert(); |
1707 | 1707 |
1708 pressAppMenuKey(); | 1708 pressAppMenuKey(); |
1709 assertAppMenuVisibility(false); | 1709 assertAppMenuVisibility(false); |
1710 | 1710 |
1711 tapBasePageToClosePanel(); | 1711 tapBasePageToClosePanel(); |
1712 | 1712 |
1713 pressAppMenuKey(); | 1713 pressAppMenuKey(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 | 1784 |
1785 // -------------------------------------------------------------------------
------------------- | 1785 // -------------------------------------------------------------------------
------------------- |
1786 // Promo open count | 1786 // Promo open count |
1787 // -------------------------------------------------------------------------
------------------- | 1787 // -------------------------------------------------------------------------
------------------- |
1788 | 1788 |
1789 /** | 1789 /** |
1790 * Tests the promo open counter. | 1790 * Tests the promo open counter. |
1791 */ | 1791 */ |
1792 @SmallTest | 1792 @SmallTest |
1793 @Feature({"ContextualSearch"}) | 1793 @Feature({"ContextualSearch"}) |
1794 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1794 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1795 public void testPromoOpenCountForUndecided() throws InterruptedException, Ti
meoutException { | 1795 public void testPromoOpenCountForUndecided() throws InterruptedException, Ti
meoutException { |
1796 mPolicy.overrideDecidedStateForTesting(false); | 1796 mPolicy.overrideDecidedStateForTesting(false); |
1797 | 1797 |
1798 // A simple click / resolve / prefetch sequence without open should not
change the counter. | 1798 // A simple click / resolve / prefetch sequence without open should not
change the counter. |
1799 clickToTriggerPrefetch(); | 1799 clickToTriggerPrefetch(); |
1800 assertEquals(0, mPolicy.getPromoOpenCount()); | 1800 assertEquals(0, mPolicy.getPromoOpenCount()); |
1801 | 1801 |
1802 // An open should count. | 1802 // An open should count. |
1803 clickToExpandAndClosePanel(); | 1803 clickToExpandAndClosePanel(); |
1804 assertEquals(1, mPolicy.getPromoOpenCount()); | 1804 assertEquals(1, mPolicy.getPromoOpenCount()); |
1805 | 1805 |
1806 // Another open should count. | 1806 // Another open should count. |
1807 clickToExpandAndClosePanel(); | 1807 clickToExpandAndClosePanel(); |
1808 assertEquals(2, mPolicy.getPromoOpenCount()); | 1808 assertEquals(2, mPolicy.getPromoOpenCount()); |
1809 | 1809 |
1810 // Once the user has decided, we should stop counting. | 1810 // Once the user has decided, we should stop counting. |
1811 mPolicy.overrideDecidedStateForTesting(true); | 1811 mPolicy.overrideDecidedStateForTesting(true); |
1812 clickToExpandAndClosePanel(); | 1812 clickToExpandAndClosePanel(); |
1813 assertEquals(2, mPolicy.getPromoOpenCount()); | 1813 assertEquals(2, mPolicy.getPromoOpenCount()); |
1814 } | 1814 } |
1815 | 1815 |
1816 /** | 1816 /** |
1817 * Tests the promo open counter. | 1817 * Tests the promo open counter. |
1818 */ | 1818 */ |
1819 @SmallTest | 1819 @SmallTest |
1820 @Feature({"ContextualSearch"}) | 1820 @Feature({"ContextualSearch"}) |
1821 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1821 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1822 public void testPromoOpenCountForDecided() throws InterruptedException, Time
outException { | 1822 public void testPromoOpenCountForDecided() throws InterruptedException, Time
outException { |
1823 mPolicy.overrideDecidedStateForTesting(true); | 1823 mPolicy.overrideDecidedStateForTesting(true); |
1824 | 1824 |
1825 // An open should not count for decided users. | 1825 // An open should not count for decided users. |
1826 clickToExpandAndClosePanel(); | 1826 clickToExpandAndClosePanel(); |
1827 assertEquals(0, mPolicy.getPromoOpenCount()); | 1827 assertEquals(0, mPolicy.getPromoOpenCount()); |
1828 } | 1828 } |
1829 | 1829 |
1830 // -------------------------------------------------------------------------
------------------- | 1830 // -------------------------------------------------------------------------
------------------- |
1831 // Tap count - number of taps between opens. | 1831 // Tap count - number of taps between opens. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 hideCount++; | 1867 hideCount++; |
1868 } | 1868 } |
1869 } | 1869 } |
1870 | 1870 |
1871 /** | 1871 /** |
1872 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search | 1872 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search |
1873 * panel via long press and then dismisses the panel by tapping on the base
page. | 1873 * panel via long press and then dismisses the panel by tapping on the base
page. |
1874 */ | 1874 */ |
1875 @SmallTest | 1875 @SmallTest |
1876 @Feature({"ContextualSearch"}) | 1876 @Feature({"ContextualSearch"}) |
1877 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1877 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1878 public void testNotifyObserverHideAfterLongPress() | 1878 public void testNotifyObserverHideAfterLongPress() |
1879 throws InterruptedException, TimeoutException { | 1879 throws InterruptedException, TimeoutException { |
1880 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1880 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
1881 mManager.addObserver(observer); | 1881 mManager.addObserver(observer); |
1882 longPressNode("states"); | 1882 longPressNode("states"); |
1883 assertEquals(0, observer.hideCount); | 1883 assertEquals(0, observer.hideCount); |
1884 | 1884 |
1885 tapBasePageToClosePanel(); | 1885 tapBasePageToClosePanel(); |
1886 assertEquals(1, observer.hideCount); | 1886 assertEquals(1, observer.hideCount); |
1887 } | 1887 } |
1888 | 1888 |
1889 /** | 1889 /** |
1890 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search | 1890 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search |
1891 * panel via tap and then dismisses the panel by tapping on the base page. | 1891 * panel via tap and then dismisses the panel by tapping on the base page. |
1892 */ | 1892 */ |
1893 @SmallTest | 1893 @SmallTest |
1894 @Feature({"ContextualSearch"}) | 1894 @Feature({"ContextualSearch"}) |
1895 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1895 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
1896 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { | 1896 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { |
1897 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1897 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
1898 mManager.addObserver(observer); | 1898 mManager.addObserver(observer); |
1899 clickWordNode("states"); | 1899 clickWordNode("states"); |
1900 assertEquals(0, observer.hideCount); | 1900 assertEquals(0, observer.hideCount); |
1901 | 1901 |
1902 tapBasePageToClosePanel(); | 1902 tapBasePageToClosePanel(); |
1903 assertEquals(1, observer.hideCount); | 1903 assertEquals(1, observer.hideCount); |
1904 } | 1904 } |
1905 | 1905 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2089 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", | 2089 fakeResponse(false, 200, "Intelligence", "United States Intelligence", "
alternate-term", |
2090 false, -14, 0, ""); | 2090 false, -14, 0, ""); |
2091 waitForSelectionToBe("United States Intelligence"); | 2091 waitForSelectionToBe("United States Intelligence"); |
2092 } | 2092 } |
2093 | 2093 |
2094 /** | 2094 /** |
2095 * Tests that long-press triggers the Peek Promo, and expanding the Panel di
smisses it. | 2095 * Tests that long-press triggers the Peek Promo, and expanding the Panel di
smisses it. |
2096 */ | 2096 */ |
2097 @SmallTest | 2097 @SmallTest |
2098 @Feature({"ContextualSearch"}) | 2098 @Feature({"ContextualSearch"}) |
2099 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2099 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2100 @CommandLineFlags.Add(ContextualSearchFieldTrial.PEEK_PROMO_ENABLED + "=true
") | 2100 @CommandLineFlags.Add(ContextualSearchFieldTrial.PEEK_PROMO_ENABLED + "=true
") |
2101 public void testLongPressShowsPeekPromo() throws InterruptedException, Timeo
utException { | 2101 public void testLongPressShowsPeekPromo() throws InterruptedException, Timeo
utException { |
2102 // Must be in undecided state in order to trigger the Peek Promo. | 2102 // Must be in undecided state in order to trigger the Peek Promo. |
2103 mPolicy.overrideDecidedStateForTesting(false); | 2103 mPolicy.overrideDecidedStateForTesting(false); |
2104 // Must have never opened the Panel in order to trigger the Peek Promo. | 2104 // Must have never opened the Panel in order to trigger the Peek Promo. |
2105 assertEquals(0, mPolicy.getPromoOpenCount()); | 2105 assertEquals(0, mPolicy.getPromoOpenCount()); |
2106 | 2106 |
2107 // Long press and make sure the Promo shows. | 2107 // Long press and make sure the Promo shows. |
2108 longPressNode("intelligence"); | 2108 longPressNode("intelligence"); |
2109 waitForPanelToPeek(); | 2109 waitForPanelToPeek(); |
(...skipping 20 matching lines...) Expand all Loading... |
2130 | 2130 |
2131 //==========================================================================
================== | 2131 //==========================================================================
================== |
2132 // Content Tests | 2132 // Content Tests |
2133 //==========================================================================
================== | 2133 //==========================================================================
================== |
2134 | 2134 |
2135 /** | 2135 /** |
2136 * Tests that tap followed by expand makes Content visible. | 2136 * Tests that tap followed by expand makes Content visible. |
2137 */ | 2137 */ |
2138 @SmallTest | 2138 @SmallTest |
2139 @Feature({"ContextualSearch"}) | 2139 @Feature({"ContextualSearch"}) |
2140 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2140 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2141 public void testTapContentVisibility() throws InterruptedException, TimeoutE
xception { | 2141 public void testTapContentVisibility() throws InterruptedException, TimeoutE
xception { |
2142 // Simulate a tap and make sure Content is not visible. | 2142 // Simulate a tap and make sure Content is not visible. |
2143 simulateTapSearch("search"); | 2143 simulateTapSearch("search"); |
2144 assertContentViewCoreCreatedButNeverMadeVisible(); | 2144 assertContentViewCoreCreatedButNeverMadeVisible(); |
2145 | 2145 |
2146 // Expanding the Panel should make the Content visible. | 2146 // Expanding the Panel should make the Content visible. |
2147 tapPeekingBarToExpandAndAssert(); | 2147 tapPeekingBarToExpandAndAssert(); |
2148 assertContentViewCoreVisible(); | 2148 assertContentViewCoreVisible(); |
2149 | 2149 |
2150 // Closing the Panel should destroy the Content. | 2150 // Closing the Panel should destroy the Content. |
2151 tapBasePageToClosePanel(); | 2151 tapBasePageToClosePanel(); |
2152 assertNoContentViewCore(); | 2152 assertNoContentViewCore(); |
2153 } | 2153 } |
2154 | 2154 |
2155 /** | 2155 /** |
2156 * Tests that long press followed by expand creates Content and makes it vis
ible. | 2156 * Tests that long press followed by expand creates Content and makes it vis
ible. |
2157 * | 2157 * |
2158 */ | 2158 */ |
2159 @SmallTest | 2159 @SmallTest |
2160 @Feature({"ContextualSearch"}) | 2160 @Feature({"ContextualSearch"}) |
2161 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2161 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2162 public void testLongPressContentVisibility() throws InterruptedException, Ti
meoutException { | 2162 public void testLongPressContentVisibility() throws InterruptedException, Ti
meoutException { |
2163 // Simulate a long press and make sure no Content is created. | 2163 // Simulate a long press and make sure no Content is created. |
2164 simulateLongPressSearch("search"); | 2164 simulateLongPressSearch("search"); |
2165 assertNoContentViewCore(); | 2165 assertNoContentViewCore(); |
2166 assertNoSearchesLoaded(); | 2166 assertNoSearchesLoaded(); |
2167 | 2167 |
2168 // Expanding the Panel should make the Content visible. | 2168 // Expanding the Panel should make the Content visible. |
2169 tapPeekingBarToExpandAndAssert(); | 2169 tapPeekingBarToExpandAndAssert(); |
2170 assertContentViewCoreCreated(); | 2170 assertContentViewCoreCreated(); |
2171 assertContentViewCoreVisible(); | 2171 assertContentViewCoreVisible(); |
2172 | 2172 |
2173 // Closing the Panel should destroy the Content. | 2173 // Closing the Panel should destroy the Content. |
2174 tapBasePageToClosePanel(); | 2174 tapBasePageToClosePanel(); |
2175 assertNoContentViewCore(); | 2175 assertNoContentViewCore(); |
2176 } | 2176 } |
2177 | 2177 |
2178 /** | 2178 /** |
2179 * Tests swiping panel up and down after a tap search will only load the Con
tent once. | 2179 * Tests swiping panel up and down after a tap search will only load the Con
tent once. |
2180 */ | 2180 */ |
2181 @SmallTest | 2181 @SmallTest |
2182 @Feature({"ContextualSearch"}) | 2182 @Feature({"ContextualSearch"}) |
2183 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2183 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2184 public void testTapMultipleSwipeOnlyLoadsContentOnce() | 2184 public void testTapMultipleSwipeOnlyLoadsContentOnce() |
2185 throws InterruptedException, TimeoutException { | 2185 throws InterruptedException, TimeoutException { |
2186 // Simulate a tap and make sure Content is not visible. | 2186 // Simulate a tap and make sure Content is not visible. |
2187 simulateTapSearch("search"); | 2187 simulateTapSearch("search"); |
2188 assertContentViewCoreCreatedButNeverMadeVisible(); | 2188 assertContentViewCoreCreatedButNeverMadeVisible(); |
2189 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2189 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
2190 | 2190 |
2191 // Expanding the Panel should make the Content visible. | 2191 // Expanding the Panel should make the Content visible. |
2192 tapPeekingBarToExpandAndAssert(); | 2192 tapPeekingBarToExpandAndAssert(); |
2193 assertContentViewCoreVisible(); | 2193 assertContentViewCoreVisible(); |
(...skipping 14 matching lines...) Expand all Loading... |
2208 tapBasePageToClosePanel(); | 2208 tapBasePageToClosePanel(); |
2209 assertNoContentViewCore(); | 2209 assertNoContentViewCore(); |
2210 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2210 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
2211 } | 2211 } |
2212 | 2212 |
2213 /** | 2213 /** |
2214 * Tests swiping panel up and down after a long press search will only load
the Content once. | 2214 * Tests swiping panel up and down after a long press search will only load
the Content once. |
2215 */ | 2215 */ |
2216 @SmallTest | 2216 @SmallTest |
2217 @Feature({"ContextualSearch"}) | 2217 @Feature({"ContextualSearch"}) |
2218 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2218 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2219 public void testLongPressMultipleSwipeOnlyLoadsContentOnce() | 2219 public void testLongPressMultipleSwipeOnlyLoadsContentOnce() |
2220 throws InterruptedException, TimeoutException { | 2220 throws InterruptedException, TimeoutException { |
2221 // Simulate a long press and make sure no Content is created. | 2221 // Simulate a long press and make sure no Content is created. |
2222 simulateLongPressSearch("search"); | 2222 simulateLongPressSearch("search"); |
2223 assertNoContentViewCore(); | 2223 assertNoContentViewCore(); |
2224 assertNoSearchesLoaded(); | 2224 assertNoSearchesLoaded(); |
2225 | 2225 |
2226 // Expanding the Panel should load the URL and make the Content visible. | 2226 // Expanding the Panel should load the URL and make the Content visible. |
2227 tapPeekingBarToExpandAndAssert(); | 2227 tapPeekingBarToExpandAndAssert(); |
2228 assertContentViewCoreCreated(); | 2228 assertContentViewCoreCreated(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2283 assertNoContentViewCore(); | 2283 assertNoContentViewCore(); |
2284 assertEquals(3, mFakeServer.getLoadedUrlCount()); | 2284 assertEquals(3, mFakeServer.getLoadedUrlCount()); |
2285 } | 2285 } |
2286 | 2286 |
2287 /** | 2287 /** |
2288 * Tests that chained searches load correctly. | 2288 * Tests that chained searches load correctly. |
2289 */ | 2289 */ |
2290 @DisabledTest // https://crbug.com/551711 | 2290 @DisabledTest // https://crbug.com/551711 |
2291 @SmallTest | 2291 @SmallTest |
2292 @Feature({"ContextualSearch"}) | 2292 @Feature({"ContextualSearch"}) |
2293 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2293 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2294 public void testChainedSearchLoadsCorrectSearchTerm() | 2294 public void testChainedSearchLoadsCorrectSearchTerm() |
2295 throws InterruptedException, TimeoutException { | 2295 throws InterruptedException, TimeoutException { |
2296 // Simulate a tap and make sure Content is not visible. | 2296 // Simulate a tap and make sure Content is not visible. |
2297 simulateTapSearch("search"); | 2297 simulateTapSearch("search"); |
2298 assertContentViewCoreCreatedButNeverMadeVisible(); | 2298 assertContentViewCoreCreatedButNeverMadeVisible(); |
2299 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2299 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
2300 ContentViewCore cvc1 = getPanelContentViewCore(); | 2300 ContentViewCore cvc1 = getPanelContentViewCore(); |
2301 | 2301 |
2302 // Expanding the Panel should make the Content visible. | 2302 // Expanding the Panel should make the Content visible. |
2303 tapPeekingBarToExpandAndAssert(); | 2303 tapPeekingBarToExpandAndAssert(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 | 2382 |
2383 // Now check that the URL has been removed from history. | 2383 // Now check that the URL has been removed from history. |
2384 assertTrue(mFakeServer.hasRemovedUrl(url)); | 2384 assertTrue(mFakeServer.hasRemovedUrl(url)); |
2385 } | 2385 } |
2386 | 2386 |
2387 /** | 2387 /** |
2388 * Tests that a tap followed by opening the Panel does not remove the loaded
URL from history. | 2388 * Tests that a tap followed by opening the Panel does not remove the loaded
URL from history. |
2389 */ | 2389 */ |
2390 @SmallTest | 2390 @SmallTest |
2391 @Feature({"ContextualSearch"}) | 2391 @Feature({"ContextualSearch"}) |
2392 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2392 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2393 public void testTapExpandNotRemovedFromHistory() | 2393 public void testTapExpandNotRemovedFromHistory() |
2394 throws InterruptedException, TimeoutException { | 2394 throws InterruptedException, TimeoutException { |
2395 // Simulate a tap and make sure a URL was loaded. | 2395 // Simulate a tap and make sure a URL was loaded. |
2396 simulateTapSearch("search"); | 2396 simulateTapSearch("search"); |
2397 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2397 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
2398 String url = mFakeServer.getLoadedUrl(); | 2398 String url = mFakeServer.getLoadedUrl(); |
2399 | 2399 |
2400 // Expand Panel so that the Content becomes visible. | 2400 // Expand Panel so that the Content becomes visible. |
2401 tapPeekingBarToExpandAndAssert(); | 2401 tapPeekingBarToExpandAndAssert(); |
2402 | 2402 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2546 assertFalse(mManager.getRequest().isTranslationForced()); | 2546 assertFalse(mManager.getRequest().isTranslationForced()); |
2547 } | 2547 } |
2548 | 2548 |
2549 /** | 2549 /** |
2550 * Tests that Contextual Search works in fullscreen. Specifically, tests tha
t tapping a word | 2550 * Tests that Contextual Search works in fullscreen. Specifically, tests tha
t tapping a word |
2551 * peeks the panel, expanding the bar results in the bar ending at the corre
ct spot in the page | 2551 * peeks the panel, expanding the bar results in the bar ending at the corre
ct spot in the page |
2552 * and tapping the base page closes the panel. | 2552 * and tapping the base page closes the panel. |
2553 */ | 2553 */ |
2554 @SmallTest | 2554 @SmallTest |
2555 @Feature({"ContextualSearch"}) | 2555 @Feature({"ContextualSearch"}) |
2556 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2556 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
2557 public void testTapContentAndExpandPanelInFullscreen() | 2557 public void testTapContentAndExpandPanelInFullscreen() |
2558 throws InterruptedException, TimeoutException { | 2558 throws InterruptedException, TimeoutException { |
2559 // Toggle tab to fulllscreen. | 2559 // Toggle tab to fulllscreen. |
2560 FullscreenTestUtils.togglePersistentFullscreenAndAssert(getActivity().ge
tActivityTab(), | 2560 FullscreenTestUtils.togglePersistentFullscreenAndAssert(getActivity().ge
tActivityTab(), |
2561 true, getActivity()); | 2561 true, getActivity()); |
2562 | 2562 |
2563 // Simulate a tap and assert that the panel peeks. | 2563 // Simulate a tap and assert that the panel peeks. |
2564 simulateTapSearch("search"); | 2564 simulateTapSearch("search"); |
2565 | 2565 |
2566 // Expand the panel and assert that it ends up in the right place. | 2566 // Expand the panel and assert that it ends up in the right place. |
(...skipping 26 matching lines...) Expand all Loading... |
2593 // Simulate a tap and assert that the panel peeks. | 2593 // Simulate a tap and assert that the panel peeks. |
2594 simulateTapSearch("search"); | 2594 simulateTapSearch("search"); |
2595 | 2595 |
2596 // Toggle tab to non-fullscreen. | 2596 // Toggle tab to non-fullscreen. |
2597 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA
ctivity()); | 2597 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA
ctivity()); |
2598 | 2598 |
2599 // Assert that the panel is closed. | 2599 // Assert that the panel is closed. |
2600 waitForPanelToClose(); | 2600 waitForPanelToClose(); |
2601 } | 2601 } |
2602 } | 2602 } |
OLD | NEW |