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