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

Unified Diff: google_apis/gaia/ubertoken_fetcher_unittest.cc

Issue 136723009: Move UbertokenFetcher from //chrome to //google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « google_apis/gaia/ubertoken_fetcher.cc ('k') | google_apis/google_apis.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/gaia/ubertoken_fetcher_unittest.cc
diff --git a/chrome/browser/signin/ubertoken_fetcher_unittest.cc b/google_apis/gaia/ubertoken_fetcher_unittest.cc
similarity index 68%
rename from chrome/browser/signin/ubertoken_fetcher_unittest.cc
rename to google_apis/gaia/ubertoken_fetcher_unittest.cc
index f90995dce53166d35d051b9dab33374ac4fc7591..a2521d86a31d8de71e8c03aad185d54b72a7c52b 100644
--- a/chrome/browser/signin/ubertoken_fetcher_unittest.cc
+++ b/google_apis/gaia/ubertoken_fetcher_unittest.cc
@@ -2,17 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/signin/ubertoken_fetcher.h"
+#include "google_apis/gaia/ubertoken_fetcher.h"
+#include "base/memory/ref_counted.h"
#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/test/base/testing_profile.h"
-#include "content/public/test/test_browser_thread_bundle.h"
+#include "base/message_loop/message_loop.h"
+#include "google_apis/gaia/fake_oauth2_token_service.h"
#include "google_apis/gaia/gaia_constants.h"
#include "net/url_request/test_url_fetcher_factory.h"
+#include "net/url_request/url_request_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -50,27 +48,22 @@ class MockUbertokenConsumer : public UbertokenConsumer {
class UbertokenFetcherTest : public testing::Test {
public:
virtual void SetUp() OVERRIDE {
- profile_ = CreateProfile();
- fetcher_.reset(new UbertokenFetcher(profile(), &consumer_));
- }
-
- scoped_ptr<TestingProfile> CreateProfile() {
- TestingProfile::Builder builder;
- builder.AddTestingFactory(ProfileOAuth2TokenServiceFactory::GetInstance(),
- &FakeProfileOAuth2TokenService::Build);
- return builder.Build().Pass();
+ OAuth2TokenService* token_service = new FakeOAuth2TokenService();
+ request_context_getter_ = new net::TestURLRequestContextGetter(
+ base::MessageLoopProxy::current());
+ fetcher_.reset(new UbertokenFetcher(token_service,
+ &consumer_,
+ request_context_getter_.get()));
}
virtual void TearDown() OVERRIDE {
fetcher_.reset();
}
- TestingProfile* profile() { return profile_.get(); }
-
protected:
- content::TestBrowserThreadBundle thread_bundle_;
- scoped_ptr<TestingProfile> profile_;
+ base::MessageLoop message_loop_;
net::TestURLFetcherFactory factory_;
+ scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
MockUbertokenConsumer consumer_;
scoped_ptr<UbertokenFetcher> fetcher_;
};
@@ -79,11 +72,10 @@ TEST_F(UbertokenFetcherTest, Basic) {
}
TEST_F(UbertokenFetcherTest, Success) {
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
- UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken(kTestAccountId);
fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time());
fetcher_->OnUberAuthTokenSuccess("uberToken");
+
EXPECT_EQ(0, consumer_.nb_error_);
EXPECT_EQ(1, consumer_.nb_correct_token_);
EXPECT_EQ("uberToken", consumer_.last_token_);
@@ -93,16 +85,14 @@ TEST_F(UbertokenFetcherTest, NoRefreshToken) {
fetcher_->StartFetchingToken(kTestAccountId);
GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
fetcher_->OnGetTokenFailure(NULL, error);
+
EXPECT_EQ(1, consumer_.nb_error_);
EXPECT_EQ(0, consumer_.nb_correct_token_);
}
TEST_F(UbertokenFetcherTest, FailureToGetAccessToken) {
- GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
-
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
- UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken(kTestAccountId);
+ GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
fetcher_->OnGetTokenFailure(NULL, error);
EXPECT_EQ(1, consumer_.nb_error_);
@@ -111,11 +101,8 @@ TEST_F(UbertokenFetcherTest, FailureToGetAccessToken) {
}
TEST_F(UbertokenFetcherTest, FailureToGetUberToken) {
- GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
-
- ProfileOAuth2TokenServiceFactory::GetForProfile(profile())->
- UpdateCredentials(kTestAccountId, "refreshToken");
fetcher_->StartFetchingToken(kTestAccountId);
+ GoogleServiceAuthError error(GoogleServiceAuthError::USER_NOT_SIGNED_UP);
fetcher_->OnGetTokenSuccess(NULL, "accessToken", base::Time());
fetcher_->OnUberAuthTokenFailure(error);
« no previous file with comments | « google_apis/gaia/ubertoken_fetcher.cc ('k') | google_apis/google_apis.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698