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