| 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" |
| 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 11 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 12 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
| 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 14 #include "chrome/browser/signin/signin_manager_factory.h" |
| 14 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" | 15 #include "chrome/browser/supervised_user/custodian_profile_downloader_service.h" |
| 15 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa
ctory.h" | 16 #include "chrome/browser/supervised_user/custodian_profile_downloader_service_fa
ctory.h" |
| 16 #include "chrome/browser/supervised_user/permission_request_creator.h" | 17 #include "chrome/browser/supervised_user/permission_request_creator.h" |
| 17 #include "chrome/browser/supervised_user/supervised_user_service.h" | 18 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 18 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 19 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 24 #include "components/signin/core/browser/signin_manager.h" |
| 23 #include "content/public/test/test_browser_thread_bundle.h" | 25 #include "content/public/test/test_browser_thread_bundle.h" |
| 24 #include "content/public/test/test_utils.h" | 26 #include "content/public/test/test_utils.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 28 |
| 27 #if defined(ENABLE_EXTENSIONS) | 29 #if defined(ENABLE_EXTENSIONS) |
| 28 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
| 29 #include "chrome/browser/extensions/extension_service_test_base.h" | 31 #include "chrome/browser/extensions/extension_service_test_base.h" |
| 30 #include "chrome/browser/extensions/unpacked_installer.h" | 32 #include "chrome/browser/extensions/unpacked_installer.h" |
| 31 #include "chrome/common/extensions/features/feature_channel.h" | 33 #include "chrome/common/extensions/features/feature_channel.h" |
| 32 #include "extensions/common/extension.h" | 34 #include "extensions/common/extension.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 } | 135 } |
| 134 | 136 |
| 135 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no | 137 // Ensure that the CustodianProfileDownloaderService shuts down cleanly. If no |
| 136 // DCHECK is hit when the service is destroyed, this test passed. | 138 // DCHECK is hit when the service is destroyed, this test passed. |
| 137 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { | 139 TEST_F(SupervisedUserServiceTest, ShutDownCustodianProfileDownloader) { |
| 138 CustodianProfileDownloaderService* downloader_service = | 140 CustodianProfileDownloaderService* downloader_service = |
| 139 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); | 141 CustodianProfileDownloaderServiceFactory::GetForProfile(profile_.get()); |
| 140 | 142 |
| 141 // Emulate being logged in, then start to download a profile so a | 143 // Emulate being logged in, then start to download a profile so a |
| 142 // ProfileDownloader gets created. | 144 // ProfileDownloader gets created. |
| 143 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, "Logged In"); | 145 SigninManagerFactory::GetForProfile(profile_.get())-> |
| 146 SetAuthenticatedUsername("Logged In"); |
| 144 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); | 147 downloader_service->DownloadProfile(base::Bind(&OnProfileDownloadedFail)); |
| 145 } | 148 } |
| 146 | 149 |
| 147 namespace { | 150 namespace { |
| 148 | 151 |
| 149 class MockPermissionRequestCreator : public PermissionRequestCreator { | 152 class MockPermissionRequestCreator : public PermissionRequestCreator { |
| 150 public: | 153 public: |
| 151 MockPermissionRequestCreator() : enabled_(false) {} | 154 MockPermissionRequestCreator() : enabled_(false) {} |
| 152 ~MockPermissionRequestCreator() override {} | 155 ~MockPermissionRequestCreator() override {} |
| 153 | 156 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 site_lists[0]->GetSites(&sites); | 515 site_lists[0]->GetSites(&sites); |
| 513 ASSERT_EQ(1u, sites.size()); | 516 ASSERT_EQ(1u, sites.size()); |
| 514 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); | 517 EXPECT_EQ(base::ASCIIToUTF16("Moose"), sites[0].name); |
| 515 | 518 |
| 516 EXPECT_EQ(SupervisedUserURLFilter::WARN, | 519 EXPECT_EQ(SupervisedUserURLFilter::WARN, |
| 517 url_filter->GetFilteringBehaviorForURL(example_url)); | 520 url_filter->GetFilteringBehaviorForURL(example_url)); |
| 518 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, | 521 EXPECT_EQ(SupervisedUserURLFilter::ALLOW, |
| 519 url_filter->GetFilteringBehaviorForURL(moose_url)); | 522 url_filter->GetFilteringBehaviorForURL(moose_url)); |
| 520 } | 523 } |
| 521 #endif // defined(ENABLE_EXTENSIONS) | 524 #endif // defined(ENABLE_EXTENSIONS) |
| OLD | NEW |