| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "components/omnibox/browser/zero_suggest_provider.h" | 5 #include "components/omnibox/browser/zero_suggest_provider.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "components/history/core/browser/top_sites.h" | 11 #include "components/history/core/browser/top_sites.h" |
| 11 #include "components/metrics/proto/omnibox_event.pb.h" | 12 #include "components/metrics/proto/omnibox_event.pb.h" |
| 12 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 13 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
| 13 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" | 14 #include "components/omnibox/browser/mock_autocomplete_provider_client.h" |
| 14 #include "components/omnibox/browser/omnibox_field_trial.h" | 15 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 15 #include "components/omnibox/browser/omnibox_pref_names.h" | 16 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 16 #include "components/omnibox/browser/test_scheme_classifier.h" | 17 #include "components/omnibox/browser/test_scheme_classifier.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 202 |
| 202 TemplateURLService* turl_model = client_->GetTemplateURLService(); | 203 TemplateURLService* turl_model = client_->GetTemplateURLService(); |
| 203 turl_model->Load(); | 204 turl_model->Load(); |
| 204 | 205 |
| 205 TemplateURLData data; | 206 TemplateURLData data; |
| 206 data.SetShortName(base::ASCIIToUTF16("t")); | 207 data.SetShortName(base::ASCIIToUTF16("t")); |
| 207 data.SetURL("https://www.google.com/?q={searchTerms}"); | 208 data.SetURL("https://www.google.com/?q={searchTerms}"); |
| 208 data.suggestions_url = "https://www.google.com/complete/?q={searchTerms}"; | 209 data.suggestions_url = "https://www.google.com/complete/?q={searchTerms}"; |
| 209 data.instant_url = "https://does/not/exist?strk=1"; | 210 data.instant_url = "https://does/not/exist?strk=1"; |
| 210 data.search_terms_replacement_key = "strk"; | 211 data.search_terms_replacement_key = "strk"; |
| 211 default_t_url_ = new TemplateURL(data); | 212 default_t_url_ = turl_model->Add(base::MakeUnique<TemplateURL>(data)); |
| 212 turl_model->Add(default_t_url_); | |
| 213 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); | 213 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); |
| 214 | 214 |
| 215 provider_ = ZeroSuggestProvider::Create(client_.get(), nullptr, this); | 215 provider_ = ZeroSuggestProvider::Create(client_.get(), nullptr, this); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void ZeroSuggestProviderTest::OnProviderUpdate(bool updated_matches) { | 218 void ZeroSuggestProviderTest::OnProviderUpdate(bool updated_matches) { |
| 219 } | 219 } |
| 220 | 220 |
| 221 void ZeroSuggestProviderTest::ResetFieldTrialList() { | 221 void ZeroSuggestProviderTest::ResetFieldTrialList() { |
| 222 // Destroy the existing FieldTrialList before creating a new one to avoid | 222 // Destroy the existing FieldTrialList before creating a new one to avoid |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 453 |
| 454 base::RunLoop().RunUntilIdle(); | 454 base::RunLoop().RunUntilIdle(); |
| 455 | 455 |
| 456 // Expect that the matches have been cleared. | 456 // Expect that the matches have been cleared. |
| 457 ASSERT_TRUE(provider_->matches().empty()); | 457 ASSERT_TRUE(provider_->matches().empty()); |
| 458 | 458 |
| 459 // Expect the new results have been stored. | 459 // Expect the new results have been stored. |
| 460 EXPECT_EQ(empty_response, | 460 EXPECT_EQ(empty_response, |
| 461 prefs->GetString(omnibox::kZeroSuggestCachedResults)); | 461 prefs->GetString(omnibox::kZeroSuggestCachedResults)); |
| 462 } | 462 } |
| OLD | NEW |