| 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/files/scoped_file.h" | 7 #include "base/files/scoped_file.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "sql/connection.h" | 10 #include "sql/connection.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 ~ScopedUmaskSetter() { umask(old_umask_); } | 84 ~ScopedUmaskSetter() { umask(old_umask_); } |
| 85 private: | 85 private: |
| 86 mode_t old_umask_; | 86 mode_t old_umask_; |
| 87 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedUmaskSetter); | 87 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedUmaskSetter); |
| 88 }; | 88 }; |
| 89 #endif | 89 #endif |
| 90 | 90 |
| 91 class SQLConnectionTest : public testing::Test { | 91 class SQLConnectionTest : public testing::Test { |
| 92 public: | 92 public: |
| 93 virtual void SetUp() { | 93 void SetUp() override { |
| 94 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 94 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 95 db_path_ = temp_dir_.path().AppendASCII("SQLConnectionTest.db"); | 95 db_path_ = temp_dir_.path().AppendASCII("SQLConnectionTest.db"); |
| 96 ASSERT_TRUE(db_.Open(db_path_)); | 96 ASSERT_TRUE(db_.Open(db_path_)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual void TearDown() { | 99 void TearDown() override { db_.Close(); } |
| 100 db_.Close(); | |
| 101 } | |
| 102 | 100 |
| 103 sql::Connection& db() { return db_; } | 101 sql::Connection& db() { return db_; } |
| 104 const base::FilePath& db_path() { return db_path_; } | 102 const base::FilePath& db_path() { return db_path_; } |
| 105 | 103 |
| 106 // Handle errors by blowing away the database. | 104 // Handle errors by blowing away the database. |
| 107 void RazeErrorCallback(int expected_error, int error, sql::Statement* stmt) { | 105 void RazeErrorCallback(int expected_error, int error, sql::Statement* stmt) { |
| 108 EXPECT_EQ(expected_error, error); | 106 EXPECT_EQ(expected_error, error); |
| 109 db_.RazeAndClose(); | 107 db_.RazeAndClose(); |
| 110 } | 108 } |
| 111 | 109 |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 EXPECT_LT(1u, messages.size()); | 859 EXPECT_LT(1u, messages.size()); |
| 862 EXPECT_NE(kOk, messages[0]); | 860 EXPECT_NE(kOk, messages[0]); |
| 863 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 861 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); |
| 864 } | 862 } |
| 865 | 863 |
| 866 // TODO(shess): CorruptTableOrIndex could be used to produce a | 864 // TODO(shess): CorruptTableOrIndex could be used to produce a |
| 867 // file that would pass the quick check and fail the full check. | 865 // file that would pass the quick check and fail the full check. |
| 868 } | 866 } |
| 869 | 867 |
| 870 } // namespace | 868 } // namespace |
| OLD | NEW |