| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ | 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 SigninManager* signin = SigninManagerFactory::GetForProfile( | 200 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 201 browser()->profile()); | 201 browser()->profile()); |
| 202 EXPECT_FALSE(signin->HasSigninProcess()); | 202 EXPECT_FALSE(signin->HasSigninProcess()); |
| 203 | 203 |
| 204 ui_test_utils::NavigateToURL(browser(), start_url); | 204 ui_test_utils::NavigateToURL(browser(), start_url); |
| 205 EXPECT_EQ(kOneClickSigninEnabled, signin->HasSigninProcess()); | 205 EXPECT_EQ(kOneClickSigninEnabled, signin->HasSigninProcess()); |
| 206 | 206 |
| 207 content::WebContents* web_contents = | 207 content::WebContents* web_contents = |
| 208 browser()->tab_strip_model()->GetActiveWebContents(); | 208 browser()->tab_strip_model()->GetActiveWebContents(); |
| 209 | 209 |
| 210 // Simulate clicking on the Skip for now link by navigating to the URL. | 210 // Simulate clicking on the Skip for now link. It's important to have a |
| 211 ui_test_utils::NavigateToURL(browser(), skip_url); | 211 // link transition so that OneClickSigninHelper removes the blank page |
| 212 // from the history. |
| 213 chrome::NavigateParams navigate_params(browser(), |
| 214 skip_url, |
| 215 content::PAGE_TRANSITION_LINK); |
| 216 ui_test_utils::NavigateToURL(&navigate_params); |
| 212 | 217 |
| 213 // Register an observer that will navigate back immediately on the commit of | 218 // Register an observer that will navigate back immediately on the commit of |
| 214 // the NTP. This will allow us to hit the race condition of navigating back | 219 // the NTP. This will allow us to hit the race condition of navigating back |
| 215 // before the DidStopLoading message of NTP gets delivered. This must be | 220 // before the DidStopLoading message of NTP gets delivered. This must be |
| 216 // created after the navigation to the skip_url has finished loading, | 221 // created after the navigation to the skip_url has finished loading, |
| 217 // otherwise this observer will navigate back, before the history cleaner | 222 // otherwise this observer will navigate back, before the history cleaner |
| 218 // has had a chance to remove the navigation entry. | 223 // has had a chance to remove the navigation entry. |
| 219 BackOnNTPCommitObserver commit_observer(web_contents); | 224 BackOnNTPCommitObserver commit_observer(web_contents); |
| 220 | 225 |
| 221 // Since the navigation to the blank URL is monitored for, the | 226 // Since the navigation to the blank URL is monitored for, the |
| 222 // OneClickSigninHelper initiates immediately a navigation to the NTP. | 227 // OneClickSigninHelper initiates immediately a navigation to the NTP. |
| 223 // Thus, we expect the visible URL to be the NTP. | 228 // Thus, we expect the visible URL to be the NTP. |
| 224 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); | 229 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); |
| 225 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); | 230 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); |
| 226 | 231 |
| 227 content::WindowedNotificationObserver observer( | 232 content::WindowedNotificationObserver observer( |
| 228 content::NOTIFICATION_LOAD_STOP, | 233 content::NOTIFICATION_LOAD_STOP, |
| 229 content::NotificationService::AllSources()); | 234 content::NotificationService::AllSources()); |
| 230 observer.Wait(); | 235 observer.Wait(); |
| 231 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); | 236 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); |
| 232 } | 237 } |
| 233 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ | 238 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ |
| OLD | NEW |