// Copyright (c) 2011 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 #include "base/file_path.h" #include "base/file_util.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" #include "chrome/browser/history/text_database_manager.h" #include "chrome/browser/history/visit_database.h" #include "sql/connection.h" #include "testing/gtest/include/gtest/gtest.h" using base::Time; using base::TimeDelta; using base::TimeTicks; namespace history { namespace { const char* kURL1 = "http://www.google.com/asdf"; const char* kTitle1 = "Google A"; const char* kBody1 = "FOO page one."; const char* kURL2 = "http://www.google.com/qwer"; const char* kTitle2 = "Google B"; const char* kBody2 = "FOO two."; const char* kURL3 = "http://www.google.com/zxcv"; const char* kTitle3 = "Google C"; const char* kBody3 = "FOO drei"; const char* kURL4 = "http://www.google.com/hjkl"; const char* kTitle4 = "Google D"; const char* kBody4 = "FOO lalala four."; const char* kURL5 = "http://www.google.com/uiop"; const char* kTitle5 = "Google cinq"; const char* kBody5 = "FOO page one."; // This provides a simple implementation of a URL+VisitDatabase using an // in-memory sqlite connection. The text database manager expects to be able to // update the visit database to keep in sync. class InMemDB : public URLDatabase, public VisitDatabase { public: InMemDB() { EXPECT_TRUE(db_.OpenInMemory()); CreateURLTable(false); InitVisitTable(); } ~InMemDB() { } private: virtual sql::Connection& GetDB() { return db_; } sql::Connection db_; DISALLOW_COPY_AND_ASSIGN(InMemDB); }; // Adds all the pages once, and the first page once more in the next month. // The times of all the pages will be filled into |*times|. void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, std::vector