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

Unified Diff: components/password_manager/core/browser/affiliation_database_unittest.cc

Issue 1072413003: Add foundation for trimming the AffiliationDatabase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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: components/password_manager/core/browser/affiliation_database_unittest.cc
diff --git a/components/password_manager/core/browser/affiliation_database_unittest.cc b/components/password_manager/core/browser/affiliation_database_unittest.cc
index 6fc8a7e1fb2bafa647be2b939198b4d01b250818..473439272a1b5833944f4d19a18cbc38007e26bc 100644
--- a/components/password_manager/core/browser/affiliation_database_unittest.cc
+++ b/components/password_manager/core/browser/affiliation_database_unittest.cc
@@ -5,6 +5,7 @@
#include "components/password_manager/core/browser/affiliation_database.h"
#include "base/files/file_util.h"
+#include "base/files/scoped_temp_dir.h"
#include "sql/test/scoped_error_ignorer.h"
#include "sql/test/test_helpers.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -69,7 +70,7 @@ class AffiliationDatabaseTest : public testing::Test {
~AffiliationDatabaseTest() override {}
void SetUp() override {
- ASSERT_TRUE(CreateTemporaryFile(&db_path_));
+ ASSERT_TRUE(temp_directory_.CreateUniqueTempDir());
OpenDatabase();
}
@@ -88,10 +89,13 @@ class AffiliationDatabaseTest : public testing::Test {
AffiliationDatabase& db() { return *db_; }
- const base::FilePath& db_path() { return db_path_; }
+ base::FilePath db_path() {
+ return temp_directory_.path().Append(
+ FILE_PATH_LITERAL("Test Affiliation Database"));
+ }
private:
- base::FilePath db_path_;
+ base::ScopedTempDir temp_directory_;
scoped_ptr<AffiliationDatabase> db_;
DISALLOW_COPY_AND_ASSIGN(AffiliationDatabaseTest);
@@ -290,4 +294,13 @@ TEST_F(AffiliationDatabaseTest, CorruptDBGetsPoisoned) {
EXPECT_EQ(0u, affiliations.size());
}
+// Verify that all files get deleted.
+TEST_F(AffiliationDatabaseTest, Delete) {
+ ASSERT_NO_FATAL_FAILURE(StoreInitialTestData());
+ CloseDatabase();
+
+ AffiliationDatabase::Delete(db_path());
+ EXPECT_TRUE(base::IsDirectoryEmpty(db_path().DirName()));
+}
+
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698