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.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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 // TODO(pedrosimonetti): Create class with limited API to encapsulate the intern als of simulations. | 69 // TODO(pedrosimonetti): Create class with limited API to encapsulate the intern als of simulations. |
| 70 // TODO(pedrosimonetti): Separate tests into different classes grouped by type o f tests. Examples: | 70 // TODO(pedrosimonetti): Separate tests into different classes grouped by type o f tests. Examples: |
| 71 // Gestures (Tap, LongPress), Search Term Resolution (resolves, expand selection , prevent preload, | 71 // Gestures (Tap, LongPress), Search Term Resolution (resolves, expand selection , prevent preload, |
| 72 // translation), Panel interaction (tap, fling up/down, close), Content (creatio n, loading, | 72 // translation), Panel interaction (tap, fling up/down, close), Content (creatio n, loading, |
| 73 // visibility, history, delayed load), Tab Promotion, Policy (add tests to check if policies | 73 // visibility, history, delayed load), Tab Promotion, Policy (add tests to check if policies |
| 74 // affect the behavior correctly), General (remaining tests), etc. | 74 // affect the behavior correctly), General (remaining tests), etc. |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * Tests the Contextual Search Manager using instrumentation tests. | 77 * Tests the Contextual Search Manager using instrumentation tests. |
| 78 */ | 78 */ |
| 79 @CommandLineFlags.Add(ContextualSearchFieldTrial.SUPPRESSION_TAPS + "=1000") | 79 |
| 80 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> { | 80 public class ContextualSearchManagerTest extends ChromeActivityTestCaseBase<Chro meActivity> { |
| 81 | 81 |
| 82 private static final String TEST_PAGE = | 82 private static final String TEST_PAGE = |
| 83 "/chrome/test/data/android/contextualsearch/tap_test.html"; | 83 "/chrome/test/data/android/contextualsearch/tap_test.html"; |
| 84 private static final int TEST_TIMEOUT = 15000; | 84 private static final int TEST_TIMEOUT = 15000; |
| 85 private static final int TEST_EXPECTED_FAILURE_TIMEOUT = 1000; | 85 private static final int TEST_EXPECTED_FAILURE_TIMEOUT = 1000; |
| 86 private static final int PLENTY_OF_TAPS = 1000; | 86 private static final int PLENTY_OF_TAPS = 1000; |
| 87 | 87 |
| 88 // TODO(donnd): get these from TemplateURL once the low-priority or Contextu al Search API | 88 // TODO(donnd): get these from TemplateURL once the low-priority or Contextu al Search API |
| 89 // is fully supported. | 89 // is fully supported. |
| 90 private static final String NORMAL_PRIORITY_SEARCH_ENDPOINT = "/search?"; | 90 private static final String NORMAL_PRIORITY_SEARCH_ENDPOINT = "/search?"; |
| 91 private static final String LOW_PRIORITY_SEARCH_ENDPOINT = "/s?"; | 91 private static final String LOW_PRIORITY_SEARCH_ENDPOINT = "/s?"; |
| 92 private static final String CONTEXTUAL_SEARCH_PREFETCH_PARAM = "&pf=c"; | 92 private static final String CONTEXTUAL_SEARCH_PREFETCH_PARAM = "&pf=c"; |
| 93 // The number of ms to delay startup when a URL is being loaded. | |
| 94 private static final int ACTIVITY_STARTUP_DELAY_MS = 1000; | |
|
Theresa
2016/08/11 20:35:44
Can we add a TODO note to fix this more correctly?
| |
| 93 | 95 |
| 94 private ActivityMonitor mActivityMonitor; | 96 private ActivityMonitor mActivityMonitor; |
| 95 private ContextualSearchFakeServer mFakeServer; | 97 private ContextualSearchFakeServer mFakeServer; |
| 96 private ContextualSearchManager mManager; | 98 private ContextualSearchManager mManager; |
| 97 private ContextualSearchPanel mPanel; | 99 private ContextualSearchPanel mPanel; |
| 98 private ContextualSearchPolicy mPolicy; | 100 private ContextualSearchPolicy mPolicy; |
| 99 private ContextualSearchSelectionController mSelectionController; | 101 private ContextualSearchSelectionController mSelectionController; |
| 100 private EmbeddedTestServer mTestServer; | 102 private EmbeddedTestServer mTestServer; |
| 101 | 103 |
| 102 // State for an individual test. | 104 // State for an individual test. |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 /** | 216 /** |
| 215 * Runs the given Runnable in the main thread. | 217 * Runs the given Runnable in the main thread. |
| 216 * @param runnable The Runnable. | 218 * @param runnable The Runnable. |
| 217 */ | 219 */ |
| 218 public void runOnMainSync(Runnable runnable) { | 220 public void runOnMainSync(Runnable runnable) { |
| 219 getInstrumentation().runOnMainSync(runnable); | 221 getInstrumentation().runOnMainSync(runnable); |
| 220 } | 222 } |
| 221 | 223 |
| 222 @Override | 224 @Override |
| 223 public void startMainActivity() throws InterruptedException { | 225 public void startMainActivity() throws InterruptedException { |
| 224 startMainActivityWithURL(mTestServer.getURL(TEST_PAGE)); | 226 startMainActivityWithDelay(mTestServer.getURL(TEST_PAGE), ACTIVITY_START UP_DELAY_MS); |
|
Theresa
2016/08/11 20:35:44
I have a preference for putting the delay here ins
| |
| 225 } | 227 } |
| 226 | 228 |
| 227 //========================================================================== ================== | 229 //========================================================================== ================== |
| 228 // Fake Searches Helpers | 230 // Fake Searches Helpers |
| 229 //========================================================================== ================== | 231 //========================================================================== ================== |
| 230 | 232 |
| 231 /** | 233 /** |
| 232 * Simulates a long-press triggered search. | 234 * Simulates a long-press triggered search. |
| 233 * | 235 * |
| 234 * @param nodeId The id of the node to be long-pressed. | 236 * @param nodeId The id of the node to be long-pressed. |
| (...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2590 // Simulate a tap and assert that the panel peeks. | 2592 // Simulate a tap and assert that the panel peeks. |
| 2591 simulateTapSearch("search"); | 2593 simulateTapSearch("search"); |
| 2592 | 2594 |
| 2593 // Toggle tab to non-fullscreen. | 2595 // Toggle tab to non-fullscreen. |
| 2594 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA ctivity()); | 2596 FullscreenTestUtils.togglePersistentFullscreenAndAssert(tab, false, getA ctivity()); |
| 2595 | 2597 |
| 2596 // Assert that the panel is closed. | 2598 // Assert that the panel is closed. |
| 2597 waitForPanelToClose(); | 2599 waitForPanelToClose(); |
| 2598 } | 2600 } |
| 2599 } | 2601 } |
| OLD | NEW |