Commit c67cbef8 authored by Tomasz Wiszkowski's avatar Tomasz Wiszkowski Committed by Ender

Fix suggestion list not re-appearing when suggestions are unchanged.

This CL addresses the problem where AutocompleteController sends
unchanged list of suggestions to present.

Bug: 1082619
Change-Id: I78a7fb2652f45eafadb891720131b355a0649a6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2202383
Commit-Queue: Ender <ender@google.com>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Auto-Submit: Ender <ender@google.com>
Cr-Commit-Position: refs/heads/master@{#768914}
parent dfc7d7f4
...@@ -1266,6 +1266,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi ...@@ -1266,6 +1266,7 @@ class AutocompleteMediator implements OnSuggestionsReceivedListener, StartStopWi
getSuggestionModelList().clear(); getSuggestionModelList().clear();
mViewInfoList.clear(); mViewInfoList.clear();
mAutocompleteResult = new AutocompleteResult(null, null);
updateOmniboxSuggestionsVisibility(); updateOmniboxSuggestionsVisibility();
} }
......
...@@ -559,6 +559,40 @@ public class AutocompleteMediatorUnitTest { ...@@ -559,6 +559,40 @@ public class AutocompleteMediatorUnitTest {
verify(mAutocompleteDelegate, never()).setKeyboardVisibility(eq(false)); verify(mAutocompleteDelegate, never()).setKeyboardVisibility(eq(false));
} }
@CalledByNativeJavaTest
@NativeJavaTestFeatures.Disable({ChromeFeatureList.OMNIBOX_ADAPTIVE_SUGGESTIONS_COUNT,
ChromeFeatureList.OMNIBOX_DEFERRED_KEYBOARD_POPUP})
public void
updateSuggestionsList_suggestionsAreRebuiltOnSubsequentInteractions() {
// This test validates scenario:
// 1. user focuses omnibox
// 2. AutocompleteMediator receives suggestions
// 3. user sees suggestions, but leaves omnibox
// 4. user focuses omnibox again
// 5. AutocompleteMediator receives same suggestions as in (2)
// 6. user sees suggestions again.
final List<OmniboxSuggestion> res1 = buildDummySuggestionsList(10, "Suggestion");
final List<OmniboxSuggestion> res2 = buildDummySuggestionsList(10, "Suggestion");
Assert.assertEquals(res1, res2);
mMediator.onNativeInitialized();
mMediator.onSuggestionsReceived(new AutocompleteResult(res1, null), "");
Assert.assertEquals(mMediator.getSuggestionViewInfoListForTest().size(), res1.size());
Assert.assertTrue(mListModel.get(SuggestionListProperties.VISIBLE));
mMediator.onUrlFocusChange(false);
Assert.assertFalse(mListModel.get(SuggestionListProperties.VISIBLE));
Assert.assertEquals(mMediator.getSuggestionViewInfoListForTest().size(), 0);
// Simulate omnibox focused. this bypasses the native call to fetch suggestions.
mMediator.setSuggestionVisibilityState(
AutocompleteMediator.SuggestionVisibilityState.ALLOWED);
mMediator.onSuggestionsReceived(new AutocompleteResult(res2, null), "");
Assert.assertEquals(mMediator.getSuggestionViewInfoListForTest().size(), res2.size());
Assert.assertTrue(mListModel.get(SuggestionListProperties.VISIBLE));
}
@CalledByNativeJavaTest @CalledByNativeJavaTest
@NativeJavaTestFeatures.Disable({ChromeFeatureList.OMNIBOX_ADAPTIVE_SUGGESTIONS_COUNT, @NativeJavaTestFeatures.Disable({ChromeFeatureList.OMNIBOX_ADAPTIVE_SUGGESTIONS_COUNT,
ChromeFeatureList.OMNIBOX_DEFERRED_KEYBOARD_POPUP}) ChromeFeatureList.OMNIBOX_DEFERRED_KEYBOARD_POPUP})
......
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