diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 02:52:56 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-04 02:52:56 +0000 |
commit | 79c4a0cf855838b5c30ef2d13621a7f2ea8f3048 (patch) | |
tree | bfa658a3baa8f208a70360339e6b18f9e37f1164 /google_apis/gaia/gaia_oauth_client_unittest.cc | |
parent | f9380385b001d9aaab6b82d4bd01f0bd24cd52a1 (diff) | |
download | chromium_src-79c4a0cf855838b5c30ef2d13621a7f2ea8f3048.zip chromium_src-79c4a0cf855838b5c30ef2d13621a7f2ea8f3048.tar.gz chromium_src-79c4a0cf855838b5c30ef2d13621a7f2ea8f3048.tar.bz2 |
google_apis: Break the dependency on TestingProfile from chrome.
TestingProfile was only being used in order to retrieve a
net::TestURLRequestContextGetter. google_apis tests can do this themselves
using a combination of MessageLoop and MessageLoopProxy.
This one more step forward on moving these tests to a google_apis_unittests
target.
BUG=255301
TEST=unit_tests
R=joi@chromium.org
Review URL: https://chromiumcodereview.appspot.com/18285002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis/gaia/gaia_oauth_client_unittest.cc')
-rw-r--r-- | google_apis/gaia/gaia_oauth_client_unittest.cc | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/google_apis/gaia/gaia_oauth_client_unittest.cc b/google_apis/gaia/gaia_oauth_client_unittest.cc index acb366a..921a61a 100644 --- a/google_apis/gaia/gaia_oauth_client_unittest.cc +++ b/google_apis/gaia/gaia_oauth_client_unittest.cc @@ -10,7 +10,6 @@ #include "base/message_loop.h" #include "base/strings/string_number_conversions.h" #include "base/values.h" -#include "chrome/test/base/testing_profile.h" #include "google_apis/gaia/gaia_oauth_client.h" #include "googleurl/src/gurl.h" #include "net/base/net_errors.h" @@ -18,6 +17,7 @@ #include "net/url_request/test_url_fetcher_factory.h" #include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_request_status.h" +#include "net/url_request/url_request_test_util.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" @@ -163,9 +163,17 @@ class GaiaOAuthClientTest : public testing::Test { client_info_.redirect_uri = "test_redirect_uri"; }; - TestingProfile profile_; protected: + net::TestURLRequestContextGetter* GetRequestContext() { + if (!request_context_getter_) { + request_context_getter_ = new net::TestURLRequestContextGetter( + message_loop_.message_loop_proxy()); + } + return request_context_getter_; + } + base::MessageLoop message_loop_; + scoped_refptr<net::TestURLRequestContextGetter> request_context_getter_; OAuthClientInfo client_info_; }; @@ -211,7 +219,7 @@ TEST_F(GaiaOAuthClientTest, NetworkFailure) { factory.set_response_code(response_code); factory.set_max_failure_count(4); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetTokensFromAuthCode(client_info_, "auth_code", 2, &delegate); } @@ -227,7 +235,7 @@ TEST_F(GaiaOAuthClientTest, NetworkFailureRecover) { factory.set_max_failure_count(4); factory.set_results(kDummyGetTokensResult); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetTokensFromAuthCode(client_info_, "auth_code", -1, &delegate); } @@ -242,7 +250,7 @@ TEST_F(GaiaOAuthClientTest, OAuthFailure) { factory.set_max_failure_count(-1); factory.set_results(kDummyGetTokensResult); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetTokensFromAuthCode(client_info_, "auth_code", -1, &delegate); } @@ -255,7 +263,7 @@ TEST_F(GaiaOAuthClientTest, GetTokensSuccess) { MockOAuthFetcherFactory factory; factory.set_results(kDummyGetTokensResult); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetTokensFromAuthCode(client_info_, "auth_code", -1, &delegate); } @@ -268,7 +276,7 @@ TEST_F(GaiaOAuthClientTest, RefreshTokenSuccess) { factory.set_results(kDummyRefreshTokenResult); factory.set_complete_immediately(false); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.RefreshToken(client_info_, "refresh_token", std::vector<std::string>(), -1, &delegate); EXPECT_THAT(factory.get_url_fetcher()->upload_data(), @@ -285,7 +293,7 @@ TEST_F(GaiaOAuthClientTest, RefreshTokenDownscopingSuccess) { factory.set_results(kDummyRefreshTokenResult); factory.set_complete_immediately(false); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.RefreshToken(client_info_, "refresh_token", std::vector<std::string>(1, "scope4test"), -1, &delegate); EXPECT_THAT(factory.get_url_fetcher()->upload_data(), @@ -301,7 +309,7 @@ TEST_F(GaiaOAuthClientTest, GetUserEmail) { MockOAuthFetcherFactory factory; factory.set_results(kDummyUserInfoResult); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetUserEmail("access_token", 1, &delegate); } @@ -315,7 +323,7 @@ TEST_F(GaiaOAuthClientTest, GetTokenInfo) { MockOAuthFetcherFactory factory; factory.set_results(kDummyTokenInfoResult); - GaiaOAuthClient auth(profile_.GetRequestContext()); + GaiaOAuthClient auth(GetRequestContext()); auth.GetTokenInfo("access_token", 1, &delegate); std::string issued_to; |