Chromium Code Reviews| 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; | 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 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 import org.chromium.base.ThreadUtils; | 27 import org.chromium.base.ThreadUtils; |
| 28 import org.chromium.base.test.util.CommandLineFlags; | 28 import org.chromium.base.test.util.CommandLineFlags; |
| 29 import org.chromium.base.test.util.Feature; | 29 import org.chromium.base.test.util.Feature; |
| 30 import org.chromium.base.test.util.Restriction; | 30 import org.chromium.base.test.util.Restriction; |
| 31 import org.chromium.chrome.R; | 31 import org.chromium.chrome.R; |
| 32 import org.chromium.chrome.browser.ChromeActivity; | 32 import org.chromium.chrome.browser.ChromeActivity; |
| 33 import org.chromium.chrome.browser.ChromeSwitches; | 33 import org.chromium.chrome.browser.ChromeSwitches; |
| 34 import org.chromium.chrome.browser.ChromeTabbedActivity; | 34 import org.chromium.chrome.browser.ChromeTabbedActivity; |
| 35 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate; | 35 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate; |
| 36 import org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressOb server; | |
| 36 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.PanelState; | 37 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanel.PanelState; |
| 37 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanelDelegate; | 38 import org.chromium.chrome.browser.compositor.bottombar.contextualsearch.Context ualSearchPanelDelegate; |
| 38 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; | 39 import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler; |
| 39 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; | 40 import org.chromium.chrome.browser.gsa.GSAContextDisplaySelection; |
| 40 import org.chromium.chrome.browser.omnibox.UrlBar; | 41 import org.chromium.chrome.browser.omnibox.UrlBar; |
| 41 import org.chromium.chrome.browser.tab.Tab; | 42 import org.chromium.chrome.browser.tab.Tab; |
| 42 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; | 43 import org.chromium.chrome.browser.tabmodel.EmptyTabModelSelectorObserver; |
| 43 import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; | 44 import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver; |
| 44 import org.chromium.chrome.browser.tabmodel.TabModelUtils; | 45 import org.chromium.chrome.browser.tabmodel.TabModelUtils; |
| 45 import org.chromium.chrome.browser.util.FeatureUtilities; | 46 import org.chromium.chrome.browser.util.FeatureUtilities; |
| 46 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 47 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 47 import org.chromium.chrome.test.util.ChromeTabUtils; | 48 import org.chromium.chrome.test.util.ChromeTabUtils; |
| 48 import org.chromium.chrome.test.util.OmniboxTestUtils; | 49 import org.chromium.chrome.test.util.OmniboxTestUtils; |
| 49 import org.chromium.chrome.test.util.TestHttpServerClient; | 50 import org.chromium.chrome.test.util.TestHttpServerClient; |
| 50 import org.chromium.components.navigation_interception.NavigationParams; | 51 import org.chromium.components.navigation_interception.NavigationParams; |
| 51 import org.chromium.content.browser.ContentViewCore; | 52 import org.chromium.content.browser.ContentViewCore; |
| 52 import org.chromium.content.browser.test.util.CallbackHelper; | 53 import org.chromium.content.browser.test.util.CallbackHelper; |
| 53 import org.chromium.content.browser.test.util.Criteria; | 54 import org.chromium.content.browser.test.util.Criteria; |
| 54 import org.chromium.content.browser.test.util.CriteriaHelper; | 55 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 55 import org.chromium.content.browser.test.util.DOMUtils; | 56 import org.chromium.content.browser.test.util.DOMUtils; |
| 56 import org.chromium.content.browser.test.util.TouchCommon; | 57 import org.chromium.content.browser.test.util.TouchCommon; |
| 57 import org.chromium.ui.base.PageTransition; | 58 import org.chromium.ui.base.PageTransition; |
| 58 import org.chromium.ui.touch_selection.SelectionEventType; | 59 import org.chromium.ui.touch_selection.SelectionEventType; |
| 59 | 60 |
| 60 import java.util.concurrent.TimeoutException; | 61 import java.util.concurrent.TimeoutException; |
| 61 | 62 |
| 63 // TODO(pedrosimonetti): add tests for recent regressions. | |
|
aurimas (slooooooooow)
2015/10/14 21:56:11
Is there a bug tracking that? Please mention it he
pedro (no code reviews)
2015/10/14 22:43:37
Done.
| |
| 64 | |
| 62 /** | 65 /** |
| 63 * Tests the Contextual Search Manager using instrumentation tests. | 66 * Tests the Contextual Search Manager using instrumentation tests. |
| 64 */ | 67 */ |
| 65 @CommandLineFlags.Add(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH_FOR_TESTING) | 68 @CommandLineFlags.Add(ChromeSwitches.ENABLE_CONTEXTUAL_SEARCH_FOR_TESTING) |
| 66 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> { | 69 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> { |
| 67 | 70 |
| 68 private static final String TEST_PAGE = | 71 private static final String TEST_PAGE = |
| 69 TestHttpServerClient.getUrl("chrome/test/data/android/contextualsear ch/tap_test.html"); | 72 TestHttpServerClient.getUrl("chrome/test/data/android/contextualsear ch/tap_test.html"); |
| 70 private static final int TEST_TIMEOUT = 15000; | 73 private static final int TEST_TIMEOUT = 15000; |
| 71 | 74 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 88 | 91 |
| 89 @Override | 92 @Override |
| 90 protected void setUp() throws Exception { | 93 protected void setUp() throws Exception { |
| 91 super.setUp(); | 94 super.setUp(); |
| 92 | 95 |
| 93 mManager = getActivity().getContextualSearchManager(); | 96 mManager = getActivity().getContextualSearchManager(); |
| 94 | 97 |
| 95 if (mManager != null) { | 98 if (mManager != null) { |
| 96 mPanelDelegate = mManager.getContextualSearchPanelDelegate(); | 99 mPanelDelegate = mManager.getContextualSearchPanelDelegate(); |
| 97 mFakeServer = new ContextualSearchFakeServer(mManager, | 100 mFakeServer = new ContextualSearchFakeServer(mManager, |
| 98 mManager.getOverlayContentDelegate()); | 101 mManager.getOverlayContentDelegate(), |
| 99 mPanelDelegate.setOverlayPanelContent(mFakeServer); | 102 new OverlayContentProgressObserver(), |
| 103 getActivity()); | |
| 104 | |
| 105 mPanelDelegate.setOverlayPanelContentFactory(mFakeServer); | |
| 100 mManager.setNetworkCommunicator(mFakeServer); | 106 mManager.setNetworkCommunicator(mFakeServer); |
| 101 mSelectionController = mManager.getSelectionController(); | 107 mSelectionController = mManager.getSelectionController(); |
| 102 mPolicy = ContextualSearchPolicy.getInstance(getActivity()); | 108 mPolicy = ContextualSearchPolicy.getInstance(getActivity()); |
| 103 | 109 |
| 104 mPolicy.overrideDecidedStateForTesting(true); | 110 mPolicy.overrideDecidedStateForTesting(true); |
| 105 resetCounters(); | 111 resetCounters(); |
| 106 } | 112 } |
| 107 | 113 |
| 108 IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); | 114 IntentFilter filter = new IntentFilter(Intent.ACTION_VIEW); |
| 109 filter.addCategory(Intent.CATEGORY_BROWSABLE); | 115 filter.addCategory(Intent.CATEGORY_BROWSABLE); |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 mFakeServer.getLoadedUrl() != null | 289 mFakeServer.getLoadedUrl() != null |
| 284 && !mFakeServer.getLoadedUrl().contains(CONTEXTUAL_SEARCH_PREFET CH_PARAM)); | 290 && !mFakeServer.getLoadedUrl().contains(CONTEXTUAL_SEARCH_PREFET CH_PARAM)); |
| 285 } | 291 } |
| 286 | 292 |
| 287 private void assertNoSearchesLoaded() { | 293 private void assertNoSearchesLoaded() { |
| 288 assertEquals(0, mFakeServer.loadedUrlCount()); | 294 assertEquals(0, mFakeServer.loadedUrlCount()); |
| 289 assertLoadedNoUrl(); | 295 assertLoadedNoUrl(); |
| 290 } | 296 } |
| 291 | 297 |
| 292 private void assertContentViewCoreCreated() { | 298 private void assertContentViewCoreCreated() { |
| 293 assertTrue(mFakeServer.isSearchContentViewCreated()); | 299 assertTrue(mFakeServer.didCreateContentView()); |
| 294 } | 300 } |
| 295 | 301 |
| 296 private void assertNoContentViewCore() { | 302 private void assertNoContentViewCore() { |
| 297 assertFalse(mFakeServer.isSearchContentViewCreated()); | 303 assertFalse(mFakeServer.didCreateContentView()); |
| 298 } | 304 } |
| 299 | 305 |
| 300 /** | 306 /** |
| 301 * Asserts that the tap triggered promo counter is enabled and at the specif ied count. | 307 * Asserts that the tap triggered promo counter is enabled and at the specif ied count. |
| 302 */ | 308 */ |
| 303 private void assertTapPromoCounterEnabledAt(int expectedCount) { | 309 private void assertTapPromoCounterEnabledAt(int expectedCount) { |
| 304 assertTrue(mPolicy.getPromoTapCounter().isEnabled()); | 310 assertTrue(mPolicy.getPromoTapCounter().isEnabled()); |
| 305 assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount()); | 311 assertEquals(expectedCount, mPolicy.getPromoTapCounter().getCount()); |
| 306 } | 312 } |
| 307 | 313 |
| (...skipping 1671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1979 // Click elsewhere to clear the selection. | 1985 // Click elsewhere to clear the selection. |
| 1980 clickNode("question-mark"); | 1986 clickNode("question-mark"); |
| 1981 waitForSelectionToBe(null); | 1987 waitForSelectionToBe(null); |
| 1982 | 1988 |
| 1983 // Now that the Panel was opened at least once, the Promo should not sho w again. | 1989 // Now that the Panel was opened at least once, the Promo should not sho w again. |
| 1984 longPressNode("intelligence"); | 1990 longPressNode("intelligence"); |
| 1985 waitForPanelToPeekAndAssert(); | 1991 waitForPanelToPeekAndAssert(); |
| 1986 assertFalse(mPanelDelegate.isPeekPromoVisible()); | 1992 assertFalse(mPanelDelegate.isPeekPromoVisible()); |
| 1987 } | 1993 } |
| 1988 } | 1994 } |
| OLD | NEW |