| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "components/browser_sync/profile_sync_service_mock.h" | 10 #include "components/browser_sync/profile_sync_service_mock.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager
.h" | 39 #include "ios/chrome/test/ios_chrome_scoped_testing_chrome_browser_state_manager
.h" |
| 40 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 40 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 41 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" | 41 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" |
| 42 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" | 42 #import "ios/public/provider/chrome/browser/signin/fake_chrome_identity_service.
h" |
| 43 #include "ios/web/public/test/test_web_thread_bundle.h" | 43 #include "ios/web/public/test/test_web_thread_bundle.h" |
| 44 #include "testing/gtest/include/gtest/gtest.h" | 44 #include "testing/gtest/include/gtest/gtest.h" |
| 45 #include "testing/gtest_mac.h" | 45 #include "testing/gtest_mac.h" |
| 46 #include "testing/platform_test.h" | 46 #include "testing/platform_test.h" |
| 47 #import "third_party/ocmock/OCMock/OCMock.h" | 47 #import "third_party/ocmock/OCMock/OCMock.h" |
| 48 | 48 |
| 49 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 50 #error "This file requires ARC support." |
| 51 #endif |
| 52 |
| 49 using testing::_; | 53 using testing::_; |
| 50 using testing::Invoke; | 54 using testing::Invoke; |
| 51 using testing::Return; | 55 using testing::Return; |
| 52 | 56 |
| 53 namespace { | 57 namespace { |
| 54 | 58 |
| 55 class FakeSigninClient : public SigninClientImpl { | 59 class FakeSigninClient : public SigninClientImpl { |
| 56 public: | 60 public: |
| 57 explicit FakeSigninClient(ios::ChromeBrowserState* browser_state) | 61 explicit FakeSigninClient(ios::ChromeBrowserState* browser_state) |
| 58 : SigninClientImpl(browser_state, | 62 : SigninClientImpl(browser_state, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 authentication_service_->OnAccessTokenRefreshFailed(identity, user_info); | 194 authentication_service_->OnAccessTokenRefreshFailed(identity, user_info); |
| 191 } | 195 } |
| 192 | 196 |
| 193 void FireIdentityListChanged() { | 197 void FireIdentityListChanged() { |
| 194 authentication_service_->OnIdentityListChanged(); | 198 authentication_service_->OnIdentityListChanged(); |
| 195 } | 199 } |
| 196 | 200 |
| 197 void SetCachedMDMInfo(ChromeIdentity* identity, NSDictionary* user_info) { | 201 void SetCachedMDMInfo(ChromeIdentity* identity, NSDictionary* user_info) { |
| 198 authentication_service_ | 202 authentication_service_ |
| 199 ->cached_mdm_infos_[base::SysNSStringToUTF8([identity gaiaID])] | 203 ->cached_mdm_infos_[base::SysNSStringToUTF8([identity gaiaID])] |
| 200 .reset([user_info retain]); | 204 .reset(user_info); |
| 201 } | 205 } |
| 202 | 206 |
| 203 bool HasCachedMDMInfo(ChromeIdentity* identity) { | 207 bool HasCachedMDMInfo(ChromeIdentity* identity) { |
| 204 return authentication_service_->cached_mdm_infos_.count( | 208 return authentication_service_->cached_mdm_infos_.count( |
| 205 base::SysNSStringToUTF8([identity gaiaID])) > 0; | 209 base::SysNSStringToUTF8([identity gaiaID])) > 0; |
| 206 } | 210 } |
| 207 | 211 |
| 208 void OnRefreshTokenAvailable(const std::string& account_id) override { | 212 void OnRefreshTokenAvailable(const std::string& account_id) override { |
| 209 refresh_token_available_count_++; | 213 refresh_token_available_count_++; |
| 210 } | 214 } |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 NSDictionary* user_info = [NSDictionary dictionary]; | 739 NSDictionary* user_info = [NSDictionary dictionary]; |
| 736 SetCachedMDMInfo(identity_, user_info); | 740 SetCachedMDMInfo(identity_, user_info); |
| 737 | 741 |
| 738 EXPECT_CALL(*identity_service_, | 742 EXPECT_CALL(*identity_service_, |
| 739 HandleMDMNotification(identity_, user_info, _)) | 743 HandleMDMNotification(identity_, user_info, _)) |
| 740 .WillOnce(Return(true)); | 744 .WillOnce(Return(true)); |
| 741 | 745 |
| 742 EXPECT_TRUE( | 746 EXPECT_TRUE( |
| 743 authentication_service_->ShowMDMErrorDialogForIdentity(identity_)); | 747 authentication_service_->ShowMDMErrorDialogForIdentity(identity_)); |
| 744 } | 748 } |
| OLD | NEW |