OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "storage/browser/fileapi/sandbox_directory_database.h" | 5 #include "storage/browser/fileapi/sandbox_directory_database.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
8 #include <limits> | 10 #include <limits> |
9 | 11 |
10 #include "base/files/file.h" | 12 #include "base/files/file.h" |
11 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
12 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
| 15 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
16 #include "content/browser/fileapi/sandbox_database_test_helper.h" | 19 #include "content/browser/fileapi/sandbox_database_test_helper.h" |
17 #include "storage/common/fileapi/file_system_util.h" | 20 #include "storage/common/fileapi/file_system_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 22 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
20 | 23 |
21 #define FPL(x) FILE_PATH_LITERAL(x) | 24 #define FPL(x) FILE_PATH_LITERAL(x) |
22 | 25 |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 | 492 |
490 EXPECT_FALSE(db()->GetFileWithPath(base::FilePath(info0.name), &check_id)); | 493 EXPECT_FALSE(db()->GetFileWithPath(base::FilePath(info0.name), &check_id)); |
491 EXPECT_TRUE(db()->GetFileWithPath( | 494 EXPECT_TRUE(db()->GetFileWithPath( |
492 base::FilePath(dir_info.name).Append(info1.name), &check_id)); | 495 base::FilePath(dir_info.name).Append(info1.name), &check_id)); |
493 EXPECT_TRUE(db()->GetFileInfo(check_id, &check_info)); | 496 EXPECT_TRUE(db()->GetFileInfo(check_id, &check_info)); |
494 | 497 |
495 EXPECT_EQ(info0.data_path, check_info.data_path); | 498 EXPECT_EQ(info0.data_path, check_info.data_path); |
496 } | 499 } |
497 | 500 |
498 TEST_F(SandboxDirectoryDatabaseTest, TestGetNextInteger) { | 501 TEST_F(SandboxDirectoryDatabaseTest, TestGetNextInteger) { |
499 int64 next = -1; | 502 int64_t next = -1; |
500 EXPECT_TRUE(db()->GetNextInteger(&next)); | 503 EXPECT_TRUE(db()->GetNextInteger(&next)); |
501 EXPECT_EQ(0, next); | 504 EXPECT_EQ(0, next); |
502 EXPECT_TRUE(db()->GetNextInteger(&next)); | 505 EXPECT_TRUE(db()->GetNextInteger(&next)); |
503 EXPECT_EQ(1, next); | 506 EXPECT_EQ(1, next); |
504 InitDatabase(); | 507 InitDatabase(); |
505 EXPECT_TRUE(db()->GetNextInteger(&next)); | 508 EXPECT_TRUE(db()->GetNextInteger(&next)); |
506 EXPECT_EQ(2, next); | 509 EXPECT_EQ(2, next); |
507 EXPECT_TRUE(db()->GetNextInteger(&next)); | 510 EXPECT_TRUE(db()->GetNextInteger(&next)); |
508 EXPECT_EQ(3, next); | 511 EXPECT_EQ(3, next); |
509 InitDatabase(); | 512 InitDatabase(); |
510 EXPECT_TRUE(db()->GetNextInteger(&next)); | 513 EXPECT_TRUE(db()->GetNextInteger(&next)); |
511 EXPECT_EQ(4, next); | 514 EXPECT_EQ(4, next); |
512 } | 515 } |
513 | 516 |
514 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Empty) { | 517 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Empty) { |
515 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 518 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
516 | 519 |
517 int64 next = -1; | 520 int64_t next = -1; |
518 EXPECT_TRUE(db()->GetNextInteger(&next)); | 521 EXPECT_TRUE(db()->GetNextInteger(&next)); |
519 EXPECT_EQ(0, next); | 522 EXPECT_EQ(0, next); |
520 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 523 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
521 } | 524 } |
522 | 525 |
523 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Consistent) { | 526 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_Consistent) { |
524 FileId dir_id; | 527 FileId dir_id; |
525 CreateFile(0, FPL("foo"), FPL("hoge"), NULL); | 528 CreateFile(0, FPL("foo"), FPL("hoge"), NULL); |
526 CreateDirectory(0, FPL("bar"), &dir_id); | 529 CreateDirectory(0, FPL("bar"), &dir_id); |
527 CreateFile(dir_id, FPL("baz"), FPL("fuga"), NULL); | 530 CreateFile(dir_id, FPL("baz"), FPL("fuga"), NULL); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 EXPECT_FALSE(db()->IsFileSystemConsistent()); | 669 EXPECT_FALSE(db()->IsFileSystemConsistent()); |
667 | 670 |
668 FileId file_id; | 671 FileId file_id; |
669 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); | 672 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); |
670 EXPECT_EQ(file_id_prev, file_id); | 673 EXPECT_EQ(file_id_prev, file_id); |
671 | 674 |
672 EXPECT_TRUE(db()->IsFileSystemConsistent()); | 675 EXPECT_TRUE(db()->IsFileSystemConsistent()); |
673 } | 676 } |
674 | 677 |
675 } // namespace content | 678 } // namespace content |
OLD | NEW |