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 "components/autofill/content/browser/wallet/wallet_signin_helper.h" | 5 #include "components/autofill/content/browser/wallet/wallet_signin_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 signin_helper_->GetGetAccountInfoUrlForTesting(), | 155 signin_helper_->GetGetAccountInfoUrlForTesting(), |
156 404, | 156 404, |
157 net::ResponseCookies(), | 157 net::ResponseCookies(), |
158 std::string()); | 158 std::string()); |
159 } | 159 } |
160 | 160 |
161 void MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse() { | 161 void MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse() { |
162 SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), | 162 SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), |
163 200, | 163 200, |
164 net::ResponseCookies(), | 164 net::ResponseCookies(), |
165 std::string()); | 165 "YES"); |
166 } | |
167 | |
168 void MockFailedPassiveAuthUrlMergeAndRedirectResponseNo() { | |
169 SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), | |
170 200, | |
ahutter
2013/06/13 23:52:10
Any reason you aren't using net::HTTP_OK?
aruslan
2013/06/18 21:21:47
Done.
| |
171 net::ResponseCookies(), | |
172 "NOOOO"); | |
166 } | 173 } |
167 | 174 |
168 void MockFailedPassiveAuthUrlMergeAndRedirectResponse404() { | 175 void MockFailedPassiveAuthUrlMergeAndRedirectResponse404() { |
169 SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), | 176 SetUpFetcherResponseAndCompleteRequest(wallet::GetPassiveAuthUrl().spec(), |
170 404, | 177 404, |
171 net::ResponseCookies(), | 178 net::ResponseCookies(), |
172 std::string()); | 179 std::string()); |
173 } | 180 } |
174 | 181 |
175 WalletSigninHelperForTesting::State state() const { | 182 WalletSigninHelperForTesting::State state() const { |
(...skipping 10 matching lines...) Expand all Loading... | |
186 TestingProfile profile_; | 193 TestingProfile profile_; |
187 }; | 194 }; |
188 | 195 |
189 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { | 196 TEST_F(WalletSigninHelperTest, PassiveSigninSuccessful) { |
190 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com")); | 197 EXPECT_CALL(mock_delegate_, OnPassiveSigninSuccess("user@gmail.com")); |
191 signin_helper_->StartPassiveSignin(); | 198 signin_helper_->StartPassiveSignin(); |
192 MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse(); | 199 MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse(); |
193 MockSuccessfulGetAccountInfoResponse("user@gmail.com"); | 200 MockSuccessfulGetAccountInfoResponse("user@gmail.com"); |
194 } | 201 } |
195 | 202 |
196 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin) { | 203 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSignin404) { |
197 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); | 204 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); |
198 signin_helper_->StartPassiveSignin(); | 205 signin_helper_->StartPassiveSignin(); |
199 MockFailedPassiveAuthUrlMergeAndRedirectResponse404(); | 206 MockFailedPassiveAuthUrlMergeAndRedirectResponse404(); |
200 } | 207 } |
201 | 208 |
209 TEST_F(WalletSigninHelperTest, PassiveSigninFailedSigninNo) { | |
210 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); | |
211 signin_helper_->StartPassiveSignin(); | |
212 MockFailedPassiveAuthUrlMergeAndRedirectResponseNo(); | |
213 } | |
214 | |
202 TEST_F(WalletSigninHelperTest, PassiveSigninFailedUserInfo) { | 215 TEST_F(WalletSigninHelperTest, PassiveSigninFailedUserInfo) { |
203 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); | 216 EXPECT_CALL(mock_delegate_, OnPassiveSigninFailure(_)); |
204 signin_helper_->StartPassiveSignin(); | 217 signin_helper_->StartPassiveSignin(); |
205 MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse(); | 218 MockSuccessfulPassiveAuthUrlMergeAndRedirectResponse(); |
206 MockFailedGetAccountInfoResponse404(); | 219 MockFailedGetAccountInfoResponse404(); |
207 } | 220 } |
208 | 221 |
209 TEST_F(WalletSigninHelperTest, PassiveUserInfoSuccessful) { | 222 TEST_F(WalletSigninHelperTest, PassiveUserInfoSuccessful) { |
210 EXPECT_CALL(mock_delegate_, OnUserNameFetchSuccess("user@gmail.com")); | 223 EXPECT_CALL(mock_delegate_, OnUserNameFetchSuccess("user@gmail.com")); |
211 signin_helper_->StartUserNameFetch(); | 224 signin_helper_->StartUserNameFetch(); |
(...skipping 20 matching lines...) Expand all Loading... | |
232 MockFailedGaiaUserInfoResponse404(); | 245 MockFailedGaiaUserInfoResponse404(); |
233 } | 246 } |
234 | 247 |
235 TEST_F(WalletSigninHelperTest, AutomaticSigninFailedOAuthLogin) { | 248 TEST_F(WalletSigninHelperTest, AutomaticSigninFailedOAuthLogin) { |
236 EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_)); | 249 EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_)); |
237 signin_helper_->StartAutomaticSignin("123SID", "123LSID"); | 250 signin_helper_->StartAutomaticSignin("123SID", "123LSID"); |
238 MockSuccessfulGaiaUserInfoResponse("user@gmail.com"); | 251 MockSuccessfulGaiaUserInfoResponse("user@gmail.com"); |
239 MockFailedOAuthLoginResponse404(); | 252 MockFailedOAuthLoginResponse404(); |
240 } | 253 } |
241 | 254 |
242 TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSignin) { | 255 TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSignin404) { |
243 EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_)); | 256 EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_)); |
244 signin_helper_->StartAutomaticSignin("123SID", "123LSID"); | 257 signin_helper_->StartAutomaticSignin("123SID", "123LSID"); |
245 MockSuccessfulGaiaUserInfoResponse("user@gmail.com"); | 258 MockSuccessfulGaiaUserInfoResponse("user@gmail.com"); |
246 MockSuccessfulOAuthLoginResponse(); | 259 MockSuccessfulOAuthLoginResponse(); |
247 MockFailedPassiveAuthUrlMergeAndRedirectResponse404(); | 260 MockFailedPassiveAuthUrlMergeAndRedirectResponse404(); |
248 } | 261 } |
249 | 262 |
263 TEST_F(WalletSigninHelperTest, AutomaticSigninFailedSigninNo) { | |
264 EXPECT_CALL(mock_delegate_, OnAutomaticSigninFailure(_)); | |
265 signin_helper_->StartAutomaticSignin("123SID", "123LSID"); | |
266 MockSuccessfulGaiaUserInfoResponse("user@gmail.com"); | |
267 MockSuccessfulOAuthLoginResponse(); | |
268 MockFailedPassiveAuthUrlMergeAndRedirectResponseNo(); | |
269 } | |
270 | |
250 // TODO(aruslan): http://crbug.com/188317 Need more tests. | 271 // TODO(aruslan): http://crbug.com/188317 Need more tests. |
251 | 272 |
252 } // namespace wallet | 273 } // namespace wallet |
253 } // namespace autofill | 274 } // namespace autofill |
OLD | NEW |