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

Side by Side 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 3 years, 12 months 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/settings/sync_encryption_collection_view_controll er.h"
6
7 #include <memory>
8
9 #include "base/compiler_specific.h"
10 #include "base/memory/ptr_util.h"
11 #include "components/browser_sync/profile_sync_service_mock.h"
12 #include "components/strings/grit/components_strings.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"
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 "
17 #import "ios/chrome/browser/ui/settings/cells/encryption_item.h"
18 #include "ios/chrome/grit/ios_strings.h"
19 #include "ios/web/public/test/test_web_thread_bundle.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gtest_mac.h"
23 #include "ui/base/l10n/l10n_util.h"
24
25 namespace {
26
27 using testing::NiceMock;
28 using testing::Return;
29
30 std::unique_ptr<KeyedService> CreateNiceProfileSyncServiceMock(
31 web::BrowserState* context) {
32 browser_sync::ProfileSyncService::InitParams init_params =
33 CreateProfileSyncServiceParamsForTest(
34 nullptr, ios::ChromeBrowserState::FromBrowserState(context));
35 return base::MakeUnique<NiceMock<browser_sync::ProfileSyncServiceMock>>(
36 &init_params);
37 }
38
39 class SyncEncryptionCollectionViewControllerTest
40 : public CollectionViewControllerTest {
41 protected:
42 void SetUp() override {
43 TestChromeBrowserState::Builder test_cbs_builder;
44 test_cbs_builder.AddTestingFactory(
45 IOSChromeProfileSyncServiceFactory::GetInstance(),
46 &CreateNiceProfileSyncServiceMock);
47 chrome_browser_state_ = test_cbs_builder.Build();
48 CollectionViewControllerTest::SetUp();
49
50 mock_profile_sync_service_ =
51 static_cast<browser_sync::ProfileSyncServiceMock*>(
52 IOSChromeProfileSyncServiceFactory::GetForBrowserState(
53 chrome_browser_state_.get()));
54 ON_CALL(*mock_profile_sync_service_, IsEngineInitialized())
55 .WillByDefault(Return(true));
56 ON_CALL(*mock_profile_sync_service_, IsUsingSecondaryPassphrase())
57 .WillByDefault(Return(true));
58
59 CreateController();
60 }
61
62 CollectionViewController* NewController() override NS_RETURNS_RETAINED {
63 return [[SyncEncryptionCollectionViewController alloc]
64 initWithBrowserState:chrome_browser_state_.get()];
65 }
66
67 web::TestWebThreadBundle thread_bundle_;
68 std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
69 // Weak, owned by |chrome_browser_state_|.
70 browser_sync::ProfileSyncServiceMock* mock_profile_sync_service_;
71 };
72
73 TEST_F(SyncEncryptionCollectionViewControllerTest, TestModel) {
74 CheckController();
75 CheckTitleWithId(IDS_IOS_SYNC_ENCRYPTION_TITLE);
76
77 EXPECT_EQ(2, NumberOfSections());
78
79 NSInteger const kSection = 0;
80 EXPECT_EQ(2, NumberOfItemsInSection(kSection));
81
82 EncryptionItem* accountItem = GetCollectionViewItem(kSection, 0);
83 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_BASIC_ENCRYPTION_DATA),
84 accountItem.text);
85
86 EncryptionItem* passphraseItem = GetCollectionViewItem(kSection, 1);
87 EXPECT_NSEQ(l10n_util::GetNSString(IDS_SYNC_FULL_ENCRYPTION_DATA),
88 passphraseItem.text);
89 }
90
91 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698