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

Side by Side Diff: ios/chrome/test/app/signin_test_util.mm

Issue 2888173002: [ObjC ARC] Converts ios/chrome/test/app:test_support to ARC. (Closed)
Patch Set: fix test and DEPS Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "ios/chrome/test/app/signin_test_util.h" 5 #include "ios/chrome/test/app/signin_test_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #import "base/test/ios/wait_util.h" 9 #import "base/test/ios/wait_util.h"
10 #include "components/prefs/pref_service.h" 10 #include "components/prefs/pref_service.h"
11 #include "components/signin/core/browser/account_tracker_service.h" 11 #include "components/signin/core/browser/account_tracker_service.h"
12 #include "components/signin/core/common/signin_pref_names.h" 12 #include "components/signin/core/common/signin_pref_names.h"
13 #include "google_apis/gaia/gaia_constants.h" 13 #include "google_apis/gaia/gaia_constants.h"
14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" 14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
15 #include "ios/chrome/browser/signin/account_tracker_service_factory.h" 15 #include "ios/chrome/browser/signin/account_tracker_service_factory.h"
16 #import "ios/chrome/browser/signin/authentication_service.h" 16 #import "ios/chrome/browser/signin/authentication_service.h"
17 #include "ios/chrome/browser/signin/authentication_service_factory.h" 17 #include "ios/chrome/browser/signin/authentication_service_factory.h"
18 #include "ios/chrome/browser/signin/gaia_auth_fetcher_ios.h" 18 #include "ios/chrome/browser/signin/gaia_auth_fetcher_ios.h"
19 #import "ios/chrome/test/app/chrome_test_util.h" 19 #import "ios/chrome/test/app/chrome_test_util.h"
20 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h" 20 #import "ios/public/provider/chrome/browser/chrome_browser_provider.h"
21 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h" 21 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service. h"
22 #include "net/http/http_status_code.h" 22 #include "net/http/http_status_code.h"
23 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
24 #include "net/url_request/url_fetcher_delegate.h" 24 #include "net/url_request/url_fetcher_delegate.h"
25 #include "net/url_request/url_request_status.h" 25 #include "net/url_request/url_request_status.h"
26 26
27 #if !defined(__has_feature) || !__has_feature(objc_arc)
28 #error "This file requires ARC support."
29 #endif
30
27 namespace { 31 namespace {
28 32
29 net::FakeURLFetcherFactory* gFakeURLFetcherFactory = nullptr; 33 net::FakeURLFetcherFactory* gFakeURLFetcherFactory = nullptr;
30 34
31 // Specialization of the FakeURLFetcherFactory that will recognize GET requests 35 // Specialization of the FakeURLFetcherFactory that will recognize GET requests
32 // for MergeSession and answer those requests correctly. 36 // for MergeSession and answer those requests correctly.
33 class MergeSessionFakeURLFetcherFactory : public net::FakeURLFetcherFactory { 37 class MergeSessionFakeURLFetcherFactory : public net::FakeURLFetcherFactory {
34 public: 38 public:
35 explicit MergeSessionFakeURLFetcherFactory(URLFetcherFactory* default_factory) 39 explicit MergeSessionFakeURLFetcherFactory(URLFetcherFactory* default_factory)
36 : net::FakeURLFetcherFactory(default_factory) {} 40 : net::FakeURLFetcherFactory(default_factory) {}
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 account_tracker->RemoveAccount(info.account_id); 149 account_tracker->RemoveAccount(info.account_id);
146 } 150 }
147 151
148 // Clear last signed in user preference. 152 // Clear last signed in user preference.
149 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); 153 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId);
150 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); 154 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername);
151 155
152 // Clear known identities. 156 // Clear known identities.
153 ios::ChromeIdentityService* identity_service = 157 ios::ChromeIdentityService* identity_service =
154 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); 158 ios::GetChromeBrowserProvider()->GetChromeIdentityService();
155 base::scoped_nsobject<NSArray> identities( 159 NSArray* identities([identity_service->GetAllIdentities() copy]);
156 [identity_service->GetAllIdentities() copy]); 160 for (ChromeIdentity* identity in identities) {
157 for (ChromeIdentity* identity in identities.get()) {
158 identity_service->ForgetIdentity(identity, nil); 161 identity_service->ForgetIdentity(identity, nil);
159 } 162 }
160 163
161 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:10.0]; 164 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:10.0];
162 while (identity_service->HasIdentities() && 165 while (identity_service->HasIdentities() &&
163 [[NSDate date] compare:deadline] != NSOrderedDescending) { 166 [[NSDate date] compare:deadline] != NSOrderedDescending) {
164 base::test::ios::SpinRunLoopWithMaxDelay( 167 base::test::ios::SpinRunLoopWithMaxDelay(
165 base::TimeDelta::FromSecondsD(0.01)); 168 base::TimeDelta::FromSecondsD(0.01));
166 } 169 }
167 return !identity_service->HasIdentities(); 170 return !identity_service->HasIdentities();
168 } 171 }
169 172
170 } // namespace chrome_test_util 173 } // namespace chrome_test_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698