| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 std::string GetSchema(sql::Connection* db) { | 58 std::string GetSchema(sql::Connection* db) { |
| 59 const char kSql[] = | 59 const char kSql[] = |
| 60 "SELECT COALESCE(sql, name) FROM sqlite_master ORDER BY 1"; | 60 "SELECT COALESCE(sql, name) FROM sqlite_master ORDER BY 1"; |
| 61 return ExecuteWithResults(db, kSql, "|", "\n"); | 61 return ExecuteWithResults(db, kSql, "|", "\n"); |
| 62 } | 62 } |
| 63 | 63 |
| 64 class SQLRecoveryTest : public testing::Test { | 64 class SQLRecoveryTest : public testing::Test { |
| 65 public: | 65 public: |
| 66 SQLRecoveryTest() {} | 66 SQLRecoveryTest() {} |
| 67 | 67 |
| 68 virtual void SetUp() { | 68 void SetUp() override { |
| 69 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 69 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 70 ASSERT_TRUE(db_.Open(db_path())); | 70 ASSERT_TRUE(db_.Open(db_path())); |
| 71 } | 71 } |
| 72 | 72 |
| 73 virtual void TearDown() { | 73 void TearDown() override { db_.Close(); } |
| 74 db_.Close(); | |
| 75 } | |
| 76 | 74 |
| 77 sql::Connection& db() { return db_; } | 75 sql::Connection& db() { return db_; } |
| 78 | 76 |
| 79 base::FilePath db_path() { | 77 base::FilePath db_path() { |
| 80 return temp_dir_.path().AppendASCII("SQLRecoveryTest.db"); | 78 return temp_dir_.path().AppendASCII("SQLRecoveryTest.db"); |
| 81 } | 79 } |
| 82 | 80 |
| 83 bool Reopen() { | 81 bool Reopen() { |
| 84 db_.Close(); | 82 db_.Close(); |
| 85 return db_.Open(db_path()); | 83 return db_.Open(db_path()); |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 EXPECT_TRUE(recovery->AutoRecoverTable("x", 0, &rows)); | 709 EXPECT_TRUE(recovery->AutoRecoverTable("x", 0, &rows)); |
| 712 EXPECT_EQ(43u, rows); | 710 EXPECT_EQ(43u, rows); |
| 713 | 711 |
| 714 // Successfully recovered. | 712 // Successfully recovered. |
| 715 EXPECT_TRUE(sql::Recovery::Recovered(recovery.Pass())); | 713 EXPECT_TRUE(sql::Recovery::Recovered(recovery.Pass())); |
| 716 } | 714 } |
| 717 } | 715 } |
| 718 #endif // !defined(USE_SYSTEM_SQLITE) | 716 #endif // !defined(USE_SYSTEM_SQLITE) |
| 719 | 717 |
| 720 } // namespace | 718 } // namespace |
| OLD | NEW |