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

Side by Side Diff: chrome/browser/chromeos/login/signin/merge_session_load_page_unittest.cc

Issue 562603002: Move PageTransition from //content/public/common to //ui/base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
OLDNEW
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 "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/time/time.h" 6 #include "base/time/time.h"
7 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h" 7 #include "chrome/browser/chromeos/login/signin/merge_session_load_page.h"
8 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" 8 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
9 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" 9 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h"
10 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 10 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 // Clean up pending tasks that might depend on the user manager. 66 // Clean up pending tasks that might depend on the user manager.
67 base::RunLoop().RunUntilIdle(); 67 base::RunLoop().RunUntilIdle();
68 test_user_manager_.reset(); 68 test_user_manager_.reset();
69 #endif 69 #endif
70 ChromeRenderViewHostTestHarness::TearDown(); 70 ChromeRenderViewHostTestHarness::TearDown();
71 } 71 }
72 72
73 void Navigate(const char* url, int page_id) { 73 void Navigate(const char* url, int page_id) {
74 WebContentsTester::For(web_contents())->TestDidNavigate( 74 WebContentsTester::For(web_contents())->TestDidNavigate(
75 web_contents()->GetMainFrame(), page_id, GURL(url), 75 web_contents()->GetMainFrame(), page_id, GURL(url),
76 content::PAGE_TRANSITION_TYPED); 76 ui::PAGE_TRANSITION_TYPED);
77 } 77 }
78 78
79 void ShowInterstitial(const char* url) { 79 void ShowInterstitial(const char* url) {
80 (new TestMergeSessionLoadPage(web_contents(), GURL(url), this))->Show(); 80 (new TestMergeSessionLoadPage(web_contents(), GURL(url), this))->Show();
81 } 81 }
82 82
83 // Returns the MergeSessionLoadPage currently showing or NULL if none is 83 // Returns the MergeSessionLoadPage currently showing or NULL if none is
84 // showing. 84 // showing.
85 InterstitialPage* GetMergeSessionLoadPage() { 85 InterstitialPage* GetMergeSessionLoadPage() {
86 return InterstitialPage::GetInterstitialPage(web_contents()); 86 return InterstitialPage::GetInterstitialPage(web_contents());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ScopedTestCrosSettings test_cros_settings_; 119 ScopedTestCrosSettings test_cros_settings_;
120 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; 120 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
121 }; 121 };
122 122
123 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShown) { 123 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShown) {
124 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE); 124 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE);
125 // Start a load. 125 // Start a load.
126 Navigate(kURL1, 1); 126 Navigate(kURL1, 1);
127 // Load next page. 127 // Load next page.
128 controller().LoadURL(GURL(kURL2), content::Referrer(), 128 controller().LoadURL(GURL(kURL2), content::Referrer(),
129 content::PAGE_TRANSITION_TYPED, std::string()); 129 ui::PAGE_TRANSITION_TYPED, std::string());
130 130
131 // Simulate the load causing an merge session interstitial page 131 // Simulate the load causing an merge session interstitial page
132 // to be shown. 132 // to be shown.
133 InterstitialPage* interstitial = GetMergeSessionLoadPage(); 133 InterstitialPage* interstitial = GetMergeSessionLoadPage();
134 EXPECT_FALSE(interstitial); 134 EXPECT_FALSE(interstitial);
135 } 135 }
136 136
137 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShownOnTimeout) { 137 TEST_F(MergeSessionLoadPageTest, MergeSessionPageNotShownOnTimeout) {
138 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS); 138 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS);
139 SetSessionRestoreStart( 139 SetSessionRestoreStart(
140 base::Time::Now() + 140 base::Time::Now() +
141 base::TimeDelta::FromSeconds(kSessionMergeTimeout + 1)); 141 base::TimeDelta::FromSeconds(kSessionMergeTimeout + 1));
142 142
143 // Start a load. 143 // Start a load.
144 Navigate(kURL1, 1); 144 Navigate(kURL1, 1);
145 // Load next page. 145 // Load next page.
146 controller().LoadURL(GURL(kURL2), content::Referrer(), 146 controller().LoadURL(GURL(kURL2), content::Referrer(),
147 content::PAGE_TRANSITION_TYPED, std::string()); 147 ui::PAGE_TRANSITION_TYPED, std::string());
148 148
149 // Simulate the load causing an merge session interstitial page 149 // Simulate the load causing an merge session interstitial page
150 // to be shown. 150 // to be shown.
151 InterstitialPage* interstitial = GetMergeSessionLoadPage(); 151 InterstitialPage* interstitial = GetMergeSessionLoadPage();
152 EXPECT_FALSE(interstitial); 152 EXPECT_FALSE(interstitial);
153 } 153 }
154 154
155 TEST_F(MergeSessionLoadPageTest, MergeSessionPageShown) { 155 TEST_F(MergeSessionLoadPageTest, MergeSessionPageShown) {
156 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS); 156 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_IN_PROGRESS);
157 157
158 // Start a load. 158 // Start a load.
159 Navigate(kURL1, 1); 159 Navigate(kURL1, 1);
160 // Load next page. 160 // Load next page.
161 controller().LoadURL(GURL(kURL2), content::Referrer(), 161 controller().LoadURL(GURL(kURL2), content::Referrer(),
162 content::PAGE_TRANSITION_TYPED, std::string()); 162 ui::PAGE_TRANSITION_TYPED, std::string());
163 163
164 // Simulate the load causing an merge session interstitial page 164 // Simulate the load causing an merge session interstitial page
165 // to be shown. 165 // to be shown.
166 ShowInterstitial(kURL2); 166 ShowInterstitial(kURL2);
167 InterstitialPage* interstitial = GetMergeSessionLoadPage(); 167 InterstitialPage* interstitial = GetMergeSessionLoadPage();
168 ASSERT_TRUE(interstitial); 168 ASSERT_TRUE(interstitial);
169 base::RunLoop().RunUntilIdle(); 169 base::RunLoop().RunUntilIdle();
170 170
171 // Simulate merge session completion. 171 // Simulate merge session completion.
172 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE); 172 SetMergeSessionState(OAuth2LoginManager::SESSION_RESTORE_DONE);
173 base::RunLoop().RunUntilIdle(); 173 base::RunLoop().RunUntilIdle();
174 174
175 // The URL remains to be URL2. 175 // The URL remains to be URL2.
176 EXPECT_EQ(kURL2, web_contents()->GetVisibleURL().spec()); 176 EXPECT_EQ(kURL2, web_contents()->GetVisibleURL().spec());
177 177
178 // Commit navigation and the interstitial page is gone. 178 // Commit navigation and the interstitial page is gone.
179 Navigate(kURL2, 2); 179 Navigate(kURL2, 2);
180 EXPECT_FALSE(GetMergeSessionLoadPage()); 180 EXPECT_FALSE(GetMergeSessionLoadPage());
181 } 181 }
182 182
183 } // namespace chromeos 183 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698