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

Side by Side Diff: chrome/browser/google_url_tracker_unittest.cc

Issue 3176028: Use ChromeThread::IO instead of virtual set_request_context (Closed)
Patch Set: Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/common/net/test_url_fetcher_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/google_url_tracker.h" 5 #include "chrome/browser/google_url_tracker.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profile.h" 8 #include "chrome/browser/profile.h"
9 #include "chrome/browser/tab_contents/infobar_delegate.h" 9 #include "chrome/browser/tab_contents/infobar_delegate.h"
10 #include "chrome/common/net/url_fetcher.h" 10 #include "chrome/common/net/url_fetcher.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 const GURL& new_google_url) { 63 const GURL& new_google_url) {
64 return new TestInfoBar(google_url_tracker, new_google_url); 64 return new TestInfoBar(google_url_tracker, new_google_url);
65 } 65 }
66 }; 66 };
67 67
68 } // anonymous namespace 68 } // anonymous namespace
69 69
70 class GoogleURLTrackerTest : public testing::Test { 70 class GoogleURLTrackerTest : public testing::Test {
71 protected: 71 protected:
72 GoogleURLTrackerTest() 72 GoogleURLTrackerTest()
73 : original_default_request_context_(NULL) { 73 : message_loop_(NULL),
74 io_thread_(NULL),
75 original_default_request_context_(NULL) {
74 } 76 }
75 77
76 void SetUp() { 78 void SetUp() {
77 original_default_request_context_ = Profile::GetDefaultRequestContext(); 79 original_default_request_context_ = Profile::GetDefaultRequestContext();
78 Profile::set_default_request_context(NULL); 80 Profile::set_default_request_context(NULL);
79 message_loop_ = new MessageLoop(MessageLoop::TYPE_IO); 81 message_loop_ = new MessageLoop(MessageLoop::TYPE_IO);
82 io_thread_ = new ChromeThread(ChromeThread::IO, message_loop_);
80 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); 83 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
81 testing_profile_.reset(new TestingProfile); 84 testing_profile_.reset(new TestingProfile);
82 TestingBrowserProcess* testing_browser_process = 85 TestingBrowserProcess* testing_browser_process =
83 static_cast<TestingBrowserProcess*>(g_browser_process); 86 static_cast<TestingBrowserProcess*>(g_browser_process);
84 PrefService* pref_service = testing_profile_->GetPrefs(); 87 PrefService* pref_service = testing_profile_->GetPrefs();
85 testing_browser_process->SetPrefService(pref_service); 88 testing_browser_process->SetPrefService(pref_service);
86 testing_browser_process->SetGoogleURLTracker(new GoogleURLTracker); 89 testing_browser_process->SetGoogleURLTracker(new GoogleURLTracker);
87 90
88 URLFetcher::set_factory(&fetcher_factory_); 91 URLFetcher::set_factory(&fetcher_factory_);
89 observer_.reset(new TestNotificationObserver); 92 observer_.reset(new TestNotificationObserver);
90 g_browser_process->google_url_tracker()->infobar_factory_.reset( 93 g_browser_process->google_url_tracker()->infobar_factory_.reset(
91 new TestInfoBarDelegateFactory); 94 new TestInfoBarDelegateFactory);
92 } 95 }
93 96
94 void TearDown() { 97 void TearDown() {
95 URLFetcher::set_factory(NULL); 98 URLFetcher::set_factory(NULL);
96 TestingBrowserProcess* testing_browser_process = 99 TestingBrowserProcess* testing_browser_process =
97 static_cast<TestingBrowserProcess*>(g_browser_process); 100 static_cast<TestingBrowserProcess*>(g_browser_process);
98 testing_browser_process->SetGoogleURLTracker(NULL); 101 testing_browser_process->SetGoogleURLTracker(NULL);
99 testing_browser_process->SetPrefService(NULL); 102 testing_browser_process->SetPrefService(NULL);
100 testing_profile_.reset(); 103 testing_profile_.reset();
101 network_change_notifier_.reset(); 104 network_change_notifier_.reset();
105 delete io_thread_;
102 delete message_loop_; 106 delete message_loop_;
103 Profile::set_default_request_context(original_default_request_context_); 107 Profile::set_default_request_context(original_default_request_context_);
108 original_default_request_context_ = NULL;
104 } 109 }
105 110
106 void CreateRequestContext() { 111 void CreateRequestContext() {
107 testing_profile_->CreateRequestContext(); 112 testing_profile_->CreateRequestContext();
108 Profile::set_default_request_context(testing_profile_->GetRequestContext()); 113 Profile::set_default_request_context(testing_profile_->GetRequestContext());
109 NotificationService::current()->Notify( 114 NotificationService::current()->Notify(
110 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, 115 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
111 NotificationService::AllSources(), NotificationService::NoDetails()); 116 NotificationService::AllSources(), NotificationService::NoDetails());
112 } 117 }
113 118
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 213 }
209 214
210 void ExpectDefaultURLs() { 215 void ExpectDefaultURLs() {
211 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), 216 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage),
212 GoogleURLTracker::GoogleURL()); 217 GoogleURLTracker::GoogleURL());
213 EXPECT_EQ(GURL(), GetFetchedGoogleURL()); 218 EXPECT_EQ(GURL(), GetFetchedGoogleURL());
214 } 219 }
215 220
216 private: 221 private:
217 MessageLoop* message_loop_; 222 MessageLoop* message_loop_;
223 ChromeThread* io_thread_;
Paweł Hajdan Jr. 2010/08/23 17:22:48 Why isn't it a scoped_ptr? I suggest we just make
218 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 224 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
219 scoped_ptr<TestingProfile> testing_profile_; 225 scoped_ptr<TestingProfile> testing_profile_;
220 226
221 TestURLFetcherFactory fetcher_factory_; 227 TestURLFetcherFactory fetcher_factory_;
222 NotificationRegistrar registrar_; 228 NotificationRegistrar registrar_;
223 scoped_ptr<NotificationObserver> observer_; 229 scoped_ptr<NotificationObserver> observer_;
224 230
225 URLRequestContextGetter* original_default_request_context_; 231 URLRequestContextGetter* original_default_request_context_;
226 }; 232 };
227 233
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 449 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
444 450
445 SearchCommitted(GURL("http://www.google.co.uk/search?q=test")); 451 SearchCommitted(GURL("http://www.google.co.uk/search?q=test"));
446 NavEntryCommitted(); 452 NavEntryCommitted();
447 453
448 EXPECT_FALSE(InfoBarIsShown()); 454 EXPECT_FALSE(InfoBarIsShown());
449 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 455 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
450 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 456 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
451 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 457 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
452 } 458 }
OLDNEW
« no previous file with comments | « no previous file | chrome/common/net/test_url_fetcher_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698