| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/files/scoped_temp_dir.h" | 13 #include "base/files/scoped_temp_dir.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "chrome/browser/history/expire_history_backend.h" | 18 #include "chrome/browser/history/expire_history_backend.h" |
| 19 #include "chrome/browser/history/history_database.h" | |
| 20 #include "chrome/browser/history/history_details.h" | 19 #include "chrome/browser/history/history_details.h" |
| 21 #include "chrome/browser/history/top_sites.h" | 20 #include "chrome/browser/history/top_sites.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/tools/profiles/thumbnail-inl.h" | 22 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 24 #include "components/history/core/browser/history_backend_notifier.h" | 23 #include "components/history/core/browser/history_backend_notifier.h" |
| 24 #include "components/history/core/browser/history_database.h" |
| 25 #include "components/history/core/browser/thumbnail_database.h" | 25 #include "components/history/core/browser/thumbnail_database.h" |
| 26 #include "components/history/core/common/thumbnail_score.h" | 26 #include "components/history/core/common/thumbnail_score.h" |
| 27 #include "components/history/core/test/history_client_fake_bookmarks.h" | 27 #include "components/history/core/test/history_client_fake_bookmarks.h" |
| 28 #include "components/history/core/test/test_history_database.h" |
| 28 #include "content/public/test/test_browser_thread.h" | 29 #include "content/public/test/test_browser_thread.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 31 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/gfx/codec/jpeg_codec.h" | 32 #include "ui/gfx/codec/jpeg_codec.h" |
| 32 | 33 |
| 33 using base::Time; | 34 using base::Time; |
| 34 using base::TimeDelta; | 35 using base::TimeDelta; |
| 35 using base::TimeTicks; | 36 using base::TimeTicks; |
| 36 using content::BrowserThread; | 37 using content::BrowserThread; |
| 37 | 38 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 URLsModifiedNotificationList urls_modified_notifications_; | 123 URLsModifiedNotificationList urls_modified_notifications_; |
| 123 | 124 |
| 124 typedef std::vector<std::pair<bool, URLRows>> URLsDeletedNotificationList; | 125 typedef std::vector<std::pair<bool, URLRows>> URLsDeletedNotificationList; |
| 125 URLsDeletedNotificationList urls_deleted_notifications_; | 126 URLsDeletedNotificationList urls_deleted_notifications_; |
| 126 | 127 |
| 127 private: | 128 private: |
| 128 void SetUp() override { | 129 void SetUp() override { |
| 129 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | 130 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); |
| 130 | 131 |
| 131 base::FilePath history_name = path().Append(kHistoryFile); | 132 base::FilePath history_name = path().Append(kHistoryFile); |
| 132 main_db_.reset(new HistoryDatabase); | 133 main_db_.reset(new TestHistoryDatabase); |
| 133 if (main_db_->Init(history_name) != sql::INIT_OK) | 134 if (main_db_->Init(history_name) != sql::INIT_OK) |
| 134 main_db_.reset(); | 135 main_db_.reset(); |
| 135 | 136 |
| 136 base::FilePath thumb_name = path().Append(kThumbnailFile); | 137 base::FilePath thumb_name = path().Append(kThumbnailFile); |
| 137 thumb_db_.reset(new ThumbnailDatabase(NULL)); | 138 thumb_db_.reset(new ThumbnailDatabase(NULL)); |
| 138 if (thumb_db_->Init(thumb_name) != sql::INIT_OK) | 139 if (thumb_db_->Init(thumb_name) != sql::INIT_OK) |
| 139 thumb_db_.reset(); | 140 thumb_db_.reset(); |
| 140 | 141 |
| 141 expirer_.SetDatabases(main_db_.get(), thumb_db_.get()); | 142 expirer_.SetDatabases(main_db_.get(), thumb_db_.get()); |
| 142 profile_.CreateTopSites(); | 143 profile_.CreateTopSites(); |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 EXPECT_TRUE(all->Read(now, main_db_.get(), &visits, 1)); | 875 EXPECT_TRUE(all->Read(now, main_db_.get(), &visits, 1)); |
| 875 EXPECT_EQ(1U, visits.size()); | 876 EXPECT_EQ(1U, visits.size()); |
| 876 } | 877 } |
| 877 | 878 |
| 878 // TODO(brettw) add some visits with no URL to make sure everything is updated | 879 // TODO(brettw) add some visits with no URL to make sure everything is updated |
| 879 // properly. Have the visits also refer to nonexistent FTS rows. | 880 // properly. Have the visits also refer to nonexistent FTS rows. |
| 880 // | 881 // |
| 881 // Maybe also refer to invalid favicons. | 882 // Maybe also refer to invalid favicons. |
| 882 | 883 |
| 883 } // namespace history | 884 } // namespace history |
| OLD | NEW |