| 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/do_not_track_collection_view_controller.
h" | 5 #import "ios/chrome/browser/ui/settings/do_not_track_collection_view_controller.
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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #import "base/mac/scoped_nsobject.h" | |
| 12 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 13 #include "components/prefs/pref_member.h" | 12 #include "components/prefs/pref_member.h" |
| 14 #include "components/prefs/pref_registry_simple.h" | 13 #include "components/prefs/pref_registry_simple.h" |
| 15 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 16 #include "components/sync_preferences/pref_service_mock_factory.h" | 15 #include "components/sync_preferences/pref_service_mock_factory.h" |
| 17 #include "ios/chrome/browser/pref_names.h" | 16 #include "ios/chrome/browser/pref_names.h" |
| 18 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 17 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
| 19 #include "ios/chrome/grit/ios_strings.h" | 18 #include "ios/chrome/grit/ios_strings.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #import "testing/gtest_mac.h" | 20 #import "testing/gtest_mac.h" |
| 22 #include "testing/platform_test.h" | 21 #include "testing/platform_test.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 class DoNotTrackCollectionViewControllerTest | 30 class DoNotTrackCollectionViewControllerTest |
| 28 : public CollectionViewControllerTest { | 31 : public CollectionViewControllerTest { |
| 29 protected: | 32 protected: |
| 30 void SetUp() override { | 33 void SetUp() override { |
| 31 CollectionViewControllerTest::SetUp(); | 34 CollectionViewControllerTest::SetUp(); |
| 32 pref_service_ = CreateLocalState(); | 35 pref_service_ = CreateLocalState(); |
| 33 } | 36 } |
| 34 | 37 |
| 35 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 38 CollectionViewController* InstantiateController() override { |
| 36 return [[DoNotTrackCollectionViewController alloc] | 39 return [[DoNotTrackCollectionViewController alloc] |
| 37 initWithPrefs:pref_service_.get()]; | 40 initWithPrefs:pref_service_.get()]; |
| 38 } | 41 } |
| 39 | 42 |
| 40 std::unique_ptr<PrefService> CreateLocalState() { | 43 std::unique_ptr<PrefService> CreateLocalState() { |
| 41 scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); | 44 scoped_refptr<PrefRegistrySimple> registry(new PrefRegistrySimple()); |
| 42 registry->RegisterBooleanPref(prefs::kEnableDoNotTrack, false); | 45 registry->RegisterBooleanPref(prefs::kEnableDoNotTrack, false); |
| 43 base::FilePath path("DoNotTrackCollectionViewControllerTest.pref"); | 46 base::FilePath path("DoNotTrackCollectionViewControllerTest.pref"); |
| 44 | 47 |
| 45 sync_preferences::PrefServiceMockFactory factory; | 48 sync_preferences::PrefServiceMockFactory factory; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 65 doNotTrackEnabled.Init(prefs::kEnableDoNotTrack, pref_service_.get()); | 68 doNotTrackEnabled.Init(prefs::kEnableDoNotTrack, pref_service_.get()); |
| 66 doNotTrackEnabled.SetValue(true); | 69 doNotTrackEnabled.SetValue(true); |
| 67 CreateController(); | 70 CreateController(); |
| 68 EXPECT_EQ(2, NumberOfSections()); | 71 EXPECT_EQ(2, NumberOfSections()); |
| 69 EXPECT_EQ(1, NumberOfItemsInSection(0)); | 72 EXPECT_EQ(1, NumberOfItemsInSection(0)); |
| 70 CheckSwitchCellStateAndTitleWithId(YES, IDS_IOS_OPTIONS_DO_NOT_TRACK_MOBILE, | 73 CheckSwitchCellStateAndTitleWithId(YES, IDS_IOS_OPTIONS_DO_NOT_TRACK_MOBILE, |
| 71 0, 0); | 74 0, 0); |
| 72 } | 75 } |
| 73 | 76 |
| 74 } // namespace | 77 } // namespace |
| OLD | NEW |