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/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 29 matching lines...) Expand all Loading... |
40 {"http://www.google.com/", "Google", 3, 3, 0}, | 40 {"http://www.google.com/", "Google", 3, 3, 0}, |
41 {"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100, 0}, | 41 {"http://slashdot.org/favorite_page.html", "Favorite page", 200, 100, 0}, |
42 {"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0, 0}, | 42 {"http://kerneltrap.org/not_very_popular.html", "Less popular", 4, 0, 0}, |
43 {"http://freshmeat.net/unpopular.html", "Unpopular", 1, 1, 0}, | 43 {"http://freshmeat.net/unpopular.html", "Unpopular", 1, 1, 0}, |
44 {"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2, 0}, | 44 {"http://news.google.com/?ned=us&topic=n", "Google News - U.S.", 2, 2, 0}, |
45 {"http://news.google.com/", "Google News", 1, 1, 0}, | 45 {"http://news.google.com/", "Google News", 1, 1, 0}, |
46 {"http://foo.com/", "Dir", 200, 100, 0}, | 46 {"http://foo.com/", "Dir", 200, 100, 0}, |
47 {"http://foo.com/dir/", "Dir", 2, 1, 10}, | 47 {"http://foo.com/dir/", "Dir", 2, 1, 10}, |
48 {"http://foo.com/dir/another/", "Dir", 5, 1, 0}, | 48 {"http://foo.com/dir/another/", "Dir", 5, 1, 0}, |
49 {"http://foo.com/dir/another/again/", "Dir", 5, 1, 0}, | 49 {"http://foo.com/dir/another/again/", "Dir", 5, 1, 0}, |
50 {"http://foo.com/dir/another/again/myfile.html", "File", 10, 2, 0}, | 50 {"http://foo.com/dir/another/again/myfile.html", "File", 3, 2, 0}, |
51 {"http://visitedest.com/y/a", "VA", 10, 1, 20}, | 51 {"http://visitedest.com/y/a", "VA", 10, 1, 20}, |
52 {"http://visitedest.com/y/b", "VB", 9, 1, 20}, | 52 {"http://visitedest.com/y/b", "VB", 9, 1, 20}, |
53 {"http://visitedest.com/x/c", "VC", 8, 1, 20}, | 53 {"http://visitedest.com/x/c", "VC", 8, 1, 20}, |
54 {"http://visitedest.com/x/d", "VD", 7, 1, 20}, | 54 {"http://visitedest.com/x/d", "VD", 7, 1, 20}, |
55 {"http://visitedest.com/y/e", "VE", 6, 1, 20}, | 55 {"http://visitedest.com/y/e", "VE", 6, 1, 20}, |
56 {"http://typeredest.com/y/a", "TA", 3, 5, 0}, | 56 {"http://typeredest.com/y/a", "TA", 3, 5, 0}, |
57 {"http://typeredest.com/y/b", "TB", 3, 4, 0}, | 57 {"http://typeredest.com/y/b", "TB", 3, 4, 0}, |
58 {"http://typeredest.com/x/c", "TC", 3, 3, 0}, | 58 {"http://typeredest.com/x/c", "TC", 3, 3, 0}, |
59 {"http://typeredest.com/x/d", "TD", 3, 2, 0}, | 59 {"http://typeredest.com/x/d", "TD", 3, 2, 0}, |
60 {"http://typeredest.com/y/e", "TE", 3, 1, 0}, | 60 {"http://typeredest.com/y/e", "TE", 3, 1, 0}, |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 ASCIIToUTF16("slashdot.org/favorite_page.html")); | 256 ASCIIToUTF16("slashdot.org/favorite_page.html")); |
257 } | 257 } |
258 | 258 |
259 TEST_F(HistoryQuickProviderTest, MultiMatch) { | 259 TEST_F(HistoryQuickProviderTest, MultiMatch) { |
260 std::vector<std::string> expected_urls; | 260 std::vector<std::string> expected_urls; |
261 // Scores high because of typed_count. | 261 // Scores high because of typed_count. |
262 expected_urls.push_back("http://foo.com/"); | 262 expected_urls.push_back("http://foo.com/"); |
263 // Scores high because of visit count. | 263 // Scores high because of visit count. |
264 expected_urls.push_back("http://foo.com/dir/another/"); | 264 expected_urls.push_back("http://foo.com/dir/another/"); |
265 // Scores high because of high visit count. | 265 // Scores high because of high visit count. |
266 expected_urls.push_back("http://foo.com/dir/another/again/myfile.html"); | 266 expected_urls.push_back("http://foo.com/dir/another/again/"); |
267 RunTest(ASCIIToUTF16("foo"), expected_urls, "http://foo.com/", true, | 267 RunTest(ASCIIToUTF16("foo"), expected_urls, "http://foo.com/", true, |
268 ASCIIToUTF16("foo.com")); | 268 ASCIIToUTF16("foo.com")); |
269 } | 269 } |
270 | 270 |
271 TEST_F(HistoryQuickProviderTest, StartRelativeMatch) { | 271 TEST_F(HistoryQuickProviderTest, StartRelativeMatch) { |
272 std::vector<std::string> expected_urls; | 272 std::vector<std::string> expected_urls; |
273 expected_urls.push_back("http://xyzabcdefghijklmnopqrstuvw.com/a"); | 273 expected_urls.push_back("http://xyzabcdefghijklmnopqrstuvw.com/a"); |
274 expected_urls.push_back("http://abcxyzdefghijklmnopqrstuvw.com/a"); | 274 expected_urls.push_back("http://abcxyzdefghijklmnopqrstuvw.com/a"); |
275 expected_urls.push_back("http://abcdefxyzghijklmnopqrstuvw.com/a"); | 275 expected_urls.push_back("http://abcdefxyzghijklmnopqrstuvw.com/a"); |
276 RunTest(ASCIIToUTF16("xyz"), expected_urls, | 276 RunTest(ASCIIToUTF16("xyz"), expected_urls, |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 kMaxNonInliningScore - 1); | 448 kMaxNonInliningScore - 1); |
449 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); | 449 EXPECT_EQ(next_score, kMaxNonInliningScore - 2); |
450 | 450 |
451 // Low score, can inline, not clamped. | 451 // Low score, can inline, not clamped. |
452 next_score = 1500; | 452 next_score = 1500; |
453 match.raw_score = 500; | 453 match.raw_score = 500; |
454 match.can_inline = true; | 454 match.can_inline = true; |
455 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 455 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
456 EXPECT_EQ(next_score, 499); | 456 EXPECT_EQ(next_score, 499); |
457 } | 457 } |
OLD | NEW |