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

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

Issue 7337007: Introduce a field trial for Instant. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix onchange handling Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1); 146 keyword_url_ = AddSearchToHistory(keyword_t_url_, keyword_term_, 1);
147 147
148 // Keywords are updated by the InMemoryHistoryBackend only after the message 148 // Keywords are updated by the InMemoryHistoryBackend only after the message
149 // has been processed on the history thread. Block until history processes all 149 // has been processed on the history thread. Block until history processes all
150 // requests to ensure the InMemoryDatabase is the state we expect it. 150 // requests to ensure the InMemoryDatabase is the state we expect it.
151 profile_.BlockUntilHistoryProcessesPendingRequests(); 151 profile_.BlockUntilHistoryProcessesPendingRequests();
152 152
153 provider_ = new SearchProvider(this, &profile_); 153 provider_ = new SearchProvider(this, &profile_);
154 154
155 URLFetcher::set_factory(&test_factory_); 155 URLFetcher::set_factory(&test_factory_);
156
157 // Prevent the Instant field trial from kicking in.
158 PrefService* service = profile_.GetPrefs();
159 service->SetBoolean(prefs::kInstantEnabledOnce, true);
156 } 160 }
157 161
158 void SearchProviderTest::OnProviderUpdate(bool updated_matches) { 162 void SearchProviderTest::OnProviderUpdate(bool updated_matches) {
159 if (quit_when_done_ && provider_->done()) { 163 if (quit_when_done_ && provider_->done()) {
160 quit_when_done_ = false; 164 quit_when_done_ = false;
161 message_loop_.Quit(); 165 message_loop_.Quit();
162 } 166 }
163 } 167 }
164 168
165 void SearchProviderTest::RunTillProviderDone() { 169 void SearchProviderTest::RunTillProviderDone() {
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 620
617 // Verifies AutocompleteControllers sets descriptions for results correctly. 621 // Verifies AutocompleteControllers sets descriptions for results correctly.
618 TEST_F(SearchProviderTest, UpdateKeywordDescriptions) { 622 TEST_F(SearchProviderTest, UpdateKeywordDescriptions) {
619 // Add an entry that corresponds to a keyword search with 'term2'. 623 // Add an entry that corresponds to a keyword search with 'term2'.
620 AddSearchToHistory(keyword_t_url_, ASCIIToUTF16("term2"), 1); 624 AddSearchToHistory(keyword_t_url_, ASCIIToUTF16("term2"), 1);
621 profile_.BlockUntilHistoryProcessesPendingRequests(); 625 profile_.BlockUntilHistoryProcessesPendingRequests();
622 626
623 ACProviders providers; 627 ACProviders providers;
624 SearchProvider* provider = provider_.release(); 628 SearchProvider* provider = provider_.release();
625 providers.push_back(provider); 629 providers.push_back(provider);
626 AutocompleteController controller(providers); 630 AutocompleteController controller(providers, &profile_);
627 controller.set_search_provider(provider); 631 controller.set_search_provider(provider);
628 provider->set_listener(&controller); 632 provider->set_listener(&controller);
629 controller.Start(ASCIIToUTF16("k t"), string16(), false, false, true, 633 controller.Start(ASCIIToUTF16("k t"), string16(), false, false, true,
630 AutocompleteInput::ALL_MATCHES); 634 AutocompleteInput::ALL_MATCHES);
631 const AutocompleteResult& result = controller.result(); 635 const AutocompleteResult& result = controller.result();
632 636
633 // There should be two matches, one for the keyword one for what you typed. 637 // There should be two matches, one for the keyword one for what you typed.
634 ASSERT_EQ(2u, result.size()); 638 ASSERT_EQ(2u, result.size());
635 639
636 EXPECT_TRUE(result.match_at(0).template_url != NULL); 640 EXPECT_TRUE(result.match_at(0).template_url != NULL);
637 EXPECT_TRUE(result.match_at(1).template_url != NULL); 641 EXPECT_TRUE(result.match_at(1).template_url != NULL);
638 EXPECT_NE(result.match_at(0).template_url, 642 EXPECT_NE(result.match_at(0).template_url,
639 result.match_at(1).template_url); 643 result.match_at(1).template_url);
640 644
641 EXPECT_FALSE(result.match_at(0).description.empty()); 645 EXPECT_FALSE(result.match_at(0).description.empty());
642 EXPECT_FALSE(result.match_at(1).description.empty()); 646 EXPECT_FALSE(result.match_at(1).description.empty());
643 EXPECT_NE(result.match_at(0).description, 647 EXPECT_NE(result.match_at(0).description,
644 result.match_at(1).description); 648 result.match_at(1).description);
645 } 649 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698