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

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

Issue 12647008: Refactor OAuth2TokenService to have profile- and device-based implementations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase again Created 7 years, 8 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
Index: chrome/browser/signin/oauth2_token_service_test_util.cc
diff --git a/chrome/browser/signin/oauth2_token_service_test_util.cc b/chrome/browser/signin/oauth2_token_service_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dd03199a20fa77dc7b7753682ba9214d1fa36da4
--- /dev/null
+++ b/chrome/browser/signin/oauth2_token_service_test_util.cc
@@ -0,0 +1,40 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/signin/oauth2_token_service_test_util.h"
+
+const char kValidTokenResponse[] =
+ "{"
+ " \"access_token\": \"%s\","
+ " \"expires_in\": %d,"
+ " \"token_type\": \"Bearer\""
+ "}";
+
+std::string GetValidTokenResponse(std::string token, int expiration) {
+ return base::StringPrintf(kValidTokenResponse, token.c_str(), expiration);
+}
+
+TestingOAuth2TokenServiceConsumer::TestingOAuth2TokenServiceConsumer()
+ : number_of_successful_tokens_(0),
+ last_error_(GoogleServiceAuthError::AuthErrorNone()),
+ number_of_errors_(0) {
+}
+
+TestingOAuth2TokenServiceConsumer::~TestingOAuth2TokenServiceConsumer() {
+}
+
+void TestingOAuth2TokenServiceConsumer::OnGetTokenSuccess(
+ const OAuth2TokenService::Request* request,
+ const std::string& token,
+ const base::Time& expiration_date) {
+ last_token_ = token;
+ ++number_of_successful_tokens_;
+}
+
+void TestingOAuth2TokenServiceConsumer::OnGetTokenFailure(
+ const OAuth2TokenService::Request* request,
+ const GoogleServiceAuthError& error) {
+ last_error_ = error;
+ ++number_of_errors_;
+}
« no previous file with comments | « chrome/browser/signin/oauth2_token_service_test_util.h ('k') | chrome/browser/signin/oauth2_token_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698