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

Unified Diff: ui/app_list/search/tokenized_string_match_unittest.cc

Issue 1138193002: Changed the app list string matching formula. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/search/tokenized_string_match.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/search/tokenized_string_match_unittest.cc
diff --git a/ui/app_list/search/tokenized_string_match_unittest.cc b/ui/app_list/search/tokenized_string_match_unittest.cc
index e9e959e0a3be5563f709a187a8451f92be0420cd..e412a8a856337686c5020c1378879a3c67285232 100644
--- a/ui/app_list/search/tokenized_string_match_unittest.cc
+++ b/ui/app_list/search/tokenized_string_match_unittest.cc
@@ -14,7 +14,7 @@ namespace app_list {
namespace test {
// Returns a string of |text| marked the hits in |match| using block bracket.
-// e.g. text= "Text", hits = [{0,1}], returns "[T]ext".
+// e.g. text= "Text", match.hits = [{0,1}], returns "[T]ext".
std::string MatchHit(const base::string16& text,
const TokenizedStringMatch& match) {
base::string16 marked = text;
@@ -119,5 +119,36 @@ TEST(TokenizedStringMatchTest, Relevance) {
}
}
+// More specialized tests of the absolute relevance scores. (These tests are
+// minimal, because they are so brittle. Changing the scoring algorithm will
+// require updating this test.)
+TEST(TokenizedStringMatchTest, AbsoluteRelevance) {
+ const double kEpsilon = 0.006;
+ struct {
+ const char* text;
+ const char* query;
+ double expected_score;
+ } kTestCases[] = {
+ // The first few chars should increase the score extremely high. After
+ // that, they should count less.
+ // NOTE: 0.87 is a magic number, as it is the Omnibox score for a "pretty
+ // good" match. We want a 3-letter prefix match to be slightly above 0.87.
+ {"Google Chrome", "g", 0.5},
+ {"Google Chrome", "go", 0.75},
+ {"Google Chrome", "goo", 0.88},
+ {"Google Chrome", "goog", 0.94},
+ };
+
+ TokenizedStringMatch match;
+ for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+ const base::string16 text(base::UTF8ToUTF16(kTestCases[i].text));
+ EXPECT_TRUE(match.Calculate(base::UTF8ToUTF16(kTestCases[i].query), text));
+ EXPECT_NEAR(match.relevance(), kTestCases[i].expected_score, kEpsilon)
+ << "Test case " << i << " : text=" << kTestCases[i].text
+ << ", query=" << kTestCases[i].query
+ << ", expected_score=" << kTestCases[i].expected_score;
+ }
+}
+
} // namespace test
} // namespace app_list
« no previous file with comments | « ui/app_list/search/tokenized_string_match.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698