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 GaiaOAuthFetcher. | 5 // A complete set of unit tests for GaiaOAuthFetcher. |
6 // Originally ported from GaiaAuthFetcher tests. | 6 // Originally ported from GaiaAuthFetcher tests. |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | |
12 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" | 11 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" |
13 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 12 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
14 #include "chrome/test/base/testing_profile.h" | 13 #include "chrome/test/base/testing_profile.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "google_apis/gaia/gaia_constants.h" | 15 #include "google_apis/gaia/gaia_constants.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 16 #include "google_apis/gaia/gaia_urls.h" |
17 #include "google_apis/gaia/google_service_auth_error.h" | 17 #include "google_apis/gaia/google_service_auth_error.h" |
18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
19 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
20 #include "net/url_request/test_url_fetcher_factory.h" | 20 #include "net/url_request/test_url_fetcher_factory.h" |
21 #include "net/url_request/url_request_status.h" | 21 #include "net/url_request/url_request_status.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 TestingProfile profile; | 117 TestingProfile profile; |
118 | 118 |
119 MockGaiaOAuthFetcher oauth_fetcher(&consumer, | 119 MockGaiaOAuthFetcher oauth_fetcher(&consumer, |
120 profile.GetRequestContext(), | 120 profile.GetRequestContext(), |
121 std::string()); | 121 std::string()); |
122 EXPECT_CALL(oauth_fetcher, StartOAuthGetAccessToken(oauth_token)).Times(1); | 122 EXPECT_CALL(oauth_fetcher, StartOAuthGetAccessToken(oauth_token)).Times(1); |
123 } | 123 } |
124 #endif // 0 // Suppressing for now | 124 #endif // 0 // Suppressing for now |
125 | 125 |
126 typedef testing::Test GaiaOAuthFetcherTest; | 126 class GaiaOAuthFetcherTest : public testing::Test { |
| 127 private: |
| 128 content::TestBrowserThreadBundle thread_bundle_; |
| 129 }; |
127 | 130 |
128 TEST_F(GaiaOAuthFetcherTest, OAuthGetAccessToken) { | 131 TEST_F(GaiaOAuthFetcherTest, OAuthGetAccessToken) { |
129 const std::string oauth_token = | 132 const std::string oauth_token = |
130 "1/OAuth1-Access_Token-1234567890abcdefghijklm"; | 133 "1/OAuth1-Access_Token-1234567890abcdefghijklm"; |
131 const std::string oauth_token_secret = "Dont_tell_the_secret-123"; | 134 const std::string oauth_token_secret = "Dont_tell_the_secret-123"; |
132 const std::string data("oauth_token=" | 135 const std::string data("oauth_token=" |
133 "1%2FOAuth1-Access_Token-1234567890abcdefghijklm" | 136 "1%2FOAuth1-Access_Token-1234567890abcdefghijklm" |
134 "&oauth_token_secret=Dont_tell_the_secret-123"); | 137 "&oauth_token_secret=Dont_tell_the_secret-123"); |
135 | 138 |
136 MockGaiaOAuthConsumer consumer; | 139 MockGaiaOAuthConsumer consumer; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); | 246 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); |
244 GURL url(GaiaUrls::GetInstance()->oauth_revoke_token_url()); | 247 GURL url(GaiaUrls::GetInstance()->oauth_revoke_token_url()); |
245 | 248 |
246 net::TestURLFetcher test_fetcher(0, GURL(), &oauth_fetcher); | 249 net::TestURLFetcher test_fetcher(0, GURL(), &oauth_fetcher); |
247 test_fetcher.set_url(url); | 250 test_fetcher.set_url(url); |
248 test_fetcher.set_status(status); | 251 test_fetcher.set_status(status); |
249 test_fetcher.set_response_code(net::HTTP_OK); | 252 test_fetcher.set_response_code(net::HTTP_OK); |
250 test_fetcher.set_cookies(cookies); | 253 test_fetcher.set_cookies(cookies); |
251 oauth_fetcher.OnURLFetchComplete(&test_fetcher); | 254 oauth_fetcher.OnURLFetchComplete(&test_fetcher); |
252 } | 255 } |
OLD | NEW |