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

Side by Side Diff: chrome/browser/autocomplete/search_provider_unittest.cc

Issue 839193002: Move ServiceAccessType into //components/keyed_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on android Created 5 years, 11 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
OLDNEW
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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 keyword_fetcher->set_response_code(200); 434 keyword_fetcher->set_response_code(200);
435 keyword_fetcher->SetResponseString(keyword_fetcher_response); 435 keyword_fetcher->SetResponseString(keyword_fetcher_response);
436 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher); 436 keyword_fetcher->delegate()->OnURLFetchComplete(keyword_fetcher);
437 } 437 }
438 RunTillProviderDone(); 438 RunTillProviderDone();
439 } 439 }
440 440
441 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, 441 GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url,
442 base::string16 term, 442 base::string16 term,
443 int visit_count) { 443 int visit_count) {
444 HistoryService* history = 444 HistoryService* history = HistoryServiceFactory::GetForProfile(
445 HistoryServiceFactory::GetForProfile(&profile_, 445 &profile_, ServiceAccessType::EXPLICIT_ACCESS);
446 Profile::EXPLICIT_ACCESS);
447 GURL search(t_url->url_ref().ReplaceSearchTerms( 446 GURL search(t_url->url_ref().ReplaceSearchTerms(
448 TemplateURLRef::SearchTermsArgs(term), 447 TemplateURLRef::SearchTermsArgs(term),
449 TemplateURLServiceFactory::GetForProfile( 448 TemplateURLServiceFactory::GetForProfile(
450 &profile_)->search_terms_data())); 449 &profile_)->search_terms_data()));
451 static base::Time last_added_time; 450 static base::Time last_added_time;
452 last_added_time = std::max(base::Time::Now(), 451 last_added_time = std::max(base::Time::Now(),
453 last_added_time + base::TimeDelta::FromMicroseconds(1)); 452 last_added_time + base::TimeDelta::FromMicroseconds(1));
454 history->AddPageWithDetails(search, base::string16(), visit_count, visit_count , 453 history->AddPageWithDetails(search, base::string16(), visit_count, visit_count ,
455 last_added_time, false, history::SOURCE_BROWSED); 454 last_added_time, false, history::SOURCE_BROWSED);
456 history->SetKeywordSearchTermsForURL(search, t_url->id(), term); 455 history->SetKeywordSearchTermsForURL(search, t_url->id(), term);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 ASSERT_TRUE(test_factory_.GetFetcherByID( 731 ASSERT_TRUE(test_factory_.GetFetcherByID(
733 SearchProvider::kDefaultProviderURLFetcherID) != NULL); 732 SearchProvider::kDefaultProviderURLFetcherID) != NULL);
734 } 733 }
735 } 734 }
736 735
737 TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) { 736 TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) {
738 GURL url = AddSearchToHistory(default_t_url_, 737 GURL url = AddSearchToHistory(default_t_url_,
739 ASCIIToUTF16("docs.google.com"), 1); 738 ASCIIToUTF16("docs.google.com"), 1);
740 739
741 // Add the term as a url. 740 // Add the term as a url.
742 HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)-> 741 HistoryServiceFactory::GetForProfile(&profile_,
743 AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1, 1, 742 ServiceAccessType::EXPLICIT_ACCESS)
744 base::Time::Now(), false, history::SOURCE_BROWSED); 743 ->AddPageWithDetails(GURL("http://docs.google.com"), base::string16(), 1,
744 1, base::Time::Now(), false,
745 history::SOURCE_BROWSED);
745 profile_.BlockUntilHistoryProcessesPendingRequests(); 746 profile_.BlockUntilHistoryProcessesPendingRequests();
746 747
747 AutocompleteMatch wyt_match; 748 AutocompleteMatch wyt_match;
748 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("docs"), 749 ASSERT_NO_FATAL_FAILURE(QueryForInputAndSetWYTMatch(ASCIIToUTF16("docs"),
749 &wyt_match)); 750 &wyt_match));
750 751
751 // There should be two matches, one for what you typed, the other for 752 // There should be two matches, one for what you typed, the other for
752 // 'docs.google.com'. The search term should have a lower priority than the 753 // 'docs.google.com'. The search term should have a lower priority than the
753 // what you typed match. 754 // what you typed match.
754 ASSERT_EQ(2u, provider_->matches().size()); 755 ASSERT_EQ(2u, provider_->matches().size());
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 EXPECT_TRUE(matches[2].answer_contents.empty()); 3465 EXPECT_TRUE(matches[2].answer_contents.empty());
3465 EXPECT_TRUE(matches[2].answer_type.empty()); 3466 EXPECT_TRUE(matches[2].answer_type.empty());
3466 EXPECT_FALSE(matches[2].answer); 3467 EXPECT_FALSE(matches[2].answer);
3467 EXPECT_TRUE(matches[3].answer_contents.empty()); 3468 EXPECT_TRUE(matches[3].answer_contents.empty());
3468 EXPECT_TRUE(matches[3].answer_type.empty()); 3469 EXPECT_TRUE(matches[3].answer_type.empty());
3469 EXPECT_FALSE(matches[3].answer); 3470 EXPECT_FALSE(matches[3].answer);
3470 EXPECT_TRUE(matches[4].answer_contents.empty()); 3471 EXPECT_TRUE(matches[4].answer_contents.empty());
3471 EXPECT_TRUE(matches[4].answer_type.empty()); 3472 EXPECT_TRUE(matches[4].answer_type.empty());
3472 EXPECT_FALSE(matches[4].answer); 3473 EXPECT_FALSE(matches[4].answer);
3473 } 3474 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider_unittest.cc ('k') | chrome/browser/autocomplete/shortcuts_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698