| 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/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 int update_called_; | 79 int update_called_; |
| 80 bool set_blacklist_called_; | 80 bool set_blacklist_called_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(TestingURLBlacklistManager); | 82 DISALLOW_COPY_AND_ASSIGN(TestingURLBlacklistManager); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class URLBlacklistManagerTest : public testing::Test { | 85 class URLBlacklistManagerTest : public testing::Test { |
| 86 protected: | 86 protected: |
| 87 URLBlacklistManagerTest() : loop_(base::MessageLoop::TYPE_IO) {} | 87 URLBlacklistManagerTest() {} |
| 88 | 88 |
| 89 virtual void SetUp() OVERRIDE { | 89 virtual void SetUp() OVERRIDE { |
| 90 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlBlacklist); | 90 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlBlacklist); |
| 91 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlWhitelist); | 91 pref_service_.registry()->RegisterListPref(policy_prefs::kUrlWhitelist); |
| 92 blacklist_manager_.reset(new TestingURLBlacklistManager(&pref_service_)); | 92 blacklist_manager_.reset(new TestingURLBlacklistManager(&pref_service_)); |
| 93 loop_.RunUntilIdle(); | 93 loop_.RunUntilIdle(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void TearDown() OVERRIDE { | 96 virtual void TearDown() OVERRIDE { |
| 97 if (blacklist_manager_.get()) | 97 if (blacklist_manager_.get()) |
| 98 blacklist_manager_->ShutdownOnUIThread(); | 98 blacklist_manager_->ShutdownOnUIThread(); |
| 99 loop_.RunUntilIdle(); | 99 loop_.RunUntilIdle(); |
| 100 // Delete |blacklist_manager_| while |io_thread_| is mapping IO to | 100 // Delete |blacklist_manager_| while |io_thread_| is mapping IO to |
| 101 // |loop_|. | 101 // |loop_|. |
| 102 blacklist_manager_.reset(); | 102 blacklist_manager_.reset(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 base::MessageLoop loop_; | 105 base::MessageLoopForIO loop_; |
| 106 TestingPrefServiceSimple pref_service_; | 106 TestingPrefServiceSimple pref_service_; |
| 107 scoped_ptr<TestingURLBlacklistManager> blacklist_manager_; | 107 scoped_ptr<TestingURLBlacklistManager> blacklist_manager_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 // Parameters for the FilterToComponents test. | 110 // Parameters for the FilterToComponents test. |
| 111 struct FilterTestParams { | 111 struct FilterTestParams { |
| 112 public: | 112 public: |
| 113 FilterTestParams(const std::string& filter, const std::string& scheme, | 113 FilterTestParams(const std::string& filter, const std::string& scheme, |
| 114 const std::string& host, bool match_subdomains, uint16 port, | 114 const std::string& host, bool match_subdomains, uint16 port, |
| 115 const std::string& path) | 115 const std::string& path) |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 519 |
| 520 GURL sync_url(GaiaUrls::GetInstance()->service_login_url().Resolve( | 520 GURL sync_url(GaiaUrls::GetInstance()->service_login_url().Resolve( |
| 521 "?service=chromiumsync")); | 521 "?service=chromiumsync")); |
| 522 net::URLRequest sync_request(sync_url, net::DEFAULT_PRIORITY, NULL, &context); | 522 net::URLRequest sync_request(sync_url, net::DEFAULT_PRIORITY, NULL, &context); |
| 523 sync_request.SetLoadFlags(net::LOAD_MAIN_FRAME); | 523 sync_request.SetLoadFlags(net::LOAD_MAIN_FRAME); |
| 524 EXPECT_EQ(block_signin_urls, | 524 EXPECT_EQ(block_signin_urls, |
| 525 blacklist_manager_->IsRequestBlocked(sync_request)); | 525 blacklist_manager_->IsRequestBlocked(sync_request)); |
| 526 } | 526 } |
| 527 | 527 |
| 528 } // namespace policy | 528 } // namespace policy |
| OLD | NEW |