Chromium Code Reviews| 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 "webkit/fileapi/file_system_directory_database.h" | 5 #include "webkit/fileapi/file_system_directory_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 643 CorruptDatabase(kDatabaseDirectory, leveldb::kLogFile, | 643 CorruptDatabase(kDatabaseDirectory, leveldb::kLogFile, |
| 644 -1, 1); | 644 -1, 1); |
| 645 InitDatabase(); | 645 InitDatabase(); |
| 646 EXPECT_FALSE(db()->IsFileSystemConsistent()); | 646 EXPECT_FALSE(db()->IsFileSystemConsistent()); |
| 647 | 647 |
| 648 FileId file_id; | 648 FileId file_id; |
| 649 EXPECT_FALSE(db()->GetChildWithName(0, kFileName, &file_id)); | 649 EXPECT_FALSE(db()->GetChildWithName(0, kFileName, &file_id)); |
| 650 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 650 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
| 651 } | 651 } |
| 652 | 652 |
| 653 TEST_F(FileSystemDirectoryDatabaseTest, TestRepairDatabase_MissingManifest) { | |
| 654 base::FilePath::StringType kFileName = FPL("bar"); | |
| 655 | |
| 656 FileId file_id_prev; | |
| 657 CreateFile(0, FPL("foo"), FPL("hoge"), NULL); | |
| 658 CreateFile(0, kFileName, FPL("fuga"), &file_id_prev); | |
| 659 | |
| 660 const base::FilePath kDatabaseDirectory = | |
| 661 path().Append(kDirectoryDatabaseName); | |
| 662 CloseDatabase(); | |
| 663 | |
| 664 DeleteDatabaseFile(kDatabaseDirectory, leveldb::kDescriptorFile); | |
|
kinuko
2013/04/10 06:23:49
What happens when other files are deleted?
tzik
2013/04/10 06:49:20
For .sst deletion, that was handled as corruption.
kinuko
2013/04/10 08:41:17
Should we add tests for them too (even if they may
tzik
2013/04/10 10:59:49
Added tests for them on OriginDatabase test.
Shoul
kinuko
2013/04/10 11:02:13
If you think we should do so please add them; I'm
tzik
2013/04/10 13:01:09
I believe it's enough to catch leveldb change. ;)
| |
| 665 | |
| 666 InitDatabase(); | |
| 667 EXPECT_FALSE(db()->IsFileSystemConsistent()); | |
| 668 | |
| 669 FileId file_id; | |
| 670 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); | |
| 671 EXPECT_EQ(file_id_prev, file_id); | |
| 672 | |
| 673 EXPECT_TRUE(db()->IsFileSystemConsistent()); | |
| 674 } | |
| 675 | |
| 653 } // namespace fileapi | 676 } // namespace fileapi |
| OLD | NEW |