| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h" | 10 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h" |
| 11 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 11 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
| 12 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 12 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
| 13 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 14 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 14 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 15 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 15 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 16 #include "content/public/browser/interstitial_page.h" | 17 #include "content/public/browser/interstitial_page.h" |
| 17 #include "content/public/browser/navigation_controller.h" | 18 #include "content/public/browser/navigation_controller.h" |
| 18 #include "content/public/browser/navigation_entry.h" | 19 #include "content/public/browser/navigation_entry.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/test/web_contents_tester.h" | 21 #include "content/public/test/web_contents_tester.h" |
| 21 | 22 |
| 22 using content::InterstitialPage; | 23 using content::InterstitialPage; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 merge_session_throttling_utils::CompletionCallback()) { | 45 merge_session_throttling_utils::CompletionCallback()) { |
| 45 interstitial_page_->DontCreateViewForTesting(); | 46 interstitial_page_->DontCreateViewForTesting(); |
| 46 } | 47 } |
| 47 | 48 |
| 48 private: | 49 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(TestMergeSessionLoadPage); | 50 DISALLOW_COPY_AND_ASSIGN(TestMergeSessionLoadPage); |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 class MergeSessionLoadPageTest : public ChromeRenderViewHostTestHarness { | 53 class MergeSessionLoadPageTest : public ChromeRenderViewHostTestHarness { |
| 53 protected: | 54 protected: |
| 55 void SetUp() override { |
| 56 ChromeRenderViewHostTestHarness::SetUp(); |
| 57 #if defined OS_CHROMEOS |
| 58 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| 59 #endif |
| 60 } |
| 61 |
| 54 void TearDown() override { | 62 void TearDown() override { |
| 63 #if defined OS_CHROMEOS |
| 64 // Clean up pending tasks that might depend on the user manager. |
| 65 base::RunLoop().RunUntilIdle(); |
| 66 test_user_manager_.reset(); |
| 67 #endif |
| 55 ChromeRenderViewHostTestHarness::TearDown(); | 68 ChromeRenderViewHostTestHarness::TearDown(); |
| 56 } | 69 } |
| 57 | 70 |
| 58 void Navigate(const char* url, | 71 void Navigate(const char* url, |
| 59 int nav_entry_id, | 72 int nav_entry_id, |
| 60 bool did_create_new_entry) { | 73 bool did_create_new_entry) { |
| 61 WebContentsTester::For(web_contents()) | 74 WebContentsTester::For(web_contents()) |
| 62 ->TestDidNavigate(web_contents()->GetMainFrame(), nav_entry_id, | 75 ->TestDidNavigate(web_contents()->GetMainFrame(), nav_entry_id, |
| 63 did_create_new_entry, GURL(url), | 76 did_create_new_entry, GURL(url), |
| 64 ui::PAGE_TRANSITION_TYPED); | 77 ui::PAGE_TRANSITION_TYPED); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 111 |
| 99 void SetSessionRestoreStart(const base::Time& time) { | 112 void SetSessionRestoreStart(const base::Time& time) { |
| 100 OAuth2LoginManager* login_manager = GetOAuth2LoginManager(); | 113 OAuth2LoginManager* login_manager = GetOAuth2LoginManager(); |
| 101 ASSERT_TRUE(login_manager); | 114 ASSERT_TRUE(login_manager); |
| 102 login_manager->SetSessionRestoreStartForTesting(time); | 115 login_manager->SetSessionRestoreStartForTesting(time); |
| 103 } | 116 } |
| 104 | 117 |
| 105 private: | 118 private: |
| 106 ScopedTestDeviceSettingsService test_device_settings_service_; | 119 ScopedTestDeviceSettingsService test_device_settings_service_; |
| 107 ScopedTestCrosSettings test_cros_settings_; | 120 ScopedTestCrosSettings test_cros_settings_; |
| 121 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 108 }; | 122 }; |
| 109 | 123 |
| 110 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShown) { | 124 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShown) { |
| 111 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE); | 125 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE); |
| 112 // Start a load. | 126 // Start a load. |
| 113 Navigate(kURL1, 0, true); | 127 Navigate(kURL1, 0, true); |
| 114 // Load next page. | 128 // Load next page. |
| 115 controller().LoadURL(GURL(kURL2), content::Referrer(), | 129 controller().LoadURL(GURL(kURL2), content::Referrer(), |
| 116 ui::PAGE_TRANSITION_TYPED, std::string()); | 130 ui::PAGE_TRANSITION_TYPED, std::string()); |
| 117 | 131 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 176 |
| 163 // The URL remains to be URL2. | 177 // The URL remains to be URL2. |
| 164 EXPECT_EQ(kURL2, web_contents()->GetVisibleURL().spec()); | 178 EXPECT_EQ(kURL2, web_contents()->GetVisibleURL().spec()); |
| 165 | 179 |
| 166 // Commit navigation and the interstitial page is gone. | 180 // Commit navigation and the interstitial page is gone. |
| 167 Navigate(kURL2, pending_id, true); | 181 Navigate(kURL2, pending_id, true); |
| 168 EXPECT_FALSE(GetMergeSessionLoadPage()); | 182 EXPECT_FALSE(GetMergeSessionLoadPage()); |
| 169 } | 183 } |
| 170 | 184 |
| 171 } // namespace chromeos | 185 } // namespace chromeos |
| OLD | NEW |