Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Unified Diff: ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller_unittest.mm

Issue 2587023002: Upstream Chrome on iOS source code [8/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller_unittest.mm
diff --git a/ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller_unittest.mm b/ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..232a9870e5d8a30e3e645dea03b37bf945ff0857
--- /dev/null
+++ b/ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller_unittest.mm
@@ -0,0 +1,91 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/browser/ui/settings/sync_encryption_collection_view_controller.h"
+
+#include <memory>
+
+#include "base/compiler_specific.h"
+#include "base/memory/ptr_util.h"
+#include "components/browser_sync/profile_sync_service_mock.h"
+#include "components/strings/grit/components_strings.h"
+#include "ios/chrome/browser/browser_state/test_chrome_browser_state.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_service_factory.h"
+#include "ios/chrome/browser/sync/ios_chrome_profile_sync_test_util.h"
+#import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h"
+#import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
+#include "ios/chrome/grit/ios_strings.h"
+#include "ios/web/public/test/test_web_thread_bundle.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+using testing::NiceMock;
+using testing::Return;
+
+std::unique_ptr<KeyedService> CreateNiceProfileSyncServiceMock(
+ web::BrowserState* context) {
+ browser_sync::ProfileSyncService::InitParams init_params =
+ CreateProfileSyncServiceParamsForTest(
+ nullptr, ios::ChromeBrowserState::FromBrowserState(context));
+ return base::MakeUnique<NiceMock<browser_sync::ProfileSyncServiceMock>>(
+ &init_params);
+}
+
+class SyncEncryptionCollectionViewControllerTest
+ : public CollectionViewControllerTest {
+ protected:
+ void SetUp() override {
+ TestChromeBrowserState::Builder test_cbs_builder;
+ test_cbs_builder.AddTestingFactory(
+ IOSChromeProfileSyncServiceFactory::GetInstance(),
+ &CreateNiceProfileSyncServiceMock);
+ chrome_browser_state_ = test_cbs_builder.Build();
+ CollectionViewControllerTest::SetUp();
+
+ mock_profile_sync_service_ =
+ static_cast<browser_sync::ProfileSyncServiceMock*>(
+ IOSChromeProfileSyncServiceFactory::GetForBrowserState(
+ chrome_browser_state_.get()));
+ ON_CALL(*mock_profile_sync_service_, IsEngineInitialized())
+ .WillByDefault(Return(true));
+ ON_CALL(*mock_profile_sync_service_, IsUsingSecondaryPassphrase())
+ .WillByDefault(Return(true));
+
+ CreateController();
+ }
+
+ CollectionViewController* NewController() override NS_RETURNS_RETAINED {
+ return [[SyncEncryptionCollectionViewController alloc]
+ initWithBrowserState:chrome_browser_state_.get()];
+ }
+
+ web::TestWebThreadBundle thread_bundle_;
+ std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
+ // Weak, owned by |chrome_browser_state_|.
+ browser_sync::ProfileSyncServiceMock* mock_profile_sync_service_;
+};
+
+TEST_F(SyncEncryptionCollectionViewControllerTest, TestModel) {
+ CheckController();
+ CheckTitleWithId(IDS_IOS_SYNC_ENCRYPTION_TITLE);
+
+ EXPECT_EQ(2, NumberOfSections());
+
+ NSInteger const kSection = 0;
+ EXPECT_EQ(2, NumberOfItemsInSection(kSection));
+
+ EncryptionItem* accountItem = GetCollectionViewItem(kSection, 0);
+ EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_BASIC_ENCRYPTION_DATA),
+ accountItem.text);
+
+ EncryptionItem* passphraseItem = GetCollectionViewItem(kSection, 1);
+ EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_FULL_ENCRYPTION_DATA),
+ passphraseItem.text);
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698