Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Unified Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 2717893002: Omnibox - Warm Up PSuggest on Focus (Closed)
Patch Set: rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/search_provider_unittest.cc
diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc
index 3595a3bd49a7cf5c212360ea973ac0960cec0242..bf4c088b852e7c329f329af87d509a6c9fc69a72 100644
--- a/chrome/browser/autocomplete/search_provider_unittest.cc
+++ b/chrome/browser/autocomplete/search_provider_unittest.cc
@@ -17,6 +17,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
@@ -3523,3 +3524,40 @@ TEST_F(SearchProviderTest, DoesNotProvideOnFocus) {
provider_->Start(input, false);
EXPECT_TRUE(provider_->matches().empty());
}
+
+TEST_F(SearchProviderTest, SendsWarmUpRequestOnFocus) {
+ AutocompleteInput input(
+ base::ASCIIToUTF16("f"), base::string16::npos, std::string(), GURL(),
+ metrics::OmniboxEventProto::INVALID_SPEC, false, true, true, true, true,
+ ChromeAutocompleteSchemeClassifier(&profile_));
+
+ // First, verify that without the warm-up feature enabled, the provider
+ // immediately terminates with no matches.
+ provider_->Start(input, false);
+ // RunUntilIdle so that SearchProvider has a chance to create the URLFetchers
+ // (if it wants to, which it shouldn't in this case).
+ base::RunLoop().RunUntilIdle();
+ EXPECT_TRUE(provider_->done());
+ EXPECT_TRUE(provider_->matches().empty());
+
+ // Then, check the behavior with the warm-up feature enabled.
+ base::test::ScopedFeatureList feature_list;
+ feature_list.InitAndEnableFeature(omnibox::kSearchProviderWarmUpOnFocus);
+ provider_->Start(input, false);
+ // RunUntilIdle so that SearchProvider create the URLFetcher.
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(provider_->done());
+ EXPECT_TRUE(provider_->matches().empty());
+ // Make sure the default providers suggest service was queried.
Peter Kasting 2017/03/01 03:00:34 Nit: provider's
Mark P 2017/03/01 20:02:32 Done.
+ net::TestURLFetcher* fetcher = test_factory_.GetFetcherByID(
+ SearchProvider::kDefaultProviderURLFetcherID);
+ EXPECT_TRUE(fetcher);
+ // Even if the fetcher returns results, we should still have no suggestions
+ // (though the provider should now we done).
Peter Kasting 2017/03/01 03:00:34 Nit: we -> be
Mark P 2017/03/01 20:02:32 Done.
+ fetcher->set_response_code(200);
+ fetcher->SetResponseString("[\"\",[\"a\", \"b\"],[],[],{}]");
Peter Kasting 2017/03/01 03:00:34 Nit: Might be more readable with a raw string lite
Mark P 2017/03/01 20:02:32 Indeed, it is. I didn't know those existed. :-)
+ fetcher->delegate()->OnURLFetchComplete(fetcher);
+ RunTillProviderDone();
+ EXPECT_TRUE(provider_->done());
+ EXPECT_TRUE(provider_->matches().empty());
+}
« no previous file with comments | « no previous file | components/omnibox/browser/omnibox_field_trial.h » ('j') | components/omnibox/browser/omnibox_field_trial.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698