| OLD | NEW |
| 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/browser_thread.h" | 10 #include "chrome/browser/browser_thread.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 notified_ = true; | 53 notified_ = true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 | 56 |
| 57 // TestInfoBarDelegate -------------------------------------------------------- | 57 // TestInfoBarDelegate -------------------------------------------------------- |
| 58 | 58 |
| 59 class TestInfoBarDelegate : public InfoBarDelegate { | 59 class TestInfoBarDelegate : public InfoBarDelegate { |
| 60 public: | 60 public: |
| 61 TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, | 61 TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, |
| 62 const GURL& new_google_url); | 62 const GURL& new_google_url); |
| 63 virtual ~TestInfoBarDelegate(); | |
| 64 | |
| 65 // InfoBarDelegate | |
| 66 virtual InfoBar* CreateInfoBar(); | |
| 67 | 63 |
| 68 GoogleURLTracker* google_url_tracker() const { return google_url_tracker_; } | 64 GoogleURLTracker* google_url_tracker() const { return google_url_tracker_; } |
| 69 GURL new_google_url() const { return new_google_url_; } | 65 GURL new_google_url() const { return new_google_url_; } |
| 70 | 66 |
| 71 private: | 67 private: |
| 68 virtual ~TestInfoBarDelegate(); |
| 69 |
| 70 // InfoBarDelegate: |
| 71 virtual InfoBar* CreateInfoBar(); |
| 72 |
| 72 GoogleURLTracker* google_url_tracker_; | 73 GoogleURLTracker* google_url_tracker_; |
| 73 GURL new_google_url_; | 74 GURL new_google_url_; |
| 74 }; | 75 }; |
| 75 | 76 |
| 76 TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, | 77 TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTracker* google_url_tracker, |
| 77 const GURL& new_google_url) | 78 const GURL& new_google_url) |
| 78 : InfoBarDelegate(NULL), | 79 : InfoBarDelegate(NULL), |
| 79 google_url_tracker_(google_url_tracker), | 80 google_url_tracker_(google_url_tracker), |
| 80 new_google_url_(new_google_url) { | 81 new_google_url_(new_google_url) { |
| 81 } | 82 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 ASSERT_TRUE(infobar->google_url_tracker()); | 293 ASSERT_TRUE(infobar->google_url_tracker()); |
| 293 infobar->google_url_tracker()->CancelGoogleURL(infobar->new_google_url()); | 294 infobar->google_url_tracker()->CancelGoogleURL(infobar->new_google_url()); |
| 294 } | 295 } |
| 295 | 296 |
| 296 void GoogleURLTrackerTest::InfoBarClosed() { | 297 void GoogleURLTrackerTest::InfoBarClosed() { |
| 297 TestInfoBarDelegate* infobar = static_cast<TestInfoBarDelegate*>( | 298 TestInfoBarDelegate* infobar = static_cast<TestInfoBarDelegate*>( |
| 298 g_browser_process->google_url_tracker()->infobar_); | 299 g_browser_process->google_url_tracker()->infobar_); |
| 299 ASSERT_TRUE(infobar); | 300 ASSERT_TRUE(infobar); |
| 300 ASSERT_TRUE(infobar->google_url_tracker()); | 301 ASSERT_TRUE(infobar->google_url_tracker()); |
| 301 infobar->google_url_tracker()->InfoBarClosed(); | 302 infobar->google_url_tracker()->InfoBarClosed(); |
| 302 delete infobar; | 303 delete g_browser_process->google_url_tracker()->infobar_; |
| 303 } | 304 } |
| 304 | 305 |
| 305 void GoogleURLTrackerTest::ExpectDefaultURLs() { | 306 void GoogleURLTrackerTest::ExpectDefaultURLs() { |
| 306 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), | 307 EXPECT_EQ(GURL(GoogleURLTracker::kDefaultGoogleHomepage), |
| 307 GoogleURLTracker::GoogleURL()); | 308 GoogleURLTracker::GoogleURL()); |
| 308 EXPECT_EQ(GURL(), GetFetchedGoogleURL()); | 309 EXPECT_EQ(GURL(), GetFetchedGoogleURL()); |
| 309 } | 310 } |
| 310 | 311 |
| 311 | 312 |
| 312 // Tests ---------------------------------------------------------------------- | 313 // Tests ---------------------------------------------------------------------- |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 NavEntryCommitted(); | 481 NavEntryCommitted(); |
| 481 EXPECT_TRUE(InfoBarIsShown()); | 482 EXPECT_TRUE(InfoBarIsShown()); |
| 482 | 483 |
| 483 AcceptGoogleURL(); | 484 AcceptGoogleURL(); |
| 484 InfoBarClosed(); | 485 InfoBarClosed(); |
| 485 EXPECT_FALSE(InfoBarIsShown()); | 486 EXPECT_FALSE(InfoBarIsShown()); |
| 486 EXPECT_EQ(GURL("http://www.google.co.jp/"), GoogleURLTracker::GoogleURL()); | 487 EXPECT_EQ(GURL("http://www.google.co.jp/"), GoogleURLTracker::GoogleURL()); |
| 487 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); | 488 EXPECT_EQ(GURL("http://www.google.co.jp/"), GetLastPromptedGoogleURL()); |
| 488 EXPECT_TRUE(observer_->notified()); | 489 EXPECT_TRUE(observer_->notified()); |
| 489 } | 490 } |
| OLD | NEW |