OLD | NEW |
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 "chrome/browser/autocomplete/autocomplete_result.h" | 5 #include "chrome/browser/autocomplete/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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec()); | 312 EXPECT_EQ("http://b/", result.match_at(3)->destination_url.spec()); |
313 EXPECT_EQ(1000, result.match_at(3)->relevance); | 313 EXPECT_EQ(1000, result.match_at(3)->relevance); |
314 } | 314 } |
315 | 315 |
316 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { | 316 TEST_F(AutocompleteResultTest, SortAndCullDuplicateSearchURLs) { |
317 // Register a template URL that corresponds to 'foo' search engine. | 317 // Register a template URL that corresponds to 'foo' search engine. |
318 TemplateURLData url_data; | 318 TemplateURLData url_data; |
319 url_data.short_name = base::ASCIIToUTF16("unittest"); | 319 url_data.short_name = base::ASCIIToUTF16("unittest"); |
320 url_data.SetKeyword(base::ASCIIToUTF16("foo")); | 320 url_data.SetKeyword(base::ASCIIToUTF16("foo")); |
321 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); | 321 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); |
322 test_util_.model()->Add(new TemplateURL(test_util_.profile(), url_data)); | 322 test_util_.model()->Add(new TemplateURL(url_data)); |
323 | 323 |
324 TestData data[] = { | 324 TestData data[] = { |
325 { 0, 0, 1300 }, | 325 { 0, 0, 1300 }, |
326 { 1, 0, 1200 }, | 326 { 1, 0, 1200 }, |
327 { 2, 0, 1100 }, | 327 { 2, 0, 1100 }, |
328 { 3, 0, 1000 }, | 328 { 3, 0, 1000 }, |
329 { 4, 1, 900 }, | 329 { 4, 1, 900 }, |
330 }; | 330 }; |
331 | 331 |
332 ACMatches matches; | 332 ACMatches matches; |
(...skipping 24 matching lines...) Expand all Loading... |
357 result.match_at(2)->destination_url.spec()); | 357 result.match_at(2)->destination_url.spec()); |
358 EXPECT_EQ(900, result.match_at(2)->relevance); | 358 EXPECT_EQ(900, result.match_at(2)->relevance); |
359 } | 359 } |
360 | 360 |
361 TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) { | 361 TEST_F(AutocompleteResultTest, SortAndCullWithMatchDups) { |
362 // Register a template URL that corresponds to 'foo' search engine. | 362 // Register a template URL that corresponds to 'foo' search engine. |
363 TemplateURLData url_data; | 363 TemplateURLData url_data; |
364 url_data.short_name = base::ASCIIToUTF16("unittest"); | 364 url_data.short_name = base::ASCIIToUTF16("unittest"); |
365 url_data.SetKeyword(base::ASCIIToUTF16("foo")); | 365 url_data.SetKeyword(base::ASCIIToUTF16("foo")); |
366 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); | 366 url_data.SetURL("http://www.foo.com/s?q={searchTerms}"); |
367 test_util_.model()->Add(new TemplateURL(test_util_.profile(), url_data)); | 367 test_util_.model()->Add(new TemplateURL(url_data)); |
368 | 368 |
369 AutocompleteMatch dup_match; | 369 AutocompleteMatch dup_match; |
370 dup_match.destination_url = GURL("http://www.foo.com/s?q=foo&oq=dup"); | 370 dup_match.destination_url = GURL("http://www.foo.com/s?q=foo&oq=dup"); |
371 std::vector<AutocompleteMatch> dups; | 371 std::vector<AutocompleteMatch> dups; |
372 dups.push_back(dup_match); | 372 dups.push_back(dup_match); |
373 | 373 |
374 TestData data[] = { | 374 TestData data[] = { |
375 { 0, 0, 1300, dups }, | 375 { 0, 0, 1300, dups }, |
376 { 1, 0, 1200 }, | 376 { 1, 0, 1200 }, |
377 { 2, 0, 1100 }, | 377 { 2, 0, 1100 }, |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 result.Reset(); | 820 result.Reset(); |
821 matches.clear(); | 821 matches.clear(); |
822 | 822 |
823 // Case 5: Multiple verbatim matches found in AutocompleteResult. | 823 // Case 5: Multiple verbatim matches found in AutocompleteResult. |
824 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, | 824 PopulateAutocompleteMatchesFromTestData(kVerbatimMatches, |
825 arraysize(kVerbatimMatches), | 825 arraysize(kVerbatimMatches), |
826 &matches); | 826 &matches); |
827 result.AppendMatches(matches); | 827 result.AppendMatches(matches); |
828 EXPECT_FALSE(result.ShouldHideTopMatch()); | 828 EXPECT_FALSE(result.ShouldHideTopMatch()); |
829 } | 829 } |
OLD | NEW |