| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_passphrase_collection_vi
ew_controller.h" | 5 #import "ios/chrome/browser/ui/settings/sync_encryption_passphrase_collection_vi
ew_controller.h" |
| 6 | 6 |
| 7 #import <UIKit/UIKit.h> | 7 #import <UIKit/UIKit.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #import "base/mac/scoped_nsobject.h" | |
| 13 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 14 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 16 #import "base/test/ios/wait_util.h" | 15 #import "base/test/ios/wait_util.h" |
| 17 #include "components/browser_sync/profile_sync_service_mock.h" | 16 #include "components/browser_sync/profile_sync_service_mock.h" |
| 18 #include "components/strings/grit/components_strings.h" | 17 #include "components/strings/grit/components_strings.h" |
| 19 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 18 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
| 20 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" | 19 #include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h" |
| 21 #include "ios/chrome/browser/sync/sync_setup_service.h" | 20 #include "ios/chrome/browser/sync/sync_setup_service.h" |
| 22 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" | 21 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" |
| 23 #include "ios/chrome/browser/sync/sync_setup_service_mock.h" | 22 #include "ios/chrome/browser/sync/sync_setup_service_mock.h" |
| 24 #import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h" | 23 #import "ios/chrome/browser/ui/settings/cells/byo_textfield_item.h" |
| 25 #import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h" | 24 #import "ios/chrome/browser/ui/settings/cells/card_multiline_item.h" |
| 26 #import "ios/chrome/browser/ui/settings/passphrase_collection_view_controller_te
st.h" | 25 #import "ios/chrome/browser/ui/settings/passphrase_collection_view_controller_te
st.h" |
| 27 #import "ios/chrome/browser/ui/sync/sync_util.h" | 26 #import "ios/chrome/browser/ui/sync/sync_util.h" |
| 28 #import "testing/gtest_mac.h" | 27 #import "testing/gtest_mac.h" |
| 29 #include "testing/platform_test.h" | 28 #include "testing/platform_test.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "ui/base/l10n/l10n_util_mac.h" | 30 #include "ui/base/l10n/l10n_util_mac.h" |
| 32 | 31 |
| 32 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 33 #error "This file requires ARC support." |
| 34 #endif |
| 35 |
| 33 namespace { | 36 namespace { |
| 34 | 37 |
| 35 using testing::_; | 38 using testing::_; |
| 36 using testing::AtLeast; | 39 using testing::AtLeast; |
| 37 using testing::NiceMock; | 40 using testing::NiceMock; |
| 38 using testing::Return; | 41 using testing::Return; |
| 39 | 42 |
| 40 class SyncEncryptionPassphraseCollectionViewControllerTest | 43 class SyncEncryptionPassphraseCollectionViewControllerTest |
| 41 : public PassphraseCollectionViewControllerTest { | 44 : public PassphraseCollectionViewControllerTest { |
| 42 public: | 45 public: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // will by default return false. GetSyncServiceState(), however, returns an | 81 // will by default return false. GetSyncServiceState(), however, returns an |
| 79 // enum, and thus always needs its default value set. | 82 // enum, and thus always needs its default value set. |
| 80 TurnSyncErrorOff(); | 83 TurnSyncErrorOff(); |
| 81 }; | 84 }; |
| 82 | 85 |
| 83 void TearDown() override { | 86 void TearDown() override { |
| 84 [SyncController() stopObserving]; | 87 [SyncController() stopObserving]; |
| 85 PassphraseCollectionViewControllerTest::TearDown(); | 88 PassphraseCollectionViewControllerTest::TearDown(); |
| 86 } | 89 } |
| 87 | 90 |
| 88 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 91 CollectionViewController* InstantiateController() override { |
| 89 return [[SyncEncryptionPassphraseCollectionViewController alloc] | 92 return [[SyncEncryptionPassphraseCollectionViewController alloc] |
| 90 initWithBrowserState:chrome_browser_state_.get()]; | 93 initWithBrowserState:chrome_browser_state_.get()]; |
| 91 } | 94 } |
| 92 | 95 |
| 93 SyncEncryptionPassphraseCollectionViewController* SyncController() { | 96 SyncEncryptionPassphraseCollectionViewController* SyncController() { |
| 94 return static_cast<SyncEncryptionPassphraseCollectionViewController*>( | 97 return static_cast<SyncEncryptionPassphraseCollectionViewController*>( |
| 95 controller()); | 98 controller()); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Weak, owned by |profile_|. | 101 // Weak, owned by |profile_|. |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 EXPECT_FALSE([sync_controller syncErrorMessage]); | 232 EXPECT_FALSE([sync_controller syncErrorMessage]); |
| 230 TurnSyncOtherErrorOn(otherState); | 233 TurnSyncOtherErrorOn(otherState); |
| 231 EXPECT_NSEQ(ios_internal::sync::GetSyncErrorMessageForBrowserState( | 234 EXPECT_NSEQ(ios_internal::sync::GetSyncErrorMessageForBrowserState( |
| 232 chrome_browser_state_.get()), | 235 chrome_browser_state_.get()), |
| 233 [sync_controller syncErrorMessage]); | 236 [sync_controller syncErrorMessage]); |
| 234 TurnSyncErrorOff(); | 237 TurnSyncErrorOff(); |
| 235 EXPECT_FALSE([sync_controller syncErrorMessage]); | 238 EXPECT_FALSE([sync_controller syncErrorMessage]); |
| 236 } | 239 } |
| 237 | 240 |
| 238 } // namespace | 241 } // namespace |
| OLD | NEW |