OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/policy/core/browser/url_blacklist_manager.h" | 5 #include "components/policy/core/browser/url_blacklist_manager.h" |
6 | 6 |
7 #include <ostream> | 7 #include <ostream> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 int update_called_; | 82 int update_called_; |
83 bool set_blacklist_called_; | 83 bool set_blacklist_called_; |
84 | 84 |
85 DISALLOW_COPY_AND_ASSIGN(TestingURLBlacklistManager); | 85 DISALLOW_COPY_AND_ASSIGN(TestingURLBlacklistManager); |
86 }; | 86 }; |
87 | 87 |
88 class URLBlacklistManagerTest : public testing::Test { | 88 class URLBlacklistManagerTest : public testing::Test { |
89 protected: | 89 protected: |
90 URLBlacklistManagerTest() {} | 90 URLBlacklistManagerTest() {} |
91 | 91 |
92 virtual void SetUp() override { | 92 void SetUp() override { |
93 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlBlacklist); | 93 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlBlacklist); |
94 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlWhitelist); | 94 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlWhitelist); |
95 blacklist_manager_.reset(new TestingURLBlacklistManager(&pref_service_)); | 95 blacklist_manager_.reset(new TestingURLBlacklistManager(&pref_service_)); |
96 loop_.RunUntilIdle(); | 96 loop_.RunUntilIdle(); |
97 } | 97 } |
98 | 98 |
99 virtual void TearDown() override { | 99 void TearDown() override { |
100 if (blacklist_manager_.get()) | 100 if (blacklist_manager_.get()) |
101 blacklist_manager_->ShutdownOnUIThread(); | 101 blacklist_manager_->ShutdownOnUIThread(); |
102 loop_.RunUntilIdle(); | 102 loop_.RunUntilIdle(); |
103 // Delete |blacklist_manager_| while |io_thread_| is mapping IO to | 103 // Delete |blacklist_manager_| while |io_thread_| is mapping IO to |
104 // |loop_|. | 104 // |loop_|. |
105 blacklist_manager_.reset(); | 105 blacklist_manager_.reset(); |
106 } | 106 } |
107 | 107 |
108 base::MessageLoopForIO loop_; | 108 base::MessageLoopForIO loop_; |
109 TestingPrefServiceSimple pref_service_; | 109 TestingPrefServiceSimple pref_service_; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 blacklist.Allow(allowed.get()); | 694 blacklist.Allow(allowed.get()); |
695 | 695 |
696 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); | 696 EXPECT_TRUE(blacklist.IsURLBlocked(GURL("http://www.google.com"))); |
697 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); | 697 EXPECT_TRUE((blacklist.IsURLBlocked(GURL("chrome-extension://xyz")))); |
698 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); | 698 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-extension://abc")))); |
699 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); | 699 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-search://local-ntp")))); |
700 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); | 700 EXPECT_FALSE((blacklist.IsURLBlocked(GURL("chrome-native://ntp")))); |
701 } | 701 } |
702 | 702 |
703 } // namespace policy | 703 } // namespace policy |
OLD | NEW |