OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/omnibox/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 ASSERT_NE(0, keyword_t_url_->id()); | 285 ASSERT_NE(0, keyword_t_url_->id()); |
286 | 286 |
287 // Add a page and search term for keyword_t_url_. | 287 // Add a page and search term for keyword_t_url_. |
288 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1); | 288 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1); |
289 | 289 |
290 // Keywords are updated by the InMemoryHistoryBackend only after the message | 290 // Keywords are updated by the InMemoryHistoryBackend only after the message |
291 // has been processed on the history thread. Block until history processes all | 291 // has been processed on the history thread. Block until history processes all |
292 // requests to ensure the InMemoryDatabase is the state we expect it. | 292 // requests to ensure the InMemoryDatabase is the state we expect it. |
293 profile_.BlockUntilHistoryProcessesPendingRequests(); | 293 profile_.BlockUntilHistoryProcessesPendingRequests(); |
294 | 294 |
| 295 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( |
| 296 &profile_, &AutocompleteClassifierFactory::BuildInstanceFor); |
| 297 |
295 provider_ = new SearchProviderForTest(this, turl_model, &profile_); | 298 provider_ = new SearchProviderForTest(this, turl_model, &profile_); |
296 provider_->kMinimumTimeBetweenSuggestQueriesMs = 0; | 299 provider_->kMinimumTimeBetweenSuggestQueriesMs = 0; |
297 } | 300 } |
298 | 301 |
299 void SearchProviderTest::TearDown() { | 302 void SearchProviderTest::TearDown() { |
300 base::RunLoop().RunUntilIdle(); | 303 base::RunLoop().RunUntilIdle(); |
301 | 304 |
302 // Shutdown the provider before the profile. | 305 // Shutdown the provider before the profile. |
303 provider_ = NULL; | 306 provider_ = NULL; |
304 } | 307 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 profile_.BlockUntilHistoryProcessesPendingRequests(); | 657 profile_.BlockUntilHistoryProcessesPendingRequests(); |
655 for (size_t i = 0; i < arraysize(inputs); ++i) { | 658 for (size_t i = 0; i < arraysize(inputs); ++i) { |
656 QueryForInput(ASCIIToUTF16(inputs[i]), false, false); | 659 QueryForInput(ASCIIToUTF16(inputs[i]), false, false); |
657 // Make sure the default provider's suggest service was queried. | 660 // Make sure the default provider's suggest service was queried. |
658 ASSERT_TRUE(test_factory_.GetFetcherByID( | 661 ASSERT_TRUE(test_factory_.GetFetcherByID( |
659 SearchProvider::kDefaultProviderURLFetcherID) != NULL); | 662 SearchProvider::kDefaultProviderURLFetcherID) != NULL); |
660 } | 663 } |
661 } | 664 } |
662 | 665 |
663 TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) { | 666 TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) { |
664 AutocompleteClassifierFactory::GetInstance()->SetTestingFactoryAndUse( | |
665 &profile_, &AutocompleteClassifierFactory::BuildInstanceFor); | |
666 GURL url = AddSearchToHistory(default_t_url_, | 667 GURL url = AddSearchToHistory(default_t_url_, |
667 ASCIIToUTF16("docs.google.com"), 1); | 668 ASCIIToUTF16("docs.google.com"), 1); |
668 | 669 |
669 // Add the term as a url. | 670 // Add the term as a url. |
670 HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)-> | 671 HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)-> |
671 AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1, 1, | 672 AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1, 1, |
672 base::Time::Now(), false, history::SOURCE_BROWSED); | 673 base::Time::Now(), false, history::SOURCE_BROWSED); |
673 profile_.BlockUntilHistoryProcessesPendingRequests(); | 674 profile_.BlockUntilHistoryProcessesPendingRequests(); |
674 | 675 |
675 AutocompleteMatch wyt_match; | 676 AutocompleteMatch wyt_match; |
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3259 AutocompleteInput input(base::ASCIIToUTF16("weather l"), | 3260 AutocompleteInput input(base::ASCIIToUTF16("weather l"), |
3260 base::string16::npos, base::string16(), GURL(), | 3261 base::string16::npos, base::string16(), GURL(), |
3261 metrics::OmniboxEventProto::INVALID_SPEC, false, | 3262 metrics::OmniboxEventProto::INVALID_SPEC, false, |
3262 false, true, true, | 3263 false, true, true, |
3263 ChromeAutocompleteSchemeClassifier(&profile_)); | 3264 ChromeAutocompleteSchemeClassifier(&profile_)); |
3264 provider_->DoAnswersQuery(input); | 3265 provider_->DoAnswersQuery(input); |
3265 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), | 3266 EXPECT_EQ(base::ASCIIToUTF16("weather los angeles"), |
3266 provider_->prefetch_data_.full_query_text); | 3267 provider_->prefetch_data_.full_query_text); |
3267 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); | 3268 EXPECT_EQ(base::ASCIIToUTF16("2334"), provider_->prefetch_data_.query_type); |
3268 } | 3269 } |
OLD | NEW |