| 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" | |
| 11 #include "chrome/browser/extensions/extension_service_test_base.h" | |
| 12 #include "chrome/browser/extensions/unpacked_installer.h" | |
| 13 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 15 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 17 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" | 14 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" |
| 18 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa
ctory.h" | 15 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa
ctory.h" |
| 19 #include "chrome/browser/supervised_user/supervised_user_service.h" | 16 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 20 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 17 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 21 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/extensions/features/feature_channel.h" | |
| 24 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 22 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 |
| 26 #if defined(ENABLE_EXTENSIONS) |
| 27 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 29 #include "chrome/browser/extensions/unpacked_installer.h" |
| 30 #include "chrome/common/extensions/features/feature_channel.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" |
| 31 #include "testing/gtest/include/gtest/gtest.h" | 34 #endif |
| 32 | 35 |
| 33 using content::MessageLoopRunner; | 36 using content::MessageLoopRunner; |
| 34 | 37 |
| 35 namespace { | 38 namespace { |
| 36 | 39 |
| 37 void OnProfileDownloadedFail(const base::string16& full_name) { | 40 void OnProfileDownloadedFail(const base::string16& full_name) { |
| 38 ASSERT_TRUE(false) << "Profile download should not have succeeded."; | 41 ASSERT_TRUE(false) << "Profile download should not have succeeded."; |
| 39 } | 42 } |
| 40 | 43 |
| 41 class SupervisedUserURLFilterObserver : | 44 class SupervisedUserURLFilterObserver : |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 167 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
| 165 CustodianProfileDownloaderService* downloader_service = | 168 CustodianProfileDownloaderService* downloader_service = |
| 166 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); | 169 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); |
| 167 | 170 |
| 168 // Emulate being logged in, then start to download a profile so a | 171 // Emulate being logged in, then start to download a profile so a |
| 169 // ProfileDownloader gets created. | 172 // ProfileDownloader gets created. |
| 170 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); | 173 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); |
| 171 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); | 174 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); |
| 172 } | 175 } |
| 173 | 176 |
| 174 #if !defined(OS_ANDROID) | 177 #if defined(ENABLE_EXTENSIONS) |
| 175 class SupervisedUserServiceExtensionTestBase | 178 class SupervisedUserServiceExtensionTestBase |
| 176 : public extensions::ExtensionServiceTestBase { | 179 : public extensions::ExtensionServiceTestBase { |
| 177 public: | 180 public: |
| 178 explicit SupervisedUserServiceExtensionTestBase(bool is_supervised) | 181 explicit SupervisedUserServiceExtensionTestBase(bool is_supervised) |
| 179 : is_supervised_(is_supervised), | 182 : is_supervised_(is_supervised), |
| 180 channel_(chrome::VersionInfo::CHANNEL_DEV) {} | 183 channel_(chrome::VersionInfo::CHANNEL_DEV) {} |
| 181 virtual ~SupervisedUserServiceExtensionTestBase() {} | 184 virtual ~SupervisedUserServiceExtensionTestBase() {} |
| 182 | 185 |
| 183 virtual void SetUp() override { | 186 virtual void SetUp() override { |
| 184 ExtensionServiceTestBase::SetUp(); | 187 ExtensionServiceTestBase::SetUp(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 sites.clear(); | 419 sites.clear(); |
| 417 site_lists[0]->GetSites(&sites); | 420 site_lists[0]->GetSites(&sites); |
| 418 ASSERT_EQ(1u, sites.size()); | 421 ASSERT_EQ(1u, sites.size()); |
| 419 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 422 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
| 420 | 423 |
| 421 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 424 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
| 422 url_filter->GetFilteringBehaviorForURL(example_url)); | 425 url_filter->GetFilteringBehaviorForURL(example_url)); |
| 423 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 426 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 424 url_filter->GetFilteringBehaviorForURL(moose_url)); | 427 url_filter->GetFilteringBehaviorForURL(moose_url)); |
| 425 } | 428 } |
| 426 #endif // !defined(OS_ANDROID) | 429 #endif // defined(ENABLE_EXTENSIONS) |
| OLD | NEW |