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