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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "sql/connection.h" | 8 #include "sql/connection.h" |
9 #include "sql/meta_table.h" | 9 #include "sql/meta_table.h" |
10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 390 |
391 sql::MetaTable meta_table; | 391 sql::MetaTable meta_table; |
392 // Below call needs a temporary directory in sqlite3 | 392 // Below call needs a temporary directory in sqlite3 |
393 // On Android, it can pass only when the temporary directory is set. | 393 // On Android, it can pass only when the temporary directory is set. |
394 // Otherwise, sqlite3 doesn't find the correct directory to store | 394 // Otherwise, sqlite3 doesn't find the correct directory to store |
395 // temporary files and will report the error 'unable to open | 395 // temporary files and will report the error 'unable to open |
396 // database file'. | 396 // database file'. |
397 ASSERT_TRUE(meta_table.Init(&db(), 4, 4)); | 397 ASSERT_TRUE(meta_table.Init(&db(), 4, 4)); |
398 } | 398 } |
399 #endif | 399 #endif |
| 400 |
| 401 TEST_F(SQLConnectionTest, Delete) { |
| 402 EXPECT_TRUE(db().Execute("CREATE TABLE x (x)")); |
| 403 db().Close(); |
| 404 |
| 405 // Should have both a main database file and a journal file because |
| 406 // of journal_mode PERSIST. |
| 407 base::FilePath journal(db_path().value() + FILE_PATH_LITERAL("-journal")); |
| 408 ASSERT_TRUE(file_util::PathExists(db_path())); |
| 409 ASSERT_TRUE(file_util::PathExists(journal)); |
| 410 |
| 411 sql::Connection::Delete(db_path()); |
| 412 EXPECT_FALSE(file_util::PathExists(db_path())); |
| 413 EXPECT_FALSE(file_util::PathExists(journal)); |
| 414 } |
OLD | NEW |