OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "components/history/core/test/history_unittest_base.h" | 5 #include "components/history/core/test/history_unittest_base.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <vector> | 9 #include <vector> |
8 | 10 |
9 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
10 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
11 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
13 #include "sql/connection.h" | 15 #include "sql/connection.h" |
14 | 16 |
15 namespace history { | 17 namespace history { |
16 | 18 |
17 HistoryUnitTestBase::~HistoryUnitTestBase() { | 19 HistoryUnitTestBase::~HistoryUnitTestBase() { |
18 } | 20 } |
19 | 21 |
20 void HistoryUnitTestBase::ExecuteSQLScript(const base::FilePath& sql_path, | 22 void HistoryUnitTestBase::ExecuteSQLScript(const base::FilePath& sql_path, |
21 const base::FilePath& db_path) { | 23 const base::FilePath& db_path) { |
22 std::string sql; | 24 std::string sql; |
23 ASSERT_TRUE(base::ReadFileToString(sql_path, &sql)); | 25 ASSERT_TRUE(base::ReadFileToString(sql_path, &sql)); |
24 | 26 |
25 // Replace the 'last_visit_time', 'visit_time', 'time_slot' values in this | 27 // Replace the 'last_visit_time', 'visit_time', 'time_slot' values in this |
26 // SQL with the current time. | 28 // SQL with the current time. |
27 int64 now = base::Time::Now().ToInternalValue(); | 29 int64_t now = base::Time::Now().ToInternalValue(); |
28 std::vector<std::string> sql_time; | 30 std::vector<std::string> sql_time; |
29 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // last_visit_time | 31 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // last_visit_time |
30 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // visit_time | 32 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // visit_time |
31 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // time_slot | 33 sql_time.push_back(base::StringPrintf("%" PRId64, now)); // time_slot |
32 sql = base::ReplaceStringPlaceholders(sql, sql_time, NULL); | 34 sql = base::ReplaceStringPlaceholders(sql, sql_time, NULL); |
33 | 35 |
34 sql::Connection connection; | 36 sql::Connection connection; |
35 ASSERT_TRUE(connection.Open(db_path)); | 37 ASSERT_TRUE(connection.Open(db_path)); |
36 ASSERT_TRUE(connection.Execute(sql.c_str())); | 38 ASSERT_TRUE(connection.Execute(sql.c_str())); |
37 } | 39 } |
38 | 40 |
39 HistoryUnitTestBase::HistoryUnitTestBase() { | 41 HistoryUnitTestBase::HistoryUnitTestBase() { |
40 } | 42 } |
41 | 43 |
42 } // namespace history | 44 } // namespace history |
OLD | NEW |