OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "chrome/browser/subresource_filter/subresource_filter_content_settings_
manager.h" | 5 #include "chrome/browser/subresource_filter/subresource_filter_content_settings_
manager.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/test/histogram_tester.h" | 8 #include "base/test/histogram_tester.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
10 #include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h" | 10 #include "chrome/browser/subresource_filter/chrome_subresource_filter_client.h" |
11 #include "chrome/browser/subresource_filter/subresource_filter_profile_context_f
actory.h" | 11 #include "chrome/browser/subresource_filter/subresource_filter_profile_context_f
actory.h" |
12 #include "chrome/test/base/testing_profile.h" | 12 #include "chrome/test/base/testing_profile.h" |
13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 13 #include "components/content_settings/core/browser/host_content_settings_map.h" |
14 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const char kActionsHistogram[] = "SubresourceFilter.Actions"; | 19 const char kActionsHistogram[] = "SubresourceFilter.Actions"; |
20 | 20 |
21 class SubresourceFilterContentSettingsManagerTest : public testing::Test { | 21 class SubresourceFilterContentSettingsManagerTest : public testing::Test { |
22 public: | 22 public: |
23 SubresourceFilterContentSettingsManagerTest() {} | 23 SubresourceFilterContentSettingsManagerTest() {} |
24 | 24 |
25 void SetUp() override { | 25 void SetUp() override { |
26 SubresourceFilterProfileContextFactory::EnsureForProfile(&testing_profile_); | 26 SubresourceFilterProfileContextFactory::GetForProfile(&testing_profile_); |
27 histogram_tester().ExpectTotalCount(kActionsHistogram, 0); | 27 histogram_tester().ExpectTotalCount(kActionsHistogram, 0); |
28 } | 28 } |
29 | 29 |
30 HostContentSettingsMap* GetSettingsMap() { | 30 HostContentSettingsMap* GetSettingsMap() { |
31 return HostContentSettingsMapFactory::GetForProfile(&testing_profile_); | 31 return HostContentSettingsMapFactory::GetForProfile(&testing_profile_); |
32 } | 32 } |
33 | 33 |
34 const base::HistogramTester& histogram_tester() { return histogram_tester_; } | 34 const base::HistogramTester& histogram_tester() { return histogram_tester_; } |
35 | 35 |
36 private: | 36 private: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 GetSettingsMap()->SetContentSettingCustomScope( | 92 GetSettingsMap()->SetContentSettingCustomScope( |
93 primary_pattern, secondary_pattern, | 93 primary_pattern, secondary_pattern, |
94 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, std::string(), | 94 CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER, std::string(), |
95 CONTENT_SETTING_ALLOW); | 95 CONTENT_SETTING_ALLOW); |
96 histogram_tester().ExpectTotalCount(kActionsHistogram, 2); | 96 histogram_tester().ExpectTotalCount(kActionsHistogram, 2); |
97 histogram_tester().ExpectBucketCount(kActionsHistogram, | 97 histogram_tester().ExpectBucketCount(kActionsHistogram, |
98 kActionContentSettingsWildcardUpdate, 2); | 98 kActionContentSettingsWildcardUpdate, 2); |
99 } | 99 } |
100 | 100 |
101 } // namespace | 101 } // namespace |
OLD | NEW |