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

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

Issue 1651913003: Handle origin-specific password deletion in BrowsingDataRemover (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <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
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>>);
Timo Reimann 2016/02/01 10:07:20 Note that I additionally wrapped the mocked passwo
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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 const url::Origin expectedOrigin(kOrigin1); 2173 const url::Origin expectedOrigin(kOrigin1);
2151 2174
2152 EXPECT_CALL(*tester.download_manager(), 2175 EXPECT_CALL(*tester.download_manager(),
2153 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _)); 2176 RemoveDownloadsByOriginAndTime(SameOrigin(expectedOrigin), _, _));
2154 2177
2155 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, 2178 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING,
2156 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1); 2179 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1);
2157 } 2180 }
2158 2181
2159 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { 2182 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) {
2160 PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse( 2183 RemovePasswordsTester tester(GetProfile());
2161 GetProfile(), 2184
2162 password_manager::BuildPasswordStore< 2185 EXPECT_CALL(*tester.store(), RemoveStatisticsCreatedBetweenImpl(
2163 content::BrowserContext, password_manager::MockPasswordStore>); 2186 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( 2187 BlockUntilBrowsingDataRemoved(
2172 BrowsingDataRemover::EVERYTHING, 2188 BrowsingDataRemover::EVERYTHING,
2173 BrowsingDataRemover::REMOVE_HISTORY, false); 2189 BrowsingDataRemover::REMOVE_HISTORY, false);
2174 } 2190 }
2191
2192 TEST_F(BrowsingDataRemoverTest, RemoveSameOriginPasswords) {
2193 RemovePasswordsTester tester(GetProfile());
2194 const url::Origin expectedOrigin(kOrigin1);
2195
2196 EXPECT_CALL(*tester.store(),
2197 RemoveLoginsByOriginAndTimeImpl(SameOrigin(expectedOrigin), _, _))
2198 .WillOnce(Return(password_manager::PasswordStoreChangeList()));
2199 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING,
2200 BrowsingDataRemover::REMOVE_PASSWORDS, kOrigin1);
Mike West 2016/02/04 18:25:11 Can you add a test that passes in a URL that produ
Timo Reimann 2016/02/05 01:12:38 (Assuming you meant that it shouldn't remove any *
2201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698