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" | |
| 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" |
| 22 #include "chrome/browser/sync/profile_sync_service.h" | |
| 23 #include "chrome/browser/sync/profile_sync_service_factory.h" | |
| 21 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/extensions/features/feature_channel.h" | 26 #include "chrome/common/extensions/features/feature_channel.h" |
| 24 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 28 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "content/public/test/test_utils.h" | 30 #include "content/public/test/test_utils.h" |
| 28 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
| 29 #include "extensions/common/extension_builder.h" | 32 #include "extensions/common/extension_builder.h" |
| 30 #include "extensions/common/manifest_constants.h" | 33 #include "extensions/common/manifest_constants.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); | 150 supervised_user_service_->GetManualBehaviorForURL(kExampleBarURL)); |
| 148 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | 151 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, |
| 149 supervised_user_service_->GetManualBehaviorForURL( | 152 supervised_user_service_->GetManualBehaviorForURL( |
| 150 kExampleFooNoWWWURL)); | 153 kExampleFooNoWWWURL)); |
| 151 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, | 154 EXPECT_EQ(SupervisedUserService::MANUAL_ALLOW, |
| 152 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); | 155 supervised_user_service_->GetManualBehaviorForURL(kBlurpURL)); |
| 153 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, | 156 EXPECT_EQ(SupervisedUserService::MANUAL_NONE, |
| 154 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); | 157 supervised_user_service_->GetManualBehaviorForURL(kMooseURL)); |
| 155 } | 158 } |
| 156 | 159 |
| 160 TEST_F(SupervisedUserServiceTest, ChangesSessionSyncOnChangedSettings) { | |
| 161 DictionaryPrefUpdate update(profile_->GetPrefs(), | |
|
Marc Treib
2014/08/19 14:00:28
What does this do? Do you actually need the Dictio
| |
| 162 prefs::kSupervisedUserManualURLs); | |
| 163 syncer::ModelTypeSet active_data_types = | |
| 164 ProfileSyncServiceFactory::GetForProfile( | |
| 165 supervised_user_service_->profile_)->GetActiveDataTypes(); | |
|
Marc Treib
2014/08/19 14:06:29
Is the PSS actually properly set up in a unit test
| |
| 166 base::DictionaryValue* dict = update.Get(); | |
|
Marc Treib
2014/08/19 14:00:28
Please move this below the EXPECTs, right before i
| |
| 167 dict->SetBooleanWithoutPathExpansion(supervised_users::kRecordHistory, false); | |
| 168 EXPECT_TRUE(supervised_user_service_->MaySyncSessions()); | |
| 169 EXPECT_TRUE(active_data_types.Has(syncer::SESSIONS)); | |
| 170 | |
| 171 supervised_user_service_->OnNewSettingsAvailable(dict); | |
| 172 EXPECT_FALSE(supervised_user_service_->MaySyncSessions()); | |
| 173 dict->SetBooleanWithoutPathExpansion(supervised_users::kRecordHistory, true); | |
| 174 bool changed_state = supervised_user_service_->FetchNewSessionSyncState(dict); | |
| 175 | |
| 176 ASSERT_TRUE(changed_state); | |
|
Marc Treib
2014/08/19 14:00:28
Why is this not an EXPECT?
Also, maybe just inline
| |
| 177 } | |
| 178 | |
| 157 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no | 179 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no |
| 158 // DCHECK is hit when the service is destroyed, this test passed. | 180 // DCHECK is hit when the service is destroyed, this test passed. |
| 159 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 181 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
| 160 CustodianProfileDownloaderService* downloader_service = | 182 CustodianProfileDownloaderService* downloader_service = |
| 161 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); | 183 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); |
| 162 | 184 |
| 163 // Emulate being logged in, then start to download a profile so a | 185 // Emulate being logged in, then start to download a profile so a |
| 164 // ProfileDownloader gets created. | 186 // ProfileDownloader gets created. |
| 165 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); | 187 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); |
| 166 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); | 188 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); | 436 site_lists[0]->GetSites(&sites); |
| 415 ASSERT_EQ(1u, sites.size()); | 437 ASSERT_EQ(1u, sites.size()); |
| 416 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 438 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
| 417 | 439 |
| 418 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 440 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
| 419 url_filter->GetFilteringBehaviorForURL(example_url)); | 441 url_filter->GetFilteringBehaviorForURL(example_url)); |
| 420 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 442 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 421 url_filter->GetFilteringBehaviorForURL(moose_url)); | 443 url_filter->GetFilteringBehaviorForURL(moose_url)); |
| 422 } | 444 } |
| 423 #endif // !defined(OS_ANDROID) | 445 #endif // !defined(OS_ANDROID) |
| OLD | NEW |