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 <fstream> | 6 #include <fstream> |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 void InMemoryURLIndexTest::SetUp() { | 183 void InMemoryURLIndexTest::SetUp() { |
184 // We cannot access the database until the backend has been loaded. | 184 // We cannot access the database until the backend has been loaded. |
185 profile_.CreateHistoryService(true, false); | 185 profile_.CreateHistoryService(true, false); |
186 profile_.CreateBookmarkModel(true); | 186 profile_.CreateBookmarkModel(true); |
187 profile_.BlockUntilBookmarkModelLoaded(); | 187 profile_.BlockUntilBookmarkModelLoaded(); |
188 profile_.BlockUntilHistoryProcessesPendingRequests(); | 188 profile_.BlockUntilHistoryProcessesPendingRequests(); |
189 profile_.BlockUntilHistoryIndexIsRefreshed(); | 189 profile_.BlockUntilHistoryIndexIsRefreshed(); |
190 HistoryService* history_service = | 190 HistoryService* history_service = |
191 HistoryServiceFactory::GetForProfile(&profile_, | 191 HistoryServiceFactory::GetForProfile(&profile_, |
192 Profile::EXPLICIT_ACCESS); | 192 Profile::EXPLICIT_ACCESS).get(); |
193 ASSERT_TRUE(history_service); | 193 ASSERT_TRUE(history_service); |
194 HistoryBackend* backend = history_service->history_backend_.get(); | 194 HistoryBackend* backend = history_service->history_backend_.get(); |
195 history_database_ = backend->db(); | 195 history_database_ = backend->db(); |
196 | 196 |
197 // Create and populate a working copy of the URL history database. | 197 // Create and populate a working copy of the URL history database. |
198 FilePath history_proto_path; | 198 FilePath history_proto_path; |
199 PathService::Get(chrome::DIR_TEST_DATA, &history_proto_path); | 199 PathService::Get(chrome::DIR_TEST_DATA, &history_proto_path); |
200 history_proto_path = history_proto_path.Append( | 200 history_proto_path = history_proto_path.Append( |
201 FILE_PATH_LITERAL("History")); | 201 FILE_PATH_LITERAL("History")); |
202 history_proto_path = history_proto_path.Append(TestDBName()); | 202 history_proto_path = history_proto_path.Append(TestDBName()); |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
896 HistoryIndexRestoreObserver restore_observer( | 896 HistoryIndexRestoreObserver restore_observer( |
897 base::Bind(&MessageLoop::Quit, base::Unretained(&message_loop_))); | 897 base::Bind(&MessageLoop::Quit, base::Unretained(&message_loop_))); |
898 url_index_->set_restore_cache_observer(&restore_observer); | 898 url_index_->set_restore_cache_observer(&restore_observer); |
899 PostRestoreFromCacheFileTask(); | 899 PostRestoreFromCacheFileTask(); |
900 message_loop_.Run(); | 900 message_loop_.Run(); |
901 EXPECT_TRUE(restore_observer.succeeded()); | 901 EXPECT_TRUE(restore_observer.succeeded()); |
902 | 902 |
903 URLIndexPrivateData& new_data(*GetPrivateData()); | 903 URLIndexPrivateData& new_data(*GetPrivateData()); |
904 | 904 |
905 // Compare the captured and restored for equality. | 905 // Compare the captured and restored for equality. |
906 ExpectPrivateDataEqual(*old_data, new_data); | 906 ExpectPrivateDataEqual(*old_data.get(), new_data); |
907 } | 907 } |
908 | 908 |
909 class InMemoryURLIndexCacheTest : public testing::Test { | 909 class InMemoryURLIndexCacheTest : public testing::Test { |
910 public: | 910 public: |
911 InMemoryURLIndexCacheTest() {} | 911 InMemoryURLIndexCacheTest() {} |
912 | 912 |
913 protected: | 913 protected: |
914 virtual void SetUp() OVERRIDE; | 914 virtual void SetUp() OVERRIDE; |
915 | 915 |
916 // Pass-through functions to simplify our friendship with InMemoryURLIndex. | 916 // Pass-through functions to simplify our friendship with InMemoryURLIndex. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 full_file_path.GetComponents(&actual_parts); | 948 full_file_path.GetComponents(&actual_parts); |
949 ASSERT_EQ(expected_parts.size(), actual_parts.size()); | 949 ASSERT_EQ(expected_parts.size(), actual_parts.size()); |
950 size_t count = expected_parts.size(); | 950 size_t count = expected_parts.size(); |
951 for (size_t i = 0; i < count; ++i) | 951 for (size_t i = 0; i < count; ++i) |
952 EXPECT_EQ(expected_parts[i], actual_parts[i]); | 952 EXPECT_EQ(expected_parts[i], actual_parts[i]); |
953 // Must clear the history_dir_ to satisfy the dtor's DCHECK. | 953 // Must clear the history_dir_ to satisfy the dtor's DCHECK. |
954 set_history_dir(FilePath()); | 954 set_history_dir(FilePath()); |
955 } | 955 } |
956 | 956 |
957 } // namespace history | 957 } // namespace history |
OLD | NEW |