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/ui/settings/sync_create_passphrase_collection_view_c
ontroller.h" | 5 #import "ios/chrome/browser/ui/settings/sync_create_passphrase_collection_view_c
ontroller.h" |
6 | 6 |
7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #import "base/mac/scoped_nsobject.h" | |
11 #import "base/test/ios/wait_util.h" | 10 #import "base/test/ios/wait_util.h" |
12 #include "components/browser_sync/profile_sync_service_mock.h" | 11 #include "components/browser_sync/profile_sync_service_mock.h" |
13 #include "components/strings/grit/components_strings.h" | 12 #include "components/strings/grit/components_strings.h" |
14 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
15 #import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h" | 14 #import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h" |
16 #import "ios/chrome/browser/ui/settings/cells/passphrase_error_item.h" | 15 #import "ios/chrome/browser/ui/settings/cells/passphrase_error_item.h" |
17 #import "ios/chrome/browser/ui/settings/passphrase_collection_view_controller_te
st.h" | 16 #import "ios/chrome/browser/ui/settings/passphrase_collection_view_controller_te
st.h" |
18 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
20 #import "testing/gtest_mac.h" | 19 #import "testing/gtest_mac.h" |
21 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
22 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/l10n/l10n_util_mac.h" | 22 #include "ui/base/l10n/l10n_util_mac.h" |
24 | 23 |
| 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 25 #error "This file requires ARC support." |
| 26 #endif |
| 27 |
25 namespace { | 28 namespace { |
26 | 29 |
27 using testing::_; | 30 using testing::_; |
28 using testing::AtLeast; | 31 using testing::AtLeast; |
29 using testing::Return; | 32 using testing::Return; |
30 | 33 |
31 class SyncCreatePassphraseCollectionViewControllerTest | 34 class SyncCreatePassphraseCollectionViewControllerTest |
32 : public PassphraseCollectionViewControllerTest { | 35 : public PassphraseCollectionViewControllerTest { |
33 public: | 36 public: |
34 SyncCreatePassphraseCollectionViewControllerTest() {} | 37 SyncCreatePassphraseCollectionViewControllerTest() {} |
35 | 38 |
36 protected: | 39 protected: |
37 void TearDown() override { | 40 void TearDown() override { |
38 [SyncController() stopObserving]; | 41 [SyncController() stopObserving]; |
39 PassphraseCollectionViewControllerTest::TearDown(); | 42 PassphraseCollectionViewControllerTest::TearDown(); |
40 } | 43 } |
41 | 44 |
42 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 45 CollectionViewController* InstantiateController() override { |
43 return [[SyncCreatePassphraseCollectionViewController alloc] | 46 return [[SyncCreatePassphraseCollectionViewController alloc] |
44 initWithBrowserState:chrome_browser_state_.get()]; | 47 initWithBrowserState:chrome_browser_state_.get()]; |
45 } | 48 } |
46 | 49 |
47 SyncCreatePassphraseCollectionViewController* SyncController() { | 50 SyncCreatePassphraseCollectionViewController* SyncController() { |
48 return static_cast<SyncCreatePassphraseCollectionViewController*>( | 51 return static_cast<SyncCreatePassphraseCollectionViewController*>( |
49 controller()); | 52 controller()); |
50 } | 53 } |
51 }; | 54 }; |
52 | 55 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // Verifies that sync errors don't make the navigation item disappear. | 196 // Verifies that sync errors don't make the navigation item disappear. |
194 // Regression test for http://crbug.com/501784. | 197 // Regression test for http://crbug.com/501784. |
195 TEST_F(SyncCreatePassphraseCollectionViewControllerTest, | 198 TEST_F(SyncCreatePassphraseCollectionViewControllerTest, |
196 DISABLED_TestOnStateChangedError) { | 199 DISABLED_TestOnStateChangedError) { |
197 SyncCreatePassphraseCollectionViewController* sync_controller = | 200 SyncCreatePassphraseCollectionViewController* sync_controller = |
198 SyncController(); | 201 SyncController(); |
199 SetUpNavigationController(sync_controller); | 202 SetUpNavigationController(sync_controller); |
200 EXPECT_EQ([nav_controller_ topViewController], sync_controller); | 203 EXPECT_EQ([nav_controller_ topViewController], sync_controller); |
201 EXPECT_NE(nil, sync_controller.title); | 204 EXPECT_NE(nil, sync_controller.title); |
202 // Install a fake left button item, to check it's not removed. | 205 // Install a fake left button item, to check it's not removed. |
203 base::scoped_nsobject<UIBarButtonItem> leftBarButtonItem( | 206 UIBarButtonItem* leftBarButtonItem = |
204 [[UIBarButtonItem alloc] initWithTitle:@"Left" | 207 [[UIBarButtonItem alloc] initWithTitle:@"Left" |
205 style:UIBarButtonItemStylePlain | 208 style:UIBarButtonItemStylePlain |
206 target:nil | 209 target:nil |
207 action:nil]); | 210 action:nil]; |
208 sync_controller.navigationItem.leftBarButtonItem = leftBarButtonItem; | 211 sync_controller.navigationItem.leftBarButtonItem = leftBarButtonItem; |
209 | 212 |
210 // Set up the fake sync service to be in a passphrase creation state. | 213 // Set up the fake sync service to be in a passphrase creation state. |
211 ON_CALL(*fake_sync_service_, IsPassphraseRequired()) | 214 ON_CALL(*fake_sync_service_, IsPassphraseRequired()) |
212 .WillByDefault(Return(false)); | 215 .WillByDefault(Return(false)); |
213 ON_CALL(*fake_sync_service_, IsUsingSecondaryPassphrase()) | 216 ON_CALL(*fake_sync_service_, IsUsingSecondaryPassphrase()) |
214 .WillByDefault(Return(false)); | 217 .WillByDefault(Return(false)); |
215 [sync_controller onSyncStateChanged]; | 218 [sync_controller onSyncStateChanged]; |
216 EXPECT_EQ([nav_controller_ topViewController], sync_controller); | 219 EXPECT_EQ([nav_controller_ topViewController], sync_controller); |
217 EXPECT_NE(nil, sync_controller.title); | 220 EXPECT_NE(nil, sync_controller.title); |
218 EXPECT_EQ(leftBarButtonItem.get(), | 221 EXPECT_EQ(leftBarButtonItem, |
219 sync_controller.navigationItem.leftBarButtonItem); | 222 sync_controller.navigationItem.leftBarButtonItem); |
220 } | 223 } |
221 | 224 |
222 } // namespace | 225 } // namespace |
OLD | NEW |