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

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

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix Windows, address comments Created 8 years, 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 OAuth2MintTokenFlow. 5 // A complete set of unit tests for OAuth2MintTokenFlow.
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 std::string ext_id = "ext1"; 160 std::string ext_id = "ext1";
161 std::string client_id = "client1"; 161 std::string client_id = "client1";
162 std::vector<std::string> scopes(CreateTestScopes()); 162 std::vector<std::string> scopes(CreateTestScopes());
163 flow_.reset(new MockMintTokenFlow( 163 flow_.reset(new MockMintTokenFlow(
164 delegate, 164 delegate,
165 OAuth2MintTokenFlow::Parameters(rt, ext_id, client_id, scopes, mode))); 165 OAuth2MintTokenFlow::Parameters(rt, ext_id, client_id, scopes, mode)));
166 } 166 }
167 167
168 // Helper to parse the given string to DictionaryValue. 168 // Helper to parse the given string to DictionaryValue.
169 static base::DictionaryValue* ParseJson(const std::string& str) { 169 static base::DictionaryValue* ParseJson(const std::string& str) {
170 base::JSONReader reader; 170 scoped_ptr<Value> value(base::JSONReader::Read(str));
171 scoped_ptr<Value> value(reader.Read(str, false));
172 EXPECT_TRUE(value.get()); 171 EXPECT_TRUE(value.get());
173 EXPECT_EQ(Value::TYPE_DICTIONARY, value->GetType()); 172 EXPECT_EQ(Value::TYPE_DICTIONARY, value->GetType());
174 return static_cast<base::DictionaryValue*>(value.release()); 173 return static_cast<base::DictionaryValue*>(value.release());
175 } 174 }
176 175
177 scoped_ptr<MockMintTokenFlow> flow_; 176 scoped_ptr<MockMintTokenFlow> flow_;
178 StrictMock<MockDelegate> delegate_; 177 StrictMock<MockDelegate> delegate_;
179 }; 178 };
180 179
181 TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBody) { 180 TEST_F(OAuth2MintTokenFlowTest, CreateApiCallBody) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 } 347 }
349 348
350 { // Non-null delegate. 349 { // Non-null delegate.
351 GoogleServiceAuthError error( 350 GoogleServiceAuthError error(
352 GoogleServiceAuthError::FromConnectionError(101)); 351 GoogleServiceAuthError::FromConnectionError(101));
353 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE); 352 CreateFlow(OAuth2MintTokenFlow::MODE_MINT_TOKEN_NO_FORCE);
354 EXPECT_CALL(delegate_, OnMintTokenFailure(error)); 353 EXPECT_CALL(delegate_, OnMintTokenFailure(error));
355 flow_->ProcessMintAccessTokenFailure(error); 354 flow_->ProcessMintAccessTokenFailure(error);
356 } 355 }
357 } 356 }
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/oauth2_mint_token_flow.cc ('k') | chrome/installer/util/master_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698