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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/browsing_data/browsing_data_remover_unittest.cc
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 9a824c451912b984f3ebd83924185826d54a678d..80cabd84b0316152f611926ea22752430a952c65 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -878,6 +878,29 @@ class RemoveDownloadsTester {
DISALLOW_COPY_AND_ASSIGN(RemoveDownloadsTester);
};
+class RemovePasswordsTester {
+ public:
+ explicit RemovePasswordsTester(TestingProfile* testing_profile) {
+ PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
+ testing_profile,
+ password_manager::BuildPasswordStore<
+ content::BrowserContext,
+ testing::NiceMock<password_manager::MockPasswordStore>>);
Timo Reimann 2016/02/01 10:07:20 Note that I additionally wrapped the mocked passwo
+
+ store_ = static_cast<password_manager::MockPasswordStore*>(
+ PasswordStoreFactory::GetInstance()
+ ->GetForProfile(testing_profile, ServiceAccessType::EXPLICIT_ACCESS)
+ .get());
+ }
+
+ password_manager::MockPasswordStore* store() { return store_; }
+
+ private:
+ password_manager::MockPasswordStore* store_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemovePasswordsTester);
+};
+
// Test Class ----------------------------------------------------------------
class BrowsingDataRemoverTest : public testing::Test {
@@ -2157,18 +2180,22 @@ TEST_F(BrowsingDataRemoverTest, RemoveSameOriginDownloads) {
}
TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) {
- PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
- GetProfile(),
- password_manager::BuildPasswordStore<
- content::BrowserContext, password_manager::MockPasswordStore>);
- password_manager::MockPasswordStore* store =
- static_cast<password_manager::MockPasswordStore*>(
- PasswordStoreFactory::GetInstance()
- ->GetForProfile(GetProfile(), ServiceAccessType::EXPLICIT_ACCESS)
- .get());
- EXPECT_CALL(*store, RemoveStatisticsCreatedBetweenImpl(base::Time(),
- base::Time::Max()));
+ RemovePasswordsTester tester(GetProfile());
+
+ EXPECT_CALL(*tester.store(), RemoveStatisticsCreatedBetweenImpl(
+ base::Time(), base::Time::Max()));
BlockUntilBrowsingDataRemoved(
BrowsingDataRemover::EVERYTHING,
BrowsingDataRemover::REMOVE_HISTORY, false);
}
+
+TEST_F(BrowsingDataRemoverTest, RemoveSameOriginPasswords) {
+ RemovePasswordsTester tester(GetProfile());
+ const url::Origin expectedOrigin(kOrigin1);
+
+ EXPECT_CALL(*tester.store(),
+ RemoveLoginsByOriginAndTimeImpl(SameOrigin(expectedOrigin), _, _))
+ .WillOnce(Return(password_manager::PasswordStoreChangeList()));
+ BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING,
+ 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 *
+}

Powered by Google App Engine
This is Rietveld 408576698