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

Side by Side Diff: components/autofill/content/browser/wallet/wallet_signin_helper_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix silly compile error Created 7 years, 4 months 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 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/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
12 #include "components/autofill/content/browser/wallet/wallet_service_url.h" 12 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
13 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega te.h" 13 #include "components/autofill/content/browser/wallet/wallet_signin_helper_delega te.h"
14 #include "content/public/browser/storage_partition.h"
14 #include "content/public/test/test_browser_thread_bundle.h" 15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "content/public/test/test_utils.h"
15 #include "google_apis/gaia/gaia_constants.h" 17 #include "google_apis/gaia/gaia_constants.h"
16 #include "google_apis/gaia/gaia_urls.h" 18 #include "google_apis/gaia/gaia_urls.h"
17 #include "google_apis/gaia/google_service_auth_error.h" 19 #include "google_apis/gaia/google_service_auth_error.h"
18 #include "net/cookies/canonical_cookie.h" 20 #include "net/cookies/canonical_cookie.h"
19 #include "net/cookies/cookie_monster.h" 21 #include "net/cookies/cookie_monster.h"
20 #include "net/cookies/cookie_options.h" 22 #include "net/cookies/cookie_options.h"
21 #include "net/http/http_status_code.h" 23 #include "net/http/http_status_code.h"
22 #include "net/url_request/test_url_fetcher_factory.h" 24 #include "net/url_request/test_url_fetcher_factory.h"
23 #include "net/url_request/url_request.h" 25 #include "net/url_request/url_request.h"
24 #include "net/url_request/url_request_context.h" 26 #include "net/url_request/url_request_context.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 196 }
195 197
196 TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) { 198 TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) {
197 EXPECT_CALL(mock_delegate_, OnUserNameFetchFailure(_)); 199 EXPECT_CALL(mock_delegate_, OnUserNameFetchFailure(_));
198 signin_helper_->StartUserNameFetch(); 200 signin_helper_->StartUserNameFetch();
199 MockFailedGetAccountInfoResponse404(); 201 MockFailedGetAccountInfoResponse404();
200 } 202 }
201 203
202 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) { 204 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) {
203 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken")); 205 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken"));
204 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
205 net::CookieOptions httponly_options; 206 net::CookieOptions httponly_options;
206 httponly_options.set_include_httponly(); 207 httponly_options.set_include_httponly();
207 scoped_ptr<net::CanonicalCookie> cookie( 208 scoped_ptr<net::CanonicalCookie> cookie(
208 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(), 209 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(),
209 "gdToken=gdToken; HttpOnly", 210 "gdToken=gdToken; HttpOnly",
210 base::Time::Now(), 211 base::Time::Now(),
211 httponly_options)); 212 httponly_options));
212 213
213 net::CookieList cookie_list; 214 net::CookieList cookie_list;
214 cookie_list.push_back(*cookie); 215 cookie_list.push_back(*cookie);
216
217 net::CookieMonster* cookie_monster =
218 content::GetCookieStoreForScheme(
219 content::BrowserContext::GetDefaultStoragePartition(
220 &browser_context_),
221 GetPassiveAuthUrl().scheme())->GetCookieMonster();
215 cookie_monster->InitializeFrom(cookie_list); 222 cookie_monster->InitializeFrom(cookie_list);
216 browser_context_.GetRequestContext()->GetURLRequestContext()
217 ->set_cookie_store(cookie_monster);
218 signin_helper_->StartWalletCookieValueFetch(); 223 signin_helper_->StartWalletCookieValueFetch();
219 base::RunLoop().RunUntilIdle(); 224 base::RunLoop().RunUntilIdle();
220 } 225 }
221 226
222 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) { 227 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) {
223 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string())); 228 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string()));
224 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); 229 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
225 net::CookieOptions httponly_options; 230 net::CookieOptions httponly_options;
226 httponly_options.set_include_httponly(); 231 httponly_options.set_include_httponly();
227 scoped_ptr<net::CanonicalCookie> cookie( 232 scoped_ptr<net::CanonicalCookie> cookie(
228 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(), 233 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(),
229 "fake_cookie=monkeys; HttpOnly", 234 "fake_cookie=monkeys; HttpOnly",
230 base::Time::Now(), 235 base::Time::Now(),
231 httponly_options)); 236 httponly_options));
232 237
233 net::CookieList cookie_list; 238 net::CookieList cookie_list;
234 cookie_list.push_back(*cookie); 239 cookie_list.push_back(*cookie);
235 cookie_monster->InitializeFrom(cookie_list); 240 cookie_monster->InitializeFrom(cookie_list);
236 browser_context_.GetRequestContext()->GetURLRequestContext() 241 browser_context_.GetRequestContext()->GetURLRequestContext()
237 ->set_cookie_store(cookie_monster); 242 ->set_cookie_store(cookie_monster);
238 signin_helper_->StartWalletCookieValueFetch(); 243 signin_helper_->StartWalletCookieValueFetch();
239 base::RunLoop().RunUntilIdle(); 244 base::RunLoop().RunUntilIdle();
240 } 245 }
241 246
242 // TODO(aruslan): http://crbug.com/188317 Need more tests. 247 // TODO(aruslan): http://crbug.com/188317 Need more tests.
243 248
244 } // namespace wallet 249 } // namespace wallet
245 } // namespace autofill 250 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698