| 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 "sql/meta_table.h" | 5 #include "sql/meta_table.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "sql/connection.h" | 9 #include "sql/connection.h" |
| 10 #include "sql/statement.h" | 10 #include "sql/statement.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 class SQLMetaTableTest : public testing::Test { | 15 class SQLMetaTableTest : public testing::Test { |
| 16 public: | 16 public: |
| 17 virtual void SetUp() { | 17 void SetUp() override { |
| 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 19 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLMetaTableTest.db"))); | 19 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLMetaTableTest.db"))); |
| 20 } | 20 } |
| 21 | 21 |
| 22 virtual void TearDown() { | 22 void TearDown() override { db_.Close(); } |
| 23 db_.Close(); | |
| 24 } | |
| 25 | 23 |
| 26 sql::Connection& db() { return db_; } | 24 sql::Connection& db() { return db_; } |
| 27 | 25 |
| 28 private: | 26 private: |
| 29 base::ScopedTempDir temp_dir_; | 27 base::ScopedTempDir temp_dir_; |
| 30 sql::Connection db_; | 28 sql::Connection db_; |
| 31 }; | 29 }; |
| 32 | 30 |
| 33 TEST_F(SQLMetaTableTest, DoesTableExist) { | 31 TEST_F(SQLMetaTableTest, DoesTableExist) { |
| 34 EXPECT_FALSE(sql::MetaTable::DoesTableExist(&db())); | 32 EXPECT_FALSE(sql::MetaTable::DoesTableExist(&db())); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 EXPECT_TRUE(meta_table.SetValue(kKey, kValue)); | 262 EXPECT_TRUE(meta_table.SetValue(kKey, kValue)); |
| 265 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); | 263 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); |
| 266 EXPECT_EQ(kValue, value); | 264 EXPECT_EQ(kValue, value); |
| 267 | 265 |
| 268 // After delete value isn't present. | 266 // After delete value isn't present. |
| 269 EXPECT_TRUE(meta_table.DeleteKey(kKey)); | 267 EXPECT_TRUE(meta_table.DeleteKey(kKey)); |
| 270 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); | 268 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); |
| 271 } | 269 } |
| 272 | 270 |
| 273 } // namespace | 271 } // namespace |
| OLD | NEW |