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

Side by Side Diff: chrome/browser/history/in_memory_url_index_unittest.cc

Issue 9289034: Fix keyword recognition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Change IMUI to handle trailing space as a multi-term query. Created 8 years, 10 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
OLDNEW
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 <fstream> 5 #include <fstream>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 // See if a very specific term gives a single result. 226 // See if a very specific term gives a single result.
227 ScoredHistoryMatches matches = 227 ScoredHistoryMatches matches =
228 url_index_->HistoryItemsForTerms(ASCIIToUTF16("DrudgeReport")); 228 url_index_->HistoryItemsForTerms(ASCIIToUTF16("DrudgeReport"));
229 ASSERT_EQ(1U, matches.size()); 229 ASSERT_EQ(1U, matches.size());
230 230
231 // Verify that we got back the result we expected. 231 // Verify that we got back the result we expected.
232 EXPECT_EQ(5, matches[0].url_info.id()); 232 EXPECT_EQ(5, matches[0].url_info.id());
233 EXPECT_EQ("http://drudgereport.com/", matches[0].url_info.url().spec()); 233 EXPECT_EQ("http://drudgereport.com/", matches[0].url_info.url().spec());
234 EXPECT_EQ(ASCIIToUTF16("DRUDGE REPORT 2010"), matches[0].url_info.title()); 234 EXPECT_EQ(ASCIIToUTF16("DRUDGE REPORT 2010"), matches[0].url_info.title());
235 EXPECT_TRUE(matches[0].can_inline);
236
237 // Make sure a trailing space prevents inline-ability but still results
238 // in the expected result.
239 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("DrudgeReport "));
240 ASSERT_EQ(1U, matches.size());
241 EXPECT_EQ(5, matches[0].url_info.id());
242 EXPECT_EQ("http://drudgereport.com/", matches[0].url_info.url().spec());
243 EXPECT_EQ(ASCIIToUTF16("DRUDGE REPORT 2010"), matches[0].url_info.title());
244 EXPECT_FALSE(matches[0].can_inline);
235 245
236 // Search which should result in multiple results. 246 // Search which should result in multiple results.
237 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("drudge")); 247 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("drudge"));
238 ASSERT_EQ(2U, matches.size()); 248 ASSERT_EQ(2U, matches.size());
239 // The results should be in descending score order. 249 // The results should be in descending score order.
240 EXPECT_GE(matches[0].raw_score, matches[1].raw_score); 250 EXPECT_GE(matches[0].raw_score, matches[1].raw_score);
241 251
242 // Search which should result in nearly perfect result. 252 // Search which should result in nearly perfect result.
243 matches = url_index_->HistoryItemsForTerms( 253 matches = url_index_->HistoryItemsForTerms(
244 ASCIIToUTF16("https NearlyPerfectResult")); 254 ASCIIToUTF16("https NearlyPerfectResult"));
245 ASSERT_EQ(1U, matches.size()); 255 ASSERT_EQ(1U, matches.size());
246 // The results should have a very high score. 256 // The results should have a very high score.
247 EXPECT_GT(matches[0].raw_score, 900); 257 EXPECT_GT(matches[0].raw_score, 900);
248 EXPECT_EQ(32, matches[0].url_info.id()); 258 EXPECT_EQ(32, matches[0].url_info.id());
249 EXPECT_EQ("https://nearlyperfectresult.com/", 259 EXPECT_EQ("https://nearlyperfectresult.com/",
250 matches[0].url_info.url().spec()); // Note: URL gets lowercased. 260 matches[0].url_info.url().spec()); // Note: URL gets lowercased.
251 EXPECT_EQ(ASCIIToUTF16("Practically Perfect Search Result"), 261 EXPECT_EQ(ASCIIToUTF16("Practically Perfect Search Result"),
252 matches[0].url_info.title()); 262 matches[0].url_info.title());
263 EXPECT_FALSE(matches[0].can_inline);
253 264
254 // Search which should result in very poor result. 265 // Search which should result in very poor result.
255 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("z y x")); 266 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("z y x"));
256 ASSERT_EQ(1U, matches.size()); 267 ASSERT_EQ(1U, matches.size());
257 // The results should have a poor score. 268 // The results should have a poor score.
258 EXPECT_LT(matches[0].raw_score, 500); 269 EXPECT_LT(matches[0].raw_score, 500);
259 EXPECT_EQ(33, matches[0].url_info.id()); 270 EXPECT_EQ(33, matches[0].url_info.id());
260 EXPECT_EQ("http://quiteuselesssearchresultxyz.com/", 271 EXPECT_EQ("http://quiteuselesssearchresultxyz.com/",
261 matches[0].url_info.url().spec()); // Note: URL gets lowercased. 272 matches[0].url_info.url().spec()); // Note: URL gets lowercased.
262 EXPECT_EQ(ASCIIToUTF16("Practically Useless Search Result"), 273 EXPECT_EQ(ASCIIToUTF16("Practically Useless Search Result"),
263 matches[0].url_info.title()); 274 matches[0].url_info.title());
275 EXPECT_FALSE(matches[0].can_inline);
264 276
265 // Search which will match at the end of an URL with encoded characters. 277 // Search which will match at the end of an URL with encoded characters.
266 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("ice")); 278 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("ice"));
267 ASSERT_EQ(1U, matches.size()); 279 ASSERT_EQ(1U, matches.size());
280 EXPECT_FALSE(matches[0].can_inline);
268 } 281 }
269 282
270 TEST_F(InMemoryURLIndexTest, URLPrefixMatching) { 283 TEST_F(InMemoryURLIndexTest, URLPrefixMatching) {
271 url_index_.reset(new InMemoryURLIndex(FilePath())); 284 url_index_.reset(new InMemoryURLIndex(FilePath()));
272 url_index_->Init(this, "en,ja,hi,zh"); 285 url_index_->Init(this, "en,ja,hi,zh");
273 286
274 // "drudgere" - found, can inline 287 // "drudgere" - found, can inline
275 ScoredHistoryMatches matches = 288 ScoredHistoryMatches matches =
276 url_index_->HistoryItemsForTerms(ASCIIToUTF16("drudgere")); 289 url_index_->HistoryItemsForTerms(ASCIIToUTF16("drudgere"));
277 ASSERT_EQ(1U, matches.size()); 290 ASSERT_EQ(1U, matches.size());
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 const URLRow& expected_row(expected->second); 780 const URLRow& expected_row(expected->second);
768 const URLRow& actual_row(actual->second); 781 const URLRow& actual_row(actual->second);
769 EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count()); 782 EXPECT_EQ(expected_row.visit_count(), actual_row.visit_count());
770 EXPECT_EQ(expected_row.typed_count(), actual_row.typed_count()); 783 EXPECT_EQ(expected_row.typed_count(), actual_row.typed_count());
771 EXPECT_EQ(expected_row.last_visit(), actual_row.last_visit()); 784 EXPECT_EQ(expected_row.last_visit(), actual_row.last_visit());
772 EXPECT_EQ(expected_row.url(), actual_row.url()); 785 EXPECT_EQ(expected_row.url(), actual_row.url());
773 } 786 }
774 } 787 }
775 788
776 } // namespace history 789 } // namespace history
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/url_index_private_data.cc » ('j') | chrome/browser/history/url_index_private_data.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698