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

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

Issue 1086733002: Ensure tests have an active task runner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 7 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 (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 "components/omnibox/autocomplete_provider.h" 5 #include "components/omnibox/autocomplete_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
12 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/autocomplete/autocomplete_controller.h" 14 #include "chrome/browser/autocomplete/autocomplete_controller.h"
16 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
17 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h" 17 #include "chrome/browser/search_engines/template_url_service_factory.h"
19 #include "chrome/test/base/testing_browser_process.h" 18 #include "chrome/test/base/testing_browser_process.h"
20 #include "chrome/test/base/testing_profile.h" 19 #include "chrome/test/base/testing_profile.h"
21 #include "components/metrics/proto/omnibox_event.pb.h" 20 #include "components/metrics/proto/omnibox_event.pb.h"
22 #include "components/omnibox/autocomplete_input.h" 21 #include "components/omnibox/autocomplete_input.h"
23 #include "components/omnibox/autocomplete_match.h" 22 #include "components/omnibox/autocomplete_match.h"
24 #include "components/omnibox/autocomplete_provider_listener.h" 23 #include "components/omnibox/autocomplete_provider_listener.h"
25 #include "components/omnibox/keyword_provider.h" 24 #include "components/omnibox/keyword_provider.h"
26 #include "components/omnibox/search_provider.h" 25 #include "components/omnibox/search_provider.h"
27 #include "components/search_engines/search_engines_switches.h" 26 #include "components/search_engines/search_engines_switches.h"
28 #include "components/search_engines/template_url.h" 27 #include "components/search_engines/template_url.h"
29 #include "components/search_engines/template_url_service.h" 28 #include "components/search_engines/template_url_service.h"
30 #include "content/public/browser/notification_observer.h" 29 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 30 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
32 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 34
35 static std::ostream& operator<<(std::ostream& os, 35 static std::ostream& operator<<(std::ostream& os,
36 const AutocompleteResult::const_iterator& it) { 36 const AutocompleteResult::const_iterator& it) {
37 return os << static_cast<const AutocompleteMatch*>(&(*it)); 37 return os << static_cast<const AutocompleteMatch*>(&(*it));
38 } 38 }
39 39
40 namespace { 40 namespace {
41 const size_t kResultsPerProvider = 3; 41 const size_t kResultsPerProvider = 3;
42 const char kTestTemplateURLKeyword[] = "t"; 42 const char kTestTemplateURLKeyword[] = "t";
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 228
229 AutocompleteResult result_; 229 AutocompleteResult result_;
230 230
231 private: 231 private:
232 // content::NotificationObserver: 232 // content::NotificationObserver:
233 void Observe(int type, 233 void Observe(int type,
234 const content::NotificationSource& source, 234 const content::NotificationSource& source,
235 const content::NotificationDetails& details) override; 235 const content::NotificationDetails& details) override;
236 236
237 base::MessageLoopForUI message_loop_; 237 content::TestBrowserThreadBundle thread_bundle_;
238 content::NotificationRegistrar registrar_; 238 content::NotificationRegistrar registrar_;
239 TestingProfile profile_; 239 TestingProfile profile_;
240 scoped_ptr<AutocompleteController> controller_; 240 scoped_ptr<AutocompleteController> controller_;
241 }; 241 };
242 242
243 void AutocompleteProviderTest::RegisterTemplateURL( 243 void AutocompleteProviderTest::RegisterTemplateURL(
244 const base::string16 keyword, 244 const base::string16 keyword,
245 const std::string& template_url) { 245 const std::string& template_url) {
246 if (TemplateURLServiceFactory::GetForProfile(&profile_) == NULL) { 246 if (TemplateURLServiceFactory::GetForProfile(&profile_) == NULL) {
247 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( 247 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 EXPECT_FALSE(search_provider_field_trial_triggered_in_session()); 740 EXPECT_FALSE(search_provider_field_trial_triggered_in_session());
741 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 741 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
742 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path()); 742 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j0j4&", url.path());
743 743
744 // Test page classification and field trial triggered set. 744 // Test page classification and field trial triggered set.
745 set_search_provider_field_trial_triggered_in_session(true); 745 set_search_provider_field_trial_triggered_in_session(true);
746 EXPECT_TRUE(search_provider_field_trial_triggered_in_session()); 746 EXPECT_TRUE(search_provider_field_trial_triggered_in_session());
747 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456)); 747 url = GetDestinationURL(match, base::TimeDelta::FromMilliseconds(2456));
748 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path()); 748 EXPECT_EQ("//aqs=chrome.0.69i57j69i58j5l2j0l3j69i59.2456j1j4&", url.path());
749 } 749 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698