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

Side by Side Diff: chrome/browser/sync/signin_manager_unittest.cc

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/sync/signin_manager.h" 5 #include "chrome/browser/sync/signin_manager.h"
6 6
7 #include "chrome/browser/net/gaia/token_service.h" 7 #include "chrome/browser/net/gaia/token_service.h"
8 #include "chrome/browser/net/gaia/token_service_unittest.h" 8 #include "chrome/browser/net/gaia/token_service_unittest.h"
9 #include "chrome/browser/password_manager/encryptor.h" 9 #include "chrome/browser/password_manager/encryptor.h"
10 #include "chrome/browser/sync/util/oauth.h" 10 #include "chrome/browser/sync/util/oauth.h"
(...skipping 25 matching lines...) Expand all
36 TokenServiceTestHarness::TearDown(); 36 TokenServiceTestHarness::TearDown();
37 browser_sync::SetIsUsingOAuthForTest(originally_using_oauth_); 37 browser_sync::SetIsUsingOAuthForTest(originally_using_oauth_);
38 } 38 }
39 39
40 void SimulateValidResponseClientLogin() { 40 void SimulateValidResponseClientLogin() {
41 DCHECK(!browser_sync::IsUsingOAuth()); 41 DCHECK(!browser_sync::IsUsingOAuth());
42 // Simulate the correct ClientLogin response. 42 // Simulate the correct ClientLogin response.
43 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); 43 TestURLFetcher* fetcher = factory_.GetFetcherByID(0);
44 DCHECK(fetcher); 44 DCHECK(fetcher);
45 DCHECK(fetcher->delegate()); 45 DCHECK(fetcher->delegate());
46 fetcher->delegate()->OnURLFetchComplete( 46
47 fetcher, GURL(GaiaUrls::GetInstance()->client_login_url()), 47 fetcher->set_url(GURL(GaiaUrls::GetInstance()->client_login_url()));
48 net::URLRequestStatus(), 200, net::ResponseCookies(), 48 fetcher->set_status(net::URLRequestStatus());
49 "SID=sid\nLSID=lsid\nAuth=auth"); 49 fetcher->set_response_code(200);
50 fetcher->SetResponseString("SID=sid\nLSID=lsid\nAuth=auth");
51 fetcher->delegate()->OnURLFetchComplete(fetcher);
50 52
51 // Then simulate the correct GetUserInfo response for the canonical email. 53 // Then simulate the correct GetUserInfo response for the canonical email.
52 // A new URL fetcher is used for each call. 54 // A new URL fetcher is used for each call.
53 fetcher = factory_.GetFetcherByID(0); 55 fetcher = factory_.GetFetcherByID(0);
54 DCHECK(fetcher); 56 DCHECK(fetcher);
55 DCHECK(fetcher->delegate()); 57 DCHECK(fetcher->delegate());
56 fetcher->delegate()->OnURLFetchComplete( 58 fetcher->set_url(GURL(GaiaUrls::GetInstance()->get_user_info_url()));
57 fetcher, GURL(GaiaUrls::GetInstance()->get_user_info_url()), 59 fetcher->set_status(net::URLRequestStatus());
58 net::URLRequestStatus(), 200, net::ResponseCookies(), 60 fetcher->set_response_code(200);
59 "email=user@gmail.com"); 61 fetcher->SetResponseString("email=user@gmail.com");
62 fetcher->delegate()->OnURLFetchComplete(fetcher);
60 } 63 }
61 64
62 void SimulateSigninStartOAuth() { 65 void SimulateSigninStartOAuth() {
63 DCHECK(browser_sync::IsUsingOAuth()); 66 DCHECK(browser_sync::IsUsingOAuth());
64 // Simulate a valid OAuth-based signin 67 // Simulate a valid OAuth-based signin
65 manager_->OnGetOAuthTokenSuccess("oauth_token-Ev1Vu1hv"); 68 manager_->OnGetOAuthTokenSuccess("oauth_token-Ev1Vu1hv");
66 manager_->OnOAuthGetAccessTokenSuccess("oauth1_access_token-qOAmlrSM", 69 manager_->OnOAuthGetAccessTokenSuccess("oauth1_access_token-qOAmlrSM",
67 "secret-NKKn1DuR"); 70 "secret-NKKn1DuR");
68 manager_->OnOAuthWrapBridgeSuccess(browser_sync::SyncServiceName(), 71 manager_->OnOAuthWrapBridgeSuccess(browser_sync::SyncServiceName(),
69 "oauth2_wrap_access_token-R0Z3nRtw", 72 "oauth2_wrap_access_token-R0Z3nRtw",
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 TEST_F(SigninManagerTest, SignOutOnUserInfoSucessRaceTest) { 246 TEST_F(SigninManagerTest, SignOutOnUserInfoSucessRaceTest) {
244 browser_sync::SetIsUsingOAuthForTest(true); 247 browser_sync::SetIsUsingOAuthForTest(true);
245 manager_->Initialize(profile_.get()); 248 manager_->Initialize(profile_.get());
246 EXPECT_TRUE(manager_->GetUsername().empty()); 249 EXPECT_TRUE(manager_->GetUsername().empty());
247 250
248 SimulateSigninStartOAuth(); 251 SimulateSigninStartOAuth();
249 manager_->SignOut(); 252 manager_->SignOut();
250 SimulateOAuthUserInfoSuccess(); 253 SimulateOAuthUserInfoSuccess();
251 EXPECT_TRUE(manager_->GetUsername().empty()); 254 EXPECT_TRUE(manager_->GetUsername().empty());
252 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698