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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper_unittest.cc

Issue 11418200: Setup from settings should allow configuration first (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/utf_string_conversions.h" 6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/content_settings/cookie_settings.h" 7 #include "chrome/browser/content_settings/cookie_settings.h"
8 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" 9 #include "chrome/browser/prefs/scoped_user_pref_update.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 30 matching lines...) Expand all
41 41
42 // Explicit URLs are sign in URLs created by chrome for specific sign in access 42 // Explicit URLs are sign in URLs created by chrome for specific sign in access
43 // points. Implicit URLs are those to sign for some Google service, like gmail 43 // points. Implicit URLs are those to sign for some Google service, like gmail
44 // or drive. In former case, with a valid URL, we don't want to offer the 44 // or drive. In former case, with a valid URL, we don't want to offer the
45 // interstitial. In all other cases we do. 45 // interstitial. In all other cases we do.
46 46
47 const char kImplicitURLString[] = 47 const char kImplicitURLString[] =
48 "https://accounts.google.com/ServiceLogin" 48 "https://accounts.google.com/ServiceLogin"
49 "?service=foo&continue=http://foo.google.com"; 49 "?service=foo&continue=http://foo.google.com";
50 50
51 bool UseWebBasedSigninFlow() {
52 const bool use_web_based_singin_flow =
53 CommandLine::ForCurrentProcess()->HasSwitch(
54 switches::kUseWebBasedSigninFlow);
Andrew T Wilson (Slow) 2012/12/03 13:19:02 Why do we have a separate variable? Also, should b
Roger Tawa OOO till Jul 10th 2012/12/03 19:08:28 No need. Too bad we're now loosing the singin'
55 return use_web_based_singin_flow;
56 }
57
51 class SigninManagerMock : public FakeSigninManager { 58 class SigninManagerMock : public FakeSigninManager {
52 public: 59 public:
53 explicit SigninManagerMock(Profile* profile) 60 explicit SigninManagerMock(Profile* profile)
54 : FakeSigninManager(profile) {} 61 : FakeSigninManager(profile) {}
55 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); 62 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username));
56 }; 63 };
57 64
58 class TestProfileIOData : public ProfileIOData { 65 class TestProfileIOData : public ProfileIOData {
59 public: 66 public:
60 TestProfileIOData(bool is_incognito, PrefService* pref_service, 67 TestProfileIOData(bool is_incognito, PrefService* pref_service,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 true)); 352 true));
346 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), "", false)); 353 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), "", false));
347 } 354 }
348 355
349 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) { 356 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) {
350 CreateSigninManager(false, ""); 357 CreateSigninManager(false, "");
351 358
352 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). 359 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
353 WillRepeatedly(Return(true)); 360 WillRepeatedly(Return(true));
354 361
355 // Invoke OneClickTestProfileSyncService factory function and grab result. 362 // Invoke OneClickTestProfileSyncService factory function and grab result.
356 OneClickTestProfileSyncService* sync = 363 OneClickTestProfileSyncService* sync =
357 static_cast<OneClickTestProfileSyncService*>( 364 static_cast<OneClickTestProfileSyncService*>(
358 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 365 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
359 static_cast<Profile*>(browser_context()), 366 static_cast<Profile*>(browser_context()),
360 OneClickTestProfileSyncService::Build)); 367 OneClickTestProfileSyncService::Build));
361 368
362 sync->set_first_setup_in_progress(true); 369 sync->set_first_setup_in_progress(true);
363 370
364 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), 371 EXPECT_EQ(UseWebBasedSigninFlow(),
365 "foo@gmail.com", 372 OneClickSigninHelper::CanOffer(web_contents(),
366 true)); 373 "foo@gmail.com",
367 EXPECT_TRUE(OneClickSigninHelper::CanOffer(web_contents(), 374 true));
368 "foo@gmail.com", 375 EXPECT_TRUE(OneClickSigninHelper::CanOffer(web_contents(),
369 false)); 376 "foo@gmail.com",
377 false));
370 } 378 }
371 379
372 TEST_F(OneClickSigninHelperTest, CanOfferProfileConnected) { 380 TEST_F(OneClickSigninHelperTest, CanOfferProfileConnected) {
373 CreateSigninManager(false, "foo@gmail.com"); 381 CreateSigninManager(false, "foo@gmail.com");
374 382
375 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). 383 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
376 WillRepeatedly(Return(true)); 384 WillRepeatedly(Return(true));
377 385
378 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), 386 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(),
379 "foo@gmail.com", 387 "foo@gmail.com",
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 valid_gaia_url_, "", &request_, io_data.get())); 563 valid_gaia_url_, "", &request_, io_data.get()));
556 } 564 }
557 565
558 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadNoSigninCookies) { 566 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadNoSigninCookies) {
559 AllowSigninCookies(false); 567 AllowSigninCookies(false);
560 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false)); 568 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false));
561 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, 569 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER,
562 OneClickSigninHelper::CanOfferOnIOThreadImpl( 570 OneClickSigninHelper::CanOfferOnIOThreadImpl(
563 valid_gaia_url_, "", &request_, io_data.get())); 571 valid_gaia_url_, "", &request_, io_data.get()));
564 } 572 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698