Chromium Code Reviews| 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/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_service_test_base.h" | 11 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 12 #include "chrome/browser/extensions/unpacked_installer.h" | 12 #include "chrome/browser/extensions/unpacked_installer.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" | 17 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" |
| 18 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa ctory.h" | 18 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa ctory.h" |
| 19 #include "chrome/browser/supervised_user/supervised_user_constants.h" | |
|
Marc Treib
2014/08/20 14:14:26
I don't think this is necessary anymore.
fhorschig
2014/08/20 14:48:04
Done.
| |
| 19 #include "chrome/browser/supervised_user/supervised_user_service.h" | 20 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 20 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 21 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 21 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/extensions/features/feature_channel.h" | 24 #include "chrome/common/extensions/features/feature_channel.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 27 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "content/public/test/test_utils.h" | 28 #include "content/public/test/test_utils.h" |
| 28 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); | 148 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); |
| 148 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | 149 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, |
| 149 supervised_user_service_->GetManualBehaviorForURL( | 150 supervised_user_service_->GetManualBehaviorForURL( |
| 150 kExampleFooNoWWWURL)); | 151 kExampleFooNoWWWURL)); |
| 151 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | 152 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, |
| 152 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); | 153 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); |
| 153 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | 154 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, |
| 154 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); | 155 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); |
| 155 } | 156 } |
| 156 | 157 |
| 158 TEST_F(SupervisedUserServiceTest, ChangesIncludedSessionOnChangedSettings) { | |
| 159 EXPECT_TRUE(supervised_user_service_->IncludesSyncSessions()); | |
| 160 profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, false); | |
| 161 | |
| 162 supervised_user_service_->OnHistoryRecordingStateChanged(); | |
|
Marc Treib
2014/08/20 14:14:26
You shouldn't need to call this explicitly, since
fhorschig
2014/08/20 14:48:04
Done.
| |
| 163 | |
| 164 EXPECT_FALSE(supervised_user_service_->IncludesSyncSessions()); | |
| 165 } | |
| 166 | |
| 167 TEST_F(SupervisedUserServiceTest, ChangesSyncSessionStateOnChangedSettings) { | |
| 168 profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, false); | |
| 169 supervised_user_service_->OnHistoryRecordingStateChanged(); | |
|
Marc Treib
2014/08/20 14:14:26
^^
fhorschig
2014/08/20 14:48:04
Done.
| |
| 170 profile_->GetPrefs()->SetBoolean(prefs::kRecordHistory, true); | |
| 171 | |
| 172 bool changed_state = supervised_user_service_->FetchNewSessionSyncState(); | |
| 173 | |
| 174 EXPECT_TRUE(changed_state); | |
| 175 } | |
| 176 | |
| 157 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no | 177 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no |
| 158 // DCHECK is hit when the service is destroyed, this test passed. | 178 // DCHECK is hit when the service is destroyed, this test passed. |
| 159 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 179 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
| 160 CustodianProfileDownloaderService* downloader_service = | 180 CustodianProfileDownloaderService* downloader_service = |
| 161 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); | 181 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); |
| 162 | 182 |
| 163 // Emulate being logged in, then start to download a profile so a | 183 // Emulate being logged in, then start to download a profile so a |
| 164 // ProfileDownloader gets created. | 184 // ProfileDownloader gets created. |
| 165 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); | 185 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); |
| 166 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); | 186 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 414 site_lists[0]->GetSites(&sites); | 434 site_lists[0]->GetSites(&sites); |
| 415 ASSERT_EQ(1u, sites.size()); | 435 ASSERT_EQ(1u, sites.size()); |
| 416 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 436 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
| 417 | 437 |
| 418 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 438 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
| 419 url_filter->GetFilteringBehaviorForURL(example_url)); | 439 url_filter->GetFilteringBehaviorForURL(example_url)); |
| 420 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 440 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 421 url_filter->GetFilteringBehaviorForURL(moose_url)); | 441 url_filter->GetFilteringBehaviorForURL(moose_url)); |
| 422 } | 442 } |
| 423 #endif // !defined(OS_ANDROID) | 443 #endif // !defined(OS_ANDROID) |
| OLD | NEW |