| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/dom_storage/dom_storage_database.h" | 5 #include "content/browser/dom_storage/dom_storage_database.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "content/public/common/content_paths.h" |
| 12 #include "sql/statement.h" | 13 #include "sql/statement.h" |
| 13 #include "sql/test/scoped_error_ignorer.h" | 14 #include "sql/test/scoped_error_ignorer.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/sqlite/sqlite3.h" | 16 #include "third_party/sqlite/sqlite3.h" |
| 16 | 17 |
| 17 using base::ASCIIToUTF16; | 18 using base::ASCIIToUTF16; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 void CreateV1Table(sql::Connection* db) { | 22 void CreateV1Table(sql::Connection* db) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // A null string in the map should mean that that key gets | 303 // A null string in the map should mean that that key gets |
| 303 // removed. | 304 // removed. |
| 304 values[kCannedKey] = base::NullableString16(); | 305 values[kCannedKey] = base::NullableString16(); |
| 305 EXPECT_TRUE(db.CommitChanges(false, values)); | 306 EXPECT_TRUE(db.CommitChanges(false, values)); |
| 306 | 307 |
| 307 expected.clear(); | 308 expected.clear(); |
| 308 CheckValuesMatch(&db, expected); | 309 CheckValuesMatch(&db, expected); |
| 309 } | 310 } |
| 310 | 311 |
| 311 TEST(DOMStorageDatabaseTest, TestCanOpenAndReadWebCoreDatabase) { | 312 TEST(DOMStorageDatabaseTest, TestCanOpenAndReadWebCoreDatabase) { |
| 312 base::FilePath webcore_database; | 313 base::FilePath dir_test_data; |
| 313 PathService::Get(base::DIR_SOURCE_ROOT, &webcore_database); | 314 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &dir_test_data)); |
| 314 webcore_database = webcore_database.AppendASCII("webkit"); | 315 base::FilePath webcore_database = dir_test_data.AppendASCII("dom_storage"); |
| 315 webcore_database = webcore_database.AppendASCII("data"); | |
| 316 webcore_database = webcore_database.AppendASCII("dom_storage"); | |
| 317 webcore_database = | 316 webcore_database = |
| 318 webcore_database.AppendASCII("webcore_test_database.localstorage"); | 317 webcore_database.AppendASCII("webcore_test_database.localstorage"); |
| 319 | 318 |
| 320 ASSERT_TRUE(base::PathExists(webcore_database)); | 319 ASSERT_TRUE(base::PathExists(webcore_database)); |
| 321 | 320 |
| 322 DOMStorageDatabase db(webcore_database); | 321 DOMStorageDatabase db(webcore_database); |
| 323 DOMStorageValuesMap values; | 322 DOMStorageValuesMap values; |
| 324 db.ReadAllValues(&values); | 323 db.ReadAllValues(&values); |
| 325 EXPECT_TRUE(db.IsOpen()); | 324 EXPECT_TRUE(db.IsOpen()); |
| 326 EXPECT_EQ(2u, values.size()); | 325 EXPECT_EQ(2u, values.size()); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 EXPECT_EQ(0u, values.size()); | 385 EXPECT_EQ(0u, values.size()); |
| 387 EXPECT_FALSE(db.IsOpen()); | 386 EXPECT_FALSE(db.IsOpen()); |
| 388 | 387 |
| 389 EXPECT_TRUE(base::PathExists(temp_dir.path())); | 388 EXPECT_TRUE(base::PathExists(temp_dir.path())); |
| 390 | 389 |
| 391 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 390 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); |
| 392 } | 391 } |
| 393 } | 392 } |
| 394 | 393 |
| 395 } // namespace content | 394 } // namespace content |
| OLD | NEW |