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

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

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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 "chrome/browser/autocomplete/shortcuts_provider.h" 5 #include "chrome/browser/autocomplete/shortcuts_provider.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 struct TestShortcutInfo { 47 struct TestShortcutInfo {
48 std::string guid; 48 std::string guid;
49 std::string text; 49 std::string text;
50 std::string fill_into_edit; 50 std::string fill_into_edit;
51 std::string destination_url; 51 std::string destination_url;
52 std::string contents; 52 std::string contents;
53 std::string contents_class; 53 std::string contents_class;
54 std::string description; 54 std::string description;
55 std::string description_class; 55 std::string description_class;
56 content::PageTransition transition; 56 ui::PageTransition transition;
57 AutocompleteMatch::Type type; 57 AutocompleteMatch::Type type;
58 std::string keyword; 58 std::string keyword;
59 int days_from_now; 59 int days_from_now;
60 int number_of_hits; 60 int number_of_hits;
61 } shortcut_test_db[] = { 61 } shortcut_test_db[] = {
62 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E0", "goog", "www.google.com", 62 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E0", "goog", "www.google.com",
63 "http://www.google.com/", "Google", "0,1,4,0", "Google", "0,3,4,1", 63 "http://www.google.com/", "Google", "0,1,4,0", "Google", "0,3,4,1",
64 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1, 64 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1,
65 100 }, 65 100 },
66 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E1", "slash", "slashdot.org", 66 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E1", "slash", "slashdot.org",
67 "http://slashdot.org/", "slashdot.org", "0,3,5,1", 67 "http://slashdot.org/", "slashdot.org", "0,3,5,1",
68 "Slashdot - News for nerds, stuff that matters", "0,2,5,0", 68 "Slashdot - News for nerds, stuff that matters", "0,2,5,0",
69 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 0, 69 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 0,
70 100 }, 70 100 },
71 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E2", "news", "slashdot.org", 71 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E2", "news", "slashdot.org",
72 "http://slashdot.org/", "slashdot.org", "0,1", 72 "http://slashdot.org/", "slashdot.org", "0,1",
73 "Slashdot - News for nerds, stuff that matters", "0,0,11,2,15,0", 73 "Slashdot - News for nerds, stuff that matters", "0,0,11,2,15,0",
74 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 0, 74 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 0,
75 5 }, 75 5 },
76 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E3", "news", "sports.yahoo.com", 76 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E3", "news", "sports.yahoo.com",
77 "http://sports.yahoo.com/", "sports.yahoo.com", "0,1", 77 "http://sports.yahoo.com/", "sports.yahoo.com", "0,1",
78 "Yahoo! Sports - Sports News, Scores, Rumors, Fantasy Games, and more", 78 "Yahoo! Sports - Sports News, Scores, Rumors, Fantasy Games, and more",
79 "0,0,23,2,27,0", content::PAGE_TRANSITION_TYPED, 79 "0,0,23,2,27,0", ui::PAGE_TRANSITION_TYPED,
80 AutocompleteMatchType::HISTORY_TITLE, "", 2, 5 }, 80 AutocompleteMatchType::HISTORY_TITLE, "", 2, 5 },
81 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E4", "news weather", 81 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E4", "news weather",
82 "www.cnn.com/index.html", "http://www.cnn.com/index.html", 82 "www.cnn.com/index.html", "http://www.cnn.com/index.html",
83 "www.cnn.com/index.html", "0,1", 83 "www.cnn.com/index.html", "0,1",
84 "CNN.com - Breaking News, U.S., World, Weather, Entertainment & Video", 84 "CNN.com - Breaking News, U.S., World, Weather, Entertainment & Video",
85 "0,0,19,2,23,0,38,2,45,0", content::PAGE_TRANSITION_TYPED, 85 "0,0,19,2,23,0,38,2,45,0", ui::PAGE_TRANSITION_TYPED,
86 AutocompleteMatchType::HISTORY_TITLE, "", 1, 10 }, 86 AutocompleteMatchType::HISTORY_TITLE, "", 1, 10 },
87 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E5", "nhl scores", "sports.yahoo.com", 87 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E5", "nhl scores", "sports.yahoo.com",
88 "http://sports.yahoo.com/", "sports.yahoo.com", "0,1", 88 "http://sports.yahoo.com/", "sports.yahoo.com", "0,1",
89 "Yahoo! Sports - Sports News, Scores, Rumors, Fantasy Games, and more", 89 "Yahoo! Sports - Sports News, Scores, Rumors, Fantasy Games, and more",
90 "0,0,29,2,35,0", content::PAGE_TRANSITION_TYPED, 90 "0,0,29,2,35,0", ui::PAGE_TRANSITION_TYPED,
91 AutocompleteMatchType::HISTORY_BODY, "", 1, 10 }, 91 AutocompleteMatchType::HISTORY_BODY, "", 1, 10 },
92 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E6", "nhl scores", 92 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E6", "nhl scores",
93 "www.nhl.com/scores/index.html", "http://www.nhl.com/scores/index.html", 93 "www.nhl.com/scores/index.html", "http://www.nhl.com/scores/index.html",
94 "www.nhl.com/scores/index.html", "0,1,4,3,7,1", 94 "www.nhl.com/scores/index.html", "0,1,4,3,7,1",
95 "January 13, 2010 - NHL.com - Scores", "0,0,19,2,22,0,29,2,35,0", 95 "January 13, 2010 - NHL.com - Scores", "0,0,19,2,22,0,29,2,35,0",
96 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 5, 96 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 5,
97 1 }, 97 1 },
98 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E7", "just", "www.testsite.com/a.html", 98 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E7", "just", "www.testsite.com/a.html",
99 "http://www.testsite.com/a.html", "www.testsite.com/a.html", "0,1", 99 "http://www.testsite.com/a.html", "www.testsite.com/a.html", "0,1",
100 "Test - site - just a test", "0,0,14,2,18,0", 100 "Test - site - just a test", "0,0,14,2,18,0",
101 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 5, 101 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 5,
102 1 }, 102 1 },
103 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E8", "just", "www.testsite.com/b.html", 103 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E8", "just", "www.testsite.com/b.html",
104 "http://www.testsite.com/b.html", "www.testsite.com/b.html", "0,1", 104 "http://www.testsite.com/b.html", "www.testsite.com/b.html", "0,1",
105 "Test - site - just a test", "0,0,14,2,18,0", 105 "Test - site - just a test", "0,0,14,2,18,0",
106 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 5, 106 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 5,
107 2 }, 107 2 },
108 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E9", "just", "www.testsite.com/c.html", 108 { "BD85DBA2-8C29-49F9-84AE-48E1E90880E9", "just", "www.testsite.com/c.html",
109 "http://www.testsite.com/c.html", "www.testsite.com/c.html", "0,1", 109 "http://www.testsite.com/c.html", "www.testsite.com/c.html", "0,1",
110 "Test - site - just a test", "0,0,14,2,18,0", 110 "Test - site - just a test", "0,0,14,2,18,0",
111 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 8, 111 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 8,
112 1 }, 112 1 },
113 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EA", "just a", "www.testsite.com/d.html", 113 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EA", "just a", "www.testsite.com/d.html",
114 "http://www.testsite.com/d.html", "www.testsite.com/d.html", "0,1", 114 "http://www.testsite.com/d.html", "www.testsite.com/d.html", "0,1",
115 "Test - site - just a test", "0,0,14,2,18,0", 115 "Test - site - just a test", "0,0,14,2,18,0",
116 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "", 116 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_TITLE, "",
117 12, 1 }, 117 12, 1 },
118 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EB", "just a t", 118 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EB", "just a t",
119 "www.testsite.com/e.html", "http://www.testsite.com/e.html", 119 "www.testsite.com/e.html", "http://www.testsite.com/e.html",
120 "www.testsite.com/e.html", "0,1", "Test - site - just a test", 120 "www.testsite.com/e.html", "0,1", "Test - site - just a test",
121 "0,0,14,2,18,0", content::PAGE_TRANSITION_TYPED, 121 "0,0,14,2,18,0", ui::PAGE_TRANSITION_TYPED,
122 AutocompleteMatchType::HISTORY_TITLE, "", 12, 1 }, 122 AutocompleteMatchType::HISTORY_TITLE, "", 12, 1 },
123 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EC", "just a te", 123 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EC", "just a te",
124 "www.testsite.com/f.html", "http://www.testsite.com/f.html", 124 "www.testsite.com/f.html", "http://www.testsite.com/f.html",
125 "www.testsite.com/f.html", "0,1", "Test - site - just a test", 125 "www.testsite.com/f.html", "0,1", "Test - site - just a test",
126 "0,0,14,2,18,0", content::PAGE_TRANSITION_TYPED, 126 "0,0,14,2,18,0", ui::PAGE_TRANSITION_TYPED,
127 AutocompleteMatchType::HISTORY_TITLE, "", 12, 1 }, 127 AutocompleteMatchType::HISTORY_TITLE, "", 12, 1 },
128 { "BD85DBA2-8C29-49F9-84AE-48E1E90880ED", "ago", "www.daysagotest.com/a.html", 128 { "BD85DBA2-8C29-49F9-84AE-48E1E90880ED", "ago", "www.daysagotest.com/a.html",
129 "http://www.daysagotest.com/a.html", "www.daysagotest.com/a.html", 129 "http://www.daysagotest.com/a.html", "www.daysagotest.com/a.html",
130 "0,1,8,3,11,1", "Test - site", "0,0", content::PAGE_TRANSITION_TYPED, 130 "0,1,8,3,11,1", "Test - site", "0,0", ui::PAGE_TRANSITION_TYPED,
131 AutocompleteMatchType::HISTORY_URL, "", 1, 1 }, 131 AutocompleteMatchType::HISTORY_URL, "", 1, 1 },
132 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EE", "ago", "www.daysagotest.com/b.html", 132 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EE", "ago", "www.daysagotest.com/b.html",
133 "http://www.daysagotest.com/b.html", "www.daysagotest.com/b.html", 133 "http://www.daysagotest.com/b.html", "www.daysagotest.com/b.html",
134 "0,1,8,3,11,1", "Test - site", "0,0", content::PAGE_TRANSITION_TYPED, 134 "0,1,8,3,11,1", "Test - site", "0,0", ui::PAGE_TRANSITION_TYPED,
135 AutocompleteMatchType::HISTORY_URL, "", 2, 1 }, 135 AutocompleteMatchType::HISTORY_URL, "", 2, 1 },
136 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EF", "ago", "www.daysagotest.com/c.html", 136 { "BD85DBA2-8C29-49F9-84AE-48E1E90880EF", "ago", "www.daysagotest.com/c.html",
137 "http://www.daysagotest.com/c.html", "www.daysagotest.com/c.html", 137 "http://www.daysagotest.com/c.html", "www.daysagotest.com/c.html",
138 "0,1,8,3,11,1", "Test - site", "0,0", content::PAGE_TRANSITION_TYPED, 138 "0,1,8,3,11,1", "Test - site", "0,0", ui::PAGE_TRANSITION_TYPED,
139 AutocompleteMatchType::HISTORY_URL, "", 3, 1 }, 139 AutocompleteMatchType::HISTORY_URL, "", 3, 1 },
140 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F0", "ago", "www.daysagotest.com/d.html", 140 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F0", "ago", "www.daysagotest.com/d.html",
141 "http://www.daysagotest.com/d.html", "www.daysagotest.com/d.html", 141 "http://www.daysagotest.com/d.html", "www.daysagotest.com/d.html",
142 "0,1,8,3,11,1", "Test - site", "0,0", content::PAGE_TRANSITION_TYPED, 142 "0,1,8,3,11,1", "Test - site", "0,0", ui::PAGE_TRANSITION_TYPED,
143 AutocompleteMatchType::HISTORY_URL, "", 4, 1 }, 143 AutocompleteMatchType::HISTORY_URL, "", 4, 1 },
144 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F1", "echo echo", "echo echo", 144 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F1", "echo echo", "echo echo",
145 "chrome-extension://cedabbhfglmiikkmdgcpjdkocfcmbkee/?q=echo", 145 "chrome-extension://cedabbhfglmiikkmdgcpjdkocfcmbkee/?q=echo",
146 "Run Echo command: echo", "0,0", "Echo", "0,4", 146 "Run Echo command: echo", "0,0", "Echo", "0,4",
147 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::EXTENSION_APP, 147 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::EXTENSION_APP,
148 "echo", 1, 1 }, 148 "echo", 1, 1 },
149 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F2", "abcdef.com", "http://abcdef.com", 149 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F2", "abcdef.com", "http://abcdef.com",
150 "http://abcdef.com/", "Abcdef", "0,1,4,0", "Abcdef", "0,3,4,1", 150 "http://abcdef.com/", "Abcdef", "0,1,4,0", "Abcdef", "0,3,4,1",
151 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1, 151 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1,
152 100 }, 152 100 },
153 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F3", "query", "query", 153 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F3", "query", "query",
154 "https://www.google.com/search?q=query", "query", "0,0", 154 "https://www.google.com/search?q=query", "query", "0,0",
155 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED, 155 "Google Search", "0,4", ui::PAGE_TRANSITION_GENERATED,
156 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 }, 156 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 },
157 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F4", "word", "www.word", 157 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F4", "word", "www.word",
158 "https://www.google.com/search?q=www.word", "www.word", "0,0", 158 "https://www.google.com/search?q=www.word", "www.word", "0,0",
159 "Google Search", "0,4", content::PAGE_TRANSITION_GENERATED, 159 "Google Search", "0,4", ui::PAGE_TRANSITION_GENERATED,
160 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 }, 160 AutocompleteMatchType::SEARCH_HISTORY, "", 1, 100 },
161 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F5", "about:o", "chrome://omnibox", 161 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F5", "about:o", "chrome://omnibox",
162 "chrome://omnibox/", "about:omnibox", "0,3,10,1", "", "", 162 "chrome://omnibox/", "about:omnibox", "0,3,10,1", "", "",
163 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::NAVSUGGEST, "", 163 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::NAVSUGGEST, "",
164 1, 100 }, 164 1, 100 },
165 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F6", "www/real sp", 165 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F6", "www/real sp",
166 "http://www/real space/long-url-with-space.html", 166 "http://www/real space/long-url-with-space.html",
167 "http://www/real%20space/long-url-with-space.html", 167 "http://www/real%20space/long-url-with-space.html",
168 "www/real space/long-url-with-space.html", "0,3,11,1", 168 "www/real space/long-url-with-space.html", "0,3,11,1",
169 "Page With Space; Input with Space", "0,0", 169 "Page With Space; Input with Space", "0,0",
170 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 170 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "",
171 1, 100 }, 171 1, 100 },
172 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F7", "duplicate", "http://duplicate.com", 172 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F7", "duplicate", "http://duplicate.com",
173 "http://duplicate.com/", "Duplicate", "0,1", "Duplicate", "0,1", 173 "http://duplicate.com/", "Duplicate", "0,1", "Duplicate", "0,1",
174 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1, 174 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1,
175 100 }, 175 100 },
176 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F8", "dupl", "http://duplicate.com", 176 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F8", "dupl", "http://duplicate.com",
177 "http://duplicate.com/", "Duplicate", "0,1", "Duplicate", "0,1", 177 "http://duplicate.com/", "Duplicate", "0,1", "Duplicate", "0,1",
178 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1, 178 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 1,
179 100 }, 179 100 },
180 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F9", "notrailing.com/", 180 { "BD85DBA2-8C29-49F9-84AE-48E1E90880F9", "notrailing.com/",
181 "http://notrailing.com", "http://notrailing.com/", "No Trailing Slash", 181 "http://notrailing.com", "http://notrailing.com/", "No Trailing Slash",
182 "0,1", "No Trailing Slash on fill_into_edit", "0,1", 182 "0,1", "No Trailing Slash on fill_into_edit", "0,1",
183 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 183 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "",
184 1, 100 }, 184 1, 100 },
185 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FA", "http:///foo.com", 185 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FA", "http:///foo.com",
186 "http://foo.com", "http://foo.com/", "Foo - Typo in Input", 186 "http://foo.com", "http://foo.com/", "Foo - Typo in Input",
187 "0,1", "Foo - Typo in Input Corrected in fill_into_edit", "0,1", 187 "0,1", "Foo - Typo in Input Corrected in fill_into_edit", "0,1",
188 content::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "", 188 ui::PAGE_TRANSITION_TYPED, AutocompleteMatchType::HISTORY_URL, "",
189 1, 100 }, 189 1, 100 },
190 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FB", "trailing1 ", 190 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FB", "trailing1 ",
191 "http://trailing1.com", "http://trailing1.com/", 191 "http://trailing1.com", "http://trailing1.com/",
192 "Trailing1 - Space in Shortcut", "0,1", 192 "Trailing1 - Space in Shortcut", "0,1",
193 "Trailing1 - Space in Shortcut", "0,1", content::PAGE_TRANSITION_TYPED, 193 "Trailing1 - Space in Shortcut", "0,1", ui::PAGE_TRANSITION_TYPED,
194 AutocompleteMatchType::HISTORY_URL, "", 1, 100 }, 194 AutocompleteMatchType::HISTORY_URL, "", 1, 100 },
195 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FC", "about:trailing2 ", 195 { "BD85DBA2-8C29-49F9-84AE-48E1E90880FC", "about:trailing2 ",
196 "chrome://trailing2blah", "chrome://trailing2blah/", 196 "chrome://trailing2blah", "chrome://trailing2blah/",
197 "Trailing2 - Space in Shortcut", "0,1", 197 "Trailing2 - Space in Shortcut", "0,1",
198 "Trailing2 - Space in Shortcut", "0,1", content::PAGE_TRANSITION_TYPED, 198 "Trailing2 - Space in Shortcut", "0,1", ui::PAGE_TRANSITION_TYPED,
199 AutocompleteMatchType::HISTORY_URL, "", 1, 100 }, 199 AutocompleteMatchType::HISTORY_URL, "", 1, 100 },
200 }; 200 };
201 201
202 } // namespace 202 } // namespace
203 203
204 204
205 // ClassifyTest --------------------------------------------------------------- 205 // ClassifyTest ---------------------------------------------------------------
206 206
207 // Helper class to make running tests of ClassifyAllMatchesInString() more 207 // Helper class to make running tests of ClassifyAllMatchesInString() more
208 // convenient. 208 // convenient.
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 EXPECT_EQ("0,3,2,1,9,3,11,0", 707 EXPECT_EQ("0,3,2,1,9,3,11,0",
708 AutocompleteMatch::ClassificationsToString(spans_l)); 708 AutocompleteMatch::ClassificationsToString(spans_l));
709 } 709 }
710 710
711 TEST_F(ShortcutsProviderTest, CalculateScore) { 711 TEST_F(ShortcutsProviderTest, CalculateScore) {
712 history::ShortcutsDatabase::Shortcut shortcut( 712 history::ShortcutsDatabase::Shortcut shortcut(
713 std::string(), ASCIIToUTF16("test"), 713 std::string(), ASCIIToUTF16("test"),
714 history::ShortcutsDatabase::Shortcut::MatchCore( 714 history::ShortcutsDatabase::Shortcut::MatchCore(
715 ASCIIToUTF16("www.test.com"), GURL("http://www.test.com"), 715 ASCIIToUTF16("www.test.com"), GURL("http://www.test.com"),
716 ASCIIToUTF16("www.test.com"), "0,1,4,3,8,1", 716 ASCIIToUTF16("www.test.com"), "0,1,4,3,8,1",
717 ASCIIToUTF16("A test"), "0,0,2,2", content::PAGE_TRANSITION_TYPED, 717 ASCIIToUTF16("A test"), "0,0,2,2", ui::PAGE_TRANSITION_TYPED,
718 AutocompleteMatchType::HISTORY_URL, base::string16()), 718 AutocompleteMatchType::HISTORY_URL, base::string16()),
719 base::Time::Now(), 1); 719 base::Time::Now(), 1);
720 720
721 // Maximal score. 721 // Maximal score.
722 const int max_relevance = 722 const int max_relevance =
723 ShortcutsProvider::kShortcutsProviderDefaultMaxRelevance; 723 ShortcutsProvider::kShortcutsProviderDefaultMaxRelevance;
724 const int kMaxScore = CalculateScore("test", shortcut, max_relevance); 724 const int kMaxScore = CalculateScore("test", shortcut, max_relevance);
725 725
726 // Score decreases as percent of the match is decreased. 726 // Score decreases as percent of the match is decreased.
727 int score_three_quarters = CalculateScore("tes", shortcut, max_relevance); 727 int score_three_quarters = CalculateScore("tes", shortcut, max_relevance);
(...skipping 30 matching lines...) Expand all
758 EXPECT_LT(score_two_weeks_old, score_more_popular_two_weeks_old); 758 EXPECT_LT(score_two_weeks_old, score_more_popular_two_weeks_old);
759 EXPECT_LT(score_popular_two_weeks_old, score_more_popular_two_weeks_old); 759 EXPECT_LT(score_popular_two_weeks_old, score_more_popular_two_weeks_old);
760 // But still decayed. 760 // But still decayed.
761 EXPECT_LT(score_more_popular_two_weeks_old, kMaxScore); 761 EXPECT_LT(score_more_popular_two_weeks_old, kMaxScore);
762 } 762 }
763 763
764 TEST_F(ShortcutsProviderTest, DeleteMatch) { 764 TEST_F(ShortcutsProviderTest, DeleteMatch) {
765 TestShortcutInfo shortcuts_to_test_delete[] = { 765 TestShortcutInfo shortcuts_to_test_delete[] = {
766 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F1", "delete", "www.deletetest.com/1", 766 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F1", "delete", "www.deletetest.com/1",
767 "http://www.deletetest.com/1", "http://www.deletetest.com/1", "0,2", 767 "http://www.deletetest.com/1", "http://www.deletetest.com/1", "0,2",
768 "Erase this shortcut!", "0,0", content::PAGE_TRANSITION_TYPED, 768 "Erase this shortcut!", "0,0", ui::PAGE_TRANSITION_TYPED,
769 AutocompleteMatchType::HISTORY_URL, "", 1, 1}, 769 AutocompleteMatchType::HISTORY_URL, "", 1, 1},
770 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F2", "erase", "www.deletetest.com/1", 770 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F2", "erase", "www.deletetest.com/1",
771 "http://www.deletetest.com/1", "http://www.deletetest.com/1", "0,2", 771 "http://www.deletetest.com/1", "http://www.deletetest.com/1", "0,2",
772 "Erase this shortcut!", "0,0", content::PAGE_TRANSITION_TYPED, 772 "Erase this shortcut!", "0,0", ui::PAGE_TRANSITION_TYPED,
773 AutocompleteMatchType::HISTORY_TITLE, "", 1, 1}, 773 AutocompleteMatchType::HISTORY_TITLE, "", 1, 1},
774 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F3", "keep", "www.deletetest.com/1/2", 774 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F3", "keep", "www.deletetest.com/1/2",
775 "http://www.deletetest.com/1/2", "http://www.deletetest.com/1/2", "0,2", 775 "http://www.deletetest.com/1/2", "http://www.deletetest.com/1/2", "0,2",
776 "Keep this shortcut!", "0,0", content::PAGE_TRANSITION_TYPED, 776 "Keep this shortcut!", "0,0", ui::PAGE_TRANSITION_TYPED,
777 AutocompleteMatchType::HISTORY_TITLE, "", 1, 1}, 777 AutocompleteMatchType::HISTORY_TITLE, "", 1, 1},
778 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F4", "delete", "www.deletetest.com/2", 778 { "BD85DBA2-8C29-49F9-84AE-48E1E90881F4", "delete", "www.deletetest.com/2",
779 "http://www.deletetest.com/2", "http://www.deletetest.com/2", "0,2", 779 "http://www.deletetest.com/2", "http://www.deletetest.com/2", "0,2",
780 "Erase this shortcut!", "0,0", content::PAGE_TRANSITION_TYPED, 780 "Erase this shortcut!", "0,0", ui::PAGE_TRANSITION_TYPED,
781 AutocompleteMatchType::HISTORY_URL, "", 1, 1}, 781 AutocompleteMatchType::HISTORY_URL, "", 1, 1},
782 }; 782 };
783 783
784 size_t original_shortcuts_count = backend_->shortcuts_map().size(); 784 size_t original_shortcuts_count = backend_->shortcuts_map().size();
785 785
786 FillData(shortcuts_to_test_delete, arraysize(shortcuts_to_test_delete)); 786 FillData(shortcuts_to_test_delete, arraysize(shortcuts_to_test_delete));
787 787
788 EXPECT_EQ(original_shortcuts_count + 4, backend_->shortcuts_map().size()); 788 EXPECT_EQ(original_shortcuts_count + 4, backend_->shortcuts_map().size());
789 EXPECT_FALSE(backend_->shortcuts_map().end() == 789 EXPECT_FALSE(backend_->shortcuts_map().end() ==
790 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); 790 backend_->shortcuts_map().find(ASCIIToUTF16("delete")));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 extensions::UnloadedExtensionInfo details( 840 extensions::UnloadedExtensionInfo details(
841 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); 841 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL);
842 content::NotificationService::current()->Notify( 842 content::NotificationService::current()->Notify(
843 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 843 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
844 content::Source<Profile>(&profile_), 844 content::Source<Profile>(&profile_),
845 content::Details<extensions::UnloadedExtensionInfo>(&details)); 845 content::Details<extensions::UnloadedExtensionInfo>(&details));
846 846
847 // Now the URL should have disappeared. 847 // Now the URL should have disappeared.
848 RunTest(text, false, ExpectedURLs(), std::string(), base::string16()); 848 RunTest(text, false, ExpectedURLs(), std::string(), base::string16());
849 } 849 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/shortcuts_provider.cc ('k') | chrome/browser/autofill/autofill_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698