| 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 "base/files/scoped_temp_dir.h" | 5 #include "base/files/scoped_temp_dir.h" |
| 6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 7 #include "chrome/browser/extensions/activity_log/database_string_table.h" | 7 #include "chrome/browser/extensions/activity_log/database_string_table.h" |
| 8 #include "sql/connection.h" | 8 #include "sql/connection.h" |
| 9 #include "sql/statement.h" | 9 #include "sql/statement.h" |
| 10 #include "sql/transaction.h" | 10 #include "sql/transaction.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 class DatabaseStringTableTest : public testing::Test { | 15 class DatabaseStringTableTest : public testing::Test { |
| 16 protected: | 16 protected: |
| 17 virtual void SetUp() OVERRIDE { | 17 virtual void SetUp() override { |
| 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 18 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 19 base::FilePath db_file = temp_dir_.path().AppendASCII("StringTable.db"); | 19 base::FilePath db_file = temp_dir_.path().AppendASCII("StringTable.db"); |
| 20 | 20 |
| 21 ASSERT_TRUE(db_.Open(db_file)); | 21 ASSERT_TRUE(db_.Open(db_file)); |
| 22 } | 22 } |
| 23 | 23 |
| 24 virtual void TearDown() OVERRIDE { | 24 virtual void TearDown() override { |
| 25 db_.Close(); | 25 db_.Close(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 base::ScopedTempDir temp_dir_; | 28 base::ScopedTempDir temp_dir_; |
| 29 sql::Connection db_; | 29 sql::Connection db_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 // Check that initializing the database works. | 32 // Check that initializing the database works. |
| 33 TEST_F(DatabaseStringTableTest, Init) { | 33 TEST_F(DatabaseStringTableTest, Init) { |
| 34 DatabaseStringTable table("test"); | 34 DatabaseStringTable table("test"); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 transaction.Commit(); | 150 transaction.Commit(); |
| 151 | 151 |
| 152 // The maximum size below should correspond to kMaximumCacheSize in | 152 // The maximum size below should correspond to kMaximumCacheSize in |
| 153 // database_string_table.cc, with a small amount of additional slop (an entry | 153 // database_string_table.cc, with a small amount of additional slop (an entry |
| 154 // might be inserted after doing the pruning). | 154 // might be inserted after doing the pruning). |
| 155 ASSERT_LE(table.id_to_value_.size(), 1005U); | 155 ASSERT_LE(table.id_to_value_.size(), 1005U); |
| 156 ASSERT_LE(table.value_to_id_.size(), 1005U); | 156 ASSERT_LE(table.value_to_id_.size(), 1005U); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace extensions | 159 } // namespace extensions |
| OLD | NEW |