| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 9 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 12 | 12 |
| 13 class SupervisedUserURLFilterTest : public ::testing::Test, | 13 class SupervisedUserURLFilterTest : public ::testing::Test, |
| 14 public SupervisedUserURLFilter::Observer { | 14 public SupervisedUserURLFilter::Observer { |
| 15 public: | 15 public: |
| 16 SupervisedUserURLFilterTest() : filter_(new SupervisedUserURLFilter) { | 16 SupervisedUserURLFilterTest() : filter_(new SupervisedUserURLFilter) { |
| 17 filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::BLOCK); | 17 filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::BLOCK); |
| 18 filter_->AddObserver(this); | 18 filter_->AddObserver(this); |
| 19 } | 19 } |
| 20 | 20 |
| 21 virtual ~SupervisedUserURLFilterTest() { | 21 virtual ~SupervisedUserURLFilterTest() { |
| 22 filter_->RemoveObserver(this); | 22 filter_->RemoveObserver(this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 // SupervisedUserURLFilter::Observer: | 25 // SupervisedUserURLFilter::Observer: |
| 26 virtual void OnSiteListUpdated() OVERRIDE { | 26 virtual void OnSiteListUpdated() override { |
| 27 run_loop_.Quit(); | 27 run_loop_.Quit(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 bool IsURLWhitelisted(const std::string& url) { | 31 bool IsURLWhitelisted(const std::string& url) { |
| 32 return filter_->GetFilteringBehaviorForURL(GURL(url)) == | 32 return filter_->GetFilteringBehaviorForURL(GURL(url)) == |
| 33 SupervisedUserURLFilter::ALLOW; | 33 SupervisedUserURLFilter::ALLOW; |
| 34 } | 34 } |
| 35 | 35 |
| 36 base::MessageLoop message_loop_; | 36 base::MessageLoop message_loop_; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/")); | 337 EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/")); |
| 338 EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); | 338 EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); |
| 339 EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/")); | 339 EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/")); |
| 340 | 340 |
| 341 filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW); | 341 filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW); |
| 342 EXPECT_FALSE(IsURLWhitelisted("http://www.google.com/foo/")); | 342 EXPECT_FALSE(IsURLWhitelisted("http://www.google.com/foo/")); |
| 343 EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/")); | 343 EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/")); |
| 344 EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); | 344 EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); |
| 345 EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/")); | 345 EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/")); |
| 346 } | 346 } |
| OLD | NEW |