OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 8 |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.net.Uri; | 10 import android.net.Uri; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 /** | 82 /** |
83 * ContextualSearchManager wrapper that prevents network requests and most n
ative calls. | 83 * ContextualSearchManager wrapper that prevents network requests and most n
ative calls. |
84 */ | 84 */ |
85 private static class ContextualSearchManagerWrapper extends ContextualSearch
Manager { | 85 private static class ContextualSearchManagerWrapper extends ContextualSearch
Manager { |
86 public ContextualSearchManagerWrapper(ChromeActivity activity, | 86 public ContextualSearchManagerWrapper(ChromeActivity activity, |
87 WindowAndroid windowAndroid) { | 87 WindowAndroid windowAndroid) { |
88 super(activity, windowAndroid, null); | 88 super(activity, windowAndroid, null); |
89 setSelectionController(new MockCSSelectionController(activity, this)
); | 89 setSelectionController(new MockCSSelectionController(activity, this)
); |
90 ContentViewCore contentView = getSelectionController().getBaseConten
tView(); | 90 ContentViewCore contentView = getSelectionController().getBaseConten
tView(); |
91 contentView.setSelectionPopupControllerForTesting(new SelectionPopup
Controller( | 91 contentView.setSelectionPopupControllerForTesting( |
92 activity, null, null, null, contentView.getRenderCoordinates
())); | 92 new SelectionPopupController(activity, null, null, null, |
| 93 contentView.getRenderCoordinates(), null)); |
93 contentView.setSelectionClient(this); | 94 contentView.setSelectionClient(this); |
94 MockContextualSearchPolicy policy = new MockContextualSearchPolicy()
; | 95 MockContextualSearchPolicy policy = new MockContextualSearchPolicy()
; |
95 setContextualSearchPolicy(policy); | 96 setContextualSearchPolicy(policy); |
96 mTranslateController = new MockedCSTranslateController(activity, pol
icy, null); | 97 mTranslateController = new MockedCSTranslateController(activity, pol
icy, null); |
97 } | 98 } |
98 | 99 |
99 @Override | 100 @Override |
100 public void startSearchTermResolutionRequest(String selection) { | 101 public void startSearchTermResolutionRequest(String selection) { |
101 // Skip native calls and immediately "resolve" the search term. | 102 // Skip native calls and immediately "resolve" the search term. |
102 onSearchTermResolutionResponse( | 103 onSearchTermResolutionResponse( |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 .equals("text")); | 269 .equals("text")); |
269 | 270 |
270 // Fake tap on non-text. | 271 // Fake tap on non-text. |
271 mockTapEmptySpace(); | 272 mockTapEmptySpace(); |
272 | 273 |
273 assertTrue(mPanelManager.getRequestPanelShowCount() == 1); | 274 assertTrue(mPanelManager.getRequestPanelShowCount() == 1); |
274 assertTrue(mPanelManager.getPanelHideCount() == 1); | 275 assertTrue(mPanelManager.getPanelHideCount() == 1); |
275 assertTrue(mContextualSearchManager.getSelectionController().getSelected
Text() == null); | 276 assertTrue(mContextualSearchManager.getSelectionController().getSelected
Text() == null); |
276 } | 277 } |
277 } | 278 } |
OLD | NEW |