| 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 "sql/test/sql_test_base.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 class SQLMetaTableTest : public testing::Test { | 16 using SQLMetaTableTest = sql::SQLTestBase; |
| 16 public: | |
| 17 void SetUp() override { | |
| 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 19 ASSERT_TRUE(db_.Open(temp_dir_.path().AppendASCII("SQLMetaTableTest.db"))); | |
| 20 } | |
| 21 | |
| 22 void TearDown() override { db_.Close(); } | |
| 23 | |
| 24 sql::Connection& db() { return db_; } | |
| 25 | |
| 26 private: | |
| 27 base::ScopedTempDir temp_dir_; | |
| 28 sql::Connection db_; | |
| 29 }; | |
| 30 | 17 |
| 31 TEST_F(SQLMetaTableTest, DoesTableExist) { | 18 TEST_F(SQLMetaTableTest, DoesTableExist) { |
| 32 EXPECT_FALSE(sql::MetaTable::DoesTableExist(&db())); | 19 EXPECT_FALSE(sql::MetaTable::DoesTableExist(&db())); |
| 33 | 20 |
| 34 { | 21 { |
| 35 sql::MetaTable meta_table; | 22 sql::MetaTable meta_table; |
| 36 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); | 23 EXPECT_TRUE(meta_table.Init(&db(), 1, 1)); |
| 37 } | 24 } |
| 38 | 25 |
| 39 EXPECT_TRUE(sql::MetaTable::DoesTableExist(&db())); | 26 EXPECT_TRUE(sql::MetaTable::DoesTableExist(&db())); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 EXPECT_TRUE(meta_table.SetValue(kKey, kValue)); | 249 EXPECT_TRUE(meta_table.SetValue(kKey, kValue)); |
| 263 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); | 250 EXPECT_TRUE(meta_table.GetValue(kKey, &value)); |
| 264 EXPECT_EQ(kValue, value); | 251 EXPECT_EQ(kValue, value); |
| 265 | 252 |
| 266 // After delete value isn't present. | 253 // After delete value isn't present. |
| 267 EXPECT_TRUE(meta_table.DeleteKey(kKey)); | 254 EXPECT_TRUE(meta_table.DeleteKey(kKey)); |
| 268 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); | 255 EXPECT_FALSE(meta_table.GetValue(kKey, &value)); |
| 269 } | 256 } |
| 270 | 257 |
| 271 } // namespace | 258 } // namespace |
| OLD | NEW |