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/translate_collection_view_controller.h" | 5 #import "ios/chrome/browser/ui/settings/translate_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 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
13 #include "components/pref_registry/pref_registry_syncable.h" | 13 #include "components/pref_registry/pref_registry_syncable.h" |
14 #include "components/prefs/pref_member.h" | 14 #include "components/prefs/pref_member.h" |
15 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
16 #include "components/strings/grit/components_locale_settings.h" | 16 #include "components/strings/grit/components_locale_settings.h" |
17 #include "components/sync_preferences/pref_service_mock_factory.h" | 17 #include "components/sync_preferences/pref_service_mock_factory.h" |
18 #include "components/translate/core/browser/translate_prefs.h" | 18 #include "components/translate/core/browser/translate_prefs.h" |
19 #include "components/translate/core/common/translate_pref_names.h" | 19 #include "components/translate/core/common/translate_pref_names.h" |
20 #include "ios/chrome/browser/pref_names.h" | 20 #include "ios/chrome/browser/pref_names.h" |
21 #import "ios/chrome/browser/translate/chrome_ios_translate_client.h" | 21 #import "ios/chrome/browser/translate/chrome_ios_translate_client.h" |
22 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 22 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
23 #include "ios/chrome/grit/ios_strings.h" | 23 #include "ios/chrome/grit/ios_strings.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #import "testing/gtest_mac.h" | 25 #import "testing/gtest_mac.h" |
26 #include "testing/platform_test.h" | 26 #include "testing/platform_test.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/l10n/l10n_util_mac.h" | 28 #include "ui/base/l10n/l10n_util_mac.h" |
29 | 29 |
| 30 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 31 #error "This file requires ARC support." |
| 32 #endif |
| 33 |
30 using user_prefs::PrefRegistrySyncable; | 34 using user_prefs::PrefRegistrySyncable; |
31 | 35 |
32 namespace { | 36 namespace { |
33 | 37 |
34 const char kBlacklistedSite[] = "http://blacklistedsite.com"; | 38 const char kBlacklistedSite[] = "http://blacklistedsite.com"; |
35 const char kLanguage1[] = "klingon"; | 39 const char kLanguage1[] = "klingon"; |
36 const char kLanguage2[] = "pirate"; | 40 const char kLanguage2[] = "pirate"; |
37 | 41 |
38 class TranslateCollectionViewControllerTest | 42 class TranslateCollectionViewControllerTest |
39 : public CollectionViewControllerTest { | 43 : public CollectionViewControllerTest { |
40 protected: | 44 protected: |
41 void SetUp() override { | 45 void SetUp() override { |
42 CollectionViewControllerTest::SetUp(); | 46 CollectionViewControllerTest::SetUp(); |
43 pref_service_ = CreateLocalState(); | 47 pref_service_ = CreateLocalState(); |
44 } | 48 } |
45 | 49 |
46 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 50 CollectionViewController* InstantiateController() override { |
47 return [[TranslateCollectionViewController alloc] | 51 return [[TranslateCollectionViewController alloc] |
48 initWithPrefs:pref_service_.get()]; | 52 initWithPrefs:pref_service_.get()]; |
49 } | 53 } |
50 | 54 |
51 std::unique_ptr<PrefService> CreateLocalState() { | 55 std::unique_ptr<PrefService> CreateLocalState() { |
52 scoped_refptr<PrefRegistrySyncable> registry = new PrefRegistrySyncable(); | 56 scoped_refptr<PrefRegistrySyncable> registry = new PrefRegistrySyncable(); |
53 registry->RegisterBooleanPref(prefs::kEnableTranslate, false, | 57 registry->RegisterBooleanPref(prefs::kEnableTranslate, false, |
54 PrefRegistrySyncable::SYNCABLE_PREF); | 58 PrefRegistrySyncable::SYNCABLE_PREF); |
55 translate::TranslatePrefs::RegisterProfilePrefs(registry.get()); | 59 translate::TranslatePrefs::RegisterProfilePrefs(registry.get()); |
56 registry->RegisterStringPref( | 60 registry->RegisterStringPref( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 [controller collectionView:[controller collectionView] | 109 [controller collectionView:[controller collectionView] |
106 didSelectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]]; | 110 didSelectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]]; |
107 // Check that preferences are gone. | 111 // Check that preferences are gone. |
108 EXPECT_FALSE(translate_prefs->IsSiteBlacklisted(kBlacklistedSite)); | 112 EXPECT_FALSE(translate_prefs->IsSiteBlacklisted(kBlacklistedSite)); |
109 EXPECT_FALSE(translate_prefs->IsBlockedLanguage(kLanguage1)); | 113 EXPECT_FALSE(translate_prefs->IsBlockedLanguage(kLanguage1)); |
110 EXPECT_FALSE( | 114 EXPECT_FALSE( |
111 translate_prefs->IsLanguagePairWhitelisted(kLanguage1, kLanguage2)); | 115 translate_prefs->IsLanguagePairWhitelisted(kLanguage1, kLanguage2)); |
112 } | 116 } |
113 | 117 |
114 } // namespace | 118 } // namespace |
OLD | NEW |