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

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

Issue 1286093006: Launch HQP & HUP score changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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
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 <algorithm> 5 #include <algorithm>
6 #include <fstream> 6 #include <fstream>
7 7
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // The results should have a very high score. 542 // The results should have a very high score.
543 EXPECT_GT(matches[0].raw_score, 900); 543 EXPECT_GT(matches[0].raw_score, 900);
544 EXPECT_EQ(32, matches[0].url_info.id()); 544 EXPECT_EQ(32, matches[0].url_info.id());
545 EXPECT_EQ("https://nearlyperfectresult.com/", 545 EXPECT_EQ("https://nearlyperfectresult.com/",
546 matches[0].url_info.url().spec()); // Note: URL gets lowercased. 546 matches[0].url_info.url().spec()); // Note: URL gets lowercased.
547 EXPECT_EQ(ASCIIToUTF16("Practically Perfect Search Result"), 547 EXPECT_EQ(ASCIIToUTF16("Practically Perfect Search Result"),
548 matches[0].url_info.title()); 548 matches[0].url_info.title());
549 EXPECT_FALSE(matches[0].can_inline); 549 EXPECT_FALSE(matches[0].can_inline);
550 550
551 // Search which should result in very poor result. 551 // Search which should result in very poor result.
552 // No results since it will be suppressed by default scoring.
552 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("qui c"), 553 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("qui c"),
553 base::string16::npos, kMaxMatches); 554 base::string16::npos, kMaxMatches);
554 ASSERT_EQ(1U, matches.size()); 555 ASSERT_EQ(0U, matches.size());
555 // The results should have a poor score.
556 EXPECT_LT(matches[0].raw_score, 500);
557 EXPECT_EQ(33, matches[0].url_info.id());
558 EXPECT_EQ("http://quiteuselesssearchresultxyz.com/",
559 matches[0].url_info.url().spec()); // Note: URL gets lowercased.
560 EXPECT_EQ(ASCIIToUTF16("Practically Useless Search Result"),
561 matches[0].url_info.title());
562 EXPECT_FALSE(matches[0].can_inline);
563 556
564 // Search which will match at the end of an URL with encoded characters. 557 // Search which will match at the end of an URL with encoded characters.
565 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("Mice"), 558 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("Mice"),
566 base::string16::npos, kMaxMatches); 559 base::string16::npos, kMaxMatches);
567 ASSERT_EQ(1U, matches.size()); 560 ASSERT_EQ(1U, matches.size());
568 EXPECT_EQ(30, matches[0].url_info.id()); 561 EXPECT_EQ(30, matches[0].url_info.id());
569 EXPECT_FALSE(matches[0].can_inline); 562 EXPECT_FALSE(matches[0].can_inline);
570 563
571 // Check that URLs are not escaped an escape time. 564 // Check that URLs are not escaped an escape time.
572 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("1% wikipedia"), 565 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("1% wikipedia"),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 ASSERT_EQ(2U, matches.size()); 665 ASSERT_EQ(2U, matches.size());
673 // One match should be inline-able, the other not. 666 // One match should be inline-able, the other not.
674 EXPECT_TRUE(matches[0].can_inline != matches[1].can_inline); 667 EXPECT_TRUE(matches[0].can_inline != matches[1].can_inline);
675 668
676 // "www.cnn.com" - found, can inline 669 // "www.cnn.com" - found, can inline
677 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("www.cnn.com"), 670 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("www.cnn.com"),
678 base::string16::npos, kMaxMatches); 671 base::string16::npos, kMaxMatches);
679 ASSERT_EQ(1U, matches.size()); 672 ASSERT_EQ(1U, matches.size());
680 EXPECT_TRUE(matches[0].can_inline); 673 EXPECT_TRUE(matches[0].can_inline);
681 674
682 // "ww.cnn.com" - found because we allow mid-term matches in hostnames 675 // "ww.cnn.com" - found because we suppress mid-term matches.
683 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("ww.cnn.com"), 676 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("ww.cnn.com"),
684 base::string16::npos, kMaxMatches); 677 base::string16::npos, kMaxMatches);
685 ASSERT_EQ(1U, matches.size()); 678 ASSERT_EQ(0U, matches.size());
686 679
687 // "www.cnn.com" - found, can inline 680 // "www.cnn.com" - found, can inline
688 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("www.cnn.com"), 681 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("www.cnn.com"),
689 base::string16::npos, kMaxMatches); 682 base::string16::npos, kMaxMatches);
690 ASSERT_EQ(1U, matches.size()); 683 ASSERT_EQ(1U, matches.size());
691 EXPECT_TRUE(matches[0].can_inline); 684 EXPECT_TRUE(matches[0].can_inline);
692 685
693 // "tp://www.cnn.com" - not found because we don't allow tp as a mid-term 686 // "tp://www.cnn.com" - not found because we don't allow tp as a mid-term
694 // match 687 // match
695 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("tp://www.cnn.com"), 688 matches = url_index_->HistoryItemsForTerms(ASCIIToUTF16("tp://www.cnn.com"),
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 ASSERT_TRUE(GetCacheFilePath(&full_file_path)); 1349 ASSERT_TRUE(GetCacheFilePath(&full_file_path));
1357 std::vector<base::FilePath::StringType> actual_parts; 1350 std::vector<base::FilePath::StringType> actual_parts;
1358 full_file_path.GetComponents(&actual_parts); 1351 full_file_path.GetComponents(&actual_parts);
1359 ASSERT_EQ(expected_parts.size(), actual_parts.size()); 1352 ASSERT_EQ(expected_parts.size(), actual_parts.size());
1360 size_t count = expected_parts.size(); 1353 size_t count = expected_parts.size();
1361 for (size_t i = 0; i < count; ++i) 1354 for (size_t i = 0; i < count; ++i)
1362 EXPECT_EQ(expected_parts[i], actual_parts[i]); 1355 EXPECT_EQ(expected_parts[i], actual_parts[i]);
1363 // Must clear the history_dir_ to satisfy the dtor's DCHECK. 1356 // Must clear the history_dir_ to satisfy the dtor's DCHECK.
1364 set_history_dir(base::FilePath()); 1357 set_history_dir(base::FilePath());
1365 } 1358 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider_unittest.cc ('k') | components/omnibox/browser/history_url_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698