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