OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 } | 215 } |
216 | 216 |
217 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { | 217 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { |
218 string16 text(ASCIIToUTF16("slashdot")); | 218 string16 text(ASCIIToUTF16("slashdot")); |
219 std::string expected_url("http://slashdot.org/favorite_page.html"); | 219 std::string expected_url("http://slashdot.org/favorite_page.html"); |
220 std::vector<std::string> expected_urls; | 220 std::vector<std::string> expected_urls; |
221 expected_urls.push_back(expected_url); | 221 expected_urls.push_back(expected_url); |
222 RunTest(text, expected_urls, expected_url); | 222 RunTest(text, expected_urls, expected_url); |
223 } | 223 } |
224 | 224 |
225 TEST_F(HistoryQuickProviderTest, NonWordLastCharacterMatch) { | |
226 string16 text(ASCIIToUTF16("slashdot.org/")); | |
227 std::string expected_url("http://slashdot.org/favorite_page.html"); | |
Peter Kasting
2011/05/20 22:06:41
Remind me why this catches the bug?
| |
228 std::vector<std::string> expected_urls; | |
229 expected_urls.push_back(expected_url); | |
230 RunTest(text, expected_urls, expected_url); | |
231 } | |
232 | |
225 TEST_F(HistoryQuickProviderTest, MultiMatch) { | 233 TEST_F(HistoryQuickProviderTest, MultiMatch) { |
226 string16 text(ASCIIToUTF16("foo")); | 234 string16 text(ASCIIToUTF16("foo")); |
227 std::vector<std::string> expected_urls; | 235 std::vector<std::string> expected_urls; |
228 // Scores high because of typed_count. | 236 // Scores high because of typed_count. |
229 expected_urls.push_back("http://foo.com/"); | 237 expected_urls.push_back("http://foo.com/"); |
230 // Scores high because of visit count. | 238 // Scores high because of visit count. |
231 expected_urls.push_back("http://foo.com/dir/another/"); | 239 expected_urls.push_back("http://foo.com/dir/another/"); |
232 // Scores high because of high visit count. | 240 // Scores high because of high visit count. |
233 expected_urls.push_back("http://foo.com/dir/another/again/myfile.html"); | 241 expected_urls.push_back("http://foo.com/dir/another/again/myfile.html"); |
234 RunTest(text, expected_urls, "http://foo.com/"); | 242 RunTest(text, expected_urls, "http://foo.com/"); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1198); | 402 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 1198); |
395 EXPECT_EQ(next_score, 1197); | 403 EXPECT_EQ(next_score, 1197); |
396 | 404 |
397 // Low score, can inline, not clamped. | 405 // Low score, can inline, not clamped. |
398 next_score = 1500; | 406 next_score = 1500; |
399 match.raw_score = 500; | 407 match.raw_score = 500; |
400 match.can_inline = true; | 408 match.can_inline = true; |
401 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); | 409 EXPECT_EQ(HistoryQuickProvider::CalculateRelevance(match, &next_score), 500); |
402 EXPECT_EQ(next_score, 499); | 410 EXPECT_EQ(next_score, 499); |
403 } | 411 } |
OLD | NEW |