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

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: android webview init fix merged in. Created 7 years, 3 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"
15 #include "google_apis/gaia/gaia_constants.h" 16 #include "google_apis/gaia/gaia_constants.h"
16 #include "google_apis/gaia/gaia_urls.h" 17 #include "google_apis/gaia/gaia_urls.h"
17 #include "google_apis/gaia/google_service_auth_error.h" 18 #include "google_apis/gaia/google_service_auth_error.h"
18 #include "net/cookies/canonical_cookie.h" 19 #include "net/cookies/canonical_cookie.h"
19 #include "net/cookies/cookie_monster.h" 20 #include "net/cookies/cookie_monster.h"
20 #include "net/cookies/cookie_options.h" 21 #include "net/cookies/cookie_options.h"
21 #include "net/http/http_status_code.h" 22 #include "net/http/http_status_code.h"
22 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
23 #include "net/url_request/url_request.h" 24 #include "net/url_request/url_request.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 195 }
195 196
196 TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) { 197 TEST_F(WalletSigninHelperTest, PassiveUserInfoFailedUserInfo) {
197 EXPECT_CALL(mock_delegate_, OnUserNameFetchFailure(_)); 198 EXPECT_CALL(mock_delegate_, OnUserNameFetchFailure(_));
198 signin_helper_->StartUserNameFetch(); 199 signin_helper_->StartUserNameFetch();
199 MockFailedGetAccountInfoResponse404(); 200 MockFailedGetAccountInfoResponse404();
200 } 201 }
201 202
202 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) { 203 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenPresent) {
203 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken")); 204 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue("gdToken"));
204 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
205 net::CookieOptions httponly_options; 205 net::CookieOptions httponly_options;
206 httponly_options.set_include_httponly(); 206 httponly_options.set_include_httponly();
207 scoped_ptr<net::CanonicalCookie> cookie( 207 scoped_ptr<net::CanonicalCookie> cookie(
208 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(), 208 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(),
209 "gdToken=gdToken; HttpOnly", 209 "gdToken=gdToken; HttpOnly",
210 base::Time::Now(), 210 base::Time::Now(),
211 httponly_options)); 211 httponly_options));
212 212
213 net::CookieList cookie_list; 213 net::CookieList cookie_list;
214 cookie_list.push_back(*cookie); 214 cookie_list.push_back(*cookie);
215
216 net::CookieMonster* cookie_monster =
217 content::BrowserContext::GetDefaultStoragePartition(&browser_context_)->
218 GetCookieStoreForScheme(GetPassiveAuthUrl().scheme())->
219 GetCookieMonster();
215 cookie_monster->InitializeFrom(cookie_list); 220 cookie_monster->InitializeFrom(cookie_list);
216 browser_context_.GetRequestContext()->GetURLRequestContext()
217 ->set_cookie_store(cookie_monster);
218 signin_helper_->StartWalletCookieValueFetch(); 221 signin_helper_->StartWalletCookieValueFetch();
219 base::RunLoop().RunUntilIdle(); 222 base::RunLoop().RunUntilIdle();
220 } 223 }
221 224
222 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) { 225 TEST_F(WalletSigninHelperTest, GetWalletCookieValueWhenMissing) {
223 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string())); 226 EXPECT_CALL(mock_delegate_, OnDidFetchWalletCookieValue(std::string()));
224 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); 227 net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL);
225 net::CookieOptions httponly_options; 228 net::CookieOptions httponly_options;
226 httponly_options.set_include_httponly(); 229 httponly_options.set_include_httponly();
227 scoped_ptr<net::CanonicalCookie> cookie( 230 scoped_ptr<net::CanonicalCookie> cookie(
228 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(), 231 net::CanonicalCookie::Create(GetPassiveAuthUrl().GetWithEmptyPath(),
229 "fake_cookie=monkeys; HttpOnly", 232 "fake_cookie=monkeys; HttpOnly",
230 base::Time::Now(), 233 base::Time::Now(),
231 httponly_options)); 234 httponly_options));
232 235
233 net::CookieList cookie_list; 236 net::CookieList cookie_list;
234 cookie_list.push_back(*cookie); 237 cookie_list.push_back(*cookie);
235 cookie_monster->InitializeFrom(cookie_list); 238 cookie_monster->InitializeFrom(cookie_list);
236 browser_context_.GetRequestContext()->GetURLRequestContext() 239 browser_context_.GetRequestContext()->GetURLRequestContext()
237 ->set_cookie_store(cookie_monster); 240 ->set_cookie_store(cookie_monster);
238 signin_helper_->StartWalletCookieValueFetch(); 241 signin_helper_->StartWalletCookieValueFetch();
239 base::RunLoop().RunUntilIdle(); 242 base::RunLoop().RunUntilIdle();
240 } 243 }
241 244
242 // TODO(aruslan): http://crbug.com/188317 Need more tests. 245 // TODO(aruslan): http://crbug.com/188317 Need more tests.
243 246
244 } // namespace wallet 247 } // namespace wallet
245 } // namespace autofill 248 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | content/browser/appcache/chrome_appcache_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698