| 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/path_service.h" | 5 #include "base/path_service.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "base/prefs/scoped_user_pref_update.h" | 7 #include "base/prefs/scoped_user_pref_update.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 base::Unretained(result_holder))); | 122 base::Unretained(result_holder))); |
| 123 } | 123 } |
| 124 | 124 |
| 125 content::TestBrowserThreadBundle thread_bundle_; | 125 content::TestBrowserThreadBundle thread_bundle_; |
| 126 scoped_ptr<TestingProfile> profile_; | 126 scoped_ptr<TestingProfile> profile_; |
| 127 SupervisedUserService* supervised_user_service_; | 127 SupervisedUserService* supervised_user_service_; |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace | 130 } // namespace |
| 131 | 131 |
| 132 TEST_F(SupervisedUserServiceTest, GetManualExceptionsForHost) { | |
| 133 GURL kExampleFooURL("http://www.example.com/foo"); | |
| 134 GURL kExampleBarURL("http://www.example.com/bar"); | |
| 135 GURL kExampleFooNoWWWURL("http://example.com/foo"); | |
| 136 GURL kBlurpURL("http://blurp.net/bla"); | |
| 137 GURL kMooseURL("http://moose.org/baz"); | |
| 138 { | |
| 139 DictionaryPrefUpdate update(profile_->GetPrefs(), | |
| 140 prefs::kSupervisedUserManualURLs); | |
| 141 base::DictionaryValue* dict = update.Get(); | |
| 142 dict->SetBooleanWithoutPathExpansion(kExampleFooURL.spec(), true); | |
| 143 dict->SetBooleanWithoutPathExpansion(kExampleBarURL.spec(), false); | |
| 144 dict->SetBooleanWithoutPathExpansion(kExampleFooNoWWWURL.spec(), true); | |
| 145 dict->SetBooleanWithoutPathExpansion(kBlurpURL.spec(), true); | |
| 146 } | |
| 147 | |
| 148 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | |
| 149 supervised_user_service_->GetManualBehaviorForURL(kExampleFooURL)); | |
| 150 EXPECT_EQ(SupervisedUserService::MANUAL_BLOCK, | |
| 151 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); | |
| 152 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | |
| 153 supervised_user_service_->GetManualBehaviorForURL( | |
| 154 kExampleFooNoWWWURL)); | |
| 155 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | |
| 156 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); | |
| 157 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | |
| 158 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); | |
| 159 std::vector<GURL> exceptions; | |
| 160 supervised_user_service_->GetManualExceptionsForHost("www.example.com", | |
| 161 &exceptions); | |
| 162 ASSERT_EQ(2u, exceptions.size()); | |
| 163 EXPECT_EQ(kExampleBarURL, exceptions[0]); | |
| 164 EXPECT_EQ(kExampleFooURL, exceptions[1]); | |
| 165 | |
| 166 { | |
| 167 DictionaryPrefUpdate update(profile_->GetPrefs(), | |
| 168 prefs::kSupervisedUserManualURLs); | |
| 169 base::DictionaryValue* dict = update.Get(); | |
| 170 for (const GURL& url : exceptions) | |
| 171 dict->RemoveWithoutPathExpansion(url.spec(), NULL); | |
| 172 } | |
| 173 | |
| 174 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | |
| 175 supervised_user_service_->GetManualBehaviorForURL(kExampleFooURL)); | |
| 176 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | |
| 177 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); | |
| 178 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | |
| 179 supervised_user_service_->GetManualBehaviorForURL( | |
| 180 kExampleFooNoWWWURL)); | |
| 181 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | |
| 182 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); | |
| 183 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | |
| 184 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); | |
| 185 } | |
| 186 | |
| 187 TEST_F(SupervisedUserServiceTest, ChangesIncludedSessionOnChangedSettings) { | 132 TEST_F(SupervisedUserServiceTest, ChangesIncludedSessionOnChangedSettings) { |
| 188 supervised_user_service_->Init(); | 133 supervised_user_service_->Init(); |
| 189 EXPECT_TRUE(supervised_user_service_->IncludesSyncSessionsType()); | 134 EXPECT_TRUE(supervised_user_service_->IncludesSyncSessionsType()); |
| 190 profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, false); | 135 profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, false); |
| 191 EXPECT_FALSE(supervised_user_service_->IncludesSyncSessionsType()); | 136 EXPECT_FALSE(supervised_user_service_->IncludesSyncSessionsType()); |
| 192 } | 137 } |
| 193 | 138 |
| 194 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no | 139 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no |
| 195 // DCHECK is hit when the service is destroyed, this test passed. | 140 // DCHECK is hit when the service is destroyed, this test passed. |
| 196 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 141 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 site_lists[0]->GetSites(&sites); | 519 site_lists[0]->GetSites(&sites); |
| 575 ASSERT_EQ(1u, sites.size()); | 520 ASSERT_EQ(1u, sites.size()); |
| 576 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 521 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
| 577 | 522 |
| 578 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 523 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
| 579 url_filter->GetFilteringBehaviorForURL(example_url)); | 524 url_filter->GetFilteringBehaviorForURL(example_url)); |
| 580 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 525 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 581 url_filter->GetFilteringBehaviorForURL(moose_url)); | 526 url_filter->GetFilteringBehaviorForURL(moose_url)); |
| 582 } | 527 } |
| 583 #endif // defined(ENABLE_EXTENSIONS) | 528 #endif // defined(ENABLE_EXTENSIONS) |
| OLD | NEW |