Index: components/omnibox/browser/history_test_util.cc |
diff --git a/components/omnibox/browser/history_test_util.cc b/components/omnibox/browser/history_test_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..96c2d57ba28dc1e4a99dae69dab2565807a5c706 |
--- /dev/null |
+++ b/components/omnibox/browser/history_test_util.cc |
@@ -0,0 +1,54 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "components/omnibox/browser/history_test_util.h" |
+ |
+#include "base/format_macros.h" |
+#include "base/strings/stringprintf.h" |
+#include "sql/connection.h" |
+#include "sql/statement.h" |
+#include "sql/transaction.h" |
+ |
+namespace history { |
+ |
+void AddURLToDBForTests(sql::Connection* db, |
+ std::size_t url_id, |
+ const std::string& url, |
+ const std::string& title, |
+ int visit_count, |
+ int typed_count, |
+ base::Time last_visit_time) { |
+ sql::Transaction transaction(db); |
+ transaction.Begin(); |
+ |
+ std::string sql_cmd_line = |
+ base::StringPrintf("INSERT INTO \"urls\" VALUES(%" PRIuS |
+ ", \'%s\', \'%s\', %d, %d, %" PRId64 ", 0, 0)", |
+ url_id, url.c_str(), title.c_str(), visit_count, |
+ typed_count, last_visit_time.ToInternalValue()); |
Peter Kasting
2016/10/24 22:28:29
Don't use StringPrintf() to put the values directl
dyaroshev
2016/10/25 18:11:35
Haven't got around to it yet.
dyaroshev
2016/10/26 22:29:13
This was originally not my code, I just refactored
|
+ |
+ sql::Statement sql_stmt(db->GetUniqueStatement(sql_cmd_line.c_str())); |
+ CHECK(sql_stmt.Run()); |
+ transaction.Commit(); |
+} |
+ |
+void AddVisitToDBForTests(sql::Connection* db, |
+ std::size_t visit_id, |
+ std::size_t url_id, |
+ base::Time visit_time, |
+ ui::PageTransition transition) { |
+ sql::Transaction transaction(db); |
+ transaction.Begin(); |
+ |
+ std::string sql_cmd_line = base::StringPrintf( |
+ "INSERT INTO \"visits\" VALUES(%" PRIuS ", %" PRIuS ", %" PRId64 |
+ ", 0, %d, 0, 1)", |
+ visit_id, url_id, visit_time.ToInternalValue(), transition); |
+ |
+ sql::Statement sql_stmt(db->GetUniqueStatement(sql_cmd_line.c_str())); |
+ CHECK(sql_stmt.Run()); |
+ transaction.Commit(); |
+} |
+ |
+} // namespace history |