OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" | 5 #include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 744 |
745 content::MockDownloadManager* download_manager() { return download_manager_; } | 745 content::MockDownloadManager* download_manager() { return download_manager_; } |
746 | 746 |
747 private: | 747 private: |
748 content::MockDownloadManager* download_manager_; // Owned by testing profile. | 748 content::MockDownloadManager* download_manager_; // Owned by testing profile. |
749 ChromeDownloadManagerDelegate chrome_download_manager_delegate_; | 749 ChromeDownloadManagerDelegate chrome_download_manager_delegate_; |
750 | 750 |
751 DISALLOW_COPY_AND_ASSIGN(RemoveDownloadsTester); | 751 DISALLOW_COPY_AND_ASSIGN(RemoveDownloadsTester); |
752 }; | 752 }; |
753 | 753 |
754 // TestingProfile does not contain ChromeBrowsingDataRemoverDelegate. Add it | |
755 // for the purpose of this test. | |
756 class TestingProfileWithDelegate : public TestingProfile { | |
757 public: | |
758 TestingProfileWithDelegate() : delegate_(this) {} | |
759 | |
760 content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() | |
761 override { | |
762 return &delegate_; | |
763 } | |
764 | |
765 private: | |
766 ChromeBrowsingDataRemoverDelegate delegate_; | |
767 }; | |
768 | |
769 } // namespace | 754 } // namespace |
770 | 755 |
771 // RemoveAutofillTester is not a part of the anonymous namespace above, as | 756 // RemoveAutofillTester is not a part of the anonymous namespace above, as |
772 // PersonalDataManager declares it a friend in an empty namespace. | 757 // PersonalDataManager declares it a friend in an empty namespace. |
773 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver { | 758 class RemoveAutofillTester : public autofill::PersonalDataManagerObserver { |
774 public: | 759 public: |
775 explicit RemoveAutofillTester(TestingProfile* profile) | 760 explicit RemoveAutofillTester(TestingProfile* profile) |
776 : personal_data_manager_( | 761 : personal_data_manager_( |
777 autofill::PersonalDataManagerFactory::GetForProfile(profile)) { | 762 autofill::PersonalDataManagerFactory::GetForProfile(profile)) { |
778 autofill::test::DisableSystemServices(profile->GetPrefs()); | 763 autofill::test::DisableSystemServices(profile->GetPrefs()); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 838 |
854 autofill::PersonalDataManager* personal_data_manager_; | 839 autofill::PersonalDataManager* personal_data_manager_; |
855 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); | 840 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); |
856 }; | 841 }; |
857 | 842 |
858 // Test Class ----------------------------------------------------------------- | 843 // Test Class ----------------------------------------------------------------- |
859 | 844 |
860 class ChromeBrowsingDataRemoverDelegateTest : public testing::Test { | 845 class ChromeBrowsingDataRemoverDelegateTest : public testing::Test { |
861 public: | 846 public: |
862 ChromeBrowsingDataRemoverDelegateTest() | 847 ChromeBrowsingDataRemoverDelegateTest() |
863 : profile_(new TestingProfileWithDelegate()), | 848 : profile_(new TestingProfile()), |
864 clear_domain_reliability_tester_(profile_.get()) { | 849 clear_domain_reliability_tester_(profile_.get()) { |
865 remover_ = content::BrowserContext::GetBrowsingDataRemover(profile_.get()); | 850 remover_ = content::BrowserContext::GetBrowsingDataRemover(profile_.get()); |
866 | 851 |
867 #if defined(OS_ANDROID) | 852 #if defined(OS_ANDROID) |
868 static_cast<ChromeBrowsingDataRemoverDelegate*>( | 853 static_cast<ChromeBrowsingDataRemoverDelegate*>( |
869 profile_->GetBrowsingDataRemoverDelegate()) | 854 profile_->GetBrowsingDataRemoverDelegate()) |
870 ->OverrideWebappRegistryForTesting( | 855 ->OverrideWebappRegistryForTesting( |
871 base::WrapUnique<WebappRegistry>(new TestWebappRegistry())); | 856 base::WrapUnique<WebappRegistry>(new TestWebappRegistry())); |
872 #endif | 857 #endif |
873 } | 858 } |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2013 EXPECT_FALSE(Match(kOrigin1, kProtected, nullptr)); | 1998 EXPECT_FALSE(Match(kOrigin1, kProtected, nullptr)); |
2014 EXPECT_FALSE(Match(kOriginExt, kProtected, nullptr)); | 1999 EXPECT_FALSE(Match(kOriginExt, kProtected, nullptr)); |
2015 EXPECT_FALSE(Match(kOriginDevTools, kProtected, nullptr)); | 2000 EXPECT_FALSE(Match(kOriginDevTools, kProtected, nullptr)); |
2016 | 2001 |
2017 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2002 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2018 EXPECT_FALSE(Match(kOrigin1, kExtension, nullptr)); | 2003 EXPECT_FALSE(Match(kOrigin1, kExtension, nullptr)); |
2019 EXPECT_TRUE(Match(kOriginExt, kExtension, nullptr)); | 2004 EXPECT_TRUE(Match(kOriginExt, kExtension, nullptr)); |
2020 EXPECT_FALSE(Match(kOriginDevTools, kExtension, nullptr)); | 2005 EXPECT_FALSE(Match(kOriginDevTools, kExtension, nullptr)); |
2021 #endif | 2006 #endif |
2022 } | 2007 } |
OLD | NEW |