OLD | NEW |
---|---|
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 Loading... | |
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 size_t kMaxRelevance = 1000; | |
Peter Kasting
2012/06/18 20:49:50
Nit: Since we only use this one place, just define
Bart N
2012/06/18 21:20:52
Done.
| |
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: |
118 void ResetControllerWithTestProviders(bool same_destinations); | 158 void ResetControllerWithTestProviders(bool same_destinations); |
119 | 159 |
120 // Runs a query on the input "a", and makes sure both providers' input is | 160 // Runs a query on the input "a", and makes sure both providers' input is |
121 // properly collected. | 161 // properly collected. |
122 void RunTest(); | 162 void RunTest(); |
123 | 163 |
124 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); | 164 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); |
125 | 165 |
166 void RunAssistedQueryStatsTest( | |
167 const AssistedQueryStatsTestData* aqs_test_data, | |
168 size_t size); | |
169 | |
126 void RunQuery(const string16 query); | 170 void RunQuery(const string16 query); |
127 | 171 |
128 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); | 172 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); |
129 void ResetControllerWithKeywordProvider(); | 173 void ResetControllerWithKeywordProvider(); |
130 void RunExactKeymatchTest(bool allow_exact_keyword_match); | 174 void RunExactKeymatchTest(bool allow_exact_keyword_match); |
131 | 175 |
132 // These providers are owned by the controller once it's created. | 176 // These providers are owned by the controller once it's created. |
133 ACProviders providers_; | 177 ACProviders providers_; |
134 | 178 |
135 AutocompleteResult result_; | 179 AutocompleteResult result_; |
136 scoped_ptr<AutocompleteController> controller_; | 180 scoped_ptr<AutocompleteController> controller_; |
137 | 181 |
138 private: | 182 private: |
139 // content::NotificationObserver | 183 // content::NotificationObserver |
140 virtual void Observe(int type, | 184 virtual void Observe(int type, |
141 const content::NotificationSource& source, | 185 const content::NotificationSource& source, |
142 const content::NotificationDetails& details); | 186 const content::NotificationDetails& details); |
143 | 187 |
144 MessageLoopForUI message_loop_; | 188 MessageLoopForUI message_loop_; |
145 content::NotificationRegistrar registrar_; | 189 content::NotificationRegistrar registrar_; |
146 TestingProfile profile_; | 190 TestingProfile profile_; |
147 }; | 191 }; |
148 | 192 |
149 void AutocompleteProviderTest::ResetControllerWithTestProviders( | 193 void AutocompleteProviderTest::ResetControllerWithTestProviders( |
150 bool same_destinations) { | 194 bool same_destinations) { |
151 // Forget about any existing providers. The controller owns them and will | 195 // Forget about any existing providers. The controller owns them and will |
152 // Release() them below, when we delete it during the call to reset(). | 196 // Release() them below, when we delete it during the call to reset(). |
153 providers_.clear(); | 197 providers_.clear(); |
154 | 198 |
199 // Register a TemplateURL for test keyword "t". | |
200 const string16 test_keyword(ASCIIToUTF16("t")); | |
201 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
202 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | |
203 TemplateURLData data; | |
204 data.SetURL("http://aqs/{searchTerms}/{google:assistedQueryStats}"); | |
205 data.SetKeyword(test_keyword); | |
206 TemplateURL* default_t_url = new TemplateURL(&profile_, data); | |
207 TemplateURLService* turl_model = | |
208 TemplateURLServiceFactory::GetForProfile(&profile_); | |
209 turl_model->Add(default_t_url); | |
210 turl_model->SetDefaultSearchProvider(default_t_url); | |
211 TemplateURLID default_provider_id = default_t_url->id(); | |
212 ASSERT_NE(0, default_provider_id); | |
213 | |
155 // Construct two new providers, with either the same or different prefixes. | 214 // Construct two new providers, with either the same or different prefixes. |
156 TestProvider* providerA = new TestProvider(kResultsPerProvider, | 215 TestProvider* providerA = new TestProvider(kResultsPerProvider, |
157 ASCIIToUTF16("http://a")); | 216 ASCIIToUTF16("http://a"), |
217 &profile_, | |
218 test_keyword); | |
158 providerA->AddRef(); | 219 providerA->AddRef(); |
159 providers_.push_back(providerA); | 220 providers_.push_back(providerA); |
160 | 221 |
161 TestProvider* providerB = new TestProvider(kResultsPerProvider * 2, | 222 TestProvider* providerB = new TestProvider( |
162 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); | 223 kResultsPerProvider * 2, |
224 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), | |
225 &profile_, | |
226 string16()); | |
163 providerB->AddRef(); | 227 providerB->AddRef(); |
164 providers_.push_back(providerB); | 228 providers_.push_back(providerB); |
165 | 229 |
166 // Reset the controller to contain our new providers. | 230 // Reset the controller to contain our new providers. |
167 AutocompleteController* controller = | 231 AutocompleteController* controller = |
168 new AutocompleteController(providers_, &profile_); | 232 new AutocompleteController(providers_, &profile_); |
169 controller_.reset(controller); | 233 controller_.reset(controller); |
170 providerA->set_listener(controller); | 234 providerA->set_listener(controller); |
171 providerB->set_listener(controller); | 235 providerB->set_listener(controller); |
172 | 236 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); | 274 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); |
211 keyword_provider->AddRef(); | 275 keyword_provider->AddRef(); |
212 providers_.push_back(keyword_provider); | 276 providers_.push_back(keyword_provider); |
213 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); | 277 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); |
214 search_provider->AddRef(); | 278 search_provider->AddRef(); |
215 providers_.push_back(search_provider); | 279 providers_.push_back(search_provider); |
216 | 280 |
217 controller_.reset(new AutocompleteController(providers_, &profile_)); | 281 controller_.reset(new AutocompleteController(providers_, &profile_)); |
218 } | 282 } |
219 | 283 |
220 void AutocompleteProviderTest:: | 284 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { |
221 ResetControllerWithKeywordProvider() { | |
222 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 285 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
223 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 286 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
224 | 287 |
225 TemplateURLService* turl_model = | 288 TemplateURLService* turl_model = |
226 TemplateURLServiceFactory::GetForProfile(&profile_); | 289 TemplateURLServiceFactory::GetForProfile(&profile_); |
227 | 290 |
228 // Create a TemplateURL for KeywordProvider. | 291 // Create a TemplateURL for KeywordProvider. |
229 TemplateURLData data; | 292 TemplateURLData data; |
230 data.short_name = ASCIIToUTF16("foo.com"); | 293 data.short_name = ASCIIToUTF16("foo.com"); |
231 data.SetKeyword(ASCIIToUTF16("foo.com")); | 294 data.SetKeyword(ASCIIToUTF16("foo.com")); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 match.keyword = match_data[i].keyword; | 336 match.keyword = match_data[i].keyword; |
274 matches.push_back(match); | 337 matches.push_back(match); |
275 } | 338 } |
276 | 339 |
277 AutocompleteResult result; | 340 AutocompleteResult result; |
278 result.AppendMatches(matches); | 341 result.AppendMatches(matches); |
279 controller_->UpdateAssociatedKeywords(&result); | 342 controller_->UpdateAssociatedKeywords(&result); |
280 | 343 |
281 for (size_t j = 0; j < result.size(); ++j) { | 344 for (size_t j = 0; j < result.size(); ++j) { |
282 EXPECT_EQ(match_data[j].expected_keyword_result, | 345 EXPECT_EQ(match_data[j].expected_keyword_result, |
283 result.match_at(j).associated_keyword.get() != NULL); | 346 result.match_at(j)->associated_keyword.get() != NULL); |
284 } | 347 } |
285 } | 348 } |
286 | 349 |
350 void AutocompleteProviderTest::RunAssistedQueryStatsTest( | |
351 const AssistedQueryStatsTestData* aqs_test_data, | |
352 size_t size) { | |
353 // Prepare input. | |
354 ACMatches matches; | |
355 for (size_t i = 0; i < size; ++i) { | |
356 AutocompleteMatch match(NULL, kMaxRelevance - i, false, | |
357 aqs_test_data[i].match_type); | |
358 match.keyword = ASCIIToUTF16("t"); | |
359 match.search_terms_args.reset( | |
360 new TemplateURLRef::SearchTermsArgs(string16())); | |
361 matches.push_back(match); | |
362 } | |
363 result_.Reset(); | |
364 result_.AppendMatches(matches); | |
365 | |
366 // Update AQS. | |
367 controller_->UpdateAssistedQueryStats(&result_); | |
368 | |
369 // Verify data. | |
370 for (size_t i = 0; i < size; ++i) { | |
371 EXPECT_EQ(aqs_test_data[i].expected_aqs, | |
372 result_.match_at(i)->search_terms_args->assisted_query_stats); | |
373 } | |
374 } | |
287 | 375 |
288 void AutocompleteProviderTest::RunQuery(const string16 query) { | 376 void AutocompleteProviderTest::RunQuery(const string16 query) { |
289 result_.Reset(); | 377 result_.Reset(); |
290 controller_->Start(query, string16(), true, false, true, | 378 controller_->Start(query, string16(), true, false, true, |
291 AutocompleteInput::ALL_MATCHES); | 379 AutocompleteInput::ALL_MATCHES); |
292 | 380 |
293 if (!controller_->done()) | 381 if (!controller_->done()) |
294 // The message loop will terminate when all autocomplete input has been | 382 // The message loop will terminate when all autocomplete input has been |
295 // collected. | 383 // collected. |
296 MessageLoop::current()->Run(); | 384 MessageLoop::current()->Run(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
328 ResetControllerWithTestProviders(false); | 416 ResetControllerWithTestProviders(false); |
329 RunTest(); | 417 RunTest(); |
330 | 418 |
331 // Make sure the default match gets set to the highest relevance match. The | 419 // Make sure the default match gets set to the highest relevance match. The |
332 // highest relevance matches should come from the second provider. | 420 // highest relevance matches should come from the second provider. |
333 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers | 421 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers |
334 ASSERT_NE(result_.end(), result_.default_match()); | 422 ASSERT_NE(result_.end(), result_.default_match()); |
335 EXPECT_EQ(providers_[1], result_.default_match()->provider); | 423 EXPECT_EQ(providers_[1], result_.default_match()->provider); |
336 } | 424 } |
337 | 425 |
426 // Tests assisted query stats. | |
427 TEST_F(AutocompleteProviderTest, AssistedQueryStats) { | |
428 ResetControllerWithTestProviders(false); | |
429 RunTest(); | |
430 | |
431 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers | |
432 | |
433 // Now, check the results from the second provider, as they should not have | |
434 // assisted query stats set. | |
435 for (size_t i = 0; i < kResultsPerProvider; ++i) { | |
436 EXPECT_TRUE( | |
437 result_.match_at(i)->search_terms_args->assisted_query_stats.empty()); | |
438 } | |
439 // The first provider has a test keyword, so AQS should be non-empty. | |
440 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) { | |
441 EXPECT_FALSE( | |
442 result_.match_at(i)->search_terms_args->assisted_query_stats.empty()); | |
443 } | |
444 } | |
445 | |
338 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { | 446 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { |
339 ResetControllerWithTestProviders(true); | 447 ResetControllerWithTestProviders(true); |
340 RunTest(); | 448 RunTest(); |
341 | 449 |
342 // Make sure all the first provider's results were eliminated by the second | 450 // Make sure all the first provider's results were eliminated by the second |
343 // provider's. | 451 // provider's. |
344 EXPECT_EQ(kResultsPerProvider, result_.size()); | 452 EXPECT_EQ(kResultsPerProvider, result_.size()); |
345 for (AutocompleteResult::const_iterator i(result_.begin()); | 453 for (AutocompleteResult::const_iterator i(result_.begin()); |
346 i != result_.end(); ++i) | 454 i != result_.end(); ++i) |
347 EXPECT_EQ(providers_[1], i->provider); | 455 EXPECT_EQ(providers_[1], i->provider); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 { ASCIIToUTF16("foo.com"), string16(), false }, | 496 { ASCIIToUTF16("foo.com"), string16(), false }, |
389 { ASCIIToUTF16("bar.com"), string16(), true }, | 497 { ASCIIToUTF16("bar.com"), string16(), true }, |
390 }; | 498 }; |
391 | 499 |
392 SCOPED_TRACE("Duplicate url with multiple keywords"); | 500 SCOPED_TRACE("Duplicate url with multiple keywords"); |
393 RunRedundantKeywordTest(multiple_keyword, | 501 RunRedundantKeywordTest(multiple_keyword, |
394 ARRAYSIZE_UNSAFE(multiple_keyword)); | 502 ARRAYSIZE_UNSAFE(multiple_keyword)); |
395 } | 503 } |
396 } | 504 } |
397 | 505 |
506 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { | |
507 ResetControllerWithTestProviders(false); | |
508 | |
509 { | |
510 AssistedQueryStatsTestData test_data[] = { }; | |
511 SCOPED_TRACE("No matches"); | |
512 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
513 } | |
514 | |
515 { | |
516 AssistedQueryStatsTestData test_data[] = { | |
517 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57" } | |
518 }; | |
519 SCOPED_TRACE("One match"); | |
520 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
521 } | |
522 | |
523 { | |
524 AssistedQueryStatsTestData test_data[] = { | |
525 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57j58j5l2j0l3j59" }, | |
526 { AutocompleteMatch::URL_WHAT_YOU_TYPED, "chrome.1.57j58j5l2j0l3j59" }, | |
527 { AutocompleteMatch::NAVSUGGEST, "chrome.2.57j58j5l2j0l3j59" }, | |
528 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, | |
529 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, | |
530 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, | |
531 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, | |
532 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, | |
533 }; | |
534 SCOPED_TRACE("Multiple matches"); | |
535 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
536 } | |
537 } | |
538 | |
398 typedef testing::Test AutocompleteTest; | 539 typedef testing::Test AutocompleteTest; |
399 | 540 |
400 TEST_F(AutocompleteTest, InputType) { | 541 TEST_F(AutocompleteTest, InputType) { |
401 struct test_data { | 542 struct test_data { |
402 const string16 input; | 543 const string16 input; |
403 const AutocompleteInput::Type type; | 544 const AutocompleteInput::Type type; |
404 } input_cases[] = { | 545 } input_cases[] = { |
405 { string16(), AutocompleteInput::INVALID }, | 546 { string16(), AutocompleteInput::INVALID }, |
406 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, | 547 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, |
407 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, | 548 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 &scheme, | 748 &scheme, |
608 &host); | 749 &host); |
609 AutocompleteInput input(input_cases[i].input, string16(), true, false, | 750 AutocompleteInput input(input_cases[i].input, string16(), true, false, |
610 true, AutocompleteInput::ALL_MATCHES); | 751 true, AutocompleteInput::ALL_MATCHES); |
611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); | 752 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); |
612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); | 753 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); |
613 EXPECT_EQ(input_cases[i].host.begin, host.begin); | 754 EXPECT_EQ(input_cases[i].host.begin, host.begin); |
614 EXPECT_EQ(input_cases[i].host.len, host.len); | 755 EXPECT_EQ(input_cases[i].host.len, host.len); |
615 } | 756 } |
616 } | 757 } |
OLD | NEW |