OLD | NEW |
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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/content_settings/cookie_settings.h" | 6 #include "chrome/browser/content_settings/cookie_settings.h" |
7 #include "chrome/browser/prefs/pref_service.h" | 7 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 8 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 using ::testing::_; | 28 using ::testing::_; |
29 using ::testing::Mock; | 29 using ::testing::Mock; |
30 using ::testing::Return; | 30 using ::testing::Return; |
31 using ::testing::ReturnRef; | 31 using ::testing::ReturnRef; |
32 using ::testing::Values; | 32 using ::testing::Values; |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 class SigninManagerMock : public FakeSigninManager { | 36 class SigninManagerMock : public FakeSigninManager { |
37 public: | 37 public: |
38 explicit SigninManagerMock(Profile* profile) | 38 SigninManagerMock() {} |
39 : FakeSigninManager(profile) {} | |
40 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); | 39 MOCK_CONST_METHOD1(IsAllowedUsername, bool(const std::string& username)); |
41 }; | 40 }; |
42 | 41 |
43 class OneClickSigninHelperTest : public content::RenderViewHostTestHarness { | 42 class OneClickSigninHelperTest : public content::RenderViewHostTestHarness { |
44 public: | 43 public: |
45 OneClickSigninHelperTest(); | 44 OneClickSigninHelperTest(); |
46 | 45 |
47 virtual void SetUp() OVERRIDE; | 46 virtual void SetUp() OVERRIDE; |
48 | 47 |
49 protected: | 48 protected: |
(...skipping 22 matching lines...) Expand all Loading... |
72 : ui_thread_(content::BrowserThread::UI, &message_loop_) { | 71 : ui_thread_(content::BrowserThread::UI, &message_loop_) { |
73 } | 72 } |
74 | 73 |
75 void OneClickSigninHelperTest::SetUp() { | 74 void OneClickSigninHelperTest::SetUp() { |
76 // Don't call base class so that default browser context and test WebContents | 75 // Don't call base class so that default browser context and test WebContents |
77 // are not created now. They will be created in CreateMockWebContents() | 76 // are not created now. They will be created in CreateMockWebContents() |
78 // as needed. | 77 // as needed. |
79 } | 78 } |
80 | 79 |
81 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { | 80 static ProfileKeyedService* BuildSigninManagerMock(Profile* profile) { |
82 return new SigninManagerMock(profile); | 81 return new SigninManagerMock(); |
83 } | 82 } |
84 | 83 |
85 content::WebContents* OneClickSigninHelperTest::CreateMockWebContents( | 84 content::WebContents* OneClickSigninHelperTest::CreateMockWebContents( |
86 bool use_incognito, | 85 bool use_incognito, |
87 const std::string& username) { | 86 const std::string& username) { |
88 TestingProfile* testing_profile = new TestingProfile(); | 87 TestingProfile* testing_profile = new TestingProfile(); |
89 browser_context_.reset(testing_profile); | 88 browser_context_.reset(testing_profile); |
90 | 89 |
91 testing_profile->set_incognito(use_incognito); | 90 testing_profile->set_incognito(use_incognito); |
92 signin_manager_ = static_cast<SigninManagerMock*>( | 91 signin_manager_ = static_cast<SigninManagerMock*>( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 content::WebContents* web_contents = CreateMockWebContents(false, ""); | 208 content::WebContents* web_contents = CreateMockWebContents(false, ""); |
210 AllowSigninCookies(false); | 209 AllowSigninCookies(false); |
211 | 210 |
212 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). | 211 EXPECT_CALL(*signin_manager_, IsAllowedUsername(_)). |
213 WillRepeatedly(Return(true)); | 212 WillRepeatedly(Return(true)); |
214 | 213 |
215 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, "user@gmail.com", | 214 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, "user@gmail.com", |
216 true)); | 215 true)); |
217 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, "", false)); | 216 EXPECT_FALSE(OneClickSigninHelper::CanOffer(web_contents, "", false)); |
218 } | 217 } |
OLD | NEW |