| 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.content.browser.test.util.CriteriaHelper.DEFAULT_POLL
ING_INTERVAL; | 8 import static org.chromium.content.browser.test.util.CriteriaHelper.DEFAULT_POLL
ING_INTERVAL; |
| 9 | 9 |
| 10 import android.app.Activity; | 10 import android.app.Activity; |
| (...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 799 |
| 800 /** | 800 /** |
| 801 * Scrolls the base page. | 801 * Scrolls the base page. |
| 802 */ | 802 */ |
| 803 private void scrollBasePage() { | 803 private void scrollBasePage() { |
| 804 // TODO(pedrosimonetti): Consider using a swipe method instead. | 804 // TODO(pedrosimonetti): Consider using a swipe method instead. |
| 805 fling(0.f, 0.75f, 0.f, 0.7f, 100); | 805 fling(0.f, 0.75f, 0.f, 0.7f, 100); |
| 806 } | 806 } |
| 807 | 807 |
| 808 /** | 808 /** |
| 809 * Taps the base page near the top. | 809 * Click to cause the panel to show, tap the Bar to expand, then close. |
| 810 */ | |
| 811 private void tapBasePageToClosePanel() throws InterruptedException { | |
| 812 // TODO(pedrosimonetti): This is not reliable. Find a better approach. | |
| 813 // We use the far right side (x == 0.9f) to prevent simulating a tap on
top of an | |
| 814 // existing long-press selection (the pins are a tap target). This might
not work on RTL. | |
| 815 // We are using y == 0.35f because otherwise it will fail for long press
cases. | |
| 816 // It might be better to get the position of the Panel and tap just abou
t outside | |
| 817 // the Panel. I suspect some Flaky tests are caused by this problem (one
s involving | |
| 818 // long press and trying to close with the bar peeking, with a long pres
s selection | |
| 819 // established). | |
| 820 tapBasePage(0.9f, 0.35f); | |
| 821 waitForPanelToClose(); | |
| 822 } | |
| 823 | |
| 824 /** | |
| 825 * Taps the base page at the given x, y position. | |
| 826 */ | |
| 827 private void tapBasePage(float x, float y) { | |
| 828 View root = getActivity().getWindow().getDecorView().getRootView(); | |
| 829 x *= root.getWidth(); | |
| 830 y *= root.getHeight(); | |
| 831 TouchCommon.singleClickView(root, (int) x, (int) y); | |
| 832 } | |
| 833 | |
| 834 /** | |
| 835 * Click various places to cause the panel to show, expand, then close. | |
| 836 */ | 810 */ |
| 837 private void clickToExpandAndClosePanel() throws InterruptedException, Timeo
utException { | 811 private void clickToExpandAndClosePanel() throws InterruptedException, Timeo
utException { |
| 838 clickWordNode("states"); | 812 clickWordNode("states"); |
| 839 tapBarToExpandAndClosePanel(); | 813 tapPeekingBarToExpandAndAssert(); |
| 814 closePanel(); |
| 840 waitForSelectionDissolved(); | 815 waitForSelectionDissolved(); |
| 841 } | 816 } |
| 842 | 817 |
| 843 /** | 818 /** |
| 844 * Tap on the peeking Bar to expand the panel, then taps on the base page to
close it. | |
| 845 */ | |
| 846 private void tapBarToExpandAndClosePanel() throws InterruptedException { | |
| 847 tapPeekingBarToExpandAndAssert(); | |
| 848 tapBasePageToClosePanel(); | |
| 849 } | |
| 850 | |
| 851 /** | |
| 852 * Generate a click in the panel's bar. | 819 * Generate a click in the panel's bar. |
| 853 * TODO(donnd): Replace this method with panelBarClick since this appears to
be unreliable. | 820 * TODO(donnd): Replace this method with panelBarClick since this appears to
be unreliable. |
| 854 * @barHeight The vertical position where the click should take place as a p
ercentage | 821 * @barHeight The vertical position where the click should take place as a p
ercentage |
| 855 * of the screen size. | 822 * of the screen size. |
| 856 */ | 823 */ |
| 857 private void clickPanelBar(float barPositionVertical) { | 824 private void clickPanelBar(float barPositionVertical) { |
| 858 View root = getActivity().getWindow().getDecorView().getRootView(); | 825 View root = getActivity().getWindow().getDecorView().getRootView(); |
| 859 float w = root.getWidth(); | 826 float w = root.getWidth(); |
| 860 float h = root.getHeight(); | 827 float h = root.getHeight(); |
| 861 float tapX = w / 2f; | 828 float tapX = w / 2f; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 | 1070 |
| 1104 waitForPanelToPeek(); | 1071 waitForPanelToPeek(); |
| 1105 assertLoadedNoUrl(); | 1072 assertLoadedNoUrl(); |
| 1106 assertNoContentViewCore(); | 1073 assertNoContentViewCore(); |
| 1107 flingPanelUp(); | 1074 flingPanelUp(); |
| 1108 waitForPanelToExpand(); | 1075 waitForPanelToExpand(); |
| 1109 assertContentViewCoreCreated(); | 1076 assertContentViewCoreCreated(); |
| 1110 assertLoadedNormalPriorityUrl(); | 1077 assertLoadedNormalPriorityUrl(); |
| 1111 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 1078 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 1112 | 1079 |
| 1113 // tap the base page to close. | 1080 // close the panel. |
| 1114 tapBasePageToClosePanel(); | 1081 closePanel(); |
| 1115 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 1082 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 1116 assertNoContentViewCore(); | 1083 assertNoContentViewCore(); |
| 1117 } | 1084 } |
| 1118 | 1085 |
| 1119 /** | 1086 /** |
| 1120 * Tests that only a single low-priority request is issued for a Tap/Open se
quence. | 1087 * Tests that only a single low-priority request is issued for a Tap/Open se
quence. |
| 1121 */ | 1088 */ |
| 1122 @SmallTest | 1089 @SmallTest |
| 1123 @Feature({"ContextualSearch"}) | 1090 @Feature({"ContextualSearch"}) |
| 1124 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 1091 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1729 @Feature({"ContextualSearch"}) | 1696 @Feature({"ContextualSearch"}) |
| 1730 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 1697 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 1731 @DisableIf.Build(supported_abis_includes = "arm64-v8a", message = "crbug.com
/596533") | 1698 @DisableIf.Build(supported_abis_includes = "arm64-v8a", message = "crbug.com
/596533") |
| 1732 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { | 1699 public void testAppMenuSuppressedWhenExpanded() throws InterruptedException,
TimeoutException { |
| 1733 clickWordNode("states"); | 1700 clickWordNode("states"); |
| 1734 tapPeekingBarToExpandAndAssert(); | 1701 tapPeekingBarToExpandAndAssert(); |
| 1735 | 1702 |
| 1736 pressAppMenuKey(); | 1703 pressAppMenuKey(); |
| 1737 assertAppMenuVisibility(false); | 1704 assertAppMenuVisibility(false); |
| 1738 | 1705 |
| 1739 tapBasePageToClosePanel(); | 1706 closePanel(); |
| 1740 | 1707 |
| 1741 pressAppMenuKey(); | 1708 pressAppMenuKey(); |
| 1742 assertAppMenuVisibility(true); | 1709 assertAppMenuVisibility(true); |
| 1743 } | 1710 } |
| 1744 | 1711 |
| 1745 /** | 1712 /** |
| 1746 * Tests that the App Menu gets suppressed when Search Panel is maximized. | 1713 * Tests that the App Menu gets suppressed when Search Panel is maximized. |
| 1747 */ | 1714 */ |
| 1748 @SmallTest | 1715 @SmallTest |
| 1749 @Feature({"ContextualSearch"}) | 1716 @Feature({"ContextualSearch"}) |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1895 public void onShowContextualSearch(GSAContextDisplaySelection selectionC
ontext) {} | 1862 public void onShowContextualSearch(GSAContextDisplaySelection selectionC
ontext) {} |
| 1896 | 1863 |
| 1897 @Override | 1864 @Override |
| 1898 public void onHideContextualSearch() { | 1865 public void onHideContextualSearch() { |
| 1899 hideCount++; | 1866 hideCount++; |
| 1900 } | 1867 } |
| 1901 } | 1868 } |
| 1902 | 1869 |
| 1903 /** | 1870 /** |
| 1904 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search | 1871 * Tests that ContextualSearchObserver gets notified when user brings up con
textual search |
| 1905 * panel via long press and then dismisses the panel by tapping on the base
page. | 1872 * panel via long press and when the panel is dismissed. |
| 1906 */ | 1873 */ |
| 1907 @SmallTest | 1874 @SmallTest |
| 1908 @Feature({"ContextualSearch"}) | 1875 @Feature({"ContextualSearch"}) |
| 1909 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 1876 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 1910 @RetryOnFailure | 1877 @RetryOnFailure |
| 1911 public void testNotifyObserverHideAfterLongPress() | 1878 public void testNotifyObserverHideAfterLongPress() |
| 1912 throws InterruptedException, TimeoutException { | 1879 throws InterruptedException, TimeoutException { |
| 1913 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1880 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
| 1914 mManager.addObserver(observer); | 1881 mManager.addObserver(observer); |
| 1915 longPressNode("states"); | 1882 longPressNode("states"); |
| 1916 assertEquals(0, observer.hideCount); | 1883 assertEquals(0, observer.hideCount); |
| 1917 | 1884 |
| 1918 tapBasePageToClosePanel(); | 1885 closePanel(); |
| 1919 assertEquals(1, observer.hideCount); | 1886 assertEquals(1, observer.hideCount); |
| 1920 } | 1887 } |
| 1921 | 1888 |
| 1922 /** | 1889 /** |
| 1923 * 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 |
| 1924 * panel via tap and then dismisses the panel by tapping on the base page. | 1891 * panel via tap and when the panel is dismissed. |
| 1925 */ | 1892 */ |
| 1926 @SmallTest | 1893 @SmallTest |
| 1927 @Feature({"ContextualSearch"}) | 1894 @Feature({"ContextualSearch"}) |
| 1928 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 1895 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 1929 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { | 1896 public void testNotifyObserverHideAfterTap() throws InterruptedException, Ti
meoutException { |
| 1930 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); | 1897 TestContextualSearchObserver observer = new TestContextualSearchObserver
(); |
| 1931 mManager.addObserver(observer); | 1898 mManager.addObserver(observer); |
| 1932 clickWordNode("states"); | 1899 clickWordNode("states"); |
| 1933 assertEquals(0, observer.hideCount); | 1900 assertEquals(0, observer.hideCount); |
| 1934 | 1901 |
| 1935 tapBasePageToClosePanel(); | 1902 closePanel(); |
| 1936 assertEquals(1, observer.hideCount); | 1903 assertEquals(1, observer.hideCount); |
| 1937 } | 1904 } |
| 1938 | 1905 |
| 1939 private void assertWaitForSelectActionBarVisible(final boolean visible) | 1906 private void assertWaitForSelectActionBarVisible(final boolean visible) |
| 1940 throws InterruptedException { | 1907 throws InterruptedException { |
| 1941 CriteriaHelper.pollUiThread(Criteria.equals(visible, new Callable<Boolea
n>() { | 1908 CriteriaHelper.pollUiThread(Criteria.equals(visible, new Callable<Boolea
n>() { |
| 1942 @Override | 1909 @Override |
| 1943 public Boolean call() { | 1910 public Boolean call() { |
| 1944 return getActivity().getActivityTab().getContentViewCore() | 1911 return getActivity().getActivityTab().getContentViewCore() |
| 1945 .isSelectActionBarShowing(); | 1912 .isSelectActionBarShowing(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 longPressNode("intelligence"); | 2115 longPressNode("intelligence"); |
| 2149 waitForPanelToPeek(); | 2116 waitForPanelToPeek(); |
| 2150 assertTrue(mPanel.isPeekPromoVisible()); | 2117 assertTrue(mPanel.isPeekPromoVisible()); |
| 2151 | 2118 |
| 2152 // After expanding the Panel the Promo should be invisible. | 2119 // After expanding the Panel the Promo should be invisible. |
| 2153 flingPanelUp(); | 2120 flingPanelUp(); |
| 2154 waitForPanelToExpand(); | 2121 waitForPanelToExpand(); |
| 2155 assertFalse(mPanel.isPeekPromoVisible()); | 2122 assertFalse(mPanel.isPeekPromoVisible()); |
| 2156 | 2123 |
| 2157 // After closing the Panel the Promo should still be invisible. | 2124 // After closing the Panel the Promo should still be invisible. |
| 2158 tapBasePageToClosePanel(); | 2125 closePanel(); |
| 2159 assertFalse(mPanel.isPeekPromoVisible()); | 2126 assertFalse(mPanel.isPeekPromoVisible()); |
| 2160 | 2127 |
| 2161 // Click elsewhere to clear the selection. | 2128 // Click elsewhere to clear the selection. |
| 2162 clickNode("question-mark"); | 2129 clickNode("question-mark"); |
| 2163 waitForSelectionToBe(null); | 2130 waitForSelectionToBe(null); |
| 2164 | 2131 |
| 2165 // Now that the Panel was opened at least once, the Promo should not sho
w again. | 2132 // Now that the Panel was opened at least once, the Promo should not sho
w again. |
| 2166 longPressNode("intelligence"); | 2133 longPressNode("intelligence"); |
| 2167 waitForPanelToPeek(); | 2134 waitForPanelToPeek(); |
| 2168 assertFalse(mPanel.isPeekPromoVisible()); | 2135 assertFalse(mPanel.isPeekPromoVisible()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2182 public void testTapContentVisibility() throws InterruptedException, TimeoutE
xception { | 2149 public void testTapContentVisibility() throws InterruptedException, TimeoutE
xception { |
| 2183 // Simulate a tap and make sure Content is not visible. | 2150 // Simulate a tap and make sure Content is not visible. |
| 2184 simulateTapSearch("search"); | 2151 simulateTapSearch("search"); |
| 2185 assertContentViewCoreCreatedButNeverMadeVisible(); | 2152 assertContentViewCoreCreatedButNeverMadeVisible(); |
| 2186 | 2153 |
| 2187 // Expanding the Panel should make the Content visible. | 2154 // Expanding the Panel should make the Content visible. |
| 2188 tapPeekingBarToExpandAndAssert(); | 2155 tapPeekingBarToExpandAndAssert(); |
| 2189 assertContentViewCoreVisible(); | 2156 assertContentViewCoreVisible(); |
| 2190 | 2157 |
| 2191 // Closing the Panel should destroy the Content. | 2158 // Closing the Panel should destroy the Content. |
| 2192 tapBasePageToClosePanel(); | 2159 closePanel(); |
| 2193 assertNoContentViewCore(); | 2160 assertNoContentViewCore(); |
| 2194 } | 2161 } |
| 2195 | 2162 |
| 2196 /** | 2163 /** |
| 2197 * Tests that long press followed by expand creates Content and makes it vis
ible. | 2164 * Tests that long press followed by expand creates Content and makes it vis
ible. |
| 2198 * | 2165 * |
| 2199 */ | 2166 */ |
| 2200 @SmallTest | 2167 @SmallTest |
| 2201 @Feature({"ContextualSearch"}) | 2168 @Feature({"ContextualSearch"}) |
| 2202 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 2169 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 2203 public void testLongPressContentVisibility() throws InterruptedException, Ti
meoutException { | 2170 public void testLongPressContentVisibility() throws InterruptedException, Ti
meoutException { |
| 2204 // Simulate a long press and make sure no Content is created. | 2171 // Simulate a long press and make sure no Content is created. |
| 2205 simulateLongPressSearch("search"); | 2172 simulateLongPressSearch("search"); |
| 2206 assertNoContentViewCore(); | 2173 assertNoContentViewCore(); |
| 2207 assertNoSearchesLoaded(); | 2174 assertNoSearchesLoaded(); |
| 2208 | 2175 |
| 2209 // Expanding the Panel should make the Content visible. | 2176 // Expanding the Panel should make the Content visible. |
| 2210 tapPeekingBarToExpandAndAssert(); | 2177 tapPeekingBarToExpandAndAssert(); |
| 2211 assertContentViewCoreCreated(); | 2178 assertContentViewCoreCreated(); |
| 2212 assertContentViewCoreVisible(); | 2179 assertContentViewCoreVisible(); |
| 2213 | 2180 |
| 2214 // Closing the Panel should destroy the Content. | 2181 // Closing the Panel should destroy the Content. |
| 2215 tapBasePageToClosePanel(); | 2182 closePanel(); |
| 2216 assertNoContentViewCore(); | 2183 assertNoContentViewCore(); |
| 2217 } | 2184 } |
| 2218 | 2185 |
| 2219 /** | 2186 /** |
| 2220 * Tests swiping panel up and down after a tap search will only load the Con
tent once. | 2187 * Tests swiping panel up and down after a tap search will only load the Con
tent once. |
| 2221 */ | 2188 */ |
| 2222 @SmallTest | 2189 @SmallTest |
| 2223 @Feature({"ContextualSearch"}) | 2190 @Feature({"ContextualSearch"}) |
| 2224 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 2191 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 2225 public void testTapMultipleSwipeOnlyLoadsContentOnce() | 2192 public void testTapMultipleSwipeOnlyLoadsContentOnce() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2239 waitForPanelToPeek(); | 2206 waitForPanelToPeek(); |
| 2240 assertContentViewCoreVisible(); | 2207 assertContentViewCoreVisible(); |
| 2241 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2208 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2242 | 2209 |
| 2243 // Expanding the Panel should not change the visibility or load content
again. | 2210 // Expanding the Panel should not change the visibility or load content
again. |
| 2244 tapPeekingBarToExpandAndAssert(); | 2211 tapPeekingBarToExpandAndAssert(); |
| 2245 assertContentViewCoreVisible(); | 2212 assertContentViewCoreVisible(); |
| 2246 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2213 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2247 | 2214 |
| 2248 // Closing the Panel should destroy the Content. | 2215 // Closing the Panel should destroy the Content. |
| 2249 tapBasePageToClosePanel(); | 2216 closePanel(); |
| 2250 assertNoContentViewCore(); | 2217 assertNoContentViewCore(); |
| 2251 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2218 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2252 } | 2219 } |
| 2253 | 2220 |
| 2254 /** | 2221 /** |
| 2255 * Tests swiping panel up and down after a long press search will only load
the Content once. | 2222 * Tests swiping panel up and down after a long press search will only load
the Content once. |
| 2256 */ | 2223 */ |
| 2257 @SmallTest | 2224 @SmallTest |
| 2258 @Feature({"ContextualSearch"}) | 2225 @Feature({"ContextualSearch"}) |
| 2259 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 2226 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2275 waitForPanelToPeek(); | 2242 waitForPanelToPeek(); |
| 2276 assertContentViewCoreVisible(); | 2243 assertContentViewCoreVisible(); |
| 2277 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2244 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2278 | 2245 |
| 2279 // Expanding the Panel should not change the visibility or load content
again. | 2246 // Expanding the Panel should not change the visibility or load content
again. |
| 2280 tapPeekingBarToExpandAndAssert(); | 2247 tapPeekingBarToExpandAndAssert(); |
| 2281 assertContentViewCoreVisible(); | 2248 assertContentViewCoreVisible(); |
| 2282 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2249 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2283 | 2250 |
| 2284 // Closing the Panel should destroy the Content. | 2251 // Closing the Panel should destroy the Content. |
| 2285 tapBasePageToClosePanel(); | 2252 closePanel(); |
| 2286 assertNoContentViewCore(); | 2253 assertNoContentViewCore(); |
| 2287 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2254 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2288 } | 2255 } |
| 2289 | 2256 |
| 2290 /** | 2257 /** |
| 2291 * Tests that chained tap searches create new Content. | 2258 * Tests that chained tap searches create new Content. |
| 2292 */ | 2259 */ |
| 2293 @SmallTest | 2260 @SmallTest |
| 2294 @Feature({"ContextualSearch"}) | 2261 @Feature({"ContextualSearch"}) |
| 2295 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) | 2262 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2314 waitToPreventDoubleTapRecognition(); | 2281 waitToPreventDoubleTapRecognition(); |
| 2315 | 2282 |
| 2316 // Simulate a new tap and make sure a new Content is created. | 2283 // Simulate a new tap and make sure a new Content is created. |
| 2317 simulateTapSearch("resolution"); | 2284 simulateTapSearch("resolution"); |
| 2318 assertContentViewCoreCreatedButNeverMadeVisible(); | 2285 assertContentViewCoreCreatedButNeverMadeVisible(); |
| 2319 assertEquals(3, mFakeServer.getLoadedUrlCount()); | 2286 assertEquals(3, mFakeServer.getLoadedUrlCount()); |
| 2320 ContentViewCore cvc3 = getPanelContentViewCore(); | 2287 ContentViewCore cvc3 = getPanelContentViewCore(); |
| 2321 assertNotSame(cvc2, cvc3); | 2288 assertNotSame(cvc2, cvc3); |
| 2322 | 2289 |
| 2323 // Closing the Panel should destroy the Content. | 2290 // Closing the Panel should destroy the Content. |
| 2324 tapBasePageToClosePanel(); | 2291 closePanel(); |
| 2325 assertNoContentViewCore(); | 2292 assertNoContentViewCore(); |
| 2326 assertEquals(3, mFakeServer.getLoadedUrlCount()); | 2293 assertEquals(3, mFakeServer.getLoadedUrlCount()); |
| 2327 } | 2294 } |
| 2328 | 2295 |
| 2329 /** | 2296 /** |
| 2330 * Tests that chained searches load correctly. | 2297 * Tests that chained searches load correctly. |
| 2331 */ | 2298 */ |
| 2332 @DisabledTest(message = "crbug.com/551711") | 2299 @DisabledTest(message = "crbug.com/551711") |
| 2333 @SmallTest | 2300 @SmallTest |
| 2334 @Feature({"ContextualSearch"}) | 2301 @Feature({"ContextualSearch"}) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2360 // Expanding the Panel should load and display the new search. | 2327 // Expanding the Panel should load and display the new search. |
| 2361 tapPeekingBarToExpandAndAssert(); | 2328 tapPeekingBarToExpandAndAssert(); |
| 2362 assertContentViewCoreCreated(); | 2329 assertContentViewCoreCreated(); |
| 2363 assertContentViewCoreVisible(); | 2330 assertContentViewCoreVisible(); |
| 2364 assertEquals(2, mFakeServer.getLoadedUrlCount()); | 2331 assertEquals(2, mFakeServer.getLoadedUrlCount()); |
| 2365 assertLoadedSearchTermMatches("Resolution"); | 2332 assertLoadedSearchTermMatches("Resolution"); |
| 2366 ContentViewCore cvc2 = getPanelContentViewCore(); | 2333 ContentViewCore cvc2 = getPanelContentViewCore(); |
| 2367 assertNotSame(cvc1, cvc2); | 2334 assertNotSame(cvc1, cvc2); |
| 2368 | 2335 |
| 2369 // Closing the Panel should destroy the Content. | 2336 // Closing the Panel should destroy the Content. |
| 2370 tapBasePageToClosePanel(); | 2337 closePanel(); |
| 2371 assertNoContentViewCore(); | 2338 assertNoContentViewCore(); |
| 2372 assertEquals(2, mFakeServer.getLoadedUrlCount()); | 2339 assertEquals(2, mFakeServer.getLoadedUrlCount()); |
| 2373 } | 2340 } |
| 2374 | 2341 |
| 2375 /** | 2342 /** |
| 2376 * Tests that chained searches make Content visible when opening the Panel. | 2343 * Tests that chained searches make Content visible when opening the Panel. |
| 2377 */ | 2344 */ |
| 2378 @SmallTest | 2345 @SmallTest |
| 2379 @Feature({"ContextualSearch"}) | 2346 @Feature({"ContextualSearch"}) |
| 2380 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2347 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2415 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) | 2382 @Restriction(RESTRICTION_TYPE_NON_LOW_END_DEVICE) |
| 2416 @RetryOnFailure | 2383 @RetryOnFailure |
| 2417 public void testTapCloseRemovedFromHistory() | 2384 public void testTapCloseRemovedFromHistory() |
| 2418 throws InterruptedException, TimeoutException { | 2385 throws InterruptedException, TimeoutException { |
| 2419 // Simulate a tap and make sure a URL was loaded. | 2386 // Simulate a tap and make sure a URL was loaded. |
| 2420 simulateTapSearch("search"); | 2387 simulateTapSearch("search"); |
| 2421 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2388 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2422 String url = mFakeServer.getLoadedUrl(); | 2389 String url = mFakeServer.getLoadedUrl(); |
| 2423 | 2390 |
| 2424 // Close the Panel without seeing the Content. | 2391 // Close the Panel without seeing the Content. |
| 2425 tapBasePageToClosePanel(); | 2392 closePanel(); |
| 2426 | 2393 |
| 2427 // Now check that the URL has been removed from history. | 2394 // Now check that the URL has been removed from history. |
| 2428 assertTrue(mFakeServer.hasRemovedUrl(url)); | 2395 assertTrue(mFakeServer.hasRemovedUrl(url)); |
| 2429 } | 2396 } |
| 2430 | 2397 |
| 2431 /** | 2398 /** |
| 2432 * Tests that a tap followed by opening the Panel does not remove the loaded
URL from history. | 2399 * Tests that a tap followed by opening the Panel does not remove the loaded
URL from history. |
| 2433 */ | 2400 */ |
| 2434 @SmallTest | 2401 @SmallTest |
| 2435 @Feature({"ContextualSearch"}) | 2402 @Feature({"ContextualSearch"}) |
| 2436 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 2403 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 2437 public void testTapExpandNotRemovedFromHistory() | 2404 public void testTapExpandNotRemovedFromHistory() |
| 2438 throws InterruptedException, TimeoutException { | 2405 throws InterruptedException, TimeoutException { |
| 2439 // Simulate a tap and make sure a URL was loaded. | 2406 // Simulate a tap and make sure a URL was loaded. |
| 2440 simulateTapSearch("search"); | 2407 simulateTapSearch("search"); |
| 2441 assertEquals(1, mFakeServer.getLoadedUrlCount()); | 2408 assertEquals(1, mFakeServer.getLoadedUrlCount()); |
| 2442 String url = mFakeServer.getLoadedUrl(); | 2409 String url = mFakeServer.getLoadedUrl(); |
| 2443 | 2410 |
| 2444 // Expand Panel so that the Content becomes visible. | 2411 // Expand Panel so that the Content becomes visible. |
| 2445 tapPeekingBarToExpandAndAssert(); | 2412 tapPeekingBarToExpandAndAssert(); |
| 2446 | 2413 |
| 2447 // Close the Panel. | 2414 // Close the Panel. |
| 2448 tapBasePageToClosePanel(); | 2415 closePanel(); |
| 2449 | 2416 |
| 2450 // Now check that the URL has not been removed from history, since the C
ontent was seen. | 2417 // Now check that the URL has not been removed from history, since the C
ontent was seen. |
| 2451 assertFalse(mFakeServer.hasRemovedUrl(url)); | 2418 assertFalse(mFakeServer.hasRemovedUrl(url)); |
| 2452 } | 2419 } |
| 2453 | 2420 |
| 2454 /** | 2421 /** |
| 2455 * Tests that chained searches without opening the Panel removes all loaded
URLs from history. | 2422 * Tests that chained searches without opening the Panel removes all loaded
URLs from history. |
| 2456 */ | 2423 */ |
| 2457 @SmallTest | 2424 @SmallTest |
| 2458 @Feature({"ContextualSearch"}) | 2425 @Feature({"ContextualSearch"}) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2473 assertNotSame(url1, url2); | 2440 assertNotSame(url1, url2); |
| 2474 | 2441 |
| 2475 waitToPreventDoubleTapRecognition(); | 2442 waitToPreventDoubleTapRecognition(); |
| 2476 | 2443 |
| 2477 // Simulate another tap and make sure another URL was loaded. | 2444 // Simulate another tap and make sure another URL was loaded. |
| 2478 simulateTapSearch("resolution"); | 2445 simulateTapSearch("resolution"); |
| 2479 String url3 = mFakeServer.getLoadedUrl(); | 2446 String url3 = mFakeServer.getLoadedUrl(); |
| 2480 assertNotSame(url2, url3); | 2447 assertNotSame(url2, url3); |
| 2481 | 2448 |
| 2482 // Close the Panel without seeing any Content. | 2449 // Close the Panel without seeing any Content. |
| 2483 tapBasePageToClosePanel(); | 2450 closePanel(); |
| 2484 | 2451 |
| 2485 // Now check that all three URLs have been removed from history. | 2452 // Now check that all three URLs have been removed from history. |
| 2486 assertEquals(3, mFakeServer.getLoadedUrlCount()); | 2453 assertEquals(3, mFakeServer.getLoadedUrlCount()); |
| 2487 assertTrue(mFakeServer.hasRemovedUrl(url1)); | 2454 assertTrue(mFakeServer.hasRemovedUrl(url1)); |
| 2488 assertTrue(mFakeServer.hasRemovedUrl(url2)); | 2455 assertTrue(mFakeServer.hasRemovedUrl(url2)); |
| 2489 assertTrue(mFakeServer.hasRemovedUrl(url3)); | 2456 assertTrue(mFakeServer.hasRemovedUrl(url3)); |
| 2490 } | 2457 } |
| 2491 | 2458 |
| 2492 //==========================================================================
================== | 2459 //==========================================================================
================== |
| 2493 // Translate Tests | 2460 // Translate Tests |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2591 throws InterruptedException, TimeoutException { | 2558 throws InterruptedException, TimeoutException { |
| 2592 // Unless disabled, LongPress on any word should trigger translation. | 2559 // Unless disabled, LongPress on any word should trigger translation. |
| 2593 simulateLongPressSearch("search"); | 2560 simulateLongPressSearch("search"); |
| 2594 | 2561 |
| 2595 // Make sure we did not try to trigger translate. | 2562 // Make sure we did not try to trigger translate. |
| 2596 assertFalse(mManager.getRequest().isTranslationForced()); | 2563 assertFalse(mManager.getRequest().isTranslationForced()); |
| 2597 } | 2564 } |
| 2598 | 2565 |
| 2599 /** | 2566 /** |
| 2600 * Tests that Contextual Search works in fullscreen. Specifically, tests tha
t tapping a word | 2567 * Tests that Contextual Search works in fullscreen. Specifically, tests tha
t tapping a word |
| 2601 * peeks the panel, expanding the bar results in the bar ending at the corre
ct spot in the page | 2568 * peeks the panel, expanding the bar results in the bar ending at the corre
ct spot in the page. |
| 2602 * and tapping the base page closes the panel. | |
| 2603 */ | 2569 */ |
| 2604 @SmallTest | 2570 @SmallTest |
| 2605 @Feature({"ContextualSearch"}) | 2571 @Feature({"ContextualSearch"}) |
| 2606 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) | 2572 @Restriction({ChromeRestriction.RESTRICTION_TYPE_PHONE, RESTRICTION_TYPE_NON
_LOW_END_DEVICE}) |
| 2607 public void testTapContentAndExpandPanelInFullscreen() | 2573 public void testTapContentAndExpandPanelInFullscreen() |
| 2608 throws InterruptedException, TimeoutException { | 2574 throws InterruptedException, TimeoutException { |
| 2609 // Toggle tab to fulllscreen. | 2575 // Toggle tab to fullscreen. |
| 2610 FullscreenTestUtils.togglePersistentFullscreenAndAssert(getActivity().ge
tActivityTab(), | 2576 FullscreenTestUtils.togglePersistentFullscreenAndAssert(getActivity().ge
tActivityTab(), |
| 2611 true, getActivity()); | 2577 true, getActivity()); |
| 2612 | 2578 |
| 2613 // Simulate a tap and assert that the panel peeks. | 2579 // Simulate a tap and assert that the panel peeks. |
| 2614 simulateTapSearch("search"); | 2580 simulateTapSearch("search"); |
| 2615 | 2581 |
| 2616 // Expand the panel and assert that it ends up in the right place. | 2582 // Expand the panel and assert that it ends up in the right place. |
| 2617 tapPeekingBarToExpandAndAssert(); | 2583 tapPeekingBarToExpandAndAssert(); |
| 2618 assertEquals(mManager.getContextualSearchPanel().getHeight(), | 2584 assertEquals(mManager.getContextualSearchPanel().getHeight(), |
| 2619 mManager.getContextualSearchPanel().getPanelHeightFromState(Pane
lState.EXPANDED)); | 2585 mManager.getContextualSearchPanel().getPanelHeightFromState(Pane
lState.EXPANDED)); |
| 2620 | |
| 2621 // Tap the base page and assert that the panel is closed. | |
| 2622 tapBasePageToClosePanel(); | |
| 2623 } | 2586 } |
| 2624 | 2587 |
| 2625 /** | 2588 /** |
| 2626 * Tests that the Contextual Search panel is dismissed when entering or exit
ing fullscreen. | 2589 * Tests that the Contextual Search panel is dismissed when entering or exit
ing fullscreen. |
| 2627 */ | 2590 */ |
| 2628 @SmallTest | 2591 @SmallTest |
| 2629 @Feature({"ContextualSearch"}) | 2592 @Feature({"ContextualSearch"}) |
| 2630 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) | 2593 @Restriction({RESTRICTION_TYPE_NON_LOW_END_DEVICE}) |
| 2631 @RetryOnFailure | 2594 @RetryOnFailure |
| 2632 public void testPanelDismissedOnToggleFullscreen() | 2595 public void testPanelDismissedOnToggleFullscreen() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2644 // Simulate a tap and assert that the panel peeks. | 2607 // Simulate a tap and assert that the panel peeks. |
| 2645 simulateTapSearch("search"); | 2608 simulateTapSearch("search"); |
| 2646 | 2609 |
| 2647 // Toggle tab to non-fullscreen. | 2610 // Toggle tab to non-fullscreen. |
| 2648 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA
ctivity()); | 2611 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA
ctivity()); |
| 2649 | 2612 |
| 2650 // Assert that the panel is closed. | 2613 // Assert that the panel is closed. |
| 2651 waitForPanelToClose(); | 2614 waitForPanelToClose(); |
| 2652 } | 2615 } |
| 2653 } | 2616 } |
| OLD | NEW |