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