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

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

Issue 6292017: Extended: Add "system" URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 9 years, 9 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/google/google_url_tracker.h" 5 #include "chrome/browser/google/google_url_tracker.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/prefs/browser_prefs.h" 10 #include "chrome/browser/prefs/browser_prefs.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/common/net/test_url_fetcher_factory.h" 12 #include "chrome/common/net/test_url_fetcher_factory.h"
14 #include "chrome/common/net/url_fetcher.h" 13 #include "chrome/common/net/url_fetcher.h"
15 #include "chrome/common/net/url_request_context_getter.h" 14 #include "chrome/common/net/url_request_context_getter.h"
16 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
17 #include "chrome/test/testing_browser_process.h" 16 #include "chrome/test/testing_browser_process.h"
18 #include "chrome/test/testing_pref_service.h" 17 #include "chrome/test/testing_pref_service.h"
19 #include "chrome/test/testing_profile.h"
20 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
21 #include "content/common/notification_service.h" 19 #include "content/common/notification_service.h"
22 #include "net/url_request/url_request.h" 20 #include "net/url_request/url_request.h"
23 #include "net/url_request/url_request_test_util.h" 21 #include "net/url_request/url_request_test_util.h"
24 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
25 23
26 // TestNotificationObserver --------------------------------------------------- 24 // TestNotificationObserver ---------------------------------------------------
27 25
28 namespace { 26 namespace {
29 27
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 101
104 class GoogleURLTrackerTest : public testing::Test { 102 class GoogleURLTrackerTest : public testing::Test {
105 protected: 103 protected:
106 GoogleURLTrackerTest(); 104 GoogleURLTrackerTest();
107 virtual ~GoogleURLTrackerTest(); 105 virtual ~GoogleURLTrackerTest();
108 106
109 // testing::Test 107 // testing::Test
110 virtual void SetUp(); 108 virtual void SetUp();
111 virtual void TearDown(); 109 virtual void TearDown();
112 110
113 void CreateRequestContext();
114 TestURLFetcher* GetFetcherByID(int expected_id); 111 TestURLFetcher* GetFetcherByID(int expected_id);
115 void MockSearchDomainCheckResponse(int expected_id, 112 void MockSearchDomainCheckResponse(int expected_id,
116 const std::string& domain); 113 const std::string& domain);
117 void RequestServerCheck(); 114 void RequestServerCheck();
118 void FinishSleep(); 115 void FinishSleep();
119 void NotifyIPAddressChanged(); 116 void NotifyIPAddressChanged();
120 GURL GetFetchedGoogleURL(); 117 GURL GetFetchedGoogleURL();
121 void SetGoogleURL(const GURL& url); 118 void SetGoogleURL(const GURL& url);
122 void SetLastPromptedGoogleURL(const GURL& url); 119 void SetLastPromptedGoogleURL(const GURL& url);
123 GURL GetLastPromptedGoogleURL(); 120 GURL GetLastPromptedGoogleURL();
124 void SearchCommitted(const GURL& search_url); 121 void SearchCommitted(const GURL& search_url);
125 void NavEntryCommitted(); 122 void NavEntryCommitted();
126 bool InfoBarIsShown(); 123 bool InfoBarIsShown();
127 GURL GetInfoBarShowingURL(); 124 GURL GetInfoBarShowingURL();
128 void AcceptGoogleURL(); 125 void AcceptGoogleURL();
129 void CancelGoogleURL(); 126 void CancelGoogleURL();
130 void InfoBarClosed(); 127 void InfoBarClosed();
131 void ExpectDefaultURLs(); 128 void ExpectDefaultURLs();
132 129
133 scoped_ptr<TestNotificationObserver> observer_; 130 scoped_ptr<TestNotificationObserver> observer_;
134 131
135 private: 132 private:
136 MessageLoop* message_loop_; 133 MessageLoop* message_loop_;
137 BrowserThread* io_thread_; 134 BrowserThread* io_thread_;
138 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_; 135 scoped_ptr<net::NetworkChangeNotifier> network_change_notifier_;
139 TestingPrefService local_state_; 136 TestingPrefService local_state_;
140 scoped_ptr<TestingProfile> testing_profile_;
141 137
142 TestURLFetcherFactory fetcher_factory_; 138 TestURLFetcherFactory fetcher_factory_;
143 NotificationRegistrar registrar_; 139 NotificationRegistrar registrar_;
144
145 URLRequestContextGetter* original_default_request_context_;
146 }; 140 };
147 141
148 GoogleURLTrackerTest::GoogleURLTrackerTest() 142 GoogleURLTrackerTest::GoogleURLTrackerTest()
149 : observer_(new TestNotificationObserver), 143 : observer_(new TestNotificationObserver),
150 message_loop_(NULL), 144 message_loop_(NULL),
151 io_thread_(NULL), 145 io_thread_(NULL) {
152 original_default_request_context_(NULL) {
153 } 146 }
154 147
155 GoogleURLTrackerTest::~GoogleURLTrackerTest() { 148 GoogleURLTrackerTest::~GoogleURLTrackerTest() {
156 } 149 }
157 150
158 void GoogleURLTrackerTest::SetUp() { 151 void GoogleURLTrackerTest::SetUp() {
159 original_default_request_context_ = Profile::GetDefaultRequestContext();
160 Profile::set_default_request_context(NULL);
161 message_loop_ = new MessageLoop(MessageLoop::TYPE_IO); 152 message_loop_ = new MessageLoop(MessageLoop::TYPE_IO);
162 io_thread_ = new BrowserThread(BrowserThread::IO, message_loop_); 153 io_thread_ = new BrowserThread(BrowserThread::IO, message_loop_);
163 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock()); 154 network_change_notifier_.reset(net::NetworkChangeNotifier::CreateMock());
164 testing_profile_.reset(new TestingProfile);
165 browser::RegisterLocalState(&local_state_); 155 browser::RegisterLocalState(&local_state_);
166 TestingBrowserProcess* testing_browser_process = 156 TestingBrowserProcess* testing_browser_process =
167 static_cast<TestingBrowserProcess*>(g_browser_process); 157 static_cast<TestingBrowserProcess*>(g_browser_process);
168 testing_browser_process->SetPrefService(&local_state_); 158 testing_browser_process->SetPrefService(&local_state_);
169 GoogleURLTracker* tracker = new GoogleURLTracker; 159 GoogleURLTracker* tracker = new GoogleURLTracker;
170 tracker->queue_wakeup_task_ = false; 160 tracker->queue_wakeup_task_ = false;
171 MessageLoop::current()->RunAllPending(); 161 MessageLoop::current()->RunAllPending();
172 testing_browser_process->SetGoogleURLTracker(tracker); 162 testing_browser_process->SetGoogleURLTracker(tracker);
173 163
174 URLFetcher::set_factory(&fetcher_factory_); 164 URLFetcher::set_factory(&fetcher_factory_);
175 g_browser_process->google_url_tracker()->infobar_creator_ = 165 g_browser_process->google_url_tracker()->infobar_creator_ =
176 &CreateTestInfobar; 166 &CreateTestInfobar;
177 } 167 }
178 168
179 void GoogleURLTrackerTest::TearDown() { 169 void GoogleURLTrackerTest::TearDown() {
180 URLFetcher::set_factory(NULL); 170 URLFetcher::set_factory(NULL);
181 TestingBrowserProcess* testing_browser_process = 171 TestingBrowserProcess* testing_browser_process =
182 static_cast<TestingBrowserProcess*>(g_browser_process); 172 static_cast<TestingBrowserProcess*>(g_browser_process);
183 testing_browser_process->SetGoogleURLTracker(NULL); 173 testing_browser_process->SetGoogleURLTracker(NULL);
184 testing_browser_process->SetPrefService(NULL); 174 testing_browser_process->SetPrefService(NULL);
185 testing_profile_.reset();
186 network_change_notifier_.reset(); 175 network_change_notifier_.reset();
187 delete io_thread_; 176 delete io_thread_;
188 delete message_loop_; 177 delete message_loop_;
189 Profile::set_default_request_context(original_default_request_context_);
190 original_default_request_context_ = NULL;
191 }
192
193 void GoogleURLTrackerTest::CreateRequestContext() {
194 testing_profile_->CreateRequestContext();
195 Profile::set_default_request_context(testing_profile_->GetRequestContext());
196 NotificationService::current()->Notify(
197 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
198 NotificationService::AllSources(), NotificationService::NoDetails());
199 } 178 }
200 179
201 TestURLFetcher* GoogleURLTrackerTest::GetFetcherByID(int expected_id) { 180 TestURLFetcher* GoogleURLTrackerTest::GetFetcherByID(int expected_id) {
202 return fetcher_factory_.GetFetcherByID(expected_id); 181 return fetcher_factory_.GetFetcherByID(expected_id);
203 } 182 }
204 183
205 void GoogleURLTrackerTest::MockSearchDomainCheckResponse( 184 void GoogleURLTrackerTest::MockSearchDomainCheckResponse(
206 int expected_id, 185 int expected_id,
207 const std::string& domain) { 186 const std::string& domain) {
208 TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(expected_id); 187 TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(expected_id);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 void GoogleURLTrackerTest::ExpectDefaultURLs() { 288 void GoogleURLTrackerTest::ExpectDefaultURLs() {
310 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), 289 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage),
311 GoogleURLTracker::GoogleURL()); 290 GoogleURLTracker::GoogleURL());
312 EXPECT_EQ(GURL(), GetFetchedGoogleURL()); 291 EXPECT_EQ(GURL(), GetFetchedGoogleURL());
313 } 292 }
314 293
315 294
316 // Tests ---------------------------------------------------------------------- 295 // Tests ----------------------------------------------------------------------
317 296
318 TEST_F(GoogleURLTrackerTest, DontFetchWhenNoOneRequestsCheck) { 297 TEST_F(GoogleURLTrackerTest, DontFetchWhenNoOneRequestsCheck) {
319 CreateRequestContext();
320 ExpectDefaultURLs(); 298 ExpectDefaultURLs();
321 FinishSleep(); 299 FinishSleep();
322 // No one called RequestServerCheck() so nothing should have happened. 300 // No one called RequestServerCheck() so nothing should have happened.
323 EXPECT_FALSE(GetFetcherByID(0)); 301 EXPECT_FALSE(GetFetcherByID(0));
324 ExpectDefaultURLs(); 302 ExpectDefaultURLs();
325 EXPECT_FALSE(observer_->notified()); 303 EXPECT_FALSE(observer_->notified());
326 } 304 }
327 305
328 TEST_F(GoogleURLTrackerTest, UpdateOnFirstRun) { 306 TEST_F(GoogleURLTrackerTest, UpdateOnFirstRun) {
329 CreateRequestContext();
330 RequestServerCheck(); 307 RequestServerCheck();
331 EXPECT_FALSE(GetFetcherByID(0)); 308 EXPECT_FALSE(GetFetcherByID(0));
332 ExpectDefaultURLs(); 309 ExpectDefaultURLs();
333 EXPECT_FALSE(observer_->notified()); 310 EXPECT_FALSE(observer_->notified());
334 311
335 FinishSleep(); 312 FinishSleep();
336 MockSearchDomainCheckResponse(0, ".google.co.uk"); 313 MockSearchDomainCheckResponse(0, ".google.co.uk");
337 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 314 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
338 // GoogleURL should be updated, becase there was no last prompted URL. 315 // GoogleURL should be updated, becase there was no last prompted URL.
339 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 316 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
340 EXPECT_TRUE(observer_->notified()); 317 EXPECT_TRUE(observer_->notified());
341 } 318 }
342 319
343 TEST_F(GoogleURLTrackerTest, DontUpdateWhenUnchanged) { 320 TEST_F(GoogleURLTrackerTest, DontUpdateWhenUnchanged) {
344 CreateRequestContext();
345 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); 321 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/"));
346 322
347 RequestServerCheck(); 323 RequestServerCheck();
348 EXPECT_FALSE(GetFetcherByID(0)); 324 EXPECT_FALSE(GetFetcherByID(0));
349 ExpectDefaultURLs(); 325 ExpectDefaultURLs();
350 EXPECT_FALSE(observer_->notified()); 326 EXPECT_FALSE(observer_->notified());
351 327
352 FinishSleep(); 328 FinishSleep();
353 MockSearchDomainCheckResponse(0, ".google.co.uk"); 329 MockSearchDomainCheckResponse(0, ".google.co.uk");
354 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 330 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
355 // GoogleURL should not be updated, because the fetched and prompted URLs 331 // GoogleURL should not be updated, because the fetched and prompted URLs
356 // match. 332 // match.
357 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), 333 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage),
358 GoogleURLTracker::GoogleURL()); 334 GoogleURLTracker::GoogleURL());
359 EXPECT_FALSE(observer_->notified()); 335 EXPECT_FALSE(observer_->notified());
360 } 336 }
361 337
362 TEST_F(GoogleURLTrackerTest, UpdatePromptedURLOnReturnToPreviousLocation) { 338 TEST_F(GoogleURLTrackerTest, UpdatePromptedURLOnReturnToPreviousLocation) {
363 CreateRequestContext();
364 SetLastPromptedGoogleURL(GURL("http://www.google.co.jp/")); 339 SetLastPromptedGoogleURL(GURL("http://www.google.co.jp/"));
365 SetGoogleURL(GURL("http://www.google.co.uk/")); 340 SetGoogleURL(GURL("http://www.google.co.uk/"));
366 RequestServerCheck(); 341 RequestServerCheck();
367 FinishSleep(); 342 FinishSleep();
368 MockSearchDomainCheckResponse(0, ".google.co.uk"); 343 MockSearchDomainCheckResponse(0, ".google.co.uk");
369 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 344 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
370 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 345 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
371 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 346 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
372 EXPECT_FALSE(observer_->notified()); 347 EXPECT_FALSE(observer_->notified());
373 } 348 }
374 349
375 TEST_F(GoogleURLTrackerTest, RefetchOnIPAddressChange) { 350 TEST_F(GoogleURLTrackerTest, RefetchOnIPAddressChange) {
376 CreateRequestContext();
377 RequestServerCheck(); 351 RequestServerCheck();
378 FinishSleep(); 352 FinishSleep();
379 MockSearchDomainCheckResponse(0, ".google.co.uk"); 353 MockSearchDomainCheckResponse(0, ".google.co.uk");
380 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 354 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
381 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 355 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
382 EXPECT_TRUE(observer_->notified()); 356 EXPECT_TRUE(observer_->notified());
383 observer_->clear_notified(); 357 observer_->clear_notified();
384 358
385 NotifyIPAddressChanged(); 359 NotifyIPAddressChanged();
386 MockSearchDomainCheckResponse(1, ".google.co.in"); 360 MockSearchDomainCheckResponse(1, ".google.co.in");
387 EXPECT_EQ(GURL("http://www.google.co.in/"), GetFetchedGoogleURL()); 361 EXPECT_EQ(GURL("http://www.google.co.in/"), GetFetchedGoogleURL());
388 // Just fetching a new URL shouldn't reset things without a prompt. 362 // Just fetching a new URL shouldn't reset things without a prompt.
389 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 363 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
390 EXPECT_FALSE(observer_->notified()); 364 EXPECT_FALSE(observer_->notified());
391 } 365 }
392 366
393 TEST_F(GoogleURLTrackerTest, DontRefetchWhenNoOneRequestsCheck) { 367 TEST_F(GoogleURLTrackerTest, DontRefetchWhenNoOneRequestsCheck) {
394 CreateRequestContext();
395 FinishSleep(); 368 FinishSleep();
396 NotifyIPAddressChanged(); 369 NotifyIPAddressChanged();
397 // No one called RequestServerCheck() so nothing should have happened. 370 // No one called RequestServerCheck() so nothing should have happened.
398 EXPECT_FALSE(GetFetcherByID(0)); 371 EXPECT_FALSE(GetFetcherByID(0));
399 ExpectDefaultURLs(); 372 ExpectDefaultURLs();
400 EXPECT_FALSE(observer_->notified()); 373 EXPECT_FALSE(observer_->notified());
401 } 374 }
402 375
403 TEST_F(GoogleURLTrackerTest, FetchOnLateRequest) { 376 TEST_F(GoogleURLTrackerTest, FetchOnLateRequest) {
404 CreateRequestContext();
405 FinishSleep(); 377 FinishSleep();
406 NotifyIPAddressChanged(); 378 NotifyIPAddressChanged();
407 379
408 RequestServerCheck(); 380 RequestServerCheck();
409 // The first request for a check should trigger a fetch if it hasn't happened 381 // The first request for a check should trigger a fetch if it hasn't happened
410 // already. 382 // already.
411 MockSearchDomainCheckResponse(0, ".google.co.uk"); 383 MockSearchDomainCheckResponse(0, ".google.co.uk");
412 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 384 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
413 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 385 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
414 EXPECT_TRUE(observer_->notified()); 386 EXPECT_TRUE(observer_->notified());
415 } 387 }
416 388
417 TEST_F(GoogleURLTrackerTest, SearchingDoesNothingIfNoNeedToPrompt) { 389 TEST_F(GoogleURLTrackerTest, SearchingDoesNothingIfNoNeedToPrompt) {
418 CreateRequestContext();
419 RequestServerCheck(); 390 RequestServerCheck();
420 FinishSleep(); 391 FinishSleep();
421 MockSearchDomainCheckResponse(0, ".google.co.uk"); 392 MockSearchDomainCheckResponse(0, ".google.co.uk");
422 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 393 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
423 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 394 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
424 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 395 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
425 EXPECT_TRUE(observer_->notified()); 396 EXPECT_TRUE(observer_->notified());
426 observer_->clear_notified(); 397 observer_->clear_notified();
427 398
428 SearchCommitted(GURL("http://www.google.co.uk/search?q=test")); 399 SearchCommitted(GURL("http://www.google.co.uk/search?q=test"));
429 NavEntryCommitted(); 400 NavEntryCommitted();
430 EXPECT_FALSE(InfoBarIsShown()); 401 EXPECT_FALSE(InfoBarIsShown());
431 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL()); 402 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetFetchedGoogleURL());
432 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL()); 403 EXPECT_EQ(GURL("http://www.google.co.uk/"), GoogleURLTracker::GoogleURL());
433 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 404 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
434 EXPECT_FALSE(observer_->notified()); 405 EXPECT_FALSE(observer_->notified());
435 } 406 }
436 407
437 TEST_F(GoogleURLTrackerTest, InfobarClosed) { 408 TEST_F(GoogleURLTrackerTest, InfobarClosed) {
438 CreateRequestContext();
439 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); 409 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/"));
440 RequestServerCheck(); 410 RequestServerCheck();
441 FinishSleep(); 411 FinishSleep();
442 MockSearchDomainCheckResponse(0, ".google.co.jp"); 412 MockSearchDomainCheckResponse(0, ".google.co.jp");
443 413
444 SearchCommitted(GURL("http://www.google.co.uk/search?q=test")); 414 SearchCommitted(GURL("http://www.google.co.uk/search?q=test"));
445 NavEntryCommitted(); 415 NavEntryCommitted();
446 EXPECT_TRUE(InfoBarIsShown()); 416 EXPECT_TRUE(InfoBarIsShown());
447 417
448 InfoBarClosed(); 418 InfoBarClosed();
449 EXPECT_FALSE(InfoBarIsShown()); 419 EXPECT_FALSE(InfoBarIsShown());
450 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), 420 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage),
451 GoogleURLTracker::GoogleURL()); 421 GoogleURLTracker::GoogleURL());
452 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL()); 422 EXPECT_EQ(GURL("http://www.google.co.uk/"), GetLastPromptedGoogleURL());
453 EXPECT_FALSE(observer_->notified()); 423 EXPECT_FALSE(observer_->notified());
454 } 424 }
455 425
456 TEST_F(GoogleURLTrackerTest, InfobarRefused) { 426 TEST_F(GoogleURLTrackerTest, InfobarRefused) {
457 CreateRequestContext();
458 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); 427 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/"));
459 RequestServerCheck(); 428 RequestServerCheck();
460 FinishSleep(); 429 FinishSleep();
461 MockSearchDomainCheckResponse(0, ".google.co.jp"); 430 MockSearchDomainCheckResponse(0, ".google.co.jp");
462 431
463 SearchCommitted(GURL("http://www.google.co.uk/search?q=test")); 432 SearchCommitted(GURL("http://www.google.co.uk/search?q=test"));
464 NavEntryCommitted(); 433 NavEntryCommitted();
465 EXPECT_TRUE(InfoBarIsShown()); 434 EXPECT_TRUE(InfoBarIsShown());
466 435
467 CancelGoogleURL(); 436 CancelGoogleURL();
468 InfoBarClosed(); 437 InfoBarClosed();
469 EXPECT_FALSE(InfoBarIsShown()); 438 EXPECT_FALSE(InfoBarIsShown());
470 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), 439 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage),
471 GoogleURLTracker::GoogleURL()); 440 GoogleURLTracker::GoogleURL());
472 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); 441 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL());
473 EXPECT_FALSE(observer_->notified()); 442 EXPECT_FALSE(observer_->notified());
474 } 443 }
475 444
476 TEST_F(GoogleURLTrackerTest, InfobarAccepted) { 445 TEST_F(GoogleURLTrackerTest, InfobarAccepted) {
477 CreateRequestContext();
478 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/")); 446 SetLastPromptedGoogleURL(GURL("http://www.google.co.uk/"));
479 RequestServerCheck(); 447 RequestServerCheck();
480 FinishSleep(); 448 FinishSleep();
481 MockSearchDomainCheckResponse(0, ".google.co.jp"); 449 MockSearchDomainCheckResponse(0, ".google.co.jp");
482 450
483 SearchCommitted(GURL("http://www.google.co.uk/search?q=test")); 451 SearchCommitted(GURL("http://www.google.co.uk/search?q=test"));
484 NavEntryCommitted(); 452 NavEntryCommitted();
485 EXPECT_TRUE(InfoBarIsShown()); 453 EXPECT_TRUE(InfoBarIsShown());
486 454
487 AcceptGoogleURL(); 455 AcceptGoogleURL();
488 InfoBarClosed(); 456 InfoBarClosed();
489 EXPECT_FALSE(InfoBarIsShown()); 457 EXPECT_FALSE(InfoBarIsShown());
490 EXPECT_EQ(GURL("http://www.google.co.jp/"), GoogleURLTracker::GoogleURL()); 458 EXPECT_EQ(GURL("http://www.google.co.jp/"), GoogleURLTracker::GoogleURL());
491 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); 459 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL());
492 EXPECT_TRUE(observer_->notified()); 460 EXPECT_TRUE(observer_->notified());
493 } 461 }
OLDNEW
« no previous file with comments | « chrome/browser/google/google_url_tracker.cc ('k') | chrome/browser/intranet_redirect_detector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698