OLD | NEW |
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 "chrome/browser/google/google_url_tracker.h" | 5 #include "chrome/browser/google/google_url_tracker.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // object, we don't add the created infobar to it. Instead we will simulate | 242 // object, we don't add the created infobar to it. Instead we will simulate |
243 // any helper<->infobar interaction necessary. The returned object will be | 243 // any helper<->infobar interaction necessary. The returned object will be |
244 // cleaned up in CloseTab(). | 244 // cleaned up in CloseTab(). |
245 GoogleURLTrackerInfoBarDelegate* CreateTestInfoBar( | 245 GoogleURLTrackerInfoBarDelegate* CreateTestInfoBar( |
246 InfoBarService* infobar_service, | 246 InfoBarService* infobar_service, |
247 GoogleURLTracker* google_url_tracker, | 247 GoogleURLTracker* google_url_tracker, |
248 const GURL& search_url); | 248 const GURL& search_url); |
249 | 249 |
250 // These are required by the TestURLFetchers GoogleURLTracker will create (see | 250 // These are required by the TestURLFetchers GoogleURLTracker will create (see |
251 // test_url_fetcher_factory.h). | 251 // test_url_fetcher_factory.h). |
252 MessageLoop message_loop_; | 252 base::MessageLoop message_loop_; |
253 content::TestBrowserThread io_thread_; | 253 content::TestBrowserThread io_thread_; |
254 // Creating this allows us to call | 254 // Creating this allows us to call |
255 // net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(). | 255 // net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(). |
256 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; | 256 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; |
257 net::TestURLFetcherFactory fetcher_factory_; | 257 net::TestURLFetcherFactory fetcher_factory_; |
258 content::NotificationRegistrar registrar_; | 258 content::NotificationRegistrar registrar_; |
259 TestNotificationObserver observer_; | 259 TestNotificationObserver observer_; |
260 GoogleURLTrackerNavigationHelper* nav_helper_; | 260 GoogleURLTrackerNavigationHelper* nav_helper_; |
261 TestingProfile profile_; | 261 TestingProfile profile_; |
262 scoped_ptr<GoogleURLTracker> google_url_tracker_; | 262 scoped_ptr<GoogleURLTracker> google_url_tracker_; |
(...skipping 13 matching lines...) Expand all Loading... |
276 ASSERT_EQ(infobar, map_entry->infobar()); | 276 ASSERT_EQ(infobar, map_entry->infobar()); |
277 map_entry->Observe(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 277 map_entry->Observe(chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
278 content::Source<InfoBarService>(infobar_service), | 278 content::Source<InfoBarService>(infobar_service), |
279 content::Details<InfoBarRemovedDetails>(&removed_details)); | 279 content::Details<InfoBarRemovedDetails>(&removed_details)); |
280 | 280 |
281 // Second, simulate the infobar container closing the infobar in response. | 281 // Second, simulate the infobar container closing the infobar in response. |
282 delete infobar; | 282 delete infobar; |
283 } | 283 } |
284 | 284 |
285 GoogleURLTrackerTest::GoogleURLTrackerTest() | 285 GoogleURLTrackerTest::GoogleURLTrackerTest() |
286 : message_loop_(MessageLoop::TYPE_IO), | 286 : message_loop_(base::MessageLoop::TYPE_IO), |
287 io_thread_(content::BrowserThread::IO, &message_loop_) { | 287 io_thread_(content::BrowserThread::IO, &message_loop_) { |
288 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnBrowserContext( | 288 GoogleURLTrackerFactory::GetInstance()->RegisterUserPrefsOnBrowserContext( |
289 &profile_); | 289 &profile_); |
290 } | 290 } |
291 | 291 |
292 GoogleURLTrackerTest::~GoogleURLTrackerTest() { | 292 GoogleURLTrackerTest::~GoogleURLTrackerTest() { |
293 } | 293 } |
294 | 294 |
295 void GoogleURLTrackerTest::SetUp() { | 295 void GoogleURLTrackerTest::SetUp() { |
296 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); | 296 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } | 344 } |
345 | 345 |
346 void GoogleURLTrackerTest::FinishSleep() { | 346 void GoogleURLTrackerTest::FinishSleep() { |
347 google_url_tracker_->FinishSleep(); | 347 google_url_tracker_->FinishSleep(); |
348 } | 348 } |
349 | 349 |
350 void GoogleURLTrackerTest::NotifyIPAddressChanged() { | 350 void GoogleURLTrackerTest::NotifyIPAddressChanged() { |
351 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); | 351 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests(); |
352 // For thread safety, the NCN queues tasks to do the actual notifications, so | 352 // For thread safety, the NCN queues tasks to do the actual notifications, so |
353 // we need to spin the message loop so the tracker will actually be notified. | 353 // we need to spin the message loop so the tracker will actually be notified. |
354 MessageLoop::current()->RunUntilIdle(); | 354 base::MessageLoop::current()->RunUntilIdle(); |
355 } | 355 } |
356 | 356 |
357 void GoogleURLTrackerTest::SetLastPromptedGoogleURL(const GURL& url) { | 357 void GoogleURLTrackerTest::SetLastPromptedGoogleURL(const GURL& url) { |
358 profile_.GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, url.spec()); | 358 profile_.GetPrefs()->SetString(prefs::kLastPromptedGoogleURL, url.spec()); |
359 } | 359 } |
360 | 360 |
361 GURL GoogleURLTrackerTest::GetLastPromptedGoogleURL() { | 361 GURL GoogleURLTrackerTest::GetLastPromptedGoogleURL() { |
362 return GURL(profile_.GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); | 362 return GURL(profile_.GetPrefs()->GetString(prefs::kLastPromptedGoogleURL)); |
363 } | 363 } |
364 | 364 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); | 1078 CommitSearch(2, GURL("http://www.google.co.uk/search?q=test2")); |
1079 EXPECT_FALSE(GetInfoBar(1) == NULL); | 1079 EXPECT_FALSE(GetInfoBar(1) == NULL); |
1080 GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); | 1080 GoogleURLTrackerInfoBarDelegate* infobar2 = GetInfoBar(2); |
1081 ASSERT_FALSE(infobar2 == NULL); | 1081 ASSERT_FALSE(infobar2 == NULL); |
1082 SetNavigationPending(1, true); | 1082 SetNavigationPending(1, true); |
1083 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); | 1083 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, true)); |
1084 infobar2->Close(false); | 1084 infobar2->Close(false); |
1085 SetNavigationPending(1, false); | 1085 SetNavigationPending(1, false); |
1086 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); | 1086 ASSERT_NO_FATAL_FAILURE(ExpectListeningForCommit(1, false)); |
1087 } | 1087 } |
OLD | NEW |