| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 FileSystemDirectoryDatabaseTest() { | 22 FileSystemDirectoryDatabaseTest() { |
| 23 EXPECT_TRUE(base_.CreateUniqueTempDir()); | 23 EXPECT_TRUE(base_.CreateUniqueTempDir()); |
| 24 InitDatabase(); | 24 InitDatabase(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 FileSystemDirectoryDatabase* db() { | 27 FileSystemDirectoryDatabase* db() { |
| 28 return db_.get(); | 28 return db_.get(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void InitDatabase() { | 31 void InitDatabase() { |
| 32 // First reset() is to avoid multiple database instance for single |
| 33 // directory at once. |
| 32 db_.reset(); | 34 db_.reset(); |
| 33 FilePath path = base_.path().AppendASCII("db"); | 35 db_.reset(new FileSystemDirectoryDatabase(base_.path())); |
| 34 db_.reset(new FileSystemDirectoryDatabase(path)); | |
| 35 } | 36 } |
| 36 | 37 |
| 37 bool AddFileInfo(FileId parent_id, const FilePath::StringType& name) { | 38 bool AddFileInfo(FileId parent_id, const FilePath::StringType& name) { |
| 38 FileId file_id; | 39 FileId file_id; |
| 39 FileInfo info; | 40 FileInfo info; |
| 40 info.parent_id = parent_id; | 41 info.parent_id = parent_id; |
| 41 info.name = name; | 42 info.name = name; |
| 42 return db_->AddFileInfo(info, &file_id); | 43 return db_->AddFileInfo(info, &file_id); |
| 43 } | 44 } |
| 44 | 45 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 EXPECT_TRUE(db()->GetNextInteger(&next)); | 412 EXPECT_TRUE(db()->GetNextInteger(&next)); |
| 412 EXPECT_EQ(2, next); | 413 EXPECT_EQ(2, next); |
| 413 EXPECT_TRUE(db()->GetNextInteger(&next)); | 414 EXPECT_TRUE(db()->GetNextInteger(&next)); |
| 414 EXPECT_EQ(3, next); | 415 EXPECT_EQ(3, next); |
| 415 InitDatabase(); | 416 InitDatabase(); |
| 416 EXPECT_TRUE(db()->GetNextInteger(&next)); | 417 EXPECT_TRUE(db()->GetNextInteger(&next)); |
| 417 EXPECT_EQ(4, next); | 418 EXPECT_EQ(4, next); |
| 418 } | 419 } |
| 419 | 420 |
| 420 } // namespace fileapi | 421 } // namespace fileapi |
| OLD | NEW |