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 <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #import "base/test/ios/wait_util.h" | 11 #import "base/test/ios/wait_util.h" |
12 #include "components/content_settings/core/browser/host_content_settings_map.h" | 12 #include "components/content_settings/core/browser/host_content_settings_map.h" |
13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" | 13 #include "ios/chrome/browser/browser_state/test_chrome_browser_state.h" |
14 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" | 14 #include "ios/chrome/browser/content_settings/host_content_settings_map_factory.
h" |
15 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" | 15 #import "ios/chrome/browser/ui/collection_view/collection_view_controller_test.h
" |
16 #import "ios/chrome/browser/ui/settings/block_popups_collection_view_controller.
h" | 16 #import "ios/chrome/browser/ui/settings/block_popups_collection_view_controller.
h" |
17 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
18 #include "ios/web/public/test/test_web_thread_bundle.h" | 18 #include "ios/web/public/test/test_web_thread_bundle.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "url/gurl.h" | 20 #include "url/gurl.h" |
21 | 21 |
| 22 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 23 #error "This file requires ARC support." |
| 24 #endif |
| 25 |
22 @interface SettingsRootCollectionViewController (ExposedForTesting) | 26 @interface SettingsRootCollectionViewController (ExposedForTesting) |
23 - (void)editButtonPressed; | 27 - (void)editButtonPressed; |
24 @end | 28 @end |
25 | 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 const char* kAllowedPattern = "[*.]example.com"; | 32 const char* kAllowedPattern = "[*.]example.com"; |
29 const char* kAllowedURL = "http://example.com"; | 33 const char* kAllowedURL = "http://example.com"; |
30 | 34 |
31 class BlockPopupsCollectionViewControllerTest | 35 class BlockPopupsCollectionViewControllerTest |
32 : public CollectionViewControllerTest { | 36 : public CollectionViewControllerTest { |
33 protected: | 37 protected: |
34 void SetUp() override { | 38 void SetUp() override { |
35 CollectionViewControllerTest::SetUp(); | 39 CollectionViewControllerTest::SetUp(); |
36 TestChromeBrowserState::Builder test_cbs_builder; | 40 TestChromeBrowserState::Builder test_cbs_builder; |
37 chrome_browser_state_ = test_cbs_builder.Build(); | 41 chrome_browser_state_ = test_cbs_builder.Build(); |
38 } | 42 } |
39 | 43 |
40 CollectionViewController* NewController() override NS_RETURNS_RETAINED { | 44 CollectionViewController* InstantiateController() override { |
41 return [[BlockPopupsCollectionViewController alloc] | 45 return [[BlockPopupsCollectionViewController alloc] |
42 initWithBrowserState:chrome_browser_state_.get()]; | 46 initWithBrowserState:chrome_browser_state_.get()]; |
43 } | 47 } |
44 | 48 |
45 void SetDisallowPopups() { | 49 void SetDisallowPopups() { |
46 ios::HostContentSettingsMapFactory::GetForBrowserState( | 50 ios::HostContentSettingsMapFactory::GetForBrowserState( |
47 chrome_browser_state_.get()) | 51 chrome_browser_state_.get()) |
48 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, | 52 ->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_POPUPS, |
49 CONTENT_SETTING_BLOCK); | 53 CONTENT_SETTING_BLOCK); |
50 } | 54 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Verify that there are no longer any allowed patterns in |profile_|. | 168 // Verify that there are no longer any allowed patterns in |profile_|. |
165 ContentSettingsForOneType final_entries; | 169 ContentSettingsForOneType final_entries; |
166 ios::HostContentSettingsMapFactory::GetForBrowserState( | 170 ios::HostContentSettingsMapFactory::GetForBrowserState( |
167 chrome_browser_state_.get()) | 171 chrome_browser_state_.get()) |
168 ->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_POPUPS, std::string(), | 172 ->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_POPUPS, std::string(), |
169 &final_entries); | 173 &final_entries); |
170 EXPECT_EQ(initial_entries.size(), final_entries.size()); | 174 EXPECT_EQ(initial_entries.size(), final_entries.size()); |
171 } | 175 } |
172 | 176 |
173 } // namespace | 177 } // namespace |
OLD | NEW |