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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 /** | 83 /** |
84 * ContextualSearchManager wrapper that prevents network requests and most n
ative calls. | 84 * ContextualSearchManager wrapper that prevents network requests and most n
ative calls. |
85 */ | 85 */ |
86 private static class ContextualSearchManagerWrapper extends ContextualSearch
Manager { | 86 private static class ContextualSearchManagerWrapper extends ContextualSearch
Manager { |
87 public ContextualSearchManagerWrapper(ChromeActivity activity, | 87 public ContextualSearchManagerWrapper(ChromeActivity activity, |
88 WindowAndroid windowAndroid) { | 88 WindowAndroid windowAndroid) { |
89 super(activity, windowAndroid, null); | 89 super(activity, windowAndroid, null); |
90 setSelectionController(new MockCSSelectionController(activity, this)
); | 90 setSelectionController(new MockCSSelectionController(activity, this)
); |
91 ContentViewCore contentView = getSelectionController().getBaseConten
tView(); | 91 ContentViewCore contentView = getSelectionController().getBaseConten
tView(); |
92 contentView.setSelectionPopupControllerForTesting(new SelectionPopup
Controller( | 92 contentView.setSelectionPopupControllerForTesting( |
93 activity, null, null, null, contentView.getRenderCoordinates
())); | 93 new SelectionPopupController(activity, null, null, null, |
| 94 contentView.getRenderCoordinates(), null)); |
94 contentView.setSelectionClient(this); | 95 contentView.setSelectionClient(this); |
95 MockContextualSearchPolicy policy = new MockContextualSearchPolicy()
; | 96 MockContextualSearchPolicy policy = new MockContextualSearchPolicy()
; |
96 setContextualSearchPolicy(policy); | 97 setContextualSearchPolicy(policy); |
97 mTranslateController = new MockedCSTranslateController(activity, pol
icy, null); | 98 mTranslateController = new MockedCSTranslateController(activity, pol
icy, null); |
98 } | 99 } |
99 | 100 |
100 @Override | 101 @Override |
101 public void startSearchTermResolutionRequest(String selection) { | 102 public void startSearchTermResolutionRequest(String selection) { |
102 // Skip native calls and immediately "resolve" the search term. | 103 // Skip native calls and immediately "resolve" the search term. |
103 onSearchTermResolutionResponse( | 104 onSearchTermResolutionResponse( |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 .equals("text")); | 263 .equals("text")); |
263 | 264 |
264 // Fake tap on non-text. | 265 // Fake tap on non-text. |
265 mockTapEmptySpace(); | 266 mockTapEmptySpace(); |
266 | 267 |
267 assertTrue(mPanelManager.getRequestPanelShowCount() == 1); | 268 assertTrue(mPanelManager.getRequestPanelShowCount() == 1); |
268 assertTrue(mPanelManager.getPanelHideCount() == 1); | 269 assertTrue(mPanelManager.getPanelHideCount() == 1); |
269 assertTrue(mContextualSearchManager.getSelectionController().getSelected
Text() == null); | 270 assertTrue(mContextualSearchManager.getSelectionController().getSelected
Text() == null); |
270 } | 271 } |
271 } | 272 } |
OLD | NEW |