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

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: Addressed comments. 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 test flows.
Peter Kasting 2012/06/19 00:38:08 Nit: Can you say more about what needs to happen i
Bart N 2012/06/19 01:30:17 Done.
221 RegisterTemplateURL(ASCIIToUTF16(kTestTemplateURLKeyword),
222 "http://aqs/{searchTerms}/{google:assistedQueryStats}");
223
155 // Construct two new providers, with either the same or different prefixes. 224 // Construct two new providers, with either the same or different prefixes.
156 TestProvider* providerA = new TestProvider(kResultsPerProvider, 225 TestProvider* providerA =
157 ASCIIToUTF16("http://a")); 226 new TestProvider(kResultsPerProvider,
227 ASCIIToUTF16("http://a"),
228 &profile_,
229 ASCIIToUTF16(kTestTemplateURLKeyword));
158 providerA->AddRef(); 230 providerA->AddRef();
159 providers_.push_back(providerA); 231 providers_.push_back(providerA);
160 232
161 TestProvider* providerB = new TestProvider(kResultsPerProvider * 2, 233 TestProvider* providerB = new TestProvider(
162 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); 234 kResultsPerProvider * 2,
235 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"),
236 &profile_,
237 string16());
163 providerB->AddRef(); 238 providerB->AddRef();
164 providers_.push_back(providerB); 239 providers_.push_back(providerB);
165 240
166 // Reset the controller to contain our new providers. 241 // Reset the controller to contain our new providers.
167 AutocompleteController* controller = 242 AutocompleteController* controller =
168 new AutocompleteController(providers_, &profile_); 243 new AutocompleteController(providers_, &profile_);
169 controller_.reset(controller); 244 controller_.reset(controller);
170 providerA->set_listener(controller); 245 providerA->set_listener(controller);
171 providerB->set_listener(controller); 246 providerB->set_listener(controller);
172 247
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); 285 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_);
211 keyword_provider->AddRef(); 286 keyword_provider->AddRef();
212 providers_.push_back(keyword_provider); 287 providers_.push_back(keyword_provider);
213 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); 288 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_);
214 search_provider->AddRef(); 289 search_provider->AddRef();
215 providers_.push_back(search_provider); 290 providers_.push_back(search_provider);
216 291
217 controller_.reset(new AutocompleteController(providers_, &profile_)); 292 controller_.reset(new AutocompleteController(providers_, &profile_));
218 } 293 }
219 294
220 void AutocompleteProviderTest:: 295 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() {
221 ResetControllerWithKeywordProvider() {
222 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 296 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
223 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); 297 &profile_, &TemplateURLServiceFactory::BuildInstanceFor);
224 298
225 TemplateURLService* turl_model = 299 TemplateURLService* turl_model =
226 TemplateURLServiceFactory::GetForProfile(&profile_); 300 TemplateURLServiceFactory::GetForProfile(&profile_);
227 301
228 // Create a TemplateURL for KeywordProvider. 302 // Create a TemplateURL for KeywordProvider.
229 TemplateURLData data; 303 TemplateURLData data;
230 data.short_name = ASCIIToUTF16("foo.com"); 304 data.short_name = ASCIIToUTF16("foo.com");
231 data.SetKeyword(ASCIIToUTF16("foo.com")); 305 data.SetKeyword(ASCIIToUTF16("foo.com"));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 match.keyword = match_data[i].keyword; 347 match.keyword = match_data[i].keyword;
274 matches.push_back(match); 348 matches.push_back(match);
275 } 349 }
276 350
277 AutocompleteResult result; 351 AutocompleteResult result;
278 result.AppendMatches(matches); 352 result.AppendMatches(matches);
279 controller_->UpdateAssociatedKeywords(&result); 353 controller_->UpdateAssociatedKeywords(&result);
280 354
281 for (size_t j = 0; j < result.size(); ++j) { 355 for (size_t j = 0; j < result.size(); ++j) {
282 EXPECT_EQ(match_data[j].expected_keyword_result, 356 EXPECT_EQ(match_data[j].expected_keyword_result,
283 result.match_at(j).associated_keyword.get() != NULL); 357 result.match_at(j)->associated_keyword.get() != NULL);
284 } 358 }
285 } 359 }
286 360
361 void AutocompleteProviderTest::RunAssistedQueryStatsTest(
362 const AssistedQueryStatsTestData* aqs_test_data,
363 size_t size) {
364 // Prepare input.
365 const size_t kMaxRelevance = 1000;
366 ACMatches matches;
367 for (size_t i = 0; i < size; ++i) {
368 AutocompleteMatch match(NULL, kMaxRelevance - i, false,
369 aqs_test_data[i].match_type);
370 match.keyword = ASCIIToUTF16(kTestTemplateURLKeyword);
371 match.search_terms_args.reset(
372 new TemplateURLRef::SearchTermsArgs(string16()));
373 matches.push_back(match);
374 }
375 result_.Reset();
376 result_.AppendMatches(matches);
377
378 // Update AQS.
379 controller_->UpdateAssistedQueryStats(&result_);
380
381 // Verify data.
382 for (size_t i = 0; i < size; ++i) {
383 EXPECT_EQ(aqs_test_data[i].expected_aqs,
384 result_.match_at(i)->search_terms_args->assisted_query_stats);
385 }
386 }
287 387
288 void AutocompleteProviderTest::RunQuery(const string16 query) { 388 void AutocompleteProviderTest::RunQuery(const string16 query) {
289 result_.Reset(); 389 result_.Reset();
290 controller_->Start(query, string16(), true, false, true, 390 controller_->Start(query, string16(), true, false, true,
291 AutocompleteInput::ALL_MATCHES); 391 AutocompleteInput::ALL_MATCHES);
292 392
293 if (!controller_->done()) 393 if (!controller_->done())
294 // The message loop will terminate when all autocomplete input has been 394 // The message loop will terminate when all autocomplete input has been
295 // collected. 395 // collected.
296 MessageLoop::current()->Run(); 396 MessageLoop::current()->Run();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ResetControllerWithTestProviders(false); 428 ResetControllerWithTestProviders(false);
329 RunTest(); 429 RunTest();
330 430
331 // Make sure the default match gets set to the highest relevance match. The 431 // Make sure the default match gets set to the highest relevance match. The
332 // highest relevance matches should come from the second provider. 432 // highest relevance matches should come from the second provider.
333 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers 433 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
334 ASSERT_NE(result_.end(), result_.default_match()); 434 ASSERT_NE(result_.end(), result_.default_match());
335 EXPECT_EQ(providers_[1], result_.default_match()->provider); 435 EXPECT_EQ(providers_[1], result_.default_match()->provider);
336 } 436 }
337 437
438 // Tests assisted query stats.
439 TEST_F(AutocompleteProviderTest, AssistedQueryStats) {
440 ResetControllerWithTestProviders(false);
441 RunTest();
442
443 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers
444
445 // Now, check the results from the second provider, as they should not have
446 // assisted query stats set.
447 for (size_t i = 0; i < kResultsPerProvider; ++i) {
448 EXPECT_TRUE(
449 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
450 }
451 // The first provider has a test keyword, so AQS should be non-empty.
452 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) {
453 EXPECT_FALSE(
454 result_.match_at(i)->search_terms_args->assisted_query_stats.empty());
455 }
456 }
457
338 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { 458 TEST_F(AutocompleteProviderTest, RemoveDuplicates) {
339 ResetControllerWithTestProviders(true); 459 ResetControllerWithTestProviders(true);
340 RunTest(); 460 RunTest();
341 461
342 // Make sure all the first provider's results were eliminated by the second 462 // Make sure all the first provider's results were eliminated by the second
343 // provider's. 463 // provider's.
344 EXPECT_EQ(kResultsPerProvider, result_.size()); 464 EXPECT_EQ(kResultsPerProvider, result_.size());
345 for (AutocompleteResult::const_iterator i(result_.begin()); 465 for (AutocompleteResult::const_iterator i(result_.begin());
346 i != result_.end(); ++i) 466 i != result_.end(); ++i)
347 EXPECT_EQ(providers_[1], i->provider); 467 EXPECT_EQ(providers_[1], i->provider);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 { ASCIIToUTF16("foo.com"), string16(), false }, 508 { ASCIIToUTF16("foo.com"), string16(), false },
389 { ASCIIToUTF16("bar.com"), string16(), true }, 509 { ASCIIToUTF16("bar.com"), string16(), true },
390 }; 510 };
391 511
392 SCOPED_TRACE("Duplicate url with multiple keywords"); 512 SCOPED_TRACE("Duplicate url with multiple keywords");
393 RunRedundantKeywordTest(multiple_keyword, 513 RunRedundantKeywordTest(multiple_keyword,
394 ARRAYSIZE_UNSAFE(multiple_keyword)); 514 ARRAYSIZE_UNSAFE(multiple_keyword));
395 } 515 }
396 } 516 }
397 517
518 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) {
519 ResetControllerWithTestProviders(false);
520
521 {
522 AssistedQueryStatsTestData test_data[] = { };
523 SCOPED_TRACE("No matches");
524 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
525 }
526
527 {
528 AssistedQueryStatsTestData test_data[] = {
529 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57" }
530 };
531 SCOPED_TRACE("One match");
532 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
533 }
534
535 {
536 AssistedQueryStatsTestData test_data[] = {
537 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57j58j5l2j0l3j59" },
538 { AutocompleteMatch::URL_WHAT_YOU_TYPED, "chrome.1.57j58j5l2j0l3j59" },
539 { AutocompleteMatch::NAVSUGGEST, "chrome.2.57j58j5l2j0l3j59" },
540 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" },
541 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" },
542 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" },
543 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" },
544 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" },
545 };
546 SCOPED_TRACE("Multiple matches");
547 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data));
548 }
549 }
550
398 typedef testing::Test AutocompleteTest; 551 typedef testing::Test AutocompleteTest;
399 552
400 TEST_F(AutocompleteTest, InputType) { 553 TEST_F(AutocompleteTest, InputType) {
401 struct test_data { 554 struct test_data {
402 const string16 input; 555 const string16 input;
403 const AutocompleteInput::Type type; 556 const AutocompleteInput::Type type;
404 } input_cases[] = { 557 } input_cases[] = {
405 { string16(), AutocompleteInput::INVALID }, 558 { string16(), AutocompleteInput::INVALID },
406 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, 559 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY },
407 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, 560 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY },
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 &scheme, 760 &scheme,
608 &host); 761 &host);
609 AutocompleteInput input(input_cases[i].input, string16(), true, false, 762 AutocompleteInput input(input_cases[i].input, string16(), true, false,
610 true, AutocompleteInput::ALL_MATCHES); 763 true, AutocompleteInput::ALL_MATCHES);
611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); 764 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin);
612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); 765 EXPECT_EQ(input_cases[i].scheme.len, scheme.len);
613 EXPECT_EQ(input_cases[i].host.begin, host.begin); 766 EXPECT_EQ(input_cases[i].host.begin, host.begin);
614 EXPECT_EQ(input_cases[i].host.len, host.len); 767 EXPECT_EQ(input_cases[i].host.len, host.len);
615 } 768 }
616 } 769 }
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