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

Side by Side Diff: chrome/common/net/gaia/oauth2_access_token_fetcher_unittest.cc

Issue 8662002: Revive reverted CL with fix for CrOS build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
« no previous file with comments | « chrome/common/net/gaia/oauth2_access_token_fetcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A complete set of unit tests for OAuth2AccessTokenFetcher. 5 // A complete set of unit tests for OAuth2AccessTokenFetcher.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 fetcher_.OnURLFetchComplete(url_fetcher); 118 fetcher_.OnURLFetchComplete(url_fetcher);
119 } 119 }
120 120
121 TEST_F(OAuth2AccessTokenFetcherTest, GetAccessTokenResponseCodeFailure) { 121 TEST_F(OAuth2AccessTokenFetcherTest, GetAccessTokenResponseCodeFailure) {
122 TestURLFetcher* url_fetcher = SetupGetAccessToken(true, RC_FORBIDDEN, ""); 122 TestURLFetcher* url_fetcher = SetupGetAccessToken(true, RC_FORBIDDEN, "");
123 EXPECT_CALL(consumer_, OnGetTokenFailure(_)).Times(1); 123 EXPECT_CALL(consumer_, OnGetTokenFailure(_)).Times(1);
124 fetcher_.Start("refresh_token"); 124 fetcher_.Start("refresh_token");
125 fetcher_.OnURLFetchComplete(url_fetcher); 125 fetcher_.OnURLFetchComplete(url_fetcher);
126 } 126 }
127 127
128 TEST_F(OAuth2AccessTokenFetcherTest, GetAccessTokenResponseNoAccessToken) {
129 TestURLFetcher* url_fetcher = SetupGetAccessToken(
130 true, RC_REQUEST_OK, kTokenResponseNoAccessToken);
131 EXPECT_CALL(consumer_, OnGetTokenFailure(_)).Times(1);
132 fetcher_.Start("refresh_token");
133 fetcher_.OnURLFetchComplete(url_fetcher);
134 }
135
136 TEST_F(OAuth2AccessTokenFetcherTest, Success) { 128 TEST_F(OAuth2AccessTokenFetcherTest, Success) {
137 TestURLFetcher* url_fetcher = SetupGetAccessToken( 129 TestURLFetcher* url_fetcher = SetupGetAccessToken(
138 true, RC_REQUEST_OK, kValidTokenResponse); 130 true, RC_REQUEST_OK, kValidTokenResponse);
139 EXPECT_CALL(consumer_, OnGetTokenSuccess("at1")).Times(1); 131 EXPECT_CALL(consumer_, OnGetTokenSuccess("at1")).Times(1);
140 fetcher_.Start("refresh_token"); 132 fetcher_.Start("refresh_token");
141 fetcher_.OnURLFetchComplete(url_fetcher); 133 fetcher_.OnURLFetchComplete(url_fetcher);
142 } 134 }
143 135
144 TEST_F(OAuth2AccessTokenFetcherTest, ParseGetAccessTokenResponse) { 136 TEST_F(OAuth2AccessTokenFetcherTest, ParseGetAccessTokenResponse) {
145 { // No body. 137 { // No body.
(...skipping 25 matching lines...) Expand all
171 { // Valid json: all good. 163 { // Valid json: all good.
172 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL); 164 TestURLFetcher url_fetcher(0, GURL("www.google.com"), NULL);
173 url_fetcher.SetResponseString(kValidTokenResponse); 165 url_fetcher.SetResponseString(kValidTokenResponse);
174 166
175 std::string at; 167 std::string at;
176 EXPECT_TRUE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse( 168 EXPECT_TRUE(OAuth2AccessTokenFetcher::ParseGetAccessTokenResponse(
177 &url_fetcher, &at)); 169 &url_fetcher, &at));
178 EXPECT_EQ("at1", at); 170 EXPECT_EQ("at1", at);
179 } 171 }
180 } 172 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_access_token_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698