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 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 namespace { | 32 namespace { |
33 const size_t kResultsPerProvider = 3; | 33 const size_t kResultsPerProvider = 3; |
34 } | 34 } |
35 | 35 |
36 // Autocomplete provider that provides known results. Note that this is | 36 // Autocomplete provider that provides known results. Note that this is |
37 // refcounted so that it can also be a task on the message loop. | 37 // refcounted so that it can also be a task on the message loop. |
38 class TestProvider : public AutocompleteProvider { | 38 class TestProvider : public AutocompleteProvider { |
39 public: | 39 public: |
40 TestProvider(int relevance, const string16& prefix) | 40 TestProvider(int relevance, const string16& prefix, |
41 : AutocompleteProvider(NULL, NULL, ""), | 41 Profile* profile, |
| 42 const string16 match_keyword) |
| 43 : AutocompleteProvider(NULL, profile, ""), |
42 relevance_(relevance), | 44 relevance_(relevance), |
43 prefix_(prefix) { | 45 prefix_(prefix), |
| 46 match_keyword_(match_keyword) { |
44 } | 47 } |
45 | 48 |
46 virtual void Start(const AutocompleteInput& input, | 49 virtual void Start(const AutocompleteInput& input, |
47 bool minimal_changes); | 50 bool minimal_changes); |
48 | 51 |
49 void set_listener(ACProviderListener* listener) { | 52 void set_listener(ACProviderListener* listener) { |
50 listener_ = listener; | 53 listener_ = listener; |
51 } | 54 } |
52 | 55 |
53 private: | 56 private: |
54 ~TestProvider() {} | 57 ~TestProvider() {} |
55 | 58 |
56 void Run(); | 59 void Run(); |
57 | 60 |
58 void AddResults(int start_at, int num); | 61 void AddResults(int start_at, int num); |
| 62 void AddResultsWithSearchTermsArgs( |
| 63 int start_at, |
| 64 int num, |
| 65 AutocompleteMatch::Type type, |
| 66 const TemplateURLRef::SearchTermsArgs& search_terms_args); |
59 | 67 |
60 int relevance_; | 68 int relevance_; |
61 const string16 prefix_; | 69 const string16 prefix_; |
| 70 const string16 match_keyword_; |
62 }; | 71 }; |
63 | 72 |
64 void TestProvider::Start(const AutocompleteInput& input, | 73 void TestProvider::Start(const AutocompleteInput& input, |
65 bool minimal_changes) { | 74 bool minimal_changes) { |
66 if (minimal_changes) | 75 if (minimal_changes) |
67 return; | 76 return; |
68 | 77 |
69 matches_.clear(); | 78 matches_.clear(); |
70 | 79 |
71 // Generate one result synchronously, the rest later. | 80 // Generate 4 results synchronously, the rest later. |
72 AddResults(0, 1); | 81 AddResults(0, 1); |
| 82 AddResultsWithSearchTermsArgs( |
| 83 1, 1, AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, |
| 84 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("echo"))); |
| 85 AddResultsWithSearchTermsArgs( |
| 86 2, 1, AutocompleteMatch::NAVSUGGEST, |
| 87 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("nav"))); |
| 88 AddResultsWithSearchTermsArgs( |
| 89 3, 1, AutocompleteMatch::SEARCH_SUGGEST, |
| 90 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("query"))); |
73 | 91 |
74 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { | 92 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { |
75 done_ = false; | 93 done_ = false; |
76 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run, | 94 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run, |
77 this)); | 95 this)); |
78 } | 96 } |
79 } | 97 } |
80 | 98 |
81 void TestProvider::Run() { | 99 void TestProvider::Run() { |
82 DCHECK_GT(kResultsPerProvider, 0U); | 100 DCHECK_GT(kResultsPerProvider, 0U); |
83 AddResults(1, kResultsPerProvider); | 101 AddResults(1, kResultsPerProvider); |
84 done_ = true; | 102 done_ = true; |
85 DCHECK(listener_); | 103 DCHECK(listener_); |
86 listener_->OnProviderUpdate(true); | 104 listener_->OnProviderUpdate(true); |
87 } | 105 } |
88 | 106 |
89 void TestProvider::AddResults(int start_at, int num) { | 107 void TestProvider::AddResults(int start_at, int num) { |
| 108 AddResultsWithSearchTermsArgs(start_at, |
| 109 num, |
| 110 AutocompleteMatch::URL_WHAT_YOU_TYPED, |
| 111 TemplateURLRef::SearchTermsArgs(string16())); |
| 112 } |
| 113 |
| 114 void TestProvider::AddResultsWithSearchTermsArgs( |
| 115 int start_at, |
| 116 int num, |
| 117 AutocompleteMatch::Type type, |
| 118 const TemplateURLRef::SearchTermsArgs& search_terms_args) { |
90 for (int i = start_at; i < num; i++) { | 119 for (int i = start_at; i < num; i++) { |
91 AutocompleteMatch match(this, relevance_ - i, false, | 120 AutocompleteMatch match(this, relevance_ - i, false, type); |
92 AutocompleteMatch::URL_WHAT_YOU_TYPED); | |
93 | 121 |
94 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); | 122 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); |
95 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); | 123 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); |
96 | 124 |
97 match.contents = match.fill_into_edit; | 125 match.contents = match.fill_into_edit; |
98 match.contents_class.push_back( | 126 match.contents_class.push_back( |
99 ACMatchClassification(0, ACMatchClassification::NONE)); | 127 ACMatchClassification(0, ACMatchClassification::NONE)); |
100 match.description = match.fill_into_edit; | 128 match.description = match.fill_into_edit; |
101 match.description_class.push_back( | 129 match.description_class.push_back( |
102 ACMatchClassification(0, ACMatchClassification::NONE)); | 130 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 131 match.search_terms_args.reset( |
| 132 new TemplateURLRef::SearchTermsArgs(search_terms_args)); |
| 133 if (!match_keyword_.empty()) { |
| 134 match.keyword = match_keyword_; |
| 135 ASSERT_TRUE(match.GetTemplateURL(profile_) != NULL); |
| 136 } |
103 | 137 |
104 matches_.push_back(match); | 138 matches_.push_back(match); |
105 } | 139 } |
106 } | 140 } |
107 | 141 |
108 class AutocompleteProviderTest : public testing::Test, | 142 class AutocompleteProviderTest : public testing::Test, |
109 public content::NotificationObserver { | 143 public content::NotificationObserver { |
110 protected: | 144 protected: |
111 struct KeywordTestData { | 145 struct KeywordTestData { |
112 const string16 fill_into_edit; | 146 const string16 fill_into_edit; |
113 const string16 keyword; | 147 const string16 keyword; |
114 const bool expected_keyword_result; | 148 const bool expected_keyword_result; |
115 }; | 149 }; |
116 | 150 |
| 151 struct AssistedQueryStatsTestData { |
| 152 const AutocompleteMatch::Type match_type; |
| 153 const std::string expected_aqs; |
| 154 }; |
| 155 |
117 protected: | 156 protected: |
118 void ResetControllerWithTestProviders(bool same_destinations); | 157 void ResetControllerWithTestProviders(bool same_destinations); |
119 | 158 |
120 // Runs a query on the input "a", and makes sure both providers' input is | 159 // Runs a query on the input "a", and makes sure both providers' input is |
121 // properly collected. | 160 // properly collected. |
122 void RunTest(); | 161 void RunTest(); |
123 | 162 |
124 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); | 163 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); |
125 | 164 |
| 165 void RunAssistedQueryStatsTest( |
| 166 const AssistedQueryStatsTestData* aqs_test_data, |
| 167 size_t size); |
| 168 |
126 void RunQuery(const string16 query); | 169 void RunQuery(const string16 query); |
127 | 170 |
128 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); | 171 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); |
129 void ResetControllerWithKeywordProvider(); | 172 void ResetControllerWithKeywordProvider(); |
130 void RunExactKeymatchTest(bool allow_exact_keyword_match); | 173 void RunExactKeymatchTest(bool allow_exact_keyword_match); |
131 | 174 |
132 // These providers are owned by the controller once it's created. | 175 // These providers are owned by the controller once it's created. |
133 ACProviders providers_; | 176 ACProviders providers_; |
134 | 177 |
135 AutocompleteResult result_; | 178 AutocompleteResult result_; |
136 scoped_ptr<AutocompleteController> controller_; | 179 scoped_ptr<AutocompleteController> controller_; |
137 | 180 |
138 private: | 181 private: |
139 // content::NotificationObserver | 182 // content::NotificationObserver |
140 virtual void Observe(int type, | 183 virtual void Observe(int type, |
141 const content::NotificationSource& source, | 184 const content::NotificationSource& source, |
142 const content::NotificationDetails& details); | 185 const content::NotificationDetails& details); |
143 | 186 |
144 MessageLoopForUI message_loop_; | 187 MessageLoopForUI message_loop_; |
145 content::NotificationRegistrar registrar_; | 188 content::NotificationRegistrar registrar_; |
146 TestingProfile profile_; | 189 TestingProfile profile_; |
147 }; | 190 }; |
148 | 191 |
149 void AutocompleteProviderTest::ResetControllerWithTestProviders( | 192 void AutocompleteProviderTest::ResetControllerWithTestProviders( |
150 bool same_destinations) { | 193 bool same_destinations) { |
151 // Forget about any existing providers. The controller owns them and will | 194 // Forget about any existing providers. The controller owns them and will |
152 // Release() them below, when we delete it during the call to reset(). | 195 // Release() them below, when we delete it during the call to reset(). |
153 providers_.clear(); | 196 providers_.clear(); |
154 | 197 |
| 198 // Register a TemplateURL for test keyword "t". |
| 199 const string16 test_keyword(ASCIIToUTF16("t")); |
| 200 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 201 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
| 202 TemplateURLData data; |
| 203 data.SetURL("http://aqs/{searchTerms}/{google:assistedQueryStats}"); |
| 204 data.SetKeyword(test_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 |
155 // Construct two new providers, with either the same or different prefixes. | 213 // Construct two new providers, with either the same or different prefixes. |
156 TestProvider* providerA = new TestProvider(kResultsPerProvider, | 214 TestProvider* providerA = new TestProvider(kResultsPerProvider, |
157 ASCIIToUTF16("http://a")); | 215 ASCIIToUTF16("http://a"), |
| 216 &profile_, |
| 217 test_keyword); |
158 providerA->AddRef(); | 218 providerA->AddRef(); |
159 providers_.push_back(providerA); | 219 providers_.push_back(providerA); |
160 | 220 |
161 TestProvider* providerB = new TestProvider(kResultsPerProvider * 2, | 221 TestProvider* providerB = new TestProvider( |
162 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); | 222 kResultsPerProvider * 2, |
| 223 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), |
| 224 &profile_, |
| 225 string16()); |
163 providerB->AddRef(); | 226 providerB->AddRef(); |
164 providers_.push_back(providerB); | 227 providers_.push_back(providerB); |
165 | 228 |
166 // Reset the controller to contain our new providers. | 229 // Reset the controller to contain our new providers. |
167 AutocompleteController* controller = | 230 AutocompleteController* controller = |
168 new AutocompleteController(providers_, &profile_); | 231 new AutocompleteController(providers_, &profile_); |
169 controller_.reset(controller); | 232 controller_.reset(controller); |
170 providerA->set_listener(controller); | 233 providerA->set_listener(controller); |
171 providerB->set_listener(controller); | 234 providerB->set_listener(controller); |
172 | 235 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); | 273 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); |
211 keyword_provider->AddRef(); | 274 keyword_provider->AddRef(); |
212 providers_.push_back(keyword_provider); | 275 providers_.push_back(keyword_provider); |
213 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); | 276 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); |
214 search_provider->AddRef(); | 277 search_provider->AddRef(); |
215 providers_.push_back(search_provider); | 278 providers_.push_back(search_provider); |
216 | 279 |
217 controller_.reset(new AutocompleteController(providers_, &profile_)); | 280 controller_.reset(new AutocompleteController(providers_, &profile_)); |
218 } | 281 } |
219 | 282 |
220 void AutocompleteProviderTest:: | 283 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { |
221 ResetControllerWithKeywordProvider() { | |
222 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 284 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
223 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 285 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
224 | 286 |
225 TemplateURLService* turl_model = | 287 TemplateURLService* turl_model = |
226 TemplateURLServiceFactory::GetForProfile(&profile_); | 288 TemplateURLServiceFactory::GetForProfile(&profile_); |
227 | 289 |
228 // Create a TemplateURL for KeywordProvider. | 290 // Create a TemplateURL for KeywordProvider. |
229 TemplateURLData data; | 291 TemplateURLData data; |
230 data.short_name = ASCIIToUTF16("foo.com"); | 292 data.short_name = ASCIIToUTF16("foo.com"); |
231 data.SetKeyword(ASCIIToUTF16("foo.com")); | 293 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; | 335 match.keyword = match_data[i].keyword; |
274 matches.push_back(match); | 336 matches.push_back(match); |
275 } | 337 } |
276 | 338 |
277 AutocompleteResult result; | 339 AutocompleteResult result; |
278 result.AppendMatches(matches); | 340 result.AppendMatches(matches); |
279 controller_->UpdateAssociatedKeywords(&result); | 341 controller_->UpdateAssociatedKeywords(&result); |
280 | 342 |
281 for (size_t j = 0; j < result.size(); ++j) { | 343 for (size_t j = 0; j < result.size(); ++j) { |
282 EXPECT_EQ(match_data[j].expected_keyword_result, | 344 EXPECT_EQ(match_data[j].expected_keyword_result, |
283 result.match_at(j).associated_keyword.get() != NULL); | 345 result.match_at(j)->associated_keyword.get() != NULL); |
284 } | 346 } |
285 } | 347 } |
286 | 348 |
| 349 void AutocompleteProviderTest::RunAssistedQueryStatsTest( |
| 350 const AssistedQueryStatsTestData* aqs_test_data, |
| 351 size_t size) { |
| 352 // Prepare input. |
| 353 const size_t kMaxRelevance = 1000; |
| 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 |