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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 IconMapping icon_mapping; | 140 IconMapping icon_mapping; |
140 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, | 141 if (backend_->thumbnail_db_->GetIconMappingForPageURL(url, icon_type, |
141 &icon_mapping)) | 142 &icon_mapping)) |
142 return icon_mapping.icon_id; | 143 return icon_mapping.icon_id; |
143 else | 144 else |
144 return 0; | 145 return 0; |
145 } | 146 } |
146 | 147 |
147 BookmarkModel bookmark_model_; | 148 BookmarkModel bookmark_model_; |
148 | 149 |
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(test_dir_, | 160 backend_ = new HistoryBackend(NULL, |
| 161 test_dir_, |
161 0, | 162 0, |
162 new HistoryBackendTestDelegate(this), | 163 new HistoryBackendTestDelegate(this), |
163 &bookmark_model_); | 164 &bookmark_model_); |
164 backend_->Init(std::string(), false); | 165 backend_->Init(std::string(), false); |
165 } | 166 } |
166 virtual void TearDown() { | 167 virtual void TearDown() { |
167 if (backend_.get()) | 168 if (backend_.get()) |
168 backend_->Closing(); | 169 backend_->Closing(); |
169 backend_ = NULL; | 170 backend_ = NULL; |
170 mem_backend_.reset(); | 171 mem_backend_.reset(); |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); | 949 old_history_path = old_history_path.AppendASCII("HistoryNoSource"); |
949 | 950 |
950 // Copy history database file to current directory so that it will be deleted | 951 // Copy history database file to current directory so that it will be deleted |
951 // in Teardown. | 952 // in Teardown. |
952 FilePath new_history_path(getTestDir()); | 953 FilePath new_history_path(getTestDir()); |
953 file_util::Delete(new_history_path, true); | 954 file_util::Delete(new_history_path, true); |
954 file_util::CreateDirectory(new_history_path); | 955 file_util::CreateDirectory(new_history_path); |
955 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); | 956 FilePath new_history_file = new_history_path.Append(chrome::kHistoryFilename); |
956 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); | 957 ASSERT_TRUE(file_util::CopyFile(old_history_path, new_history_file)); |
957 | 958 |
958 backend_ = new HistoryBackend(new_history_path, | 959 backend_ = new HistoryBackend(NULL, |
| 960 new_history_path, |
959 0, | 961 0, |
960 new HistoryBackendTestDelegate(this), | 962 new HistoryBackendTestDelegate(this), |
961 &bookmark_model_); | 963 &bookmark_model_); |
962 backend_->Init(std::string(), false); | 964 backend_->Init(std::string(), false); |
963 backend_->Closing(); | 965 backend_->Closing(); |
964 backend_ = NULL; | 966 backend_ = NULL; |
965 | 967 |
966 // Now the database should already be migrated. | 968 // Now the database should already be migrated. |
967 // Check version first. | 969 // Check version first. |
968 int cur_version = HistoryDatabase::GetCurrentVersion(); | 970 int cur_version = HistoryDatabase::GetCurrentVersion(); |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1130 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); |
1129 std::string touchicon_data( | 1131 std::string touchicon_data( |
1130 favicon.image_data->front(), | 1132 favicon.image_data->front(), |
1131 favicon.image_data->front() + favicon.image_data->size()); | 1133 favicon.image_data->front() + favicon.image_data->size()); |
1132 | 1134 |
1133 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1135 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); |
1134 EXPECT_EQ(icon_url, favicon.icon_url); | 1136 EXPECT_EQ(icon_url, favicon.icon_url); |
1135 EXPECT_EQ(blob_data, touchicon_data); | 1137 EXPECT_EQ(blob_data, touchicon_data); |
1136 } | 1138 } |
1137 } // namespace history | 1139 } // namespace history |
OLD | NEW |