OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 | 871 |
872 content::MockDownloadManager* download_manager() { return download_manager_; } | 872 content::MockDownloadManager* download_manager() { return download_manager_; } |
873 | 873 |
874 private: | 874 private: |
875 content::MockDownloadManager* download_manager_; | 875 content::MockDownloadManager* download_manager_; |
876 ChromeDownloadManagerDelegate chrome_download_manager_delegate_; | 876 ChromeDownloadManagerDelegate chrome_download_manager_delegate_; |
877 | 877 |
878 DISALLOW_COPY_AND_ASSIGN(RemoveDownloadsTester); | 878 DISALLOW_COPY_AND_ASSIGN(RemoveDownloadsTester); |
879 }; | 879 }; |
880 | 880 |
| 881 class RemovePasswordsTester { |
| 882 public: |
| 883 explicit RemovePasswordsTester(TestingProfile* testing_profile) { |
| 884 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( |
| 885 testing_profile, |
| 886 password_manager::BuildPasswordStore< |
| 887 content::BrowserContext, |
| 888 testing::NiceMock<password_manager::MockPasswordStore>>); |
| 889 |
| 890 store_ = static_cast<password_manager::MockPasswordStore*>( |
| 891 PasswordStoreFactory::GetInstance() |
| 892 ->GetForProfile(testing_profile, ServiceAccessType::EXPLICIT_ACCESS) |
| 893 .get()); |
| 894 } |
| 895 |
| 896 password_manager::MockPasswordStore* store() { return store_; } |
| 897 |
| 898 private: |
| 899 password_manager::MockPasswordStore* store_; |
| 900 |
| 901 DISALLOW_COPY_AND_ASSIGN(RemovePasswordsTester); |
| 902 }; |
| 903 |
881 // Test Class ---------------------------------------------------------------- | 904 // Test Class ---------------------------------------------------------------- |
882 | 905 |
883 class BrowsingDataRemoverTest : public testing::Test { | 906 class BrowsingDataRemoverTest : public testing::Test { |
884 public: | 907 public: |
885 BrowsingDataRemoverTest() | 908 BrowsingDataRemoverTest() |
886 : profile_(new TestingProfile()), | 909 : profile_(new TestingProfile()), |
887 clear_domain_reliability_tester_(GetProfile()) { | 910 clear_domain_reliability_tester_(GetProfile()) { |
888 callback_subscription_ = | 911 callback_subscription_ = |
889 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( | 912 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback( |
890 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails, | 913 base::Bind(&BrowsingDataRemoverTest::NotifyWithDetails, |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2138 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed | 2161 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed |
2139 // for some unrelated test cases. This should be fixed so it tests the no- | 2162 // for some unrelated test cases. This should be fixed so it tests the no- |
2140 // monitor case again. | 2163 // monitor case again. |
2141 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { | 2164 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { |
2142 BlockUntilBrowsingDataRemoved( | 2165 BlockUntilBrowsingDataRemoved( |
2143 BrowsingDataRemover::EVERYTHING, | 2166 BrowsingDataRemover::EVERYTHING, |
2144 BrowsingDataRemover::REMOVE_HISTORY | | 2167 BrowsingDataRemover::REMOVE_HISTORY | |
2145 BrowsingDataRemover::REMOVE_COOKIES, false); | 2168 BrowsingDataRemover::REMOVE_COOKIES, false); |
2146 } | 2169 } |
2147 | 2170 |
2148 TEST_F(BrowsingDataRemoverTest, RemoveSameOriginDownloads) { | 2171 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { |
| 2172 RemoveDownloadsTester tester(GetProfile()); |
| 2173 |
| 2174 EXPECT_CALL(*tester.download_manager(), RemoveDownloadsBetween(_, _)); |
| 2175 |
| 2176 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2177 BrowsingDataRemover::REMOVE_DOWNLOADS, false); |
| 2178 } |
| 2179 |
| 2180 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { |
2149 RemoveDownloadsTester tester(GetProfile()); | 2181 RemoveDownloadsTester tester(GetProfile()); |
2150 const url::Origin expectedOrigin(kOrigin1); | 2182 const url::Origin expectedOrigin(kOrigin1); |
2151 | 2183 |
2152 EXPECT_CALL(*tester.download_manager(), | 2184 EXPECT_CALL(*tester.download_manager(), |
2153 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _)); | 2185 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _)); |
2154 | 2186 |
2155 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 2187 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
2156 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1); | 2188 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1); |
2157 } | 2189 } |
2158 | 2190 |
2159 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { | 2191 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { |
2160 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( | 2192 RemovePasswordsTester tester(GetProfile()); |
2161 GetProfile(), | 2193 |
2162 password_manager::BuildPasswordStore< | 2194 EXPECT_CALL(*tester.store(), RemoveStatisticsCreatedBetweenImpl( |
2163 content::BrowserContext, password_manager::MockPasswordStore>); | 2195 base::Time(), base::Time::Max())); |
2164 password_manager::MockPasswordStore* store = | |
2165 static_cast<password_manager::MockPasswordStore*>( | |
2166 PasswordStoreFactory::GetInstance() | |
2167 ->GetForProfile(GetProfile(), ServiceAccessType::EXPLICIT_ACCESS) | |
2168 .get()); | |
2169 EXPECT_CALL(*store, RemoveStatisticsCreatedBetweenImpl(base::Time(), | |
2170 base::Time::Max())); | |
2171 BlockUntilBrowsingDataRemoved( | 2196 BlockUntilBrowsingDataRemoved( |
2172 BrowsingDataRemover::EVERYTHING, | 2197 BrowsingDataRemover::EVERYTHING, |
2173 BrowsingDataRemover::REMOVE_HISTORY, false); | 2198 BrowsingDataRemover::REMOVE_HISTORY, false); |
2174 } | 2199 } |
| 2200 |
| 2201 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { |
| 2202 RemovePasswordsTester tester(GetProfile()); |
| 2203 |
| 2204 EXPECT_CALL(*tester.store(), RemoveLoginsCreatedBetweenImpl(_, _)) |
| 2205 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2206 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2207 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
| 2208 } |
| 2209 |
| 2210 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { |
| 2211 RemovePasswordsTester tester(GetProfile()); |
| 2212 const url::Origin expectedOrigin(kOrigin1); |
| 2213 |
| 2214 EXPECT_CALL(*tester.store(), |
| 2215 RemoveLoginsByOriginAndTimeImpl(SameOrigin(expectedOrigin), _, _)) |
| 2216 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2217 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2218 BrowsingDataRemover::REMOVE_PASSWORDS, kOrigin1); |
| 2219 } |
OLD | NEW |