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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManagerTest.java

Issue 1423723006: Hard-code tap resolve and prefetch limits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tap_promo
Patch Set: Add @VisibleForTesting annotation Created 5 years, 1 month 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
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.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; 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; 9 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL ING_INTERVAL;
10 10
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 clickNode("focusable"); 1509 clickNode("focusable");
1510 assertPanelNeverOpened(); 1510 assertPanelNeverOpened();
1511 } 1511 }
1512 1512
1513 /** 1513 /**
1514 * Tests that taps can be resolve-limited for decided users. 1514 * Tests that taps can be resolve-limited for decided users.
1515 */ 1515 */
1516 @SmallTest 1516 @SmallTest
1517 @Feature({"ContextualSearch"}) 1517 @Feature({"ContextualSearch"})
1518 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) 1518 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
1519 @CommandLineFlags.Add(ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_DECID ED + "=2")
1520 public void testTapResolveLimitForDecided() throws InterruptedException, Tim eoutException { 1519 public void testTapResolveLimitForDecided() throws InterruptedException, Tim eoutException {
1520 mPolicy.setTapResolveLimitForDecidedForTesting(2);
1521 clickToTriggerSearchTermResolution(); 1521 clickToTriggerSearchTermResolution();
1522 assertSearchTermRequested(); 1522 assertSearchTermRequested();
1523 clickToTriggerSearchTermResolution(); 1523 clickToTriggerSearchTermResolution();
1524 assertSearchTermRequested(); 1524 assertSearchTermRequested();
1525 // 3rd click should not resolve. 1525 // 3rd click should not resolve.
1526 clickToTriggerSearchTermResolution(); 1526 clickToTriggerSearchTermResolution();
1527 assertSearchTermNotRequested(); 1527 assertSearchTermNotRequested();
1528 1528
1529 // Expanding the panel should reset the limit. 1529 // Expanding the panel should reset the limit.
1530 clickToExpandAndClosePanel(); 1530 clickToExpandAndClosePanel();
1531 1531
1532 // Click should resolve again. 1532 // Click should resolve again.
1533 clickToTriggerSearchTermResolution(); 1533 clickToTriggerSearchTermResolution();
1534 assertSearchTermRequested(); 1534 assertSearchTermRequested();
1535 } 1535 }
1536 1536
1537 /** 1537 /**
1538 * Tests that taps can be resolve-limited for undecided users. 1538 * Tests that taps can be resolve-limited for undecided users.
1539 */ 1539 */
1540 @SmallTest 1540 @SmallTest
1541 @Feature({"ContextualSearch"}) 1541 @Feature({"ContextualSearch"})
1542 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) 1542 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
1543 @CommandLineFlags.Add(ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_UNDEC IDED + "=2")
1544 public void testTapResolveLimitForUndecided() throws InterruptedException, T imeoutException { 1543 public void testTapResolveLimitForUndecided() throws InterruptedException, T imeoutException {
1544 mPolicy.setTapResolveLimitForUndecidedForTesting(2);
1545 mPolicy.overrideDecidedStateForTesting(false); 1545 mPolicy.overrideDecidedStateForTesting(false);
1546 1546
1547 clickToTriggerSearchTermResolution(); 1547 clickToTriggerSearchTermResolution();
1548 assertSearchTermRequested(); 1548 assertSearchTermRequested();
1549 clickToTriggerSearchTermResolution(); 1549 clickToTriggerSearchTermResolution();
1550 assertSearchTermRequested(); 1550 assertSearchTermRequested();
1551 // 3rd click should not resolve. 1551 // 3rd click should not resolve.
1552 clickToTriggerSearchTermResolution(); 1552 clickToTriggerSearchTermResolution();
1553 assertSearchTermNotRequested(); 1553 assertSearchTermNotRequested();
1554 1554
1555 // Expanding the panel should reset the limit. 1555 // Expanding the panel should reset the limit.
1556 clickToExpandAndClosePanel(); 1556 clickToExpandAndClosePanel();
1557 1557
1558 // Click should resolve again. 1558 // Click should resolve again.
1559 clickToTriggerSearchTermResolution(); 1559 clickToTriggerSearchTermResolution();
1560 assertSearchTermRequested(); 1560 assertSearchTermRequested();
1561 } 1561 }
1562 1562
1563 /** 1563 /**
1564 * Tests that taps can be preload-limited for decided users. 1564 * Tests that taps can be preload-limited for decided users.
1565 */ 1565 */
1566 @SmallTest 1566 @SmallTest
1567 @Feature({"ContextualSearch"}) 1567 @Feature({"ContextualSearch"})
1568 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) 1568 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
1569 @CommandLineFlags.Add(ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECI DED + "=2")
1570 public void testTapPrefetchLimitForDecided() throws InterruptedException, Ti meoutException { 1569 public void testTapPrefetchLimitForDecided() throws InterruptedException, Ti meoutException {
1570 mPolicy.setTapPrefetchLimitForDecidedForTesting(2);
1571 clickToTriggerPrefetch(); 1571 clickToTriggerPrefetch();
1572 assertLoadedLowPriorityUrl(); 1572 assertLoadedLowPriorityUrl();
1573 clickToTriggerPrefetch(); 1573 clickToTriggerPrefetch();
1574 assertLoadedLowPriorityUrl(); 1574 assertLoadedLowPriorityUrl();
1575 // 3rd click should not preload. 1575 // 3rd click should not preload.
1576 clickToTriggerPrefetch(); 1576 clickToTriggerPrefetch();
1577 assertLoadedNoUrl(); 1577 assertLoadedNoUrl();
1578 1578
1579 // Expanding the panel should reset the limit. 1579 // Expanding the panel should reset the limit.
1580 clickToExpandAndClosePanel(); 1580 clickToExpandAndClosePanel();
1581 1581
1582 // Click should preload again. 1582 // Click should preload again.
1583 clickToTriggerPrefetch(); 1583 clickToTriggerPrefetch();
1584 assertLoadedLowPriorityUrl(); 1584 assertLoadedLowPriorityUrl();
1585 } 1585 }
1586 1586
1587 /** 1587 /**
1588 * Tests that taps can be preload-limited for undecided users. 1588 * Tests that taps can be preload-limited for undecided users.
1589 */ 1589 */
1590 @SmallTest 1590 @SmallTest
1591 @Feature({"ContextualSearch"}) 1591 @Feature({"ContextualSearch"})
1592 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE}) 1592 @Restriction({RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON_LOW_END_DEVICE})
1593 @CommandLineFlags.Add(ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_UNDE CIDED + "=2")
1594 public void testTapPrefetchLimitForUndecided() throws InterruptedException, TimeoutException { 1593 public void testTapPrefetchLimitForUndecided() throws InterruptedException, TimeoutException {
1594 mPolicy.setTapPrefetchLimitForUndecidedForTesting(2);
1595 mPolicy.overrideDecidedStateForTesting(false); 1595 mPolicy.overrideDecidedStateForTesting(false);
1596 1596
1597 clickToTriggerPrefetch(); 1597 clickToTriggerPrefetch();
1598 assertLoadedLowPriorityUrl(); 1598 assertLoadedLowPriorityUrl();
1599 clickToTriggerPrefetch(); 1599 clickToTriggerPrefetch();
1600 assertLoadedLowPriorityUrl(); 1600 assertLoadedLowPriorityUrl();
1601 // 3rd click should not preload. 1601 // 3rd click should not preload.
1602 clickToTriggerPrefetch(); 1602 clickToTriggerPrefetch();
1603 assertLoadedNoUrl(); 1603 assertLoadedNoUrl();
1604 1604
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 waitForPanelToCloseAndSelectionDissolved(); 1658 waitForPanelToCloseAndSelectionDissolved();
1659 } 1659 }
1660 1660
1661 /** 1661 /**
1662 * This is a test that happens to create a separate bar without any content area! 1662 * This is a test that happens to create a separate bar without any content area!
1663 * 1663 *
1664 * @SmallTest 1664 * @SmallTest
1665 * @Feature({"ContextualSearch"}) 1665 * @Feature({"ContextualSearch"})
1666 */ 1666 */
1667 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 1667 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
1668 @CommandLineFlags.Add(ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECI DED + "=2")
1669 @FlakyTest 1668 @FlakyTest
1670 public void testDisembodiedBar() throws InterruptedException, TimeoutExcepti on { 1669 public void testDisembodiedBar() throws InterruptedException, TimeoutExcepti on {
1670 mPolicy.setTapPrefetchLimitForDecidedForTesting(2);
1671 clickToTriggerPrefetch(); 1671 clickToTriggerPrefetch();
1672 assertLoadedLowPriorityUrl(); 1672 assertLoadedLowPriorityUrl();
1673 clickToTriggerPrefetch(); 1673 clickToTriggerPrefetch();
1674 assertLoadedLowPriorityUrl(); 1674 assertLoadedLowPriorityUrl();
1675 // 3rd click should not preload. 1675 // 3rd click should not preload.
1676 clickToTriggerPrefetch(); 1676 clickToTriggerPrefetch();
1677 assertLoadedNoUrl(); 1677 assertLoadedNoUrl();
1678 1678
1679 // Expanding the panel should reset the limit. 1679 // Expanding the panel should reset the limit.
1680 flingPanelUp(); 1680 flingPanelUp();
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 longPressNode("states-far"); 2091 longPressNode("states-far");
2092 waitForPanelToPeekAndAssert(); 2092 waitForPanelToPeekAndAssert();
2093 } 2093 }
2094 2094
2095 /** 2095 /**
2096 * Tests a bunch of taps in a row. 2096 * Tests a bunch of taps in a row.
2097 * We've had reliability problems with a sequence of simple taps, due to asy nc dissolving 2097 * We've had reliability problems with a sequence of simple taps, due to asy nc dissolving
2098 * of selection bounds, so this helps prevent a regression with that. 2098 * of selection bounds, so this helps prevent a regression with that.
2099 */ 2099 */
2100 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2100 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
2101 @CommandLineFlags.Add({ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_DECI DED + "=200",
2102 ContextualSearchFieldTrial.TAP_RESOLVE_LIMIT_FOR_UNDECIDED + "=200",
2103 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_DECIDED + "=200",
2104 ContextualSearchFieldTrial.TAP_PREFETCH_LIMIT_FOR_UNDECIDED + "=200" })
2105 public void testTapALot() throws InterruptedException, TimeoutException { 2101 public void testTapALot() throws InterruptedException, TimeoutException {
2102 mPolicy.setTapPrefetchLimitForDecidedForTesting(200);
2103 mPolicy.setTapResolveLimitForDecidedForTesting(200);
2104 mPolicy.setTapPrefetchLimitForUndecidedForTesting(200);
2105 mPolicy.setTapResolveLimitForUndecidedForTesting(200);
2106 for (int i = 0; i < 50; i++) { 2106 for (int i = 0; i < 50; i++) {
2107 clickToTriggerSearchTermResolution(); 2107 clickToTriggerSearchTermResolution();
2108 waitForSelectionDissolved(); 2108 waitForSelectionDissolved();
2109 assertSearchTermRequested(); 2109 assertSearchTermRequested();
2110 } 2110 }
2111 } 2111 }
2112 2112
2113 /** 2113 /**
2114 * Tests ContextualSearchManager#shouldInterceptNavigation for a case that a n external 2114 * Tests ContextualSearchManager#shouldInterceptNavigation for a case that a n external
2115 * navigation has a user gesture. 2115 * navigation has a user gesture.
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) 2589 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE)
2590 @CommandLineFlags.Add(ContextualSearchFieldTrial.TRANSLATION_ONEBOX_ENABLED + "=true") 2590 @CommandLineFlags.Add(ContextualSearchFieldTrial.TRANSLATION_ONEBOX_ENABLED + "=true")
2591 public void testTapWithoutLanguage() throws InterruptedException, TimeoutExc eption { 2591 public void testTapWithoutLanguage() throws InterruptedException, TimeoutExc eption {
2592 // Tapping an English word should NOT trigger translation. 2592 // Tapping an English word should NOT trigger translation.
2593 simulateTapSearch("search"); 2593 simulateTapSearch("search");
2594 2594
2595 // Make sure we did not try to trigger translate. 2595 // Make sure we did not try to trigger translate.
2596 assertFalse(mManager.getRequest().isTranslationForced()); 2596 assertFalse(mManager.getRequest().isTranslationForced());
2597 } 2597 }
2598 } 2598 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchPolicy.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698