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

Unified Diff: chrome/browser/signin/ubertoken_fetcher_unittest.cc

Issue 71723002: This is the second CL of several that will eventually replace TokenService with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo change to SigninTracker Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/signin/ubertoken_fetcher_unittest.cc
diff --git a/chrome/browser/signin/ubertoken_fetcher_unittest.cc b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
index fb685170c8e2388bebf007f5031108db10ae6dfa..6a43a05abb50b0ad5d6f3b6a8e2a65c9e146b689 100644
--- a/chrome/browser/signin/ubertoken_fetcher_unittest.cc
+++ b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
@@ -7,15 +7,20 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h"
#include "chrome/browser/signin/fake_signin_manager.h"
+#include "chrome/browser/signin/profile_oauth2_token_service.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/signin/token_service_unittest.h"
fgorski 2013/11/13 20:36:48 Is this include still needed?
Roger Tawa OOO till Jul 10th 2013/11/13 20:56:12 Done.
+#include "chrome/test/base/testing_profile.h"
+#include "content/public/test/test_browser_thread_bundle.h"
#include "google_apis/gaia/gaia_constants.h"
#include "net/url_request/test_url_fetcher_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
+const char kTestAccountId[] = "test@gmail.com";
+
class MockUbertokenConsumer : public UbertokenConsumer {
public:
MockUbertokenConsumer()
@@ -44,16 +49,14 @@ class MockUbertokenConsumer : public UbertokenConsumer {
} // namespace
-class UbertokenFetcherTest : public TokenServiceTestHarness {
+class UbertokenFetcherTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
- TokenServiceTestHarness::SetUp();
- UpdateCredentialsOnService();
+ profile_.reset(new TestingProfile());
fetcher_.reset(new UbertokenFetcher(profile(), &consumer_));
- CreateSigninManager("test@gmail.com");
}
- virtual scoped_ptr<TestingProfile> CreateProfile() OVERRIDE {
+ scoped_ptr<TestingProfile> CreateProfile() {
TestingProfile::Builder builder;
builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
&FakeProfileOAuth2TokenService::Build);
@@ -62,10 +65,13 @@ class UbertokenFetcherTest : public TokenServiceTestHarness {
virtual void TearDown() OVERRIDE {
fetcher_.reset();
- TokenServiceTestHarness::TearDown();
}
+ TestingProfile* profile() { return profile_.get(); }
+
protected:
+ content::TestBrowserThreadBundle thread_bundle_;
+ scoped_ptr<TestingProfile> profile_;
net::TestURLFetcherFactory factory_;
MockUbertokenConsumer consumer_;
scoped_ptr<UbertokenFetcher> fetcher_;
@@ -75,8 +81,8 @@ TEST_F(UbertokenFetcherTest, Basic) {
}
TEST_F(UbertokenFetcherTest, Success) {
- service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
- "refreshToken");
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
+ UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken();
fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time());
fetcher_->OnUberAuthTokenSuccess("uberToken");
@@ -96,8 +102,8 @@ TEST_F(UbertokenFetcherTest, NoRefreshToken) {
TEST_F(UbertokenFetcherTest, FailureToGetAccessToken) {
GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
- service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
- "refreshToken");
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
+ UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken();
fetcher_->OnGetTokenFailure(NULL, error);
@@ -109,8 +115,8 @@ TEST_F(UbertokenFetcherTest, FailureToGetAccessToken) {
TEST_F(UbertokenFetcherTest, FailureToGetUberToken) {
GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
- service()->IssueAuthTokenForTest(GaiaConstants::kGaiaOAuth2LoginRefreshToken,
- "refreshToken");
+ ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
+ UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken();
fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time());
fetcher_->OnUberAuthTokenFailure(error);

Powered by Google App Engine
This is Rietveld 408576698