OLD | NEW |
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/traffic_annotation/network_traffic_annotation_test_helper.h" | 23 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
24 #include "net/url_request/test_url_fetcher_factory.h" | 24 #include "net/url_request/test_url_fetcher_factory.h" |
25 #include "net/url_request/url_fetcher_delegate.h" | 25 #include "net/url_request/url_fetcher_delegate.h" |
26 #include "net/url_request/url_request_status.h" | 26 #include "net/url_request/url_request_status.h" |
27 | 27 |
| 28 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 29 #error "This file requires ARC support." |
| 30 #endif |
| 31 |
28 namespace { | 32 namespace { |
29 | 33 |
30 net::FakeURLFetcherFactory* gFakeURLFetcherFactory = nullptr; | 34 net::FakeURLFetcherFactory* gFakeURLFetcherFactory = nullptr; |
31 | 35 |
32 // Specialization of the FakeURLFetcherFactory that will recognize GET requests | 36 // Specialization of the FakeURLFetcherFactory that will recognize GET requests |
33 // for MergeSession and answer those requests correctly. | 37 // for MergeSession and answer those requests correctly. |
34 class MergeSessionFakeURLFetcherFactory : public net::FakeURLFetcherFactory { | 38 class MergeSessionFakeURLFetcherFactory : public net::FakeURLFetcherFactory { |
35 public: | 39 public: |
36 explicit MergeSessionFakeURLFetcherFactory(URLFetcherFactory* default_factory) | 40 explicit MergeSessionFakeURLFetcherFactory(URLFetcherFactory* default_factory) |
37 : net::FakeURLFetcherFactory(default_factory) {} | 41 : net::FakeURLFetcherFactory(default_factory) {} |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 account_tracker->RemoveAccount(info.account_id); | 151 account_tracker->RemoveAccount(info.account_id); |
148 } | 152 } |
149 | 153 |
150 // Clear last signed in user preference. | 154 // Clear last signed in user preference. |
151 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); | 155 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastAccountId); |
152 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); | 156 browser_state->GetPrefs()->ClearPref(prefs::kGoogleServicesLastUsername); |
153 | 157 |
154 // Clear known identities. | 158 // Clear known identities. |
155 ios::ChromeIdentityService* identity_service = | 159 ios::ChromeIdentityService* identity_service = |
156 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); | 160 ios::GetChromeBrowserProvider()->GetChromeIdentityService(); |
157 base::scoped_nsobject<NSArray> identities( | 161 NSArray* identities([identity_service->GetAllIdentities() copy]); |
158 [identity_service->GetAllIdentities() copy]); | 162 for (ChromeIdentity* identity in identities) { |
159 for (ChromeIdentity* identity in identities.get()) { | |
160 identity_service->ForgetIdentity(identity, nil); | 163 identity_service->ForgetIdentity(identity, nil); |
161 } | 164 } |
162 | 165 |
163 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:10.0]; | 166 NSDate* deadline = [NSDate dateWithTimeIntervalSinceNow:10.0]; |
164 while (identity_service->HasIdentities() && | 167 while (identity_service->HasIdentities() && |
165 [[NSDate date] compare:deadline] != NSOrderedDescending) { | 168 [[NSDate date] compare:deadline] != NSOrderedDescending) { |
166 base::test::ios::SpinRunLoopWithMaxDelay( | 169 base::test::ios::SpinRunLoopWithMaxDelay( |
167 base::TimeDelta::FromSecondsD(0.01)); | 170 base::TimeDelta::FromSecondsD(0.01)); |
168 } | 171 } |
169 return !identity_service->HasIdentities(); | 172 return !identity_service->HasIdentities(); |
170 } | 173 } |
171 | 174 |
172 } // namespace chrome_test_util | 175 } // namespace chrome_test_util |
OLD | NEW |