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 GaiaOAuthClient. | 5 // A complete set of unit tests for GaiaOAuthClient. |
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 MOCK_METHOD1(OnGetUserIdResponse, void(const std::string& user_id)); | 211 MOCK_METHOD1(OnGetUserIdResponse, void(const std::string& user_id)); |
212 MOCK_METHOD0(OnOAuthError, void()); | 212 MOCK_METHOD0(OnOAuthError, void()); |
213 MOCK_METHOD1(OnNetworkError, void(int response_code)); | 213 MOCK_METHOD1(OnNetworkError, void(int response_code)); |
214 | 214 |
215 // gMock doesn't like methods that take or return scoped_ptr. A | 215 // gMock doesn't like methods that take or return scoped_ptr. A |
216 // work-around is to create a mock method that takes a raw ptr, and | 216 // work-around is to create a mock method that takes a raw ptr, and |
217 // override the problematic method to call through to it. | 217 // override the problematic method to call through to it. |
218 // https://groups.google.com/a/chromium.org/d/msg/chromium-dev/01sDxsJ1OYw/I_S
0xCBRF2oJ | 218 // https://groups.google.com/a/chromium.org/d/msg/chromium-dev/01sDxsJ1OYw/I_S
0xCBRF2oJ |
219 MOCK_METHOD1(OnGetUserInfoResponsePtr, | 219 MOCK_METHOD1(OnGetUserInfoResponsePtr, |
220 void(const base::DictionaryValue* user_info)); | 220 void(const base::DictionaryValue* user_info)); |
221 virtual void OnGetUserInfoResponse( | 221 void OnGetUserInfoResponse( |
222 scoped_ptr<base::DictionaryValue> user_info) override { | 222 scoped_ptr<base::DictionaryValue> user_info) override { |
223 user_info_.reset(user_info.release()); | 223 user_info_.reset(user_info.release()); |
224 OnGetUserInfoResponsePtr(user_info_.get()); | 224 OnGetUserInfoResponsePtr(user_info_.get()); |
225 } | 225 } |
226 MOCK_METHOD1(OnGetTokenInfoResponsePtr, | 226 MOCK_METHOD1(OnGetTokenInfoResponsePtr, |
227 void(const base::DictionaryValue* token_info)); | 227 void(const base::DictionaryValue* token_info)); |
228 virtual void OnGetTokenInfoResponse( | 228 void OnGetTokenInfoResponse( |
229 scoped_ptr<base::DictionaryValue> token_info) override { | 229 scoped_ptr<base::DictionaryValue> token_info) override { |
230 token_info_.reset(token_info.release()); | 230 token_info_.reset(token_info.release()); |
231 OnGetTokenInfoResponsePtr(token_info_.get()); | 231 OnGetTokenInfoResponsePtr(token_info_.get()); |
232 } | 232 } |
233 | 233 |
234 private: | 234 private: |
235 scoped_ptr<base::DictionaryValue> user_info_; | 235 scoped_ptr<base::DictionaryValue> user_info_; |
236 scoped_ptr<base::DictionaryValue> token_info_; | 236 scoped_ptr<base::DictionaryValue> token_info_; |
237 DISALLOW_COPY_AND_ASSIGN(MockGaiaOAuthClientDelegate); | 237 DISALLOW_COPY_AND_ASSIGN(MockGaiaOAuthClientDelegate); |
238 }; | 238 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 | 406 |
407 GaiaOAuthClient auth(GetRequestContext()); | 407 GaiaOAuthClient auth(GetRequestContext()); |
408 auth.GetTokenHandleInfo("some_handle", 1, &delegate); | 408 auth.GetTokenHandleInfo("some_handle", 1, &delegate); |
409 | 409 |
410 std::string audience; | 410 std::string audience; |
411 ASSERT_TRUE(captured_result->GetString("audience", &audience)); | 411 ASSERT_TRUE(captured_result->GetString("audience", &audience)); |
412 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); | 412 ASSERT_EQ("1234567890.apps.googleusercontent.com", audience); |
413 } | 413 } |
414 | 414 |
415 } // namespace gaia | 415 } // namespace gaia |
OLD | NEW |