| 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/dom_storage/dom_storage_database.h" | 5 #include "webkit/dom_storage/dom_storage_database.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 ScopedTempDir temp_dir; | 111 ScopedTempDir temp_dir; |
| 112 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 112 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 113 FilePath file_name = temp_dir.path().AppendASCII("TestDomStorageDatabase.db"); | 113 FilePath file_name = temp_dir.path().AppendASCII("TestDomStorageDatabase.db"); |
| 114 ValuesMap storage; | 114 ValuesMap storage; |
| 115 CreateMapWithValues(&storage); | 115 CreateMapWithValues(&storage); |
| 116 | 116 |
| 117 // First test the case that explicitly clearing the database will | 117 // First test the case that explicitly clearing the database will |
| 118 // trigger it's deletion from disk. | 118 // trigger it's deletion from disk. |
| 119 { | 119 { |
| 120 DomStorageDatabase db(file_name); | 120 DomStorageDatabase db(file_name); |
| 121 EXPECT_EQ(file_name, db.file_path()); |
| 121 ASSERT_TRUE(db.CommitChanges(false, storage)); | 122 ASSERT_TRUE(db.CommitChanges(false, storage)); |
| 122 } | 123 } |
| 123 EXPECT_TRUE(file_util::PathExists(file_name)); | 124 EXPECT_TRUE(file_util::PathExists(file_name)); |
| 124 | 125 |
| 125 { | 126 { |
| 126 // Check that reading an existing db with data in it | 127 // Check that reading an existing db with data in it |
| 127 // keeps the DB on disk on close. | 128 // keeps the DB on disk on close. |
| 128 DomStorageDatabase db(file_name); | 129 DomStorageDatabase db(file_name); |
| 129 ValuesMap values; | 130 ValuesMap values; |
| 130 db.ReadAllValues(&values); | 131 db.ReadAllValues(&values); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 367 |
| 367 db.ReadAllValues(&values); | 368 db.ReadAllValues(&values); |
| 368 EXPECT_EQ(0u, values.size()); | 369 EXPECT_EQ(0u, values.size()); |
| 369 EXPECT_FALSE(db.IsOpen()); | 370 EXPECT_FALSE(db.IsOpen()); |
| 370 | 371 |
| 371 EXPECT_TRUE(file_util::PathExists(temp_dir.path())); | 372 EXPECT_TRUE(file_util::PathExists(temp_dir.path())); |
| 372 } | 373 } |
| 373 } | 374 } |
| 374 | 375 |
| 375 } // namespace dom_storage | 376 } // namespace dom_storage |
| OLD | NEW |