Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1257)

Side by Side Diff: chrome/browser/net/gaia/gaia_oauth_fetcher_unittest.cc

Issue 17127002: Correctly integrate StoragePartition into TestingProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix InstantNTP test. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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"
25 25
26 using ::testing::_;
27
28 class MockGaiaOAuthConsumer : public GaiaOAuthConsumer { 26 class MockGaiaOAuthConsumer : public GaiaOAuthConsumer {
29 public: 27 public:
30 MockGaiaOAuthConsumer() {} 28 MockGaiaOAuthConsumer() {}
31 ~MockGaiaOAuthConsumer() {} 29 ~MockGaiaOAuthConsumer() {}
32 30
33 MOCK_METHOD1(OnGetOAuthTokenSuccess, void(const std::string& oauth_token)); 31 MOCK_METHOD1(OnGetOAuthTokenSuccess, void(const std::string& oauth_token));
34 MOCK_METHOD1(OnGetOAuthTokenFailure, 32 MOCK_METHOD1(OnGetOAuthTokenFailure,
35 void(const GoogleServiceAuthError& error)); 33 void(const GoogleServiceAuthError& error));
36 34
37 MOCK_METHOD2(OnOAuthGetAccessTokenSuccess, void(const std::string& token, 35 MOCK_METHOD2(OnOAuthGetAccessTokenSuccess, void(const std::string& token,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 114
117 TestingProfile profile; 115 TestingProfile profile;
118 116
119 MockGaiaOAuthFetcher oauth_fetcher(&consumer, 117 MockGaiaOAuthFetcher oauth_fetcher(&consumer,
120 profile.GetRequestContext(), 118 profile.GetRequestContext(),
121 std::string()); 119 std::string());
122 EXPECT_CALL(oauth_fetcher, StartOAuthGetAccessToken(oauth_token)).Times(1); 120 EXPECT_CALL(oauth_fetcher, StartOAuthGetAccessToken(oauth_token)).Times(1);
123 } 121 }
124 #endif // 0 // Suppressing for now 122 #endif // 0 // Suppressing for now
125 123
126 typedef testing::Test GaiaOAuthFetcherTest; 124 class GaiaOAuthFetcherTest : public testing::Test {
125 private:
126 content::TestBrowserThreadBundle thread_bundle_;
127 };
127 128
128 TEST_F(GaiaOAuthFetcherTest, OAuthGetAccessToken) { 129 TEST_F(GaiaOAuthFetcherTest, OAuthGetAccessToken) {
129 const std::string oauth_token = 130 const std::string oauth_token =
130 "1/OAuth1-Access_Token-1234567890abcdefghijklm"; 131 "1/OAuth1-Access_Token-1234567890abcdefghijklm";
131 const std::string oauth_token_secret = "Dont_tell_the_secret-123"; 132 const std::string oauth_token_secret = "Dont_tell_the_secret-123";
132 const std::string data("oauth_token=" 133 const std::string data("oauth_token="
133 "1%2FOAuth1-Access_Token-1234567890abcdefghijklm" 134 "1%2FOAuth1-Access_Token-1234567890abcdefghijklm"
134 "&oauth_token_secret=Dont_tell_the_secret-123"); 135 "&oauth_token_secret=Dont_tell_the_secret-123");
135 136
136 MockGaiaOAuthConsumer consumer; 137 MockGaiaOAuthConsumer consumer;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0); 244 net::URLRequestStatus status(net::URLRequestStatus::SUCCESS, 0);
244 GURL url(GaiaUrls::GetInstance()->oauth_revoke_token_url()); 245 GURL url(GaiaUrls::GetInstance()->oauth_revoke_token_url());
245 246
246 net::TestURLFetcher test_fetcher(0, GURL(), &oauth_fetcher); 247 net::TestURLFetcher test_fetcher(0, GURL(), &oauth_fetcher);
247 test_fetcher.set_url(url); 248 test_fetcher.set_url(url);
248 test_fetcher.set_status(status); 249 test_fetcher.set_status(status);
249 test_fetcher.set_response_code(net::HTTP_OK); 250 test_fetcher.set_response_code(net::HTTP_OK);
250 test_fetcher.set_cookies(cookies); 251 test_fetcher.set_cookies(cookies);
251 oauth_fetcher.OnURLFetchComplete(&test_fetcher); 252 oauth_fetcher.OnURLFetchComplete(&test_fetcher);
252 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698