Index: chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc |
diff --git a/chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc b/chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc |
similarity index 55% |
rename from chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc |
rename to chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc |
index e1091e452657a17cec790012800b25095a3e7726..55a9dbfaedd36d5f1d54338d4ab8227e5de23c37 100644 |
--- a/chrome/browser/managed_mode/managed_mode_url_filter_unittest.cc |
+++ b/chrome/browser/supervised_user/supervised_user_url_filter_unittest.cc |
@@ -6,23 +6,23 @@ |
#include "base/bind_helpers.h" |
#include "base/message_loop/message_loop.h" |
#include "base/run_loop.h" |
-#include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
+#include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
#include "testing/gtest/include/gtest/gtest.h" |
#include "url/gurl.h" |
-class ManagedModeURLFilterTest : public ::testing::Test, |
- public ManagedModeURLFilter::Observer { |
+class SupervisedUserURLFilterTest : public ::testing::Test, |
+ public SupervisedUserURLFilter::Observer { |
public: |
- ManagedModeURLFilterTest() : filter_(new ManagedModeURLFilter) { |
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::BLOCK); |
+ SupervisedUserURLFilterTest() : filter_(new SupervisedUserURLFilter) { |
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::BLOCK); |
filter_->AddObserver(this); |
} |
- virtual ~ManagedModeURLFilterTest() { |
+ virtual ~SupervisedUserURLFilterTest() { |
filter_->RemoveObserver(this); |
} |
- // ManagedModeURLFilter::Observer: |
+ // SupervisedUserURLFilter::Observer: |
virtual void OnSiteListUpdated() OVERRIDE { |
run_loop_.Quit(); |
} |
@@ -30,15 +30,15 @@ class ManagedModeURLFilterTest : public ::testing::Test, |
protected: |
bool IsURLWhitelisted(const std::string& url) { |
return filter_->GetFilteringBehaviorForURL(GURL(url)) == |
- ManagedModeURLFilter::ALLOW; |
+ SupervisedUserURLFilter::ALLOW; |
} |
base::MessageLoop message_loop_; |
base::RunLoop run_loop_; |
- scoped_refptr<ManagedModeURLFilter> filter_; |
+ scoped_refptr<SupervisedUserURLFilter> filter_; |
}; |
-TEST_F(ManagedModeURLFilterTest, Basic) { |
+TEST_F(SupervisedUserURLFilterTest, Basic) { |
std::vector<std::string> list; |
// Allow domain and all subdomains, for any filtered scheme. |
list.push_back("google.com"); |
@@ -63,8 +63,8 @@ TEST_F(ManagedModeURLFilterTest, Basic) { |
EXPECT_TRUE(IsURLWhitelisted("file:///home/chronos/user/Downloads/img.jpg")); |
} |
-TEST_F(ManagedModeURLFilterTest, Inactive) { |
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::ALLOW); |
+TEST_F(SupervisedUserURLFilterTest, Inactive) { |
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW); |
std::vector<std::string> list; |
list.push_back("google.com"); |
@@ -76,7 +76,7 @@ TEST_F(ManagedModeURLFilterTest, Inactive) { |
EXPECT_TRUE(IsURLWhitelisted("https://www.example.com")); |
} |
-TEST_F(ManagedModeURLFilterTest, Scheme) { |
+TEST_F(SupervisedUserURLFilterTest, Scheme) { |
std::vector<std::string> list; |
// Filter only http, ftp and ws schemes. |
list.push_back("http://secure.com"); |
@@ -96,7 +96,7 @@ TEST_F(ManagedModeURLFilterTest, Scheme) { |
EXPECT_FALSE(IsURLWhitelisted("wss://www.secure.com")); |
} |
-TEST_F(ManagedModeURLFilterTest, Path) { |
+TEST_F(SupervisedUserURLFilterTest, Path) { |
std::vector<std::string> list; |
// Filter only a certain path prefix. |
list.push_back("path.to/ruin"); |
@@ -111,7 +111,7 @@ TEST_F(ManagedModeURLFilterTest, Path) { |
EXPECT_FALSE(IsURLWhitelisted("http://path.to/fortune")); |
} |
-TEST_F(ManagedModeURLFilterTest, PathAndScheme) { |
+TEST_F(SupervisedUserURLFilterTest, PathAndScheme) { |
std::vector<std::string> list; |
// Filter only a certain path prefix and scheme. |
list.push_back("https://s.aaa.com/path"); |
@@ -127,7 +127,7 @@ TEST_F(ManagedModeURLFilterTest, PathAndScheme) { |
EXPECT_FALSE(IsURLWhitelisted("https://s.aaa.com/")); |
} |
-TEST_F(ManagedModeURLFilterTest, Host) { |
+TEST_F(SupervisedUserURLFilterTest, Host) { |
std::vector<std::string> list; |
// Filter only a certain hostname, without subdomains. |
list.push_back(".www.example.com"); |
@@ -139,7 +139,7 @@ TEST_F(ManagedModeURLFilterTest, Host) { |
EXPECT_FALSE(IsURLWhitelisted("http://subdomain.example.com")); |
} |
-TEST_F(ManagedModeURLFilterTest, IPAddress) { |
+TEST_F(SupervisedUserURLFilterTest, IPAddress) { |
std::vector<std::string> list; |
// Filter an ip address. |
list.push_back("123.123.123.123"); |
@@ -150,7 +150,7 @@ TEST_F(ManagedModeURLFilterTest, IPAddress) { |
EXPECT_FALSE(IsURLWhitelisted("http://123.123.123.124/")); |
} |
-TEST_F(ManagedModeURLFilterTest, Canonicalization) { |
+TEST_F(SupervisedUserURLFilterTest, Canonicalization) { |
// We assume that the hosts and URLs are already canonicalized. |
std::map<std::string, bool> hosts; |
hosts["www.moose.org"] = true; |
@@ -187,129 +187,139 @@ TEST_F(ManagedModeURLFilterTest, Canonicalization) { |
EXPECT_TRUE(IsURLWhitelisted("http://www.example.com/foo/?bar=baz#ref")); |
} |
-TEST_F(ManagedModeURLFilterTest, HasFilteredScheme) { |
+TEST_F(SupervisedUserURLFilterTest, HasFilteredScheme) { |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("http://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("http://example.com"))); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("https://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("https://example.com"))); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("ftp://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("ftp://example.com"))); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("gopher://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("gopher://example.com"))); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("ws://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("ws://example.com"))); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("wss://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("wss://example.com"))); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("file://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("file://example.com"))); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("filesystem://80cols.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme( |
+ GURL("filesystem://80cols.com"))); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("chrome://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("chrome://example.com"))); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HasFilteredScheme(GURL("wtf://example.com"))); |
+ SupervisedUserURLFilter::HasFilteredScheme(GURL("wtf://example.com"))); |
} |
-TEST_F(ManagedModeURLFilterTest, HostMatchesPattern) { |
+TEST_F(SupervisedUserURLFilterTest, HostMatchesPattern) { |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", |
- "*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "*.google.com")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("google.com", "*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google.com", |
+ "*.google.com")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("accounts.google.com", |
- "*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("accounts.google.com", |
+ "*.google.com")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.de", |
- "*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de", |
+ "*.google.com")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("notgoogle.com", |
- "*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("notgoogle.com", |
+ "*.google.com")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "www.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.de", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de", |
+ "www.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.co.uk", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.co.uk", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.blogspot.com", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.blogspot.com", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google", "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("google.com", "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google.com", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("mail.google.com", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("mail.google.com", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.googleplex.com", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleplex.com", |
+ "www.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.googleco.uk", |
- "www.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleco.uk", |
+ "www.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "*.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("google.com", "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google.com", |
+ "*.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("accounts.google.com", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("accounts.google.com", |
+ "*.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("mail.google.com", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("mail.google.com", |
+ "*.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.de", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.de", |
+ "*.google.*")); |
EXPECT_TRUE( |
- ManagedModeURLFilter::HostMatchesPattern("google.de", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google.de", |
+ "*.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("google.blogspot.com", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google.blogspot.com", |
+ "*.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("google", "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("google", "*.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("notgoogle.com", "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("notgoogle.com", |
+ "*.google.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.googleplex.com", |
- "*.google.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.googleplex.com", |
+ "*.google.*")); |
// Now test a few invalid patterns. They should never match. |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", ".")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", ".")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", ".*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", ".*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*.")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google..com", "*..*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google..com", "*..*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*.*.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "*.*.com")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "www.*.*")); |
- EXPECT_FALSE(ManagedModeURLFilter::HostMatchesPattern("www.google.com", |
- "*.goo.*le.*")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", "www.*.*")); |
EXPECT_FALSE( |
- ManagedModeURLFilter::HostMatchesPattern("www.google.com", "*google*")); |
- EXPECT_FALSE(ManagedModeURLFilter::HostMatchesPattern("www.google.com", |
- "www.*.google.com")); |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "*.goo.*le.*")); |
+ EXPECT_FALSE( |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "*google*")); |
+ EXPECT_FALSE( |
+ SupervisedUserURLFilter::HostMatchesPattern("www.google.com", |
+ "www.*.google.com")); |
} |
-TEST_F(ManagedModeURLFilterTest, Patterns) { |
+TEST_F(SupervisedUserURLFilterTest, Patterns) { |
std::map<std::string, bool> hosts; |
// Initally, the second rule is ignored because has the same value as the |
@@ -328,7 +338,7 @@ TEST_F(ManagedModeURLFilterTest, Patterns) { |
EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); |
EXPECT_TRUE(IsURLWhitelisted("http://mail.google.com/moose/")); |
- filter_->SetDefaultFilteringBehavior(ManagedModeURLFilter::ALLOW); |
+ filter_->SetDefaultFilteringBehavior(SupervisedUserURLFilter::ALLOW); |
EXPECT_FALSE(IsURLWhitelisted("http://www.google.com/foo/")); |
EXPECT_FALSE(IsURLWhitelisted("http://accounts.google.com/bar/")); |
EXPECT_FALSE(IsURLWhitelisted("http://www.google.co.uk/blurp/")); |