OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |