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

Unified Diff: chrome/browser/history/scored_history_match_unittest.cc

Issue 905023003: Adding knobs on HQP provider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing mark comments. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/scored_history_match_unittest.cc
diff --git a/chrome/browser/history/scored_history_match_unittest.cc b/chrome/browser/history/scored_history_match_unittest.cc
index 4989966eda6eb271a3c5cc935a26e39dae626d98..c7b06bb091355023dafeea51780c93bc94bb7092 100644
--- a/chrome/browser/history/scored_history_match_unittest.cc
+++ b/chrome/browser/history/scored_history_match_unittest.cc
@@ -344,6 +344,69 @@ TEST_F(ScoredHistoryMatchTest, GetTopicalityScoreTrailingSlash) {
EXPECT_EQ(hostname_no_slash, hostname);
}
+// This function tests the function GetFinalRelevancyScore().
+TEST_F(ScoredHistoryMatchTest, GetFinalRelevancyScore) {
+ ScoredHistoryMatch scored_match;
+ // Check when topicality score is zero.
+ float topicality_score = 0.0;
+ float frequency_score = 10.0;
+ std::vector<ScoredHistoryMatch::ScoreMaxRelevance> hqp_buckets;
+ // hqp_relevance_buckets = "0.0:200,1.0:200,4.0:500,5.0:900";
+ hqp_buckets.push_back(std::make_pair(0.0, 100));
+ hqp_buckets.push_back(std::make_pair(1.0, 200));
+ hqp_buckets.push_back(std::make_pair(4.0, 500));
+ hqp_buckets.push_back(std::make_pair(5.0, 900));
+ EXPECT_EQ(0,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Check when intermediate score falls at the border range.
+ topicality_score = 0.5;
+ frequency_score = 10.0;
+ // intermediate_score = 0.5 * 10.0 = 5.0.
+ // hqp_relevance_buckets = "0.0:100,1.0:200,4.0:500,5.0:900,10.0:1000";
+ hqp_buckets.clear();
+ hqp_buckets.push_back(std::make_pair(0.0, 100));
+ hqp_buckets.push_back(std::make_pair(1.0, 200));
+ hqp_buckets.push_back(std::make_pair(4.0, 500));
+ hqp_buckets.push_back(std::make_pair(5.0, 900));
+ hqp_buckets.push_back(std::make_pair(10.0, 1000));
+ EXPECT_EQ(900,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Checking the score that falls into one of the buckets.
+ topicality_score = 0.5;
+ frequency_score = 10.0;
+ // intermediate_score = 0.5 * 10.0 = 5.0.
+ // hqp_relevance_buckets = "0.0:100,1.0:200,4.0:500,8.0:900,10.0:1000";
+ hqp_buckets.clear();
+ hqp_buckets.push_back(std::make_pair(0.0, 100));
+ hqp_buckets.push_back(std::make_pair(1.0, 200));
+ hqp_buckets.push_back(std::make_pair(4.0, 500));
+ hqp_buckets.push_back(std::make_pair(8.0, 900));
+ hqp_buckets.push_back(std::make_pair(10.0, 1000));
+ EXPECT_EQ(600, // 500 + (((900 - 500)/(8 -4)) * 1) = 600.
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+ // Never give the score greater than maximum specified.
+ topicality_score = 0.5;
+ frequency_score = 22.0;
+ // intermediate_score = 0.5 * 22.0 = 11.0
+ // hqp_relevance_buckets = "0.0:100,1.0:200,4.0:500,8.0:900,10.0:1000";
+ hqp_buckets.clear();
+ hqp_buckets.push_back(std::make_pair(0.0, 100));
+ hqp_buckets.push_back(std::make_pair(1.0, 200));
+ hqp_buckets.push_back(std::make_pair(4.0, 500));
+ hqp_buckets.push_back(std::make_pair(8.0, 900));
+ hqp_buckets.push_back(std::make_pair(10.0, 1000));
+ EXPECT_EQ(1000,
+ scored_match.GetFinalRelevancyScore(topicality_score,
+ frequency_score,
+ hqp_buckets));
+}
+
// This function only tests scoring of single terms that match exactly
// once somewhere in the URL or title.
TEST_F(ScoredHistoryMatchTest, GetTopicalityScore) {

Powered by Google App Engine
This is Rietveld 408576698