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" |
| 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/scoped_ptr.h" |
11 #include "base/platform_file.h" | 13 #include "base/platform_file.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/scoped_temp_dir.h" | |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
18 #include "webkit/fileapi/file_system_database_test_helper.h" | 18 #include "webkit/fileapi/file_system_database_test_helper.h" |
19 #include "webkit/fileapi/file_system_util.h" | 19 #include "webkit/fileapi/file_system_util.h" |
20 | 20 |
21 #define FPL(x) FILE_PATH_LITERAL(x) | 21 #define FPL(x) FILE_PATH_LITERAL(x) |
22 | 22 |
23 namespace fileapi { | 23 namespace fileapi { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 FileInfo file_info; | 130 FileInfo file_info; |
131 ASSERT_TRUE(db()->GetFileInfo(file_id, &file_info)); | 131 ASSERT_TRUE(db()->GetFileInfo(file_id, &file_info)); |
132 ASSERT_TRUE(db()->db_->Delete( | 132 ASSERT_TRUE(db()->db_->Delete( |
133 leveldb::WriteOptions(), | 133 leveldb::WriteOptions(), |
134 "CHILD_OF:" + base::Int64ToString(file_info.parent_id) + ":" + | 134 "CHILD_OF:" + base::Int64ToString(file_info.parent_id) + ":" + |
135 FilePathToString(FilePath(file_info.name))).ok()); | 135 FilePathToString(FilePath(file_info.name))).ok()); |
136 } | 136 } |
137 | 137 |
138 protected: | 138 protected: |
139 // Common temp base for nondestructive uses. | 139 // Common temp base for nondestructive uses. |
140 ScopedTempDir base_; | 140 base::ScopedTempDir base_; |
141 scoped_ptr<FileSystemDirectoryDatabase> db_; | 141 scoped_ptr<FileSystemDirectoryDatabase> db_; |
142 | 142 |
143 DISALLOW_COPY_AND_ASSIGN(FileSystemDirectoryDatabaseTest); | 143 DISALLOW_COPY_AND_ASSIGN(FileSystemDirectoryDatabaseTest); |
144 }; | 144 }; |
145 | 145 |
146 TEST_F(FileSystemDirectoryDatabaseTest, TestMissingFileGetInfo) { | 146 TEST_F(FileSystemDirectoryDatabaseTest, TestMissingFileGetInfo) { |
147 FileId file_id = 888; | 147 FileId file_id = 888; |
148 FileInfo info; | 148 FileInfo info; |
149 EXPECT_FALSE(db()->GetFileInfo(file_id, &info)); | 149 EXPECT_FALSE(db()->GetFileInfo(file_id, &info)); |
150 } | 150 } |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } // namespace fileapi | 653 } // namespace fileapi |
OLD | NEW |