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" |
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 base::DictionaryValue* dict = new base::DictionaryValue(); | |
Marc Treib
2014/08/19 15:28:02
Memleak! Use a scoped_ptr or an instance variable.
fhorschig
2014/08/20 11:59:30
Done.
| |
160 dict->SetBooleanWithoutPathExpansion(supervised_users::kRecordHistory, false); | |
161 | |
162 supervised_user_service_->OnNewSettingsAvailable(dict); | |
163 | |
164 EXPECT_FALSE(supervised_user_service_->IncludesSyncSessions()); | |
Marc Treib
2014/08/19 15:28:02
Also check that it was true before OnNewSettingsAv
fhorschig
2014/08/20 11:59:30
Done.
| |
165 } | |
166 | |
167 TEST_F(SupervisedUserServiceTest, ChangesSyncSessionStateOnChangedSettings) { | |
168 base::DictionaryValue* dict = new base::DictionaryValue(); | |
169 dict->SetBooleanWithoutPathExpansion(supervised_users::kRecordHistory, false); | |
170 supervised_user_service_->OnNewSettingsAvailable(dict); | |
171 dict->SetBooleanWithoutPathExpansion(supervised_users::kRecordHistory, true); | |
172 | |
173 bool changed_state = supervised_user_service_->FetchNewSessionSyncState(dict); | |
174 | |
175 EXPECT_TRUE(changed_state); | |
176 } | |
177 | |
157 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no | 178 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no |
158 // DCHECK is hit when the service is destroyed, this test passed. | 179 // DCHECK is hit when the service is destroyed, this test passed. |
159 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 180 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
160 CustodianProfileDownloaderService* downloader_service = | 181 CustodianProfileDownloaderService* downloader_service = |
161 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); | 182 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); |
162 | 183 |
163 // Emulate being logged in, then start to download a profile so a | 184 // Emulate being logged in, then start to download a profile so a |
164 // ProfileDownloader gets created. | 185 // ProfileDownloader gets created. |
165 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); | 186 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); |
166 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); | 187 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); | 435 site_lists[0]->GetSites(&sites); |
415 ASSERT_EQ(1u, sites.size()); | 436 ASSERT_EQ(1u, sites.size()); |
416 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 437 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
417 | 438 |
418 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 439 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
419 url_filter->GetFilteringBehaviorForURL(example_url)); | 440 url_filter->GetFilteringBehaviorForURL(example_url)); |
420 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 441 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
421 url_filter->GetFilteringBehaviorForURL(moose_url)); | 442 url_filter->GetFilteringBehaviorForURL(moose_url)); |
422 } | 443 } |
423 #endif // !defined(OS_ANDROID) | 444 #endif // !defined(OS_ANDROID) |
OLD | NEW |