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 "chrome/browser/autocomplete/zero_suggest_provider.h" | 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 TemplateURLService* turl_model = | 70 TemplateURLService* turl_model = |
71 TemplateURLServiceFactory::GetForProfile(&profile_); | 71 TemplateURLServiceFactory::GetForProfile(&profile_); |
72 turl_model->Load(); | 72 turl_model->Load(); |
73 | 73 |
74 TemplateURLData data; | 74 TemplateURLData data; |
75 data.short_name = base::ASCIIToUTF16("t"); | 75 data.short_name = base::ASCIIToUTF16("t"); |
76 data.SetURL("https://www.google.com/?q={searchTerms}"); | 76 data.SetURL("https://www.google.com/?q={searchTerms}"); |
77 data.suggestions_url = "https://www.google.com/complete/?q={searchTerms}"; | 77 data.suggestions_url = "https://www.google.com/complete/?q={searchTerms}"; |
78 data.instant_url = "https://does/not/exist?strk=1"; | 78 data.instant_url = "https://does/not/exist?strk=1"; |
79 data.search_terms_replacement_key = "strk"; | 79 data.search_terms_replacement_key = "strk"; |
80 default_t_url_ = new TemplateURL(&profile_, data); | 80 default_t_url_ = new TemplateURL(data); |
81 turl_model->Add(default_t_url_); | 81 turl_model->Add(default_t_url_); |
82 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); | 82 turl_model->SetUserSelectedDefaultSearchProvider(default_t_url_); |
83 | 83 |
84 provider_ = ZeroSuggestProvider::Create(this, &profile_); | 84 provider_ = ZeroSuggestProvider::Create(this, &profile_); |
85 } | 85 } |
86 | 86 |
87 void ZeroSuggestProviderTest::TearDown() { | 87 void ZeroSuggestProviderTest::TearDown() { |
88 // Shutdown the provider before the profile. | 88 // Shutdown the provider before the profile. |
89 provider_ = NULL; | 89 provider_ = NULL; |
90 } | 90 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 base::RunLoop().RunUntilIdle(); | 214 base::RunLoop().RunUntilIdle(); |
215 | 215 |
216 // Expect that the matches have been cleared. | 216 // Expect that the matches have been cleared. |
217 ASSERT_TRUE(provider_->matches().empty()); | 217 ASSERT_TRUE(provider_->matches().empty()); |
218 | 218 |
219 // Expect the new results have been stored. | 219 // Expect the new results have been stored. |
220 EXPECT_EQ(empty_response, | 220 EXPECT_EQ(empty_response, |
221 prefs->GetString(prefs::kZeroSuggestCachedResults)); | 221 prefs->GetString(prefs::kZeroSuggestCachedResults)); |
222 } | 222 } |
OLD | NEW |