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

Side by Side Diff: components/omnibox/browser/scored_history_match_unittest.cc

Issue 1286093006: Launch HQP & HUP score changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Barts comments 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 "components/omnibox/browser/scored_history_match.h" 5 #include "components/omnibox/browser/scored_history_match.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 float ScoredHistoryMatchTest::GetTopicalityScoreOfTermAgainstURLAndTitle( 104 float ScoredHistoryMatchTest::GetTopicalityScoreOfTermAgainstURLAndTitle(
105 const base::string16& term, 105 const base::string16& term,
106 const base::string16& url, 106 const base::string16& url,
107 const base::string16& title) { 107 const base::string16& title) {
108 // Make an empty match and simply populate the fields we need in order 108 // Make an empty match and simply populate the fields we need in order
109 // to call GetTopicalityScore(). 109 // to call GetTopicalityScore().
110 ScoredHistoryMatch scored_match; 110 ScoredHistoryMatch scored_match;
111 scored_match.url_matches = MatchTermInString(term, url, 0); 111 scored_match.url_matches = MatchTermInString(term, url, 0);
112 scored_match.title_matches = MatchTermInString(term, title, 0); 112 scored_match.title_matches = MatchTermInString(term, title, 0);
113 scored_match.topicality_threshold_ = -1;
114 scored_match.hqp_relevance_buckets_str_ =
115 "0.0:400,1.5:600,12.0:1300,20.0:1399";
113 RowWordStarts word_starts; 116 RowWordStarts word_starts;
114 String16SetFromString16(url, &word_starts.url_word_starts_); 117 String16SetFromString16(url, &word_starts.url_word_starts_);
115 String16SetFromString16(title, &word_starts.title_word_starts_); 118 String16SetFromString16(title, &word_starts.title_word_starts_);
116 WordStarts one_word_no_offset(1, 0u); 119 WordStarts one_word_no_offset(1, 0u);
117 return scored_match.GetTopicalityScore(1, url, one_word_no_offset, 120 return scored_match.GetTopicalityScore(1, url, one_word_no_offset,
118 word_starts); 121 word_starts);
119 } 122 }
120 123
121 TEST_F(ScoredHistoryMatchTest, Scoring) { 124 TEST_F(ScoredHistoryMatchTest, Scoring) {
122 // We use NowFromSystemTime() because MakeURLRow uses the same function 125 // We use NowFromSystemTime() because MakeURLRow uses the same function
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 486
484 EXPECT_TRUE( 487 EXPECT_TRUE(
485 ScoredHistoryMatch::GetHQPBucketsFromString(buckets_str, &hqp_buckets)); 488 ScoredHistoryMatch::GetHQPBucketsFromString(buckets_str, &hqp_buckets));
486 EXPECT_THAT(hqp_buckets, ElementsAre(Pair(0.0, 400), Pair(1.5, 600), 489 EXPECT_THAT(hqp_buckets, ElementsAre(Pair(0.0, 400), Pair(1.5, 600),
487 Pair(12.0, 1300), Pair(20.0, 1399))); 490 Pair(12.0, 1300), Pair(20.0, 1399)));
488 // invalid string. 491 // invalid string.
489 buckets_str = "0.0,400,1.5,600"; 492 buckets_str = "0.0,400,1.5,600";
490 EXPECT_FALSE( 493 EXPECT_FALSE(
491 ScoredHistoryMatch::GetHQPBucketsFromString(buckets_str, &hqp_buckets)); 494 ScoredHistoryMatch::GetHQPBucketsFromString(buckets_str, &hqp_buckets));
492 } 495 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698