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

Side by Side Diff: components/omnibox/browser/history_url_provider_unittest.cc

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/history_url_provider.h" 5 #include "components/omnibox/browser/history_url_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 23 matching lines...) Expand all
34 #include "components/search_engines/template_url_service.h" 34 #include "components/search_engines/template_url_service.h"
35 #include "components/url_formatter/url_fixer.h" 35 #include "components/url_formatter/url_fixer.h"
36 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
37 37
38 using base::ASCIIToUTF16; 38 using base::ASCIIToUTF16;
39 using base::Time; 39 using base::Time;
40 using base::TimeDelta; 40 using base::TimeDelta;
41 41
42 namespace { 42 namespace {
43 43
44 const char kDefaultAcceptLanguages[] = "en-US,en,ko";
45
46 struct TestURLInfo { 44 struct TestURLInfo {
47 const char* url; 45 const char* url;
48 const char* title; 46 const char* title;
49 int visit_count; 47 int visit_count;
50 int typed_count; 48 int typed_count;
51 int age_in_days; 49 int age_in_days;
52 } test_db[] = { 50 } test_db[] = {
53 {"http://www.google.com/", "Google", 3, 3, 80}, 51 {"http://www.google.com/", "Google", 3, 3, 80},
54 52
55 // High-quality pages should get a host synthesized as a lower-quality match. 53 // High-quality pages should get a host synthesized as a lower-quality match.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 {"http://7.com/5a", "Five A", 8, 0, 64}, // never typed. 154 {"http://7.com/5a", "Five A", 8, 0, 64}, // never typed.
157 }; 155 };
158 156
159 class FakeAutocompleteProviderClient : public MockAutocompleteProviderClient { 157 class FakeAutocompleteProviderClient : public MockAutocompleteProviderClient {
160 public: 158 public:
161 FakeAutocompleteProviderClient(bool create_history_db) { 159 FakeAutocompleteProviderClient(bool create_history_db) {
162 set_template_url_service( 160 set_template_url_service(
163 make_scoped_ptr(new TemplateURLService(nullptr, 0))); 161 make_scoped_ptr(new TemplateURLService(nullptr, 0)));
164 if (history_dir_.CreateUniqueTempDir()) { 162 if (history_dir_.CreateUniqueTempDir()) {
165 history_service_ = history::CreateHistoryService( 163 history_service_ = history::CreateHistoryService(
166 history_dir_.path(), kDefaultAcceptLanguages, create_history_db); 164 history_dir_.path(), create_history_db);
167 } 165 }
168 } 166 }
169 167
170 const AutocompleteSchemeClassifier& GetSchemeClassifier() const override { 168 const AutocompleteSchemeClassifier& GetSchemeClassifier() const override {
171 return scheme_classifier_; 169 return scheme_classifier_;
172 } 170 }
173 171
174 const SearchTermsData& GetSearchTermsData() const override { 172 const SearchTermsData& GetSearchTermsData() const override {
175 return search_terms_data_; 173 return search_terms_data_;
176 } 174 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 271
274 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) { 272 void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) {
275 if (autocomplete_->done()) 273 if (autocomplete_->done())
276 base::MessageLoop::current()->QuitWhenIdle(); 274 base::MessageLoop::current()->QuitWhenIdle();
277 } 275 }
278 276
279 bool HistoryURLProviderTest::SetUpImpl(bool create_history_db) { 277 bool HistoryURLProviderTest::SetUpImpl(bool create_history_db) {
280 client_.reset(new FakeAutocompleteProviderClient(create_history_db)); 278 client_.reset(new FakeAutocompleteProviderClient(create_history_db));
281 if (!client_->GetHistoryService()) 279 if (!client_->GetHistoryService())
282 return false; 280 return false;
283 EXPECT_CALL(*client_, GetAcceptLanguages())
284 .WillRepeatedly(testing::Return(kDefaultAcceptLanguages));
285 autocomplete_ = new HistoryURLProvider(client_.get(), this); 281 autocomplete_ = new HistoryURLProvider(client_.get(), this);
286 FillData(); 282 FillData();
287 return true; 283 return true;
288 } 284 }
289 285
290 void HistoryURLProviderTest::TearDown() { 286 void HistoryURLProviderTest::TearDown() {
291 autocomplete_ = NULL; 287 autocomplete_ = NULL;
292 } 288 }
293 289
294 void HistoryURLProviderTest::FillData() { 290 void HistoryURLProviderTest::FillData() {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 prevent_inline_autocomplete, false, true, true, false, 325 prevent_inline_autocomplete, false, true, true, false,
330 TestSchemeClassifier()); 326 TestSchemeClassifier());
331 *identified_input_type = input.type(); 327 *identified_input_type = input.type();
332 autocomplete_->Start(input, false); 328 autocomplete_->Start(input, false);
333 if (!autocomplete_->done()) 329 if (!autocomplete_->done())
334 base::MessageLoop::current()->Run(); 330 base::MessageLoop::current()->Run();
335 331
336 matches_ = autocomplete_->matches(); 332 matches_ = autocomplete_->matches();
337 if (sort_matches_) { 333 if (sort_matches_) {
338 TemplateURLService* service = client_->GetTemplateURLService(); 334 TemplateURLService* service = client_->GetTemplateURLService();
339 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i) { 335 for (ACMatches::iterator i = matches_.begin(); i != matches_.end(); ++i)
340 i->ComputeStrippedDestinationURL( 336 i->ComputeStrippedDestinationURL(input, service);
341 input, client_->GetAcceptLanguages(), service);
342 }
343 AutocompleteResult::DedupMatchesByDestination( 337 AutocompleteResult::DedupMatchesByDestination(
344 input.current_page_classification(), false, &matches_); 338 input.current_page_classification(), false, &matches_);
345 std::sort(matches_.begin(), matches_.end(), 339 std::sort(matches_.begin(), matches_.end(),
346 &AutocompleteMatch::MoreRelevant); 340 &AutocompleteMatch::MoreRelevant);
347 } 341 }
348 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text 342 ASSERT_EQ(num_results, matches_.size()) << "Input text: " << text
349 << "\nTLD: \"" << desired_tld << "\""; 343 << "\nTLD: \"" << desired_tld << "\"";
350 for (size_t i = 0; i < num_results; ++i) { 344 for (size_t i = 0; i < num_results; ++i) {
351 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec()); 345 EXPECT_EQ(expected_urls[i].url, matches_[i].destination_url.spec());
352 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match, 346 EXPECT_EQ(expected_urls[i].allowed_to_be_default_match,
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 // the default experimental scoring. 1114 // the default experimental scoring.
1121 autocomplete_->scoring_params_.experimental_scoring_enabled = true; 1115 autocomplete_->scoring_params_.experimental_scoring_enabled = true;
1122 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input), 1116 ASSERT_NO_FATAL_FAILURE(RunTest(ASCIIToUTF16(test_cases[i].input),
1123 std::string(), false, output, max_matches)); 1117 std::string(), false, output, max_matches));
1124 for (int j = 0; j < max_matches; ++j) { 1118 for (int j = 0; j < max_matches; ++j) {
1125 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance, 1119 EXPECT_EQ(test_cases[i].matches[j].experiment_relevance,
1126 matches_[j].relevance); 1120 matches_[j].relevance);
1127 } 1121 }
1128 } 1122 }
1129 } 1123 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/history_url_provider.cc ('k') | components/omnibox/browser/in_memory_url_index.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698