| 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/testing_browser_process_test.h" |
| 14 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
| 15 #include "content/common/test_url_fetcher_factory.h" | 16 #include "content/common/test_url_fetcher_factory.h" |
| 16 #include "content/common/url_fetcher.h" | 17 #include "content/common/url_fetcher.h" |
| 17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
| 18 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 19 #include "net/url_request/url_request_status.h" | 20 #include "net/url_request/url_request_status.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 using ::testing::_; | 24 using ::testing::_; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," | 114 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "," |
| 114 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; | 115 "\"refresh_token\":\"" + kTestRefreshToken + "\"}"; |
| 115 | 116 |
| 116 const std::string kDummyRefreshTokenResult = | 117 const std::string kDummyRefreshTokenResult = |
| 117 "{\"access_token\":\"" + kTestAccessToken + "\"," | 118 "{\"access_token\":\"" + kTestAccessToken + "\"," |
| 118 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; | 119 "\"expires_in\":" + base::IntToString(kTestExpiresIn) + "}"; |
| 119 } | 120 } |
| 120 | 121 |
| 121 namespace gaia { | 122 namespace gaia { |
| 122 | 123 |
| 123 class GaiaOAuthClientTest : public testing::Test { | 124 class GaiaOAuthClientTest : public TestingBrowserProcessTest { |
| 124 public: | 125 public: |
| 125 GaiaOAuthClientTest() {} | 126 GaiaOAuthClientTest() {} |
| 126 | 127 |
| 127 TestingProfile profile_; | 128 TestingProfile profile_; |
| 128 protected: | 129 protected: |
| 129 MessageLoop message_loop_; | 130 MessageLoop message_loop_; |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 class MockGaiaOAuthClientDelegate : public gaia::GaiaOAuthClient::Delegate { | 133 class MockGaiaOAuthClientDelegate : public gaia::GaiaOAuthClient::Delegate { |
| 133 public: | 134 public: |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 247 |
| 247 OAuthClientInfo client_info; | 248 OAuthClientInfo client_info; |
| 248 client_info.client_id = "test_client_id"; | 249 client_info.client_id = "test_client_id"; |
| 249 client_info.client_secret = "test_client_secret"; | 250 client_info.client_secret = "test_client_secret"; |
| 250 GaiaOAuthClient auth(kGaiaOAuth2Url, | 251 GaiaOAuthClient auth(kGaiaOAuth2Url, |
| 251 profile_.GetRequestContext()); | 252 profile_.GetRequestContext()); |
| 252 auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate); | 253 auth.GetTokensFromAuthCode(client_info, "auth_code", -1, &delegate); |
| 253 URLFetcher::set_factory(NULL); | 254 URLFetcher::set_factory(NULL); |
| 254 } | 255 } |
| 255 } // namespace gaia | 256 } // namespace gaia |
| OLD | NEW |