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

Side by Side Diff: chrome/browser/managed_mode/managed_user_refresh_token_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
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/gaia/gaia_oauth_fetcher_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h" 9 #include "chrome/browser/managed_mode/managed_user_refresh_token_fetcher.h"
11 #include "chrome/browser/signin/oauth2_token_service.h" 10 #include "chrome/browser/signin/oauth2_token_service.h"
12 #include "chrome/test/base/testing_profile.h" 11 #include "chrome/test/base/testing_profile.h"
13 #include "content/public/test/test_browser_thread.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
14 #include "google_apis/gaia/gaia_oauth_client.h" 13 #include "google_apis/gaia/gaia_oauth_client.h"
15 #include "google_apis/gaia/gaia_urls.h" 14 #include "google_apis/gaia/gaia_urls.h"
16 #include "google_apis/gaia/google_service_auth_error.h" 15 #include "google_apis/gaia/google_service_auth_error.h"
17 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
18 #include "net/base/url_util.h" 17 #include "net/base/url_util.h"
19 #include "net/http/http_request_headers.h" 18 #include "net/http/http_request_headers.h"
20 #include "net/http/http_status_code.h" 19 #include "net/http/http_status_code.h"
21 #include "net/url_request/test_url_fetcher_factory.h" 20 #include "net/url_request/test_url_fetcher_factory.h"
22 #include "net/url_request/url_fetcher_delegate.h" 21 #include "net/url_request/url_fetcher_delegate.h"
23 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 187
189 void Reset(); 188 void Reset();
190 189
191 const GoogleServiceAuthError& error() const { return error_; } 190 const GoogleServiceAuthError& error() const { return error_; }
192 const std::string& token() const { return token_; } 191 const std::string& token() const { return token_; }
193 192
194 private: 193 private:
195 void OnTokenFetched(const GoogleServiceAuthError& error, 194 void OnTokenFetched(const GoogleServiceAuthError& error,
196 const std::string& token); 195 const std::string& token);
197 196
198 base::WeakPtrFactory<ManagedUserRefreshTokenFetcherTest> weak_ptr_factory_; 197 content::TestBrowserThreadBundle thread_bundle_;
199 base::MessageLoop message_loop_;
200 content::TestBrowserThread ui_thread_;
201 TestingProfile profile_; 198 TestingProfile profile_;
202 MockOAuth2TokenService oauth2_token_service_; 199 MockOAuth2TokenService oauth2_token_service_;
203 net::TestURLFetcherFactory url_fetcher_factory_; 200 net::TestURLFetcherFactory url_fetcher_factory_;
204 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_; 201 scoped_ptr<ManagedUserRefreshTokenFetcher> token_fetcher_;
205 202
206 GoogleServiceAuthError error_; 203 GoogleServiceAuthError error_;
207 std::string token_; 204 std::string token_;
205 base::WeakPtrFactory<ManagedUserRefreshTokenFetcherTest> weak_ptr_factory_;
208 }; 206 };
209 207
210 ManagedUserRefreshTokenFetcherTest::ManagedUserRefreshTokenFetcherTest() 208 ManagedUserRefreshTokenFetcherTest::ManagedUserRefreshTokenFetcherTest()
211 : weak_ptr_factory_(this), 209 : token_fetcher_(
212 ui_thread_(content::BrowserThread::UI, &message_loop_),
213 token_fetcher_(
214 ManagedUserRefreshTokenFetcher::Create(&oauth2_token_service_, 210 ManagedUserRefreshTokenFetcher::Create(&oauth2_token_service_,
215 profile_.GetRequestContext())), 211 profile_.GetRequestContext())),
216 error_(GoogleServiceAuthError::NONE) {} 212 error_(GoogleServiceAuthError::NONE),
213 weak_ptr_factory_(this) {}
217 214
218 void ManagedUserRefreshTokenFetcherTest::StartFetching() { 215 void ManagedUserRefreshTokenFetcherTest::StartFetching() {
219 token_fetcher_->Start(kManagedUserId, UTF8ToUTF16(kName), kDeviceName, 216 token_fetcher_->Start(kManagedUserId, UTF8ToUTF16(kName), kDeviceName,
220 base::Bind( 217 base::Bind(
221 &ManagedUserRefreshTokenFetcherTest::OnTokenFetched, 218 &ManagedUserRefreshTokenFetcherTest::OnTokenFetched,
222 weak_ptr_factory_.GetWeakPtr())); 219 weak_ptr_factory_.GetWeakPtr()));
223 } 220 }
224 221
225 MockOAuth2TokenService::Request* 222 MockOAuth2TokenService::Request*
226 ManagedUserRefreshTokenFetcherTest::GetOAuth2TokenServiceRequest() { 223 ManagedUserRefreshTokenFetcherTest::GetOAuth2TokenServiceRequest() {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 417
421 TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileFetchingRefreshToken) { 418 TEST_F(ManagedUserRefreshTokenFetcherTest, CancelWhileFetchingRefreshToken) {
422 StartFetching(); 419 StartFetching();
423 GetOAuth2TokenServiceRequest()->Succeed(); 420 GetOAuth2TokenServiceRequest()->Succeed();
424 MakeIssueTokenRequestSucceed(); 421 MakeIssueTokenRequestSucceed();
425 Reset(); 422 Reset();
426 423
427 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state()); 424 EXPECT_EQ(GoogleServiceAuthError::NONE, error().state());
428 EXPECT_EQ(std::string(), token()); 425 EXPECT_EQ(std::string(), token());
429 } 426 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | chrome/browser/net/gaia/gaia_oauth_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698