| 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/prefs/scoped_user_pref_update.h" | 7 #include "base/prefs/scoped_user_pref_update.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/content_settings/cookie_settings.h" | 9 #include "chrome/browser/content_settings/cookie_settings.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 ASSERT_EQ(info1.pid, info2.pid); | 246 ASSERT_EQ(info1.pid, info2.pid); |
| 247 ASSERT_NE(info1.pid, info3.pid); | 247 ASSERT_NE(info1.pid, info3.pid); |
| 248 } | 248 } |
| 249 | 249 |
| 250 #if !defined(OS_CHROMEOS) | 250 #if !defined(OS_CHROMEOS) |
| 251 | 251 |
| 252 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) { | 252 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoProfile) { |
| 253 std::string error_message; | 253 std::string error_message; |
| 254 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( | 254 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( |
| 255 NULL, InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 255 NULL, InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 256 "user@gmail.com", &error_message)); | 256 "12345", "user@gmail.com", &error_message)); |
| 257 EXPECT_EQ("", error_message); | 257 EXPECT_EQ("", error_message); |
| 258 } | 258 } |
| 259 | 259 |
| 260 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOffer) { | 260 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOffer) { |
| 261 EnableOneClick(true); | 261 EnableOneClick(true); |
| 262 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 262 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 263 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 263 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 264 "user@gmail.com", NULL)); | 264 "12345", "user@gmail.com", NULL)); |
| 265 | 265 |
| 266 EnableOneClick(false); | 266 EnableOneClick(false); |
| 267 | 267 |
| 268 std::string error_message; | 268 std::string error_message; |
| 269 | 269 |
| 270 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 270 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 271 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 271 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 272 "user@gmail.com", &error_message)); | 272 "12345", "user@gmail.com", &error_message)); |
| 273 } | 273 } |
| 274 | 274 |
| 275 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferProfileConnected) { | 275 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferProfileConnected) { |
| 276 SetUpSigninManager("foo@gmail.com"); | 276 SetUpSigninManager("foo@gmail.com"); |
| 277 EnableSigninAllowed(true); | 277 EnableSigninAllowed(true); |
| 278 | 278 |
| 279 std::string error_message; | 279 std::string error_message; |
| 280 | 280 |
| 281 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 281 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 282 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 282 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 283 "foo@gmail.com", &error_message)); | 283 "12345", "foo@gmail.com", &error_message)); |
| 284 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 284 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 285 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 285 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 286 "foo", &error_message)); | 286 "12345", "foo", &error_message)); |
| 287 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( | 287 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( |
| 288 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 288 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 289 "user@gmail.com", &error_message)); | 289 "12345", "user@gmail.com", &error_message)); |
| 290 EXPECT_EQ(l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, | 290 EXPECT_EQ(l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, |
| 291 base::UTF8ToUTF16("foo@gmail.com")), | 291 base::UTF8ToUTF16("foo@gmail.com")), |
| 292 error_message); | 292 error_message); |
| 293 } | 293 } |
| 294 | 294 |
| 295 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferUsernameNotAllowed) { | 295 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferUsernameNotAllowed) { |
| 296 SetAllowedUsernamePattern("*.google.com"); | 296 SetAllowedUsernamePattern("*.google.com"); |
| 297 | 297 |
| 298 std::string error_message; | 298 std::string error_message; |
| 299 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( | 299 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( |
| 300 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 300 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 301 "foo@gmail.com", &error_message)); | 301 "12345", "foo@gmail.com", &error_message)); |
| 302 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED), | 302 EXPECT_EQ(l10n_util::GetStringUTF8(IDS_SYNC_LOGIN_NAME_PROHIBITED), |
| 303 error_message); | 303 error_message); |
| 304 } | 304 } |
| 305 | 305 |
| 306 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferWithRejectedEmail) { | 306 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferWithRejectedEmail) { |
| 307 EnableSigninAllowed(true); | 307 EnableSigninAllowed(true); |
| 308 | 308 |
| 309 AddEmailToOneClickRejectedList("foo@gmail.com"); | 309 AddEmailToOneClickRejectedList("foo@gmail.com"); |
| 310 AddEmailToOneClickRejectedList("user@gmail.com"); | 310 AddEmailToOneClickRejectedList("user@gmail.com"); |
| 311 | 311 |
| 312 std::string error_message; | 312 std::string error_message; |
| 313 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 313 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 314 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 314 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 315 "foo@gmail.com", &error_message)); | 315 "12345", "foo@gmail.com", &error_message)); |
| 316 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( | 316 EXPECT_TRUE(InlineLoginHandlerImpl::CanOffer( |
| 317 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 317 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 318 "user@gmail.com", &error_message)); | 318 "12345", "user@gmail.com", &error_message)); |
| 319 } | 319 } |
| 320 | 320 |
| 321 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoSigninCookies) { | 321 IN_PROC_BROWSER_TEST_F(InlineLoginUIBrowserTest, CanOfferNoSigninCookies) { |
| 322 AllowSigninCookies(false); | 322 AllowSigninCookies(false); |
| 323 EnableSigninAllowed(true); | 323 EnableSigninAllowed(true); |
| 324 | 324 |
| 325 std::string error_message; | 325 std::string error_message; |
| 326 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( | 326 EXPECT_FALSE(InlineLoginHandlerImpl::CanOffer( |
| 327 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, | 327 browser()->profile(), InlineLoginHandlerImpl::CAN_OFFER_FOR_ALL, |
| 328 "user@gmail.com", &error_message)); | 328 "12345", "user@gmail.com", &error_message)); |
| 329 EXPECT_EQ("", error_message); | 329 EXPECT_EQ("", error_message); |
| 330 } | 330 } |
| 331 | 331 |
| 332 #endif // OS_CHROMEOS | 332 #endif // OS_CHROMEOS |
| 333 | 333 |
| 334 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { | 334 class InlineLoginUISafeIframeBrowserTest : public InProcessBrowserTest { |
| 335 public: | 335 public: |
| 336 FooWebUIProvider& foo_provider() { return foo_provider_; } | 336 FooWebUIProvider& foo_provider() { return foo_provider_; } |
| 337 | 337 |
| 338 private: | 338 private: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 ->AddObserver(&observer); | 466 ->AddObserver(&observer); |
| 467 base::RunLoop run_loop; | 467 base::RunLoop run_loop; |
| 468 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) | 468 EXPECT_CALL(observer, OnUntrustedLoginUIShown()) |
| 469 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 469 .WillOnce(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 470 | 470 |
| 471 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); | 471 ExecuteJsToSigninInSigninFrame(browser(), "email@gmail.com", "password"); |
| 472 run_loop.Run(); | 472 run_loop.Run(); |
| 473 base::MessageLoop::current()->RunUntilIdle(); | 473 base::MessageLoop::current()->RunUntilIdle(); |
| 474 } | 474 } |
| 475 #endif // OS_CHROMEOS | 475 #endif // OS_CHROMEOS |
| OLD | NEW |