Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1550)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 895683002: Domain Reliability: Default to enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix BrowsingDataRemoverTest failures Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/domain_reliability/service_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browsing_data_remover.h" 5 #include "chrome/browser/browsing_data/browsing_data_remover.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 } 696 }
697 697
698 TestingProfile* profile_; 698 TestingProfile* profile_;
699 MockDomainReliabilityService* mock_service_; 699 MockDomainReliabilityService* mock_service_;
700 }; 700 };
701 701
702 // Test Class ---------------------------------------------------------------- 702 // Test Class ----------------------------------------------------------------
703 703
704 class BrowsingDataRemoverTest : public testing::Test { 704 class BrowsingDataRemoverTest : public testing::Test {
705 public: 705 public:
706 BrowsingDataRemoverTest() : profile_(new TestingProfile()) { 706 BrowsingDataRemoverTest()
707 : profile_(new TestingProfile()),
708 clear_domain_reliability_tester_(GetProfile()) {
707 callback_subscription_ = 709 callback_subscription_ =
708 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( 710 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
709 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails, 711 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails,
710 base::Unretained(this))); 712 base::Unretained(this)));
711 } 713 }
712 714
713 ~BrowsingDataRemoverTest() override {} 715 ~BrowsingDataRemoverTest() override {}
714 716
715 void TearDown() override { 717 void TearDown() override {
716 #if defined(ENABLE_EXTENSIONS) 718 #if defined(ENABLE_EXTENSIONS)
717 mock_policy_ = NULL; 719 mock_policy_ = NULL;
718 #endif 720 #endif
719 721
720 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor 722 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor
721 // posts a message to the WEBKIT thread to delete some of its member 723 // posts a message to the WEBKIT thread to delete some of its member
722 // variables. We need to ensure that the profile is destroyed, and that 724 // variables. We need to ensure that the profile is destroyed, and that
723 // the message loop is cleared out, before destroying the threads and loop. 725 // the message loop is cleared out, before destroying the threads and loop.
724 // Otherwise we leak memory. 726 // Otherwise we leak memory.
725 profile_.reset(); 727 profile_.reset();
726 base::MessageLoop::current()->RunUntilIdle(); 728 base::MessageLoop::current()->RunUntilIdle();
729
730 TestingBrowserProcess::GetGlobal()->SetLocalState(NULL);
727 } 731 }
728 732
729 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period, 733 void BlockUntilBrowsingDataRemoved(BrowsingDataRemover::TimePeriod period,
730 int remove_mask, 734 int remove_mask,
731 bool include_protected_origins) { 735 bool include_protected_origins) {
732 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod( 736 BrowsingDataRemover* remover = BrowsingDataRemover::CreateForPeriod(
733 profile_.get(), period); 737 profile_.get(), period);
734 738
735 TestStoragePartition storage_partition; 739 TestStoragePartition storage_partition;
736 remover->OverrideStoragePartitionForTesting(&storage_partition); 740 remover->OverrideStoragePartitionForTesting(&storage_partition);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 scoped_ptr<TestingProfile> profile_; 843 scoped_ptr<TestingProfile> profile_;
840 844
841 StoragePartitionRemovalData storage_partition_removal_data_; 845 StoragePartitionRemovalData storage_partition_removal_data_;
842 846
843 #if defined(ENABLE_EXTENSIONS) 847 #if defined(ENABLE_EXTENSIONS)
844 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_; 848 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_;
845 #endif 849 #endif
846 850
847 BrowsingDataRemover::CallbackSubscription callback_subscription_; 851 BrowsingDataRemover::CallbackSubscription callback_subscription_;
848 852
853 protected:
854 // Needed to mock out DomainReliabilityService, even for unrelated tests.
855 ClearDomainReliabilityTester clear_domain_reliability_tester_;
davidben 2015/02/03 19:09:23 I don't think we ever interleave private/protected
Deprecated (see juliatuttle) 2015/02/03 20:31:39 Done.
856
857 private:
849 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); 858 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest);
850 }; 859 };
851 860
852 // Tests --------------------------------------------------------------------- 861 // Tests ---------------------------------------------------------------------
853 862
854 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { 863 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) {
855 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, 864 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING,
856 BrowsingDataRemover::REMOVE_COOKIES, 865 BrowsingDataRemover::REMOVE_COOKIES,
857 false); 866 false);
858 867
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 1774
1766 BlockUntilBrowsingDataRemoved( 1775 BlockUntilBrowsingDataRemoved(
1767 BrowsingDataRemover::EVERYTHING, 1776 BrowsingDataRemover::EVERYTHING,
1768 BrowsingDataRemover::REMOVE_CONTENT_LICENSES, false); 1777 BrowsingDataRemover::REMOVE_CONTENT_LICENSES, false);
1769 1778
1770 chromeos::DBusThreadManager::Shutdown(); 1779 chromeos::DBusThreadManager::Shutdown();
1771 } 1780 }
1772 #endif 1781 #endif
1773 1782
1774 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) { 1783 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) {
1775 ClearDomainReliabilityTester tester(GetProfile()); 1784 ClearDomainReliabilityTester& tester = clear_domain_reliability_tester_;
davidben 2015/02/03 19:09:23 Nit: do we ever use non-const references? Pointer
Deprecated (see juliatuttle) 2015/02/03 20:31:38 Obsolete; I made it a const reference instead.
1776 1785
1777 EXPECT_EQ(0u, tester.clear_count()); 1786 EXPECT_EQ(0u, tester.clear_count());
1778 } 1787 }
1779 1788
1780 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) { 1789 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) {
1781 ClearDomainReliabilityTester tester(GetProfile()); 1790 ClearDomainReliabilityTester& tester = clear_domain_reliability_tester_;
1782 1791
1783 BlockUntilBrowsingDataRemoved( 1792 BlockUntilBrowsingDataRemoved(
1784 BrowsingDataRemover::EVERYTHING, 1793 BrowsingDataRemover::EVERYTHING,
1785 BrowsingDataRemover::REMOVE_HISTORY, false); 1794 BrowsingDataRemover::REMOVE_HISTORY, false);
1786 EXPECT_EQ(1u, tester.clear_count()); 1795 EXPECT_EQ(1u, tester.clear_count());
1787 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); 1796 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode());
1788 } 1797 }
1789 1798
1790 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) { 1799 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) {
1791 ClearDomainReliabilityTester tester(GetProfile()); 1800 ClearDomainReliabilityTester& tester = clear_domain_reliability_tester_;
1792 1801
1793 BlockUntilBrowsingDataRemoved( 1802 BlockUntilBrowsingDataRemoved(
1794 BrowsingDataRemover::EVERYTHING, 1803 BrowsingDataRemover::EVERYTHING,
1795 BrowsingDataRemover::REMOVE_COOKIES, false); 1804 BrowsingDataRemover::REMOVE_COOKIES, false);
1796 EXPECT_EQ(1u, tester.clear_count()); 1805 EXPECT_EQ(1u, tester.clear_count());
1797 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); 1806 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode());
1798 } 1807 }
1799 1808
1800 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) { 1809 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) {
1801 ClearDomainReliabilityTester tester(GetProfile()); 1810 ClearDomainReliabilityTester& tester = clear_domain_reliability_tester_;
1802 1811
1803 BlockUntilBrowsingDataRemoved( 1812 BlockUntilBrowsingDataRemoved(
1804 BrowsingDataRemover::EVERYTHING, 1813 BrowsingDataRemover::EVERYTHING,
1805 BrowsingDataRemover::REMOVE_HISTORY | 1814 BrowsingDataRemover::REMOVE_HISTORY |
1806 BrowsingDataRemover::REMOVE_COOKIES, false); 1815 BrowsingDataRemover::REMOVE_COOKIES, false);
1807 EXPECT_EQ(1u, tester.clear_count()); 1816 EXPECT_EQ(1u, tester.clear_count());
1808 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); 1817 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode());
1809 } 1818 }
1810 1819
1811 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) { 1820 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) {
1812 ClearDomainReliabilityTester tester(GetProfile()); 1821 ClearDomainReliabilityTester& tester = clear_domain_reliability_tester_;
1813 1822
1814 BlockUntilBrowsingDataRemoved( 1823 BlockUntilBrowsingDataRemoved(
1815 BrowsingDataRemover::EVERYTHING, 1824 BrowsingDataRemover::EVERYTHING,
1816 BrowsingDataRemover::REMOVE_COOKIES, true); 1825 BrowsingDataRemover::REMOVE_COOKIES, true);
1817 EXPECT_EQ(1u, tester.clear_count()); 1826 EXPECT_EQ(1u, tester.clear_count());
1818 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); 1827 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode());
1819 } 1828 }
1820 1829
1821 TEST_F(BrowsingDataRemoverTest, DomainReliability_NoMonitor) { 1830 // TODO(ttuttle): This isn't actually testing the no-monitor case, since
1831 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed
1832 // for some unrelated test cases.
1833 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) {
1822 BlockUntilBrowsingDataRemoved( 1834 BlockUntilBrowsingDataRemoved(
1823 BrowsingDataRemover::EVERYTHING, 1835 BrowsingDataRemover::EVERYTHING,
1824 BrowsingDataRemover::REMOVE_HISTORY | 1836 BrowsingDataRemover::REMOVE_HISTORY |
1825 BrowsingDataRemover::REMOVE_COOKIES, false); 1837 BrowsingDataRemover::REMOVE_COOKIES, false);
1826 } 1838 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/domain_reliability/service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698