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

Side by Side Diff: components/omnibox/autocomplete_result_unittest.cc

Issue 1135163002: Omnibox - Strip Extra Whitespace from Custom Search Engine Names (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more tests that don't set short_name Created 5 years, 7 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 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/autocomplete_result.h" 5 #include "components/omnibox/autocomplete_result.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 EXPECT_EQ(1200, result.match_at(1)->relevance); 393 EXPECT_EQ(1200, result.match_at(1)->relevance);
394 EXPECT_TRUE(result.match_at(2)->destination_url.is_empty()); 394 EXPECT_TRUE(result.match_at(2)->destination_url.is_empty());
395 EXPECT_EQ(1100, result.match_at(2)->relevance); 395 EXPECT_EQ(1100, result.match_at(2)->relevance);
396 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec()); 396 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec());
397 EXPECT_EQ(1000, result.match_at(3)->relevance); 397 EXPECT_EQ(1000, result.match_at(3)->relevance);
398 } 398 }
399 399
400 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { 400 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) {
401 // Register a template URL that corresponds to 'foo' search engine. 401 // Register a template URL that corresponds to 'foo' search engine.
402 TemplateURLData url_data; 402 TemplateURLData url_data;
403 url_data.short_name = base::ASCIIToUTF16("unittest"); 403 url_data.SetShortName(base::ASCIIToUTF16("unittest"));
404 url_data.SetKeyword(base::ASCIIToUTF16("foo")); 404 url_data.SetKeyword(base::ASCIIToUTF16("foo"));
405 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); 405 url_data.SetURL("http://www.foo.com/s?q={searchTerms}");
406 template_url_service_.get()->Add(new TemplateURL(url_data)); 406 template_url_service_.get()->Add(new TemplateURL(url_data));
407 407
408 TestData data[] = { 408 TestData data[] = {
409 { 0, 1, 1300, true }, 409 { 0, 1, 1300, true },
410 { 1, 1, 1200, true }, 410 { 1, 1, 1200, true },
411 { 2, 1, 1100, true }, 411 { 2, 1, 1100, true },
412 { 3, 1, 1000, true }, 412 { 3, 1, 1000, true },
413 { 4, 2, 900, true }, 413 { 4, 2, 900, true },
(...skipping 25 matching lines...) Expand all
439 result.match_at(1)->destination_url.spec()); 439 result.match_at(1)->destination_url.spec());
440 EXPECT_EQ(1200, result.match_at(1)->relevance); 440 EXPECT_EQ(1200, result.match_at(1)->relevance);
441 EXPECT_EQ("http://www.foo.com/", 441 EXPECT_EQ("http://www.foo.com/",
442 result.match_at(2)->destination_url.spec()); 442 result.match_at(2)->destination_url.spec());
443 EXPECT_EQ(900, result.match_at(2)->relevance); 443 EXPECT_EQ(900, result.match_at(2)->relevance);
444 } 444 }
445 445
446 TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) { 446 TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) {
447 // Register a template URL that corresponds to 'foo' search engine. 447 // Register a template URL that corresponds to 'foo' search engine.
448 TemplateURLData url_data; 448 TemplateURLData url_data;
449 url_data.short_name = base::ASCIIToUTF16("unittest"); 449 url_data.SetShortName(base::ASCIIToUTF16("unittest"));
450 url_data.SetKeyword(base::ASCIIToUTF16("foo")); 450 url_data.SetKeyword(base::ASCIIToUTF16("foo"));
451 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); 451 url_data.SetURL("http://www.foo.com/s?q={searchTerms}");
452 template_url_service_.get()->Add(new TemplateURL(url_data)); 452 template_url_service_.get()->Add(new TemplateURL(url_data));
453 453
454 AutocompleteMatch dup_match; 454 AutocompleteMatch dup_match;
455 dup_match.destination_url = GURL("http://www.foo.com/s?q=foo&oq=dup"); 455 dup_match.destination_url = GURL("http://www.foo.com/s?q=foo&oq=dup");
456 std::vector<AutocompleteMatch> dups; 456 std::vector<AutocompleteMatch> dups;
457 dups.push_back(dup_match); 457 dups.push_back(dup_match);
458 458
459 TestData data[] = { 459 TestData data[] = {
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 result.Reset(); 751 result.Reset();
752 matches.clear(); 752 matches.clear();
753 753
754 // Case 5: Multiple verbatim matches found in AutocompleteResult. 754 // Case 5: Multiple verbatim matches found in AutocompleteResult.
755 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, 755 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches,
756 arraysize(kVerbatimMatches), 756 arraysize(kVerbatimMatches),
757 &matches); 757 &matches);
758 result.AppendMatches(matches); 758 result.AppendMatches(matches);
759 EXPECT_FALSE(result.ShouldHideTopMatch()); 759 EXPECT_FALSE(result.ShouldHideTopMatch());
760 } 760 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/search_engines/template_url_table_model.cc ('k') | components/omnibox/keyword_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698