| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/bookmarks/bookmark_model.h" | 16 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 17 #include "chrome/browser/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 18 #include "chrome/browser/history/history_backend.h" | 18 #include "chrome/browser/history/history_backend.h" |
| 19 #include "chrome/browser/history/history_notifications.h" | 19 #include "chrome/browser/history/history_notifications.h" |
| 20 #include "chrome/browser/history/in_memory_database.h" | 20 #include "chrome/browser/history/in_memory_database.h" |
| 21 #include "chrome/browser/history/in_memory_history_backend.h" | 21 #include "chrome/browser/history/in_memory_history_backend.h" |
| 22 #include "chrome/browser/history/in_memory_url_index.h" |
| 22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 24 #include "chrome/common/thumbnail_score.h" | 25 #include "chrome/common/thumbnail_score.h" |
| 25 #include "chrome/tools/profiles/thumbnail-inl.h" | 26 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 26 #include "content/common/notification_details.h" | 27 #include "content/common/notification_details.h" |
| 27 #include "content/common/notification_source.h" | 28 #include "content/common/notification_source.h" |
| 28 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "ui/gfx/codec/jpeg_codec.h" | 31 #include "ui/gfx/codec/jpeg_codec.h" |
| 31 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 IconMapping icon_mapping; | 139 IconMapping icon_mapping; |
| 139 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, | 140 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, |
| 140 &icon_mapping)) | 141 &icon_mapping)) |
| 141 return icon_mapping.icon_id; | 142 return icon_mapping.icon_id; |
| 142 else | 143 else |
| 143 return 0; | 144 return 0; |
| 144 } | 145 } |
| 145 | 146 |
| 146 BookmarkModel bookmark_model_; | 147 BookmarkModel bookmark_model_; |
| 147 | 148 |
| 148 protected: | |
| 149 bool loaded_; | 149 bool loaded_; |
| 150 | 150 |
| 151 private: | 151 private: |
| 152 friend class HistoryBackendTestDelegate; | 152 friend class HistoryBackendTestDelegate; |
| 153 | 153 |
| 154 // testing::Test | 154 // testing::Test |
| 155 virtual void SetUp() { | 155 virtual void SetUp() { |
| 156 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), | 156 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), |
| 157 &test_dir_)) | 157 &test_dir_)) |
| 158 return; | 158 return; |
| 159 backend_ = new HistoryBackend(test_dir_, | 159 backend_ = new HistoryBackend(NULL, |
| 160 test_dir_, |
| 160 0, | 161 0, |
| 161 new HistoryBackendTestDelegate(this), | 162 new HistoryBackendTestDelegate(this), |
| 162 &bookmark_model_); | 163 &bookmark_model_); |
| 163 backend_->Init(std::string(), false); | 164 backend_->Init(std::string(), false); |
| 164 } | 165 } |
| 165 virtual void TearDown() { | 166 virtual void TearDown() { |
| 166 if (backend_.get()) | 167 if (backend_.get()) |
| 167 backend_->Closing(); | 168 backend_->Closing(); |
| 168 backend_ = NULL; | 169 backend_ = NULL; |
| 169 mem_backend_.reset(); | 170 mem_backend_.reset(); |
| (...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); | 933 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
| 933 | 934 |
| 934 // Copy history database file to current directory so that it will be deleted | 935 // Copy history database file to current directory so that it will be deleted |
| 935 // in Teardown. | 936 // in Teardown. |
| 936 FilePath new_history_path(getTestDir()); | 937 FilePath new_history_path(getTestDir()); |
| 937 file_util::Delete(new_history_path, true); | 938 file_util::Delete(new_history_path, true); |
| 938 file_util::CreateDirectory(new_history_path); | 939 file_util::CreateDirectory(new_history_path); |
| 939 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); | 940 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); |
| 940 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); | 941 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); |
| 941 | 942 |
| 942 backend_ = new HistoryBackend(new_history_path, | 943 backend_ = new HistoryBackend(NULL, |
| 944 new_history_path, |
| 943 0, | 945 0, |
| 944 new HistoryBackendTestDelegate(this), | 946 new HistoryBackendTestDelegate(this), |
| 945 &bookmark_model_); | 947 &bookmark_model_); |
| 946 backend_->Init(std::string(), false); | 948 backend_->Init(std::string(), false); |
| 947 backend_->Closing(); | 949 backend_->Closing(); |
| 948 backend_ = NULL; | 950 backend_ = NULL; |
| 949 | 951 |
| 950 // Now the database should already be migrated. | 952 // Now the database should already be migrated. |
| 951 // Check version first. | 953 // Check version first. |
| 952 int cur_version = HistoryDatabase::GetCurrentVersion(); | 954 int cur_version = HistoryDatabase::GetCurrentVersion(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1114 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); |
| 1113 std::string touchicon_data( | 1115 std::string touchicon_data( |
| 1114 favicon.image_data->front(), | 1116 favicon.image_data->front(), |
| 1115 favicon.image_data->front() + favicon.image_data->size()); | 1117 favicon.image_data->front() + favicon.image_data->size()); |
| 1116 | 1118 |
| 1117 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1119 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); |
| 1118 EXPECT_EQ(icon_url, favicon.icon_url); | 1120 EXPECT_EQ(icon_url, favicon.icon_url); |
| 1119 EXPECT_EQ(blob_data, touchicon_data); | 1121 EXPECT_EQ(blob_data, touchicon_data); |
| 1120 } | 1122 } |
| 1121 } // namespace history | 1123 } // namespace history |
| OLD | NEW |