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

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: Address review comments 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 return CommandLine::ForCurrentProcess()->HasSwitch(
53 switches::kUseWebBasedSigninFlow);
54 }
55
51 class SigninManagerMock : public FakeSigninManager { 56 class SigninManagerMock : public FakeSigninManager {
52 public: 57 public:
53 explicit SigninManagerMock(Profile* profile) 58 explicit SigninManagerMock(Profile* profile)
54 : FakeSigninManager(profile) {} 59 : FakeSigninManager(profile) {}
55 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); 60 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username));
56 }; 61 };
57 62
58 class TestProfileIOData : public ProfileIOData { 63 class TestProfileIOData : public ProfileIOData {
59 public: 64 public:
60 TestProfileIOData(bool is_incognito, PrefService* pref_service, 65 TestProfileIOData(bool is_incognito, PrefService* pref_service,
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 true)); 350 true));
346 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), "", false)); 351 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), "", false));
347 } 352 }
348 353
349 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) { 354 TEST_F(OneClickSigninHelperTest, CanOfferFirstSetup) {
350 CreateSigninManager(false, ""); 355 CreateSigninManager(false, "");
351 356
352 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). 357 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
353 WillRepeatedly(Return(true)); 358 WillRepeatedly(Return(true));
354 359
355 // Invoke OneClickTestProfileSyncService factory function and grab result. 360 // Invoke OneClickTestProfileSyncService factory function and grab result.
356 OneClickTestProfileSyncService* sync = 361 OneClickTestProfileSyncService* sync =
357 static_cast<OneClickTestProfileSyncService*>( 362 static_cast<OneClickTestProfileSyncService*>(
358 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse( 363 ProfileSyncServiceFactory::GetInstance()->SetTestingFactoryAndUse(
359 static_cast<Profile*>(browser_context()), 364 static_cast<Profile*>(browser_context()),
360 OneClickTestProfileSyncService::Build)); 365 OneClickTestProfileSyncService::Build));
361 366
362 sync->set_first_setup_in_progress(true); 367 sync->set_first_setup_in_progress(true);
363 368
364 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), 369 EXPECT_EQ(UseWebBasedSigninFlow(),
365 "foo@gmail.com", 370 OneClickSigninHelper::CanOffer(web_contents(),
366 true)); 371 "foo@gmail.com",
367 EXPECT_TRUE(OneClickSigninHelper::CanOffer(web_contents(), 372 true));
368 "foo@gmail.com", 373 EXPECT_TRUE(OneClickSigninHelper::CanOffer(web_contents(),
369 false)); 374 "foo@gmail.com",
375 false));
370 } 376 }
371 377
372 TEST_F(OneClickSigninHelperTest, CanOfferProfileConnected) { 378 TEST_F(OneClickSigninHelperTest, CanOfferProfileConnected) {
373 CreateSigninManager(false, "foo@gmail.com"); 379 CreateSigninManager(false, "foo@gmail.com");
374 380
375 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). 381 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)).
376 WillRepeatedly(Return(true)); 382 WillRepeatedly(Return(true));
377 383
378 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(), 384 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents(),
379 "foo@gmail.com", 385 "foo@gmail.com",
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 valid_gaia_url_, "", &request_, io_data.get())); 561 valid_gaia_url_, "", &request_, io_data.get()));
556 } 562 }
557 563
558 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadNoSigninCookies) { 564 TEST_F(OneClickSigninHelperIOTest, CanOfferOnIOThreadNoSigninCookies) {
559 AllowSigninCookies(false); 565 AllowSigninCookies(false);
560 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false)); 566 scoped_ptr<TestProfileIOData> io_data(CreateTestProfileIOData(false));
561 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER, 567 EXPECT_EQ(OneClickSigninHelper::DONT_OFFER,
562 OneClickSigninHelper::CanOfferOnIOThreadImpl( 568 OneClickSigninHelper::CanOfferOnIOThreadImpl(
563 valid_gaia_url_, "", &request_, io_data.get())); 569 valid_gaia_url_, "", &request_, io_data.get()));
564 } 570 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.cc ('k') | chrome/browser/ui/sync/one_click_signin_sync_starter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698