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

Unified Diff: ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm

Issue 234573003: Upstream PO2TS_IOS unit test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « ios/public/test/fake_profile_oauth2_token_service_ios_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm
diff --git a/ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm b/ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm
new file mode 100644
index 0000000000000000000000000000000000000000..95f863fd5d5f67347df9f5f9c5aa0ac863a3a5bf
--- /dev/null
+++ b/ios/public/test/fake_profile_oauth2_token_service_ios_provider.mm
@@ -0,0 +1,91 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
blundell 2014/04/11 11:19:17 s/2013/2014 on all the new files
msarda 2014/04/11 11:25:06 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h"
+
+#include <Foundation/Foundation.h>
+
+#include "base/logging.h"
+#include "base/strings/sys_string_conversions.h"
+
+namespace ios {
+
+FakeProfileOAuth2TokenServiceIOSProvider::
+ FakeProfileOAuth2TokenServiceIOSProvider()
+ : is_using_shared_authentication_(true) {}
+
+FakeProfileOAuth2TokenServiceIOSProvider::
+ ~FakeProfileOAuth2TokenServiceIOSProvider() {}
+
+void FakeProfileOAuth2TokenServiceIOSProvider::GetAccessToken(
+ const std::string& account_id,
+ const std::string& client_id,
+ const std::string& client_secret,
+ const std::set<std::string>& scopes,
+ const AccessTokenCallback& callback) {
+ DCHECK(is_using_shared_authentication_);
+ requests_.push_back(AccessTokenRequest(account_id, callback));
+}
+
+std::vector<std::string>
+FakeProfileOAuth2TokenServiceIOSProvider::GetAllAccountIds() {
+ return accounts_;
+}
+
+void FakeProfileOAuth2TokenServiceIOSProvider::AddAccount(
+ const std::string& account_id) {
+ accounts_.push_back(account_id);
+}
+
+void FakeProfileOAuth2TokenServiceIOSProvider::SetAccounts(
+ const std::vector<std::string>& accounts) {
+ accounts_ = accounts;
+}
+
+void FakeProfileOAuth2TokenServiceIOSProvider::ClearAccounts() {
+ accounts_.clear();
+}
+
+void
+FakeProfileOAuth2TokenServiceIOSProvider::IssueAccessTokenForAllRequests() {
+ for (auto i = requests_.begin(); i != requests_.end(); ++i) {
+ std::string account_id = i->first;
+ AccessTokenCallback callback = i->second;
+ NSString* access_token = [NSString
+ stringWithFormat:@"fake_access_token [account=%s]", account_id.c_str()];
+ NSDate* one_hour_from_now = [NSDate dateWithTimeIntervalSinceNow:3600];
+ callback.Run(access_token, one_hour_from_now, nil);
+ }
+ requests_.clear();
+}
+
+void FakeProfileOAuth2TokenServiceIOSProvider::
+ IssueAccessTokenErrorForAllRequests() {
+ for (auto i = requests_.begin(); i != requests_.end(); ++i) {
+ std::string account_id = i->first;
+ AccessTokenCallback callback = i->second;
+ NSError* error = [[[NSError alloc] initWithDomain:@"fake_access_token_error"
+ code:-1
+ userInfo:nil] autorelease];
+ callback.Run(nil, nil, error);
+ }
+ requests_.clear();
+}
+
+bool FakeProfileOAuth2TokenServiceIOSProvider::IsUsingSharedAuthentication()
+ const {
+ return is_using_shared_authentication_;
+}
+
+void
+FakeProfileOAuth2TokenServiceIOSProvider::InitializeSharedAuthentication() {}
+
+AuthenticationErrorCategory
+FakeProfileOAuth2TokenServiceIOSProvider::GetAuthenticationErrorCategory(
+ NSError* error) const {
+ DCHECK(error);
+ return ios::kAuthenticationErrorCategoryAuthorizationErrors;
+}
+
+} // namespace ios
« no previous file with comments | « ios/public/test/fake_profile_oauth2_token_service_ios_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698