Chromium Code Reviews| 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, Profile* profile, |
| 41 : AutocompleteProvider(NULL, NULL, ""), | 41 const string16 match_keyword) |
|
Peter Kasting
2012/06/18 19:45:52
Nit: One arg per line
Bart N
2012/06/18 20:34:18
Done.
| |
| 42 : AutocompleteProvider(NULL, profile, ""), | |
| 42 relevance_(relevance), | 43 relevance_(relevance), |
| 43 prefix_(prefix) { | 44 prefix_(prefix), |
| 45 match_keyword_(match_keyword) { | |
| 44 } | 46 } |
| 45 | 47 |
| 46 virtual void Start(const AutocompleteInput& input, | 48 virtual void Start(const AutocompleteInput& input, |
| 47 bool minimal_changes); | 49 bool minimal_changes); |
| 48 | 50 |
| 49 void set_listener(ACProviderListener* listener) { | 51 void set_listener(ACProviderListener* listener) { |
| 50 listener_ = listener; | 52 listener_ = listener; |
| 51 } | 53 } |
| 52 | 54 |
| 53 private: | 55 private: |
| 54 ~TestProvider() {} | 56 ~TestProvider() {} |
| 55 | 57 |
| 56 void Run(); | 58 void Run(); |
| 57 | 59 |
| 58 void AddResults(int start_at, int num); | 60 void AddResults(int start_at, int num); |
| 61 void AddResultsWithSearchTermsArgs( | |
| 62 int start_at, | |
| 63 int num, | |
| 64 AutocompleteMatch::Type type, | |
| 65 const TemplateURLRef::SearchTermsArgs& search_terms_args); | |
| 59 | 66 |
| 60 int relevance_; | 67 int relevance_; |
| 61 const string16 prefix_; | 68 const string16 prefix_; |
| 69 const string16 match_keyword_; | |
| 62 }; | 70 }; |
| 63 | 71 |
| 64 void TestProvider::Start(const AutocompleteInput& input, | 72 void TestProvider::Start(const AutocompleteInput& input, |
| 65 bool minimal_changes) { | 73 bool minimal_changes) { |
| 66 if (minimal_changes) | 74 if (minimal_changes) |
| 67 return; | 75 return; |
| 68 | 76 |
| 69 matches_.clear(); | 77 matches_.clear(); |
| 70 | 78 |
| 71 // Generate one result synchronously, the rest later. | 79 // Generate one result synchronously, the rest later. |
|
Peter Kasting
2012/06/18 19:45:52
This comment is now wrong?
Bart N
2012/06/18 20:34:18
Done.
| |
| 72 AddResults(0, 1); | 80 AddResults(0, 1); |
| 81 AddResultsWithSearchTermsArgs( | |
| 82 1, 1, AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, | |
| 83 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("echo"))); | |
| 84 AddResultsWithSearchTermsArgs( | |
| 85 2, 1, AutocompleteMatch::NAVSUGGEST, | |
| 86 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("nav"))); | |
| 87 AddResultsWithSearchTermsArgs( | |
| 88 3, 1, AutocompleteMatch::SEARCH_SUGGEST, | |
| 89 TemplateURLRef::SearchTermsArgs(ASCIIToUTF16("query"))); | |
| 73 | 90 |
| 74 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { | 91 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { |
| 75 done_ = false; | 92 done_ = false; |
| 76 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run, | 93 MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&TestProvider::Run, |
| 77 this)); | 94 this)); |
| 78 } | 95 } |
| 79 } | 96 } |
| 80 | 97 |
| 81 void TestProvider::Run() { | 98 void TestProvider::Run() { |
| 82 DCHECK_GT(kResultsPerProvider, 0U); | 99 DCHECK_GT(kResultsPerProvider, 0U); |
| 83 AddResults(1, kResultsPerProvider); | 100 AddResults(1, kResultsPerProvider); |
| 84 done_ = true; | 101 done_ = true; |
| 85 DCHECK(listener_); | 102 DCHECK(listener_); |
| 86 listener_->OnProviderUpdate(true); | 103 listener_->OnProviderUpdate(true); |
| 87 } | 104 } |
| 88 | 105 |
| 89 void TestProvider::AddResults(int start_at, int num) { | 106 void TestProvider::AddResults(int start_at, int num) { |
| 107 AddResultsWithSearchTermsArgs(start_at, | |
| 108 num, | |
| 109 AutocompleteMatch::URL_WHAT_YOU_TYPED, | |
| 110 TemplateURLRef::SearchTermsArgs(string16())); | |
| 111 } | |
| 112 | |
| 113 void TestProvider::AddResultsWithSearchTermsArgs( | |
| 114 int start_at, | |
| 115 int num, | |
| 116 AutocompleteMatch::Type type, | |
| 117 const TemplateURLRef::SearchTermsArgs& search_terms_args) { | |
| 90 for (int i = start_at; i < num; i++) { | 118 for (int i = start_at; i < num; i++) { |
| 91 AutocompleteMatch match(this, relevance_ - i, false, | 119 AutocompleteMatch match(this, relevance_ - i, false, type); |
| 92 AutocompleteMatch::URL_WHAT_YOU_TYPED); | |
| 93 | 120 |
| 94 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); | 121 match.fill_into_edit = prefix_ + UTF8ToUTF16(base::IntToString(i)); |
| 95 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); | 122 match.destination_url = GURL(UTF16ToUTF8(match.fill_into_edit)); |
| 96 | 123 |
| 97 match.contents = match.fill_into_edit; | 124 match.contents = match.fill_into_edit; |
| 98 match.contents_class.push_back( | 125 match.contents_class.push_back( |
| 99 ACMatchClassification(0, ACMatchClassification::NONE)); | 126 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 100 match.description = match.fill_into_edit; | 127 match.description = match.fill_into_edit; |
| 101 match.description_class.push_back( | 128 match.description_class.push_back( |
| 102 ACMatchClassification(0, ACMatchClassification::NONE)); | 129 ACMatchClassification(0, ACMatchClassification::NONE)); |
| 130 match.search_terms_args.reset( | |
| 131 new TemplateURLRef::SearchTermsArgs(search_terms_args)); | |
| 132 if (!match_keyword_.empty()) { | |
| 133 match.keyword = match_keyword_; | |
| 134 ASSERT_TRUE(match.GetTemplateURL(profile_) != NULL); | |
| 135 } | |
| 103 | 136 |
| 104 matches_.push_back(match); | 137 matches_.push_back(match); |
| 105 } | 138 } |
| 106 } | 139 } |
| 107 | 140 |
| 108 class AutocompleteProviderTest : public testing::Test, | 141 class AutocompleteProviderTest : public testing::Test, |
| 109 public content::NotificationObserver { | 142 public content::NotificationObserver { |
| 110 protected: | 143 protected: |
| 111 struct KeywordTestData { | 144 struct KeywordTestData { |
| 112 const string16 fill_into_edit; | 145 const string16 fill_into_edit; |
| 113 const string16 keyword; | 146 const string16 keyword; |
| 114 const bool expected_keyword_result; | 147 const bool expected_keyword_result; |
| 115 }; | 148 }; |
| 116 | 149 |
| 150 struct AssistedQueryStatsTestData { | |
| 151 const AutocompleteMatch::Type match_type; | |
| 152 const std::string expected_aqs; | |
| 153 }; | |
| 154 | |
| 117 protected: | 155 protected: |
| 118 void ResetControllerWithTestProviders(bool same_destinations); | 156 void ResetControllerWithTestProviders(bool same_destinations); |
| 119 | 157 |
| 120 // Runs a query on the input "a", and makes sure both providers' input is | 158 // Runs a query on the input "a", and makes sure both providers' input is |
| 121 // properly collected. | 159 // properly collected. |
| 122 void RunTest(); | 160 void RunTest(); |
| 123 | 161 |
| 124 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); | 162 void RunRedundantKeywordTest(const KeywordTestData* match_data, size_t size); |
| 125 | 163 |
| 164 void RunAssistedQueryStatsTest( | |
| 165 const AssistedQueryStatsTestData* aqs_test_data, | |
| 166 size_t size); | |
| 167 | |
| 126 void RunQuery(const string16 query); | 168 void RunQuery(const string16 query); |
| 127 | 169 |
| 128 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); | 170 void ResetControllerWithTestProvidersWithKeywordAndSearchProviders(); |
| 129 void ResetControllerWithKeywordProvider(); | 171 void ResetControllerWithKeywordProvider(); |
| 130 void RunExactKeymatchTest(bool allow_exact_keyword_match); | 172 void RunExactKeymatchTest(bool allow_exact_keyword_match); |
| 131 | 173 |
| 132 // These providers are owned by the controller once it's created. | 174 // These providers are owned by the controller once it's created. |
| 133 ACProviders providers_; | 175 ACProviders providers_; |
| 134 | 176 |
| 135 AutocompleteResult result_; | 177 AutocompleteResult result_; |
| 136 scoped_ptr<AutocompleteController> controller_; | 178 scoped_ptr<AutocompleteController> controller_; |
| 137 | 179 |
| 138 private: | 180 private: |
| 139 // content::NotificationObserver | 181 // content::NotificationObserver |
| 140 virtual void Observe(int type, | 182 virtual void Observe(int type, |
| 141 const content::NotificationSource& source, | 183 const content::NotificationSource& source, |
| 142 const content::NotificationDetails& details); | 184 const content::NotificationDetails& details); |
| 143 | 185 |
| 144 MessageLoopForUI message_loop_; | 186 MessageLoopForUI message_loop_; |
| 145 content::NotificationRegistrar registrar_; | 187 content::NotificationRegistrar registrar_; |
| 146 TestingProfile profile_; | 188 TestingProfile profile_; |
| 147 }; | 189 }; |
| 148 | 190 |
| 149 void AutocompleteProviderTest::ResetControllerWithTestProviders( | 191 void AutocompleteProviderTest::ResetControllerWithTestProviders( |
| 150 bool same_destinations) { | 192 bool same_destinations) { |
| 151 // Forget about any existing providers. The controller owns them and will | 193 // Forget about any existing providers. The controller owns them and will |
| 152 // Release() them below, when we delete it during the call to reset(). | 194 // Release() them below, when we delete it during the call to reset(). |
| 153 providers_.clear(); | 195 providers_.clear(); |
| 154 | 196 |
| 197 // Register a TemplateURL for test keyword "t". | |
|
Peter Kasting
2012/06/18 19:45:52
Can we do this in the UpdateAssistedQueryStats tes
Bart N
2012/06/18 20:34:18
I still wanted a full end-to-end test rather than
Peter Kasting
2012/06/18 20:49:50
Sure, but can't we do that by just moving this set
Bart N
2012/06/18 22:26:24
I tried, but there are some major implications, e.
| |
| 198 const string16 test_keyword(ASCIIToUTF16("t")); | |
| 199 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
| 200 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | |
| 201 TemplateURLData data; | |
| 202 data.SetURL("http://aqs/{searchTerms}/{google:assistedQueryStats}"); | |
| 203 data.SetKeyword(test_keyword); | |
| 204 TemplateURL* default_t_url = new TemplateURL(&profile_, data); | |
| 205 TemplateURLService* turl_model = | |
| 206 TemplateURLServiceFactory::GetForProfile(&profile_); | |
| 207 turl_model->Add(default_t_url); | |
| 208 turl_model->SetDefaultSearchProvider(default_t_url); | |
| 209 TemplateURLID default_provider_id = default_t_url->id(); | |
| 210 ASSERT_NE(0, default_provider_id); | |
| 211 | |
| 155 // Construct two new providers, with either the same or different prefixes. | 212 // Construct two new providers, with either the same or different prefixes. |
| 156 TestProvider* providerA = new TestProvider(kResultsPerProvider, | 213 TestProvider* providerA = new TestProvider(kResultsPerProvider, |
| 157 ASCIIToUTF16("http://a")); | 214 ASCIIToUTF16("http://a"), |
| 215 &profile_, | |
| 216 test_keyword); | |
| 158 providerA->AddRef(); | 217 providerA->AddRef(); |
| 159 providers_.push_back(providerA); | 218 providers_.push_back(providerA); |
| 160 | 219 |
| 161 TestProvider* providerB = new TestProvider(kResultsPerProvider * 2, | 220 TestProvider* providerB = new TestProvider( |
| 162 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b")); | 221 kResultsPerProvider * 2, |
| 222 same_destinations ? ASCIIToUTF16("http://a") : ASCIIToUTF16("http://b"), | |
| 223 &profile_, | |
| 224 string16()); | |
| 163 providerB->AddRef(); | 225 providerB->AddRef(); |
| 164 providers_.push_back(providerB); | 226 providers_.push_back(providerB); |
| 165 | 227 |
| 166 // Reset the controller to contain our new providers. | 228 // Reset the controller to contain our new providers. |
| 167 AutocompleteController* controller = | 229 AutocompleteController* controller = |
| 168 new AutocompleteController(providers_, &profile_); | 230 new AutocompleteController(providers_, &profile_); |
| 169 controller_.reset(controller); | 231 controller_.reset(controller); |
| 170 providerA->set_listener(controller); | 232 providerA->set_listener(controller); |
| 171 providerB->set_listener(controller); | 233 providerB->set_listener(controller); |
| 172 | 234 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); | 272 AutocompleteProvider* keyword_provider = new KeywordProvider(NULL, &profile_); |
| 211 keyword_provider->AddRef(); | 273 keyword_provider->AddRef(); |
| 212 providers_.push_back(keyword_provider); | 274 providers_.push_back(keyword_provider); |
| 213 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); | 275 AutocompleteProvider* search_provider = new SearchProvider(NULL, &profile_); |
| 214 search_provider->AddRef(); | 276 search_provider->AddRef(); |
| 215 providers_.push_back(search_provider); | 277 providers_.push_back(search_provider); |
| 216 | 278 |
| 217 controller_.reset(new AutocompleteController(providers_, &profile_)); | 279 controller_.reset(new AutocompleteController(providers_, &profile_)); |
| 218 } | 280 } |
| 219 | 281 |
| 220 void AutocompleteProviderTest:: | 282 void AutocompleteProviderTest::ResetControllerWithKeywordProvider() { |
| 221 ResetControllerWithKeywordProvider() { | |
| 222 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 283 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
| 223 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); | 284 &profile_, &TemplateURLServiceFactory::BuildInstanceFor); |
| 224 | 285 |
| 225 TemplateURLService* turl_model = | 286 TemplateURLService* turl_model = |
| 226 TemplateURLServiceFactory::GetForProfile(&profile_); | 287 TemplateURLServiceFactory::GetForProfile(&profile_); |
| 227 | 288 |
| 228 // Create a TemplateURL for KeywordProvider. | 289 // Create a TemplateURL for KeywordProvider. |
| 229 TemplateURLData data; | 290 TemplateURLData data; |
| 230 data.short_name = ASCIIToUTF16("foo.com"); | 291 data.short_name = ASCIIToUTF16("foo.com"); |
| 231 data.SetKeyword(ASCIIToUTF16("foo.com")); | 292 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; | 334 match.keyword = match_data[i].keyword; |
| 274 matches.push_back(match); | 335 matches.push_back(match); |
| 275 } | 336 } |
| 276 | 337 |
| 277 AutocompleteResult result; | 338 AutocompleteResult result; |
| 278 result.AppendMatches(matches); | 339 result.AppendMatches(matches); |
| 279 controller_->UpdateAssociatedKeywords(&result); | 340 controller_->UpdateAssociatedKeywords(&result); |
| 280 | 341 |
| 281 for (size_t j = 0; j < result.size(); ++j) { | 342 for (size_t j = 0; j < result.size(); ++j) { |
| 282 EXPECT_EQ(match_data[j].expected_keyword_result, | 343 EXPECT_EQ(match_data[j].expected_keyword_result, |
| 283 result.match_at(j).associated_keyword.get() != NULL); | 344 result.match_at(j)->associated_keyword.get() != NULL); |
| 284 } | 345 } |
| 285 } | 346 } |
| 286 | 347 |
| 348 void AutocompleteProviderTest::RunAssistedQueryStatsTest( | |
| 349 const AssistedQueryStatsTestData* aqs_test_data, | |
| 350 size_t size) { | |
| 351 // Prepare input. | |
| 352 ACMatches matches; | |
| 353 for (size_t i = 0; i < size; ++i) { | |
| 354 AutocompleteMatch match(NULL, -i, false, aqs_test_data[i].match_type); | |
|
Peter Kasting
2012/06/18 19:45:52
Nit: "-i" for a size_t is pretty weird, and risks
Bart N
2012/06/18 20:34:18
Done.
Bart N
2012/06/18 20:34:18
Done.
| |
| 355 match.keyword = ASCIIToUTF16("t"); | |
| 356 match.search_terms_args.reset( | |
| 357 new TemplateURLRef::SearchTermsArgs(string16())); | |
| 358 matches.push_back(match); | |
| 359 } | |
| 360 result_.Reset(); | |
| 361 result_.AppendMatches(matches); | |
| 362 | |
| 363 // Update AQS. | |
| 364 controller_->UpdateAssistedQueryStats(&result_); | |
| 365 | |
| 366 // Verify data. | |
| 367 for (size_t i = 0; i < size; ++i) { | |
| 368 EXPECT_EQ(aqs_test_data[i].expected_aqs, | |
| 369 result_.match_at(i)->search_terms_args->assisted_query_stats); | |
| 370 } | |
| 371 } | |
| 287 | 372 |
| 288 void AutocompleteProviderTest::RunQuery(const string16 query) { | 373 void AutocompleteProviderTest::RunQuery(const string16 query) { |
| 289 result_.Reset(); | 374 result_.Reset(); |
| 290 controller_->Start(query, string16(), true, false, true, | 375 controller_->Start(query, string16(), true, false, true, |
| 291 AutocompleteInput::ALL_MATCHES); | 376 AutocompleteInput::ALL_MATCHES); |
| 292 | 377 |
| 293 if (!controller_->done()) | 378 if (!controller_->done()) |
| 294 // The message loop will terminate when all autocomplete input has been | 379 // The message loop will terminate when all autocomplete input has been |
| 295 // collected. | 380 // collected. |
| 296 MessageLoop::current()->Run(); | 381 MessageLoop::current()->Run(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 ResetControllerWithTestProviders(false); | 413 ResetControllerWithTestProviders(false); |
| 329 RunTest(); | 414 RunTest(); |
| 330 | 415 |
| 331 // Make sure the default match gets set to the highest relevance match. The | 416 // Make sure the default match gets set to the highest relevance match. The |
| 332 // highest relevance matches should come from the second provider. | 417 // highest relevance matches should come from the second provider. |
| 333 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers | 418 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers |
| 334 ASSERT_NE(result_.end(), result_.default_match()); | 419 ASSERT_NE(result_.end(), result_.default_match()); |
| 335 EXPECT_EQ(providers_[1], result_.default_match()->provider); | 420 EXPECT_EQ(providers_[1], result_.default_match()->provider); |
| 336 } | 421 } |
| 337 | 422 |
| 423 // Tests assisted query stats. | |
| 424 TEST_F(AutocompleteProviderTest, AssistedQueryStats) { | |
| 425 ResetControllerWithTestProviders(false); | |
| 426 RunTest(); | |
| 427 | |
| 428 EXPECT_EQ(kResultsPerProvider * 2, result_.size()); // two providers | |
| 429 | |
| 430 // Now, check the results from the second provider, as they should not have | |
| 431 // assisted query stats set. | |
| 432 for (size_t i = 0; i < kResultsPerProvider; ++i) { | |
| 433 EXPECT_TRUE(result_.match_at(i)->search_terms_args->assisted_query_stats | |
|
Peter Kasting
2012/06/18 19:45:52
Nit: Break after '(' instead (2 places)
Bart N
2012/06/18 20:34:18
Done.
| |
| 434 .empty()); | |
| 435 } | |
| 436 // The first provider has a test keyword, so AQS should be non-empty. | |
| 437 for (size_t i = kResultsPerProvider; i < kResultsPerProvider * 2; ++i) { | |
| 438 EXPECT_FALSE(result_.match_at(i)->search_terms_args->assisted_query_stats | |
| 439 .empty()); | |
| 440 } | |
| 441 } | |
| 442 | |
| 338 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { | 443 TEST_F(AutocompleteProviderTest, RemoveDuplicates) { |
| 339 ResetControllerWithTestProviders(true); | 444 ResetControllerWithTestProviders(true); |
| 340 RunTest(); | 445 RunTest(); |
| 341 | 446 |
| 342 // Make sure all the first provider's results were eliminated by the second | 447 // Make sure all the first provider's results were eliminated by the second |
| 343 // provider's. | 448 // provider's. |
| 344 EXPECT_EQ(kResultsPerProvider, result_.size()); | 449 EXPECT_EQ(kResultsPerProvider, result_.size()); |
| 345 for (AutocompleteResult::const_iterator i(result_.begin()); | 450 for (AutocompleteResult::const_iterator i(result_.begin()); |
| 346 i != result_.end(); ++i) | 451 i != result_.end(); ++i) |
| 347 EXPECT_EQ(providers_[1], i->provider); | 452 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 }, | 493 { ASCIIToUTF16("foo.com"), string16(), false }, |
| 389 { ASCIIToUTF16("bar.com"), string16(), true }, | 494 { ASCIIToUTF16("bar.com"), string16(), true }, |
| 390 }; | 495 }; |
| 391 | 496 |
| 392 SCOPED_TRACE("Duplicate url with multiple keywords"); | 497 SCOPED_TRACE("Duplicate url with multiple keywords"); |
| 393 RunRedundantKeywordTest(multiple_keyword, | 498 RunRedundantKeywordTest(multiple_keyword, |
| 394 ARRAYSIZE_UNSAFE(multiple_keyword)); | 499 ARRAYSIZE_UNSAFE(multiple_keyword)); |
| 395 } | 500 } |
| 396 } | 501 } |
| 397 | 502 |
| 503 TEST_F(AutocompleteProviderTest, UpdateAssistedQueryStats) { | |
| 504 ResetControllerWithTestProviders(false); | |
| 505 | |
| 506 { | |
| 507 AssistedQueryStatsTestData test_data[] = { }; | |
| 508 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
|
Peter Kasting
2012/06/18 19:45:52
Nit: I think you can use arraysize() here instead
Peter Kasting
2012/06/18 20:49:50
Was this false or did you miss it?
Bart N
2012/06/18 21:20:52
I missed my reply. Here it goes:
// One caveat is
Peter Kasting
2012/06/18 21:29:21
Huh. I thought AssistedQueryStatsTestData was def
| |
| 509 SCOPED_TRACE("No matches"); | |
|
Peter Kasting
2012/06/18 19:45:52
Nit: Doesn't this need to be above the RunAssisted
Bart N
2012/06/18 20:34:18
Ah yes. Done.
| |
| 510 } | |
| 511 | |
| 512 { | |
| 513 AssistedQueryStatsTestData test_data[] = { | |
| 514 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57" } | |
| 515 }; | |
| 516 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
| 517 SCOPED_TRACE("One match"); | |
| 518 } | |
| 519 | |
| 520 { | |
| 521 AssistedQueryStatsTestData test_data[] = { | |
| 522 { AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, "chrome.0.57j58j5l2j0l3j59" }, | |
| 523 { AutocompleteMatch::URL_WHAT_YOU_TYPED, "chrome.1.57j58j5l2j0l3j59" }, | |
| 524 { AutocompleteMatch::NAVSUGGEST, "chrome.2.57j58j5l2j0l3j59" }, | |
| 525 { AutocompleteMatch::NAVSUGGEST, "chrome.3.57j58j5l2j0l3j59" }, | |
| 526 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.4.57j58j5l2j0l3j59" }, | |
| 527 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.5.57j58j5l2j0l3j59" }, | |
| 528 { AutocompleteMatch::SEARCH_SUGGEST, "chrome.6.57j58j5l2j0l3j59" }, | |
| 529 { AutocompleteMatch::SEARCH_HISTORY, "chrome.7.57j58j5l2j0l3j59" }, | |
| 530 }; | |
| 531 RunAssistedQueryStatsTest(test_data, ARRAYSIZE_UNSAFE(test_data)); | |
| 532 SCOPED_TRACE("Multiple matches"); | |
| 533 } | |
| 534 } | |
| 535 | |
| 398 typedef testing::Test AutocompleteTest; | 536 typedef testing::Test AutocompleteTest; |
| 399 | 537 |
| 400 TEST_F(AutocompleteTest, InputType) { | 538 TEST_F(AutocompleteTest, InputType) { |
| 401 struct test_data { | 539 struct test_data { |
| 402 const string16 input; | 540 const string16 input; |
| 403 const AutocompleteInput::Type type; | 541 const AutocompleteInput::Type type; |
| 404 } input_cases[] = { | 542 } input_cases[] = { |
| 405 { string16(), AutocompleteInput::INVALID }, | 543 { string16(), AutocompleteInput::INVALID }, |
| 406 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, | 544 { ASCIIToUTF16("?"), AutocompleteInput::FORCED_QUERY }, |
| 407 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, | 545 { ASCIIToUTF16("?foo"), AutocompleteInput::FORCED_QUERY }, |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 607 &scheme, | 745 &scheme, |
| 608 &host); | 746 &host); |
| 609 AutocompleteInput input(input_cases[i].input, string16(), true, false, | 747 AutocompleteInput input(input_cases[i].input, string16(), true, false, |
| 610 true, AutocompleteInput::ALL_MATCHES); | 748 true, AutocompleteInput::ALL_MATCHES); |
| 611 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); | 749 EXPECT_EQ(input_cases[i].scheme.begin, scheme.begin); |
| 612 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); | 750 EXPECT_EQ(input_cases[i].scheme.len, scheme.len); |
| 613 EXPECT_EQ(input_cases[i].host.begin, host.begin); | 751 EXPECT_EQ(input_cases[i].host.begin, host.begin); |
| 614 EXPECT_EQ(input_cases[i].host.len, host.len); | 752 EXPECT_EQ(input_cases[i].host.len, host.len); |
| 615 } | 753 } |
| 616 } | 754 } |
| OLD | NEW |