OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h" | 5 #import "ios/chrome/browser/signin/chrome_identity_service_observer_bridge.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" | 10 #import "ios/public/provider/chrome/browser/signin/chrome_identity.h" |
10 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" | 11 #include "ios/public/provider/chrome/browser/signin/chrome_identity_service.h" |
11 #include "testing/gtest_mac.h" | 12 #include "testing/gtest_mac.h" |
12 #include "testing/platform_test.h" | 13 #include "testing/platform_test.h" |
13 | 14 |
14 @interface TestChromeIdentityServiceObserver | 15 @interface TestChromeIdentityServiceObserver |
15 : NSObject<ChromeIdentityServiceObserver> | 16 : NSObject<ChromeIdentityServiceObserver> |
16 @property(nonatomic) BOOL onIdentityListChangedCalled; | 17 @property(nonatomic) BOOL onIdentityListChangedCalled; |
17 @property(nonatomic) BOOL onAccessTokenRefreshFailedCalled; | 18 @property(nonatomic) BOOL onAccessTokenRefreshFailedCalled; |
18 @property(nonatomic) BOOL onProfileUpdateCalled; | 19 @property(nonatomic) BOOL onProfileUpdateCalled; |
19 @property(nonatomic) BOOL onChromeIdentityServiceWillBeDestroyedCalled; | 20 @property(nonatomic) BOOL onChromeIdentityServiceWillBeDestroyedCalled; |
20 @property(nonatomic, assign) ChromeIdentity* identity; | 21 @property(nonatomic, assign) ChromeIdentity* identity; |
21 @property(nonatomic, readonly) NSDictionary* userInfo; | 22 @property(nonatomic, readonly) NSDictionary* userInfo; |
22 @property(nonatomic, readonly) | 23 @property(nonatomic, readonly) |
23 ios::ChromeIdentityService::Observer* observerBridge; | 24 ios::ChromeIdentityService::Observer* observerBridge; |
24 @end | 25 @end |
25 | 26 |
26 @implementation TestChromeIdentityServiceObserver { | 27 @implementation TestChromeIdentityServiceObserver { |
27 scoped_ptr<ios::ChromeIdentityService::Observer> observer_bridge_; | 28 std::unique_ptr<ios::ChromeIdentityService::Observer> observer_bridge_; |
28 } | 29 } |
29 | 30 |
30 @synthesize onIdentityListChangedCalled = _onIdentityListChangedCalled; | 31 @synthesize onIdentityListChangedCalled = _onIdentityListChangedCalled; |
31 @synthesize onAccessTokenRefreshFailedCalled = | 32 @synthesize onAccessTokenRefreshFailedCalled = |
32 _onAccessTokenRefreshFailedCalled; | 33 _onAccessTokenRefreshFailedCalled; |
33 @synthesize onProfileUpdateCalled = _onProfileUpdateCalled; | 34 @synthesize onProfileUpdateCalled = _onProfileUpdateCalled; |
34 @synthesize onChromeIdentityServiceWillBeDestroyedCalled = | 35 @synthesize onChromeIdentityServiceWillBeDestroyedCalled = |
35 _onChromeIdentityServiceWillBeDestroyedCalled; | 36 _onChromeIdentityServiceWillBeDestroyedCalled; |
36 @synthesize identity = _identity; | 37 @synthesize identity = _identity; |
37 @synthesize userInfo = _userInfo; | 38 @synthesize userInfo = _userInfo; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // Tests that |onChromeIdentityServiceWillBeDestroyed| is forwarded. | 130 // Tests that |onChromeIdentityServiceWillBeDestroyed| is forwarded. |
130 TEST_F(ChromeIdentityServiceObserverBridgeTest, | 131 TEST_F(ChromeIdentityServiceObserverBridgeTest, |
131 onChromeIdentityServiceWillBeDestroyed) { | 132 onChromeIdentityServiceWillBeDestroyed) { |
132 ASSERT_FALSE(GetTestObserver().onChromeIdentityServiceWillBeDestroyedCalled); | 133 ASSERT_FALSE(GetTestObserver().onChromeIdentityServiceWillBeDestroyedCalled); |
133 GetObserverBridge()->OnChromeIdentityServiceWillBeDestroyed(); | 134 GetObserverBridge()->OnChromeIdentityServiceWillBeDestroyed(); |
134 EXPECT_FALSE(GetTestObserver().onIdentityListChangedCalled); | 135 EXPECT_FALSE(GetTestObserver().onIdentityListChangedCalled); |
135 EXPECT_FALSE(GetTestObserver().onAccessTokenRefreshFailedCalled); | 136 EXPECT_FALSE(GetTestObserver().onAccessTokenRefreshFailedCalled); |
136 EXPECT_FALSE(GetTestObserver().onProfileUpdateCalled); | 137 EXPECT_FALSE(GetTestObserver().onProfileUpdateCalled); |
137 EXPECT_TRUE(GetTestObserver().onChromeIdentityServiceWillBeDestroyedCalled); | 138 EXPECT_TRUE(GetTestObserver().onChromeIdentityServiceWillBeDestroyedCalled); |
138 } | 139 } |
OLD | NEW |