OLD | NEW |
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 GaiaOAuthClient. | 5 // A complete set of unit tests for GaiaOAuthClient. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/common/net/gaia/gaia_oauth_client.h" | 12 #include "chrome/common/net/gaia/gaia_oauth_client.h" |
13 #include "chrome/common/net/http_return.h" | 13 #include "chrome/common/net/http_return.h" |
14 #include "chrome/test/base/testing_browser_process_test.h" | |
15 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
16 #include "content/common/url_fetcher.h" | 15 #include "content/common/url_fetcher.h" |
17 #include "content/test/test_url_fetcher_factory.h" | 16 #include "content/test/test_url_fetcher_factory.h" |
18 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
19 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
20 #include "net/url_request/url_request_status.h" | 19 #include "net/url_request/url_request_status.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
23 | 22 |
24 using ::testing::_; | 23 using ::testing::_; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," | 116 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," |
118 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; | 117 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; |
119 | 118 |
120 const std::string kDummyRefreshTokenResult = | 119 const std::string kDummyRefreshTokenResult = |
121 "{\"access_token\":\"" + kTestAccessToken + "\"," | 120 "{\"access_token\":\"" + kTestAccessToken + "\"," |
122 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; | 121 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; |
123 } | 122 } |
124 | 123 |
125 namespace gaia { | 124 namespace gaia { |
126 | 125 |
127 class GaiaOAuthClientTest : public TestingBrowserProcessTest { | 126 class GaiaOAuthClientTest : public testing::Test { |
128 public: | 127 public: |
129 GaiaOAuthClientTest() {} | 128 GaiaOAuthClientTest() {} |
130 | 129 |
131 TestingProfile profile_; | 130 TestingProfile profile_; |
132 protected: | 131 protected: |
133 MessageLoop message_loop_; | 132 MessageLoop message_loop_; |
134 }; | 133 }; |
135 | 134 |
136 class MockGaiaOAuthClientDelegate : public gaia::GaiaOAuthClient::Delegate { | 135 class MockGaiaOAuthClientDelegate : public gaia::GaiaOAuthClient::Delegate { |
137 public: | 136 public: |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 factory.set_results(kDummyRefreshTokenResult); | 239 factory.set_results(kDummyRefreshTokenResult); |
241 | 240 |
242 OAuthClientInfo client_info; | 241 OAuthClientInfo client_info; |
243 client_info.client_id = "test_client_id"; | 242 client_info.client_id = "test_client_id"; |
244 client_info.client_secret = "test_client_secret"; | 243 client_info.client_secret = "test_client_secret"; |
245 GaiaOAuthClient auth(kGaiaOAuth2Url, | 244 GaiaOAuthClient auth(kGaiaOAuth2Url, |
246 profile_.GetRequestContext()); | 245 profile_.GetRequestContext()); |
247 auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate); | 246 auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate); |
248 } | 247 } |
249 } // namespace gaia | 248 } // namespace gaia |
OLD | NEW |