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

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

Issue 10537154: A working implementation of AQS (Assisted Query Stats). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed Win compilation error. Created 8 years, 6 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 | Annotate | Revision Log
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 13 matching lines...) Expand all
24 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 26
27 static std::ostream& operator<<(std::ostream& os, 27 static std::ostream& operator<<(std::ostream& os,
28 const AutocompleteResult::const_iterator& it) { 28 const AutocompleteResult::const_iterator& it) {
29 return os << static_cast<const AutocompleteMatch*>(&(*it)); 29 return os << static_cast<const AutocompleteMatch*>(&(*it));
30 } 30 }
31 31
32 namespace { 32 namespace {
33 const size_t kResultsPerProvider = 3; 33 const size_t kResultsPerProvider = 3;
34 const char kTestTemplateURLKeyword[] = "t";
34 } 35 }
35 36
36 // Autocomplete provider that provides known results. Note that this is 37 // Autocomplete provider that provides known results. Note that this is
37 // refcounted so that it can also be a task on the message loop. 38 // refcounted so that it can also be a task on the message loop.
38 class TestProvider : public AutocompleteProvider { 39 class TestProvider : public AutocompleteProvider {
39 public: 40 public:
40 TestProvider(int relevance, const string16& prefix) 41 TestProvider(int relevance, const string16& prefix,
41 : AutocompleteProvider(NULL, NULL, ""), 42 Profile* profile,
43 const string16 match_keyword)
44 : AutocompleteProvider(NULL, profile, ""),
42 relevance_(relevance), 45 relevance_(relevance),
43 prefix_(prefix) { 46 prefix_(prefix),
47 match_keyword_(match_keyword) {
44 } 48 }
45 49
46 virtual void Start(const AutocompleteInput& input, 50 virtual void Start(const AutocompleteInput& input,
47 bool minimal_changes); 51 bool minimal_changes);
48 52
49 void set_listener(ACProviderListener* listener) { 53 void set_listener(ACProviderListener* listener) {
50 listener_ = listener; 54 listener_ = listener;
51 } 55 }
52 56
53 private: 57 private:
54 ~TestProvider() {} 58 ~TestProvider() {}
55 59
56 void Run(); 60 void Run();
57 61
58 void AddResults(int start_at, int num); 62 void AddResults(int start_at, int num);
63 void AddResultsWithSearchTermsArgs(
64 int start_at,
65 int num,
66 AutocompleteMatch::Type type,
67 const TemplateURLRef::SearchTermsArgs& search_terms_args);
59 68
60 int relevance_; 69 int relevance_;
61 const string16 prefix_; 70 const string16 prefix_;
71 const string16 match_keyword_;
62 }; 72 };
63 73
64 void TestProvider::Start(const AutocompleteInput& input, 74 void TestProvider::Start(const AutocompleteInput& input,
65 bool minimal_changes) { 75 bool minimal_changes) {
66 if (minimal_changes) 76 if (minimal_changes)
67 return; 77 return;
68 78
69 matches_.clear(); 79 matches_.clear();
70 80
71 // Generate one result synchronously, the rest later. 81 // Generate 4 results synchronously, the rest later.
72 AddResults(0, 1); 82 AddResults(0, 1);
83 AddResultsWithSearchTermsArgs(
84 1, 1, AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
85 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("echo")));
86 AddResultsWithSearchTermsArgs(
87 2, 1, AutocompleteMatch::NAVSUGGEST,
88 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("nav")));
89 AddResultsWithSearchTermsArgs(
90 3, 1, AutocompleteMatch::SEARCH_SUGGEST,
91 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("query")));
73 92
74 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { 93 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) {
75 done_ = false; 94 done_ = false;
76 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run, 95 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run,
77 this)); 96 this));
78 } 97 }
79 } 98 }
80 99
81 void TestProvider::Run() { 100 void TestProvider::Run() {
82 DCHECK_GT(kResultsPerProvider, 0U); 101 DCHECK_GT(kResultsPerProvider, 0U);
83 AddResults(1, kResultsPerProvider); 102 AddResults(1, kResultsPerProvider);
84 done_ = true; 103 done_ = true;
85 DCHECK(listener_); 104 DCHECK(listener_);
86 listener_->OnProviderUpdate(true); 105 listener_->OnProviderUpdate(true);
87 } 106 }
88 107
89 void TestProvider::AddResults(int start_at, int num) { 108 void TestProvider::AddResults(int start_at, int num) {
109 AddResultsWithSearchTermsArgs(start_at,
110 num,
111 AutocompleteMatch::URL_WHAT_YOU_TYPED,
112 TemplateURLRef::SearchTermsArgs(string16()));
113 }
114
115 void TestProvider::AddResultsWithSearchTermsArgs(
116 int start_at,
117 int num,
118 AutocompleteMatch::Type type,
119 const TemplateURLRef::SearchTermsArgs& search_terms_args) {
90 for (int i = start_at; i < num; i++) { 120 for (int i = start_at; i < num; i++) {
91 AutocompleteMatch match(this, relevance_ - i, false, 121 AutocompleteMatch match(this, relevance_ - i, false, type);
92 AutocompleteMatch::URL_WHAT_YOU_TYPED);
93 122
94 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); 123 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i));
95 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); 124 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit));
96 125
97 match.contents = match.fill_into_edit; 126 match.contents = match.fill_into_edit;
98 match.contents_class.push_back( 127 match.contents_class.push_back(
99 ACMatchClassification(0, ACMatchClassification::NONE)); 128 ACMatchClassification(0, ACMatchClassification::NONE));
100 match.description = match.fill_into_edit; 129 match.description = match.fill_into_edit;
101 match.description_class.push_back( 130 match.description_class.push_back(
102 ACMatchClassification(0, ACMatchClassification::NONE)); 131 ACMatchClassification(0, ACMatchClassification::NONE));
132 match.search_terms_args.reset(
133 new TemplateURLRef::SearchTermsArgs(search_terms_args));
134 if (!match_keyword_.empty()) {
135 match.keyword = match_keyword_;
136 ASSERT_TRUE(match.GetTemplateURL(profile_) != NULL);
137 }
103 138
104 matches_.push_back(match); 139 matches_.push_back(match);
105 } 140 }
106 } 141 }
107 142
108 class AutocompleteProviderTest : public testing::Test, 143 class AutocompleteProviderTest : public testing::Test,
109 public content::NotificationObserver { 144 public content::NotificationObserver {
110 protected: 145 protected:
111 struct KeywordTestData { 146 struct KeywordTestData {
112 const string16 fill_into_edit; 147 const string16 fill_into_edit;
113 const string16 keyword; 148 const string16 keyword;
114 const bool expected_keyword_result; 149 const bool expected_keyword_result;
115 }; 150 };
116 151
152 struct AssistedQueryStatsTestData {
153 const AutocompleteMatch::Type match_type;
154 const std::string expected_aqs;
155 };
156
117 protected: 157 protected:
158 // Registers a test TemplateURL under the given keyword.
159 void RegisterTemplateURL(const string16 keyword,
160 const std::string& template_url);
161
118 void ResetControllerWithTestProviders(bool same_destinations); 162 void ResetControllerWithTestProviders(bool same_destinations);
119 163
120 // Runs a query on the input "a", and makes sure both providers' input is 164 // Runs a query on the input "a", and makes sure both providers' input is
121 // properly collected. 165 // properly collected.
122 void RunTest(); 166 void RunTest();
123 167
124 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); 168 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size);
125 169
170 void RunAssistedQueryStatsTest(
171 const AssistedQueryStatsTestData* aqs_test_data,
172 size_t size);
173
126 void RunQuery(const string16 query); 174 void RunQuery(const string16 query);
127 175
128 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); 176 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders();
129 void ResetControllerWithKeywordProvider(); 177 void ResetControllerWithKeywordProvider();
130 void RunExactKeymatchTest(bool allow_exact_keyword_match); 178 void RunExactKeymatchTest(bool allow_exact_keyword_match);
131 179
132 // These providers are owned by the controller once it's created. 180 // These providers are owned by the controller once it's created.
133 ACProviders providers_; 181 ACProviders providers_;
134 182
135 AutocompleteResult result_; 183 AutocompleteResult result_;
136 scoped_ptr<AutocompleteController> controller_; 184 scoped_ptr<AutocompleteController> controller_;
137 185
138 private: 186 private:
139 // content::NotificationObserver 187 // content::NotificationObserver
140 virtual void Observe(int type, 188 virtual void Observe(int type,
141 const content::NotificationSource& source, 189 const content::NotificationSource& source,
142 const content::NotificationDetails& details); 190 const content::NotificationDetails& details);
143 191
144 MessageLoopForUI message_loop_; 192 MessageLoopForUI message_loop_;
145 content::NotificationRegistrar registrar_; 193 content::NotificationRegistrar registrar_;
146 TestingProfile profile_; 194 TestingProfile profile_;
147 }; 195 };
148 196
197 void AutocompleteProviderTest:: RegisterTemplateURL(
198 const string16 keyword,
199 const std::string& template_url) {
200 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
201 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
202 TemplateURLData data;
203 data.SetURL(template_url);
204 data.SetKeyword(keyword);
205 TemplateURL* default_t_url = new TemplateURL(&profile_, data);
206 TemplateURLService* turl_model =
207 TemplateURLServiceFactory::GetForProfile(&profile_);
208 turl_model->Add(default_t_url);
209 turl_model->SetDefaultSearchProvider(default_t_url);
210 TemplateURLID default_provider_id = default_t_url->id();
211 ASSERT_NE(0, default_provider_id);
212 }
213
149 void AutocompleteProviderTest::ResetControllerWithTestProviders( 214 void AutocompleteProviderTest::ResetControllerWithTestProviders(
150 bool same_destinations) { 215 bool same_destinations) {
151 // Forget about any existing providers. The controller owns them and will 216 // Forget about any existing providers. The controller owns them and will
152 // Release() them below, when we delete it during the call to reset(). 217 // Release() them below, when we delete it during the call to reset().
153 providers_.clear(); 218 providers_.clear();
154 219
220 // TODO: Move it outside this method, after refactoring the existing
221 // unit tests. Specifically:
222 // (1) Make sure that AutocompleteMatch.keyword is set iff there is
223 // a corresponding call to RegisterTemplateURL; otherwise the
224 // controller flow will crash; this practically means that
225 // RunTests/ResetControllerXXX/RegisterTemplateURL should
226 // be coordinated with each other.
227 // (2) Inject test arguments rather than rely on the hardcoded values, e.g.
228 // don't rely on kResultsPerProvided and default relevance ordering
229 // (B > A).
230 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword),
231 "http://aqs/{searchTerms}/{google:assistedQueryStats}");
232
155 // Construct two new providers, with either the same or different prefixes. 233 // Construct two new providers, with either the same or different prefixes.
156 TestProvider* providerA = new TestProvider(kResultsPerProvider, 234 TestProvider* providerA =
157 ASCIIToUTF16("http://a")); 235 new TestProvider(kResultsPerProvider,
236 ASCIIToUTF16("http://a"),
237 &profile_,
238 ASCIIToUTF16(kTestTemplateURLKeyword));
158 providerA->AddRef(); 239 providerA->AddRef();
159 providers_.push_back(providerA); 240 providers_.push_back(providerA);
160 241
161 TestProvider* providerB = new TestProvider(kResultsPerProvider * 2, 242 TestProvider* providerB = new TestProvider(
162 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); 243 kResultsPerProvider * 2,
244 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"),
245 &profile_,
246 string16());
163 providerB->AddRef(); 247 providerB->AddRef();
164 providers_.push_back(providerB); 248 providers_.push_back(providerB);
165 249
166 // Reset the controller to contain our new providers. 250 // Reset the controller to contain our new providers.
167 AutocompleteController* controller = 251 AutocompleteController* controller =
168 new AutocompleteController(providers_, &profile_); 252 new AutocompleteController(providers_, &profile_);
169 controller_.reset(controller); 253 controller_.reset(controller);
170 providerA->set_listener(controller); 254 providerA->set_listener(controller);
171 providerB->set_listener(controller); 255 providerB->set_listener(controller);
172 256
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); 294 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_);
211 keyword_provider->AddRef(); 295 keyword_provider->AddRef();
212 providers_.push_back(keyword_provider); 296 providers_.push_back(keyword_provider);
213 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); 297 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_);
214 search_provider->AddRef(); 298 search_provider->AddRef();
215 providers_.push_back(search_provider); 299 providers_.push_back(search_provider);
216 300
217 controller_.reset(new AutocompleteController(providers_, &profile_)); 301 controller_.reset(new AutocompleteController(providers_, &profile_));
218 } 302 }
219 303
220 void AutocompleteProviderTest:: 304 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
221 ResetControllerWithKeywordProvider() {
222 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 305 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
223 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 306 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
224 307
225 TemplateURLService* turl_model = 308 TemplateURLService* turl_model =
226 TemplateURLServiceFactory::GetForProfile(&profile_); 309 TemplateURLServiceFactory::GetForProfile(&profile_);
227 310
228 // Create a TemplateURL for KeywordProvider. 311 // Create a TemplateURL for KeywordProvider.
229 TemplateURLData data; 312 TemplateURLData data;
230 data.short_name = ASCIIToUTF16("foo.com"); 313 data.short_name = ASCIIToUTF16("foo.com");
231 data.SetKeyword(ASCIIToUTF16("foo.com")); 314 data.SetKeyword(ASCIIToUTF16("foo.com"));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 match.keyword = match_data[i].keyword; 356 match.keyword = match_data[i].keyword;
274 matches.push_back(match); 357 matches.push_back(match);
275 } 358 }
276 359
277 AutocompleteResult result; 360 AutocompleteResult result;
278 result.AppendMatches(matches); 361 result.AppendMatches(matches);
279 controller_->UpdateAssociatedKeywords(&result); 362 controller_->UpdateAssociatedKeywords(&result);
280 363
281 for (size_t j = 0; j < result.size(); ++j) { 364 for (size_t j = 0; j < result.size(); ++j) {
282 EXPECT_EQ(match_data[j].expected_keyword_result, 365 EXPECT_EQ(match_data[j].expected_keyword_result,
283 result.match_at(j).associated_keyword.get() != NULL); 366 result.match_at(j)->associated_keyword.get() != NULL);
284 } 367 }
285 } 368 }
286 369
370 void AutocompleteProviderTest::RunAssistedQueryStatsTest(
371 const AssistedQueryStatsTestData* aqs_test_data,
372 size_t size) {
373 // Prepare input.
374 const size_t kMaxRelevance = 1000;
375 ACMatches matches;
376 for (size_t i = 0; i < size; ++i) {
377 AutocompleteMatch match(NULL, kMaxRelevance - i, false,
378 aqs_test_data[i].match_type);
379 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword);
380 match.search_terms_args.reset(
381 new TemplateURLRef::SearchTermsArgs(string16()));
382 matches.push_back(match);
383 }
384 result_.Reset();
385 result_.AppendMatches(matches);
386
387 // Update AQS.
388 controller_->UpdateAssistedQueryStats(&result_);
389
390 // Verify data.
391 for (size_t i = 0; i < size; ++i) {
392 EXPECT_EQ(aqs_test_data[i].expected_aqs,
393 result_.match_at(i)->search_terms_args->assisted_query_stats);
394 }
395 }
287 396
288 void AutocompleteProviderTest::RunQuery(const string16 query) { 397 void AutocompleteProviderTest::RunQuery(const string16 query) {
289 result_.Reset(); 398 result_.Reset();
290 controller_->Start(query, string16(), true, false, true, 399 controller_->Start(query, string16(), true, false, true,
291 AutocompleteInput::ALL_MATCHES); 400 AutocompleteInput::ALL_MATCHES);
292 401
293 if (!controller_->done()) 402 if (!controller_->done())
294 // The message loop will terminate when all autocomplete input has been 403 // The message loop will terminate when all autocomplete input has been
295 // collected. 404 // collected.
296 MessageLoop::current()->Run(); 405 MessageLoop::current()->Run();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ResetControllerWithTestProviders(false); 437 ResetControllerWithTestProviders(false);
329 RunTest(); 438 RunTest();
330 439
331 // Make sure the default match gets set to the highest relevance match. The 440 // Make sure the default match gets set to the highest relevance match. The
332 // highest relevance matches should come from the second provider. 441 // highest relevance matches should come from the second provider.
333 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers 442 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
334 ASSERT_NE(result_.end(), result_.default_match()); 443 ASSERT_NE(result_.end(), result_.default_match());
335 EXPECT_EQ(providers_[1], result_.default_match()->provider); 444 EXPECT_EQ(providers_[1], result_.default_match()->provider);
336 } 445 }
337 446
447 // Tests assisted query stats.
448 TEST_F(AutocompleteProviderTest, AssistedQueryStats) {
449 ResetControllerWithTestProviders(false);
450 RunTest();
451
452 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
453
454 // Now, check the results from the second provider, as they should not have
455 // assisted query stats set.
456 for (size_t i = 0; i < kResultsPerProvider; ++i) {
457 EXPECT_TRUE(
458 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
459 }
460 // The first provider has a test keyword, so AQS should be non-empty.
461 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) {
462 EXPECT_FALSE(
463 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
464 }
465 }
466
338 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { 467 TEST_F(AutocompleteProviderTest, RemoveDuplicates) {
339 ResetControllerWithTestProviders(true); 468 ResetControllerWithTestProviders(true);
340 RunTest(); 469 RunTest();
341 470
342 // Make sure all the first provider's results were eliminated by the second 471 // Make sure all the first provider's results were eliminated by the second
343 // provider's. 472 // provider's.
344 EXPECT_EQ(kResultsPerProvider, result_.size()); 473 EXPECT_EQ(kResultsPerProvider, result_.size());
345 for (AutocompleteResult::const_iterator i(result_.begin()); 474 for (AutocompleteResult::const_iterator i(result_.begin());
346 i != result_.end(); ++i) 475 i != result_.end(); ++i)
347 EXPECT_EQ(providers_[1], i->provider); 476 EXPECT_EQ(providers_[1], i->provider);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 { ASCIIToUTF16("foo.com"), string16(), false }, 517 { ASCIIToUTF16("foo.com"), string16(), false },
389 { ASCIIToUTF16("bar.com"), string16(), true }, 518 { ASCIIToUTF16("bar.com"), string16(), true },
390 }; 519 };
391 520
392 SCOPED_TRACE("Duplicate url with multiple keywords"); 521 SCOPED_TRACE("Duplicate url with multiple keywords");
393 RunRedundantKeywordTest(multiple_keyword, 522 RunRedundantKeywordTest(multiple_keyword,
394 ARRAYSIZE_UNSAFE(multiple_keyword)); 523 ARRAYSIZE_UNSAFE(multiple_keyword));
395 } 524 }
396 } 525 }
397 526
527 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
528 ResetControllerWithTestProviders(false);
529
530 {
531 AssistedQueryStatsTestData test_data[] = {
532 // Note: We use dummy data to work around a compilation error
Peter Kasting 2012/06/19 05:53:43 Nit: Slightly more informative: // MSVC doe
Bart N 2012/06/22 03:22:19 Done.
533 // on Win platform.
534 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "" }
535 };
536 SCOPED_TRACE("No matches");
537 // Note: We pass 0 here to ignore the dummy data above.
538 RunAssistedQueryStatsTest(test_data, 0);
539 }
540
541 {
542 AssistedQueryStatsTestData test_data[] = {
543 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57" }
544 };
545 SCOPED_TRACE("One match");
546 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
547 }
548
549 {
550 AssistedQueryStatsTestData test_data[] = {
551 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57j58j5l2j0l3j59" },
552 { AutocompleteMatch::URL_WHAT_YOU_TYPED, "chrome.1.57j58j5l2j0l3j59" },
553 { AutocompleteMatch::NAVSUGGEST, "chrome.2.57j58j5l2j0l3j59" },
554 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
555 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
556 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
557 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
558 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
559 };
560 SCOPED_TRACE("Multiple matches");
561 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
562 }
563 }
564
398 typedef testing::Test AutocompleteTest; 565 typedef testing::Test AutocompleteTest;
399 566
400 TEST_F(AutocompleteTest, InputType) { 567 TEST_F(AutocompleteTest, InputType) {
401 struct test_data { 568 struct test_data {
402 const string16 input; 569 const string16 input;
403 const AutocompleteInput::Type type; 570 const AutocompleteInput::Type type;
404 } input_cases[] = { 571 } input_cases[] = {
405 { string16(), AutocompleteInput::INVALID }, 572 { string16(), AutocompleteInput::INVALID },
406 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, 573 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY },
407 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, 574 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY },
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 &scheme, 774 &scheme,
608 &host); 775 &host);
609 AutocompleteInput input(input_cases[i].input, string16(), true, false, 776 AutocompleteInput input(input_cases[i].input, string16(), true, false,
610 true, AutocompleteInput::ALL_MATCHES); 777 true, AutocompleteInput::ALL_MATCHES);
611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); 778 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin);
612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); 779 EXPECT_EQ(input_cases[i].scheme.len, scheme.len);
613 EXPECT_EQ(input_cases[i].host.begin, host.begin); 780 EXPECT_EQ(input_cases[i].host.begin, host.begin);
614 EXPECT_EQ(input_cases[i].host.len, host.len); 781 EXPECT_EQ(input_cases[i].host.len, host.len);
615 } 782 }
616 } 783 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.cc ('k') | chrome/browser/autocomplete/keyword_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698