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_encryption_collection_view_controll
er.h" | 5 #import "ios/chrome/browser/ui/settings/sync_encryption_collection_view_controll
er.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
11 #include "components/browser_sync/profile_sync_service_mock.h" | 11 #include "components/browser_sync/profile_sync_service_mock.h" |
12 #include "components/strings/grit/components_strings.h" | 12 #include "components/strings/grit/components_strings.h" |
13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
14 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 14 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
15 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" | 15 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h" |
16 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 16 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
17 #import "ios/chrome/browser/ui/settings/cells/encryption_item.h" | 17 #import "ios/chrome/browser/ui/settings/cells/encryption_item.h" |
18 #include "ios/chrome/grit/ios_strings.h" | 18 #include "ios/chrome/grit/ios_strings.h" |
19 #include "ios/web/public/test/test_web_thread_bundle.h" | 19 #include "ios/web/public/test/test_web_thread_bundle.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #import "testing/gtest_mac.h" | 22 #import "testing/gtest_mac.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 | 24 |
| 25 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 26 #error "This file requires ARC support." |
| 27 #endif |
| 28 |
25 namespace { | 29 namespace { |
26 | 30 |
27 using testing::NiceMock; | 31 using testing::NiceMock; |
28 using testing::Return; | 32 using testing::Return; |
29 | 33 |
30 std::unique_ptr<KeyedService> CreateNiceProfileSyncServiceMock( | 34 std::unique_ptr<KeyedService> CreateNiceProfileSyncServiceMock( |
31 web::BrowserState* context) { | 35 web::BrowserState* context) { |
32 browser_sync::ProfileSyncService::InitParams init_params = | 36 browser_sync::ProfileSyncService::InitParams init_params = |
33 CreateProfileSyncServiceParamsForTest( | 37 CreateProfileSyncServiceParamsForTest( |
34 nullptr, ios::ChromeBrowserState::FromBrowserState(context)); | 38 nullptr, ios::ChromeBrowserState::FromBrowserState(context)); |
(...skipping 17 matching lines...) Expand all Loading... |
52 IOSChromeProfileSyncServiceFactory::GetForBrowserState( | 56 IOSChromeProfileSyncServiceFactory::GetForBrowserState( |
53 chrome_browser_state_.get())); | 57 chrome_browser_state_.get())); |
54 ON_CALL(*mock_profile_sync_service_, IsEngineInitialized()) | 58 ON_CALL(*mock_profile_sync_service_, IsEngineInitialized()) |
55 .WillByDefault(Return(true)); | 59 .WillByDefault(Return(true)); |
56 ON_CALL(*mock_profile_sync_service_, IsUsingSecondaryPassphrase()) | 60 ON_CALL(*mock_profile_sync_service_, IsUsingSecondaryPassphrase()) |
57 .WillByDefault(Return(true)); | 61 .WillByDefault(Return(true)); |
58 | 62 |
59 CreateController(); | 63 CreateController(); |
60 } | 64 } |
61 | 65 |
62 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 66 CollectionViewController* InstantiateController() override { |
63 return [[SyncEncryptionCollectionViewController alloc] | 67 return [[SyncEncryptionCollectionViewController alloc] |
64 initWithBrowserState:chrome_browser_state_.get()]; | 68 initWithBrowserState:chrome_browser_state_.get()]; |
65 } | 69 } |
66 | 70 |
67 web::TestWebThreadBundle thread_bundle_; | 71 web::TestWebThreadBundle thread_bundle_; |
68 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; | 72 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_; |
69 // Weak, owned by |chrome_browser_state_|. | 73 // Weak, owned by |chrome_browser_state_|. |
70 browser_sync::ProfileSyncServiceMock* mock_profile_sync_service_; | 74 browser_sync::ProfileSyncServiceMock* mock_profile_sync_service_; |
71 }; | 75 }; |
72 | 76 |
73 TEST_F(SyncEncryptionCollectionViewControllerTest, TestModel) { | 77 TEST_F(SyncEncryptionCollectionViewControllerTest, TestModel) { |
74 CheckController(); | 78 CheckController(); |
75 CheckTitleWithId(IDS_IOS_SYNC_ENCRYPTION_TITLE); | 79 CheckTitleWithId(IDS_IOS_SYNC_ENCRYPTION_TITLE); |
76 | 80 |
77 EXPECT_EQ(2, NumberOfSections()); | 81 EXPECT_EQ(2, NumberOfSections()); |
78 | 82 |
79 NSInteger const kSection = 0; | 83 NSInteger const kSection = 0; |
80 EXPECT_EQ(2, NumberOfItemsInSection(kSection)); | 84 EXPECT_EQ(2, NumberOfItemsInSection(kSection)); |
81 | 85 |
82 EncryptionItem* accountItem = GetCollectionViewItem(kSection, 0); | 86 EncryptionItem* accountItem = GetCollectionViewItem(kSection, 0); |
83 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_BASIC_ENCRYPTION_DATA), | 87 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_BASIC_ENCRYPTION_DATA), |
84 accountItem.text); | 88 accountItem.text); |
85 | 89 |
86 EncryptionItem* passphraseItem = GetCollectionViewItem(kSection, 1); | 90 EncryptionItem* passphraseItem = GetCollectionViewItem(kSection, 1); |
87 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_FULL_ENCRYPTION_DATA), | 91 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_FULL_ENCRYPTION_DATA), |
88 passphraseItem.text); | 92 passphraseItem.text); |
89 } | 93 } |
90 | 94 |
91 } // namespace | 95 } // namespace |
OLD | NEW |