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

Side by Side Diff: chrome/browser/autocomplete/history_quick_provider_unittest.cc

Issue 7004042: Fix Wrong Offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_quick_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698