Commit cd2237d3 authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Commit Bot

Do not initialize QueryProcessor by default

This change allows most tests to operate without having the QueryTile
Processor initialized if these don't care about its presence.

Bug: 982818
Change-Id: I6fe6c0bba9fb83d99bcad9e93c84a831df2da8bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219149
Commit-Queue: Ender <ender@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772480}
parent 4cc8875a
...@@ -78,9 +78,8 @@ public class AutocompleteCoordinatorImpl implements AutocompleteCoordinator { ...@@ -78,9 +78,8 @@ public class AutocompleteCoordinatorImpl implements AutocompleteCoordinator {
MVCListAdapter.ModelList listItems = new MVCListAdapter.ModelList(); MVCListAdapter.ModelList listItems = new MVCListAdapter.ModelList();
mQueryTileCoordinator = new OmniboxQueryTileCoordinator(context, this::onTileSelected); mQueryTileCoordinator = new OmniboxQueryTileCoordinator(context, this::onTileSelected);
mMediator = new AutocompleteMediator(context, delegate, urlBarEditingTextProvider, mMediator = new AutocompleteMediator(context, delegate, urlBarEditingTextProvider,
new AutocompleteController(), mQueryTileCoordinator::setTiles, listModel, new AutocompleteController(), listModel, new Handler());
new Handler()); mMediator.initDefaultProcessors(mQueryTileCoordinator::setTiles);
mMediator.initDefaultProcessors();
listModel.set(SuggestionListProperties.EMBEDDER, dropdownEmbedder); listModel.set(SuggestionListProperties.EMBEDDER, dropdownEmbedder);
listModel.set(SuggestionListProperties.VISIBLE, false); listModel.set(SuggestionListProperties.VISIBLE, false);
......
...@@ -135,7 +135,6 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -135,7 +135,6 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
// it in the mSuggestionProcessors list. The processor currently cannot be combined with // it in the mSuggestionProcessors list. The processor currently cannot be combined with
// other processors because of its unique requirements. // other processors because of its unique requirements.
private @Nullable EditUrlSuggestionProcessor mEditUrlProcessor; private @Nullable EditUrlSuggestionProcessor mEditUrlProcessor;
private final TileSuggestionProcessor mTileSuggestionProcessor;
private HeaderProcessor mHeaderProcessor; private HeaderProcessor mHeaderProcessor;
private final List<SuggestionProcessor> mSuggestionProcessors; private final List<SuggestionProcessor> mSuggestionProcessors;
private final List<DropdownItemViewInfo> mViewInfoList; private final List<DropdownItemViewInfo> mViewInfoList;
...@@ -200,8 +199,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -200,8 +199,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
public AutocompleteMediator(Context context, AutocompleteDelegate delegate, public AutocompleteMediator(Context context, AutocompleteDelegate delegate,
UrlBarEditingTextStateProvider textProvider, UrlBarEditingTextStateProvider textProvider,
AutocompleteController autocompleteController, AutocompleteController autocompleteController, PropertyModel listPropertyModel,
Callback<List<QueryTile>> queryTileSuggestionCallback, PropertyModel listPropertyModel,
Handler handler) { Handler handler) {
mContext = context; mContext = context;
mDelegate = delegate; mDelegate = delegate;
...@@ -210,13 +208,10 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -210,13 +208,10 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
mAutocomplete = autocompleteController; mAutocomplete = autocompleteController;
mAutocomplete.setOnSuggestionsReceivedListener(this); mAutocomplete.setOnSuggestionsReceivedListener(this);
mHandler = handler; mHandler = handler;
mTileSuggestionProcessor =
new TileSuggestionProcessor(mContext, queryTileSuggestionCallback);
mHeaderProcessor = new HeaderProcessor(mContext, this, mDelegate); mHeaderProcessor = new HeaderProcessor(mContext, this, mDelegate);
mSuggestionProcessors = new ArrayList<>(); mSuggestionProcessors = new ArrayList<>();
mViewInfoList = new ArrayList<>(); mViewInfoList = new ArrayList<>();
mAutocompleteResult = new AutocompleteResult(null, null); mAutocompleteResult = new AutocompleteResult(null, null);
mOverviewModeObserver = new EmptyOverviewModeObserver() { mOverviewModeObserver = new EmptyOverviewModeObserver() {
@Override @Override
public void onOverviewModeStartedShowing(boolean showToolbar) { public void onOverviewModeStartedShowing(boolean showToolbar) {
...@@ -230,7 +225,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -230,7 +225,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
/** /**
* Initialize the Mediator with default set of suggestions processors. * Initialize the Mediator with default set of suggestions processors.
*/ */
void initDefaultProcessors() { void initDefaultProcessors(Callback<List<QueryTile>> queryTileSuggestionCallback) {
final Supplier<ImageFetcher> imageFetcherSupplier = createImageFetcherSupplier(); final Supplier<ImageFetcher> imageFetcherSupplier = createImageFetcherSupplier();
final Supplier<LargeIconBridge> iconBridgeSupplier = createIconBridgeSupplier(); final Supplier<LargeIconBridge> iconBridgeSupplier = createIconBridgeSupplier();
...@@ -243,7 +238,8 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -243,7 +238,8 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
registerSuggestionProcessor( registerSuggestionProcessor(
new EntitySuggestionProcessor(mContext, this, imageFetcherSupplier)); new EntitySuggestionProcessor(mContext, this, imageFetcherSupplier));
registerSuggestionProcessor(new TailSuggestionProcessor(mContext, this)); registerSuggestionProcessor(new TailSuggestionProcessor(mContext, this));
registerSuggestionProcessor(mTileSuggestionProcessor); registerSuggestionProcessor(
new TileSuggestionProcessor(mContext, queryTileSuggestionCallback));
registerSuggestionProcessor(new BasicSuggestionProcessor( registerSuggestionProcessor(new BasicSuggestionProcessor(
mContext, this, mUrlBarEditingTextProvider, iconBridgeSupplier)); mContext, this, mUrlBarEditingTextProvider, iconBridgeSupplier));
} }
......
...@@ -87,8 +87,8 @@ public class AutocompleteMediatorUnitTest { ...@@ -87,8 +87,8 @@ public class AutocompleteMediatorUnitTest {
mListModel.set(SuggestionListProperties.SUGGESTION_MODELS, mSuggestionModels); mListModel.set(SuggestionListProperties.SUGGESTION_MODELS, mSuggestionModels);
mMediator = new AutocompleteMediator(ContextUtils.getApplicationContext(), mMediator = new AutocompleteMediator(ContextUtils.getApplicationContext(),
mAutocompleteDelegate, mTextStateProvider, mAutocompleteController, null, mAutocompleteDelegate, mTextStateProvider, mAutocompleteController, mListModel,
mListModel, mHandler); mHandler);
mMediator.setToolbarDataProvider(mToolbarDataProvider); mMediator.setToolbarDataProvider(mToolbarDataProvider);
mMediator.registerSuggestionProcessor(mMockProcessor); mMediator.registerSuggestionProcessor(mMockProcessor);
mMediator.setSuggestionVisibilityState( mMediator.setSuggestionVisibilityState(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment