| 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" | |
| 23 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/thumbnail_score.h" | 24 #include "chrome/common/thumbnail_score.h" |
| 26 #include "chrome/tools/profiles/thumbnail-inl.h" | 25 #include "chrome/tools/profiles/thumbnail-inl.h" |
| 27 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
| 29 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "ui/gfx/codec/jpeg_codec.h" | 30 #include "ui/gfx/codec/jpeg_codec.h" |
| 32 #include "ui/gfx/image/image.h" | 31 #include "ui/gfx/image/image.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 IconMapping icon_mapping; | 139 IconMapping icon_mapping; |
| 141 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, | 140 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, |
| 142 &icon_mapping)) | 141 &icon_mapping)) |
| 143 return icon_mapping.icon_id; | 142 return icon_mapping.icon_id; |
| 144 else | 143 else |
| 145 return 0; | 144 return 0; |
| 146 } | 145 } |
| 147 | 146 |
| 148 BookmarkModel bookmark_model_; | 147 BookmarkModel bookmark_model_; |
| 149 | 148 |
| 149 protected: |
| 150 bool loaded_; | 150 bool loaded_; |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 friend class HistoryBackendTestDelegate; | 153 friend class HistoryBackendTestDelegate; |
| 154 | 154 |
| 155 // testing::Test | 155 // testing::Test |
| 156 virtual void SetUp() { | 156 virtual void SetUp() { |
| 157 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), | 157 if (!file_util::CreateNewTempDirectory(FILE_PATH_LITERAL("BackendTest"), |
| 158 &test_dir_)) | 158 &test_dir_)) |
| 159 return; | 159 return; |
| 160 backend_ = new HistoryBackend(NULL, | 160 backend_ = new HistoryBackend(test_dir_, |
| 161 test_dir_, | |
| 162 0, | 161 0, |
| 163 new HistoryBackendTestDelegate(this), | 162 new HistoryBackendTestDelegate(this), |
| 164 &bookmark_model_); | 163 &bookmark_model_); |
| 165 backend_->Init(std::string(), false); | 164 backend_->Init(std::string(), false); |
| 166 } | 165 } |
| 167 virtual void TearDown() { | 166 virtual void TearDown() { |
| 168 if (backend_.get()) | 167 if (backend_.get()) |
| 169 backend_->Closing(); | 168 backend_->Closing(); |
| 170 backend_ = NULL; | 169 backend_ = NULL; |
| 171 mem_backend_.reset(); | 170 mem_backend_.reset(); |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); | 948 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
| 950 | 949 |
| 951 // Copy history database file to current directory so that it will be deleted | 950 // Copy history database file to current directory so that it will be deleted |
| 952 // in Teardown. | 951 // in Teardown. |
| 953 FilePath new_history_path(getTestDir()); | 952 FilePath new_history_path(getTestDir()); |
| 954 file_util::Delete(new_history_path, true); | 953 file_util::Delete(new_history_path, true); |
| 955 file_util::CreateDirectory(new_history_path); | 954 file_util::CreateDirectory(new_history_path); |
| 956 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); | 955 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); |
| 957 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); | 956 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); |
| 958 | 957 |
| 959 backend_ = new HistoryBackend(NULL, | 958 backend_ = new HistoryBackend(new_history_path, |
| 960 new_history_path, | |
| 961 0, | 959 0, |
| 962 new HistoryBackendTestDelegate(this), | 960 new HistoryBackendTestDelegate(this), |
| 963 &bookmark_model_); | 961 &bookmark_model_); |
| 964 backend_->Init(std::string(), false); | 962 backend_->Init(std::string(), false); |
| 965 backend_->Closing(); | 963 backend_->Closing(); |
| 966 backend_ = NULL; | 964 backend_ = NULL; |
| 967 | 965 |
| 968 // Now the database should already be migrated. | 966 // Now the database should already be migrated. |
| 969 // Check version first. | 967 // Check version first. |
| 970 int cur_version = HistoryDatabase::GetCurrentVersion(); | 968 int cur_version = HistoryDatabase::GetCurrentVersion(); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1128 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); |
| 1131 std::string touchicon_data( | 1129 std::string touchicon_data( |
| 1132 favicon.image_data->front(), | 1130 favicon.image_data->front(), |
| 1133 favicon.image_data->front() + favicon.image_data->size()); | 1131 favicon.image_data->front() + favicon.image_data->size()); |
| 1134 | 1132 |
| 1135 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1133 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); |
| 1136 EXPECT_EQ(icon_url, favicon.icon_url); | 1134 EXPECT_EQ(icon_url, favicon.icon_url); |
| 1137 EXPECT_EQ(blob_data, touchicon_data); | 1135 EXPECT_EQ(blob_data, touchicon_data); |
| 1138 } | 1136 } |
| 1139 } // namespace history | 1137 } // namespace history |
| OLD | NEW |