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