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/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/scoped_temp_dir.h" | |
13 #include "base/string16.h" | 13 #include "base/string16.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "chrome/browser/autocomplete/autocomplete_provider.h" | 16 #include "chrome/browser/autocomplete/autocomplete_provider.h" |
17 #include "chrome/browser/history/history.h" | 17 #include "chrome/browser/history/history.h" |
18 #include "chrome/browser/history/history_backend.h" | 18 #include "chrome/browser/history/history_backend.h" |
19 #include "chrome/browser/history/history_database.h" | 19 #include "chrome/browser/history/history_database.h" |
20 #include "chrome/browser/history/history_notifications.h" | 20 #include "chrome/browser/history/history_notifications.h" |
21 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
22 #include "chrome/browser/history/in_memory_url_index.h" | 22 #include "chrome/browser/history/in_memory_url_index.h" |
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 URLIndexPrivateData& private_data(*GetPrivateData()); | 847 URLIndexPrivateData& private_data(*GetPrivateData()); |
848 const std::set<std::string>& whitelist(scheme_whitelist()); | 848 const std::set<std::string>& whitelist(scheme_whitelist()); |
849 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { | 849 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(data); ++i) { |
850 GURL url(data[i].url_spec); | 850 GURL url(data[i].url_spec); |
851 EXPECT_EQ(data[i].expected_is_whitelisted, | 851 EXPECT_EQ(data[i].expected_is_whitelisted, |
852 private_data.URLSchemeIsWhitelisted(url, whitelist)); | 852 private_data.URLSchemeIsWhitelisted(url, whitelist)); |
853 } | 853 } |
854 } | 854 } |
855 | 855 |
856 TEST_F(InMemoryURLIndexTest, CacheSaveRestore) { | 856 TEST_F(InMemoryURLIndexTest, CacheSaveRestore) { |
857 ScopedTempDir temp_directory; | 857 base::ScopedTempDir temp_directory; |
858 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); | 858 ASSERT_TRUE(temp_directory.CreateUniqueTempDir()); |
859 set_history_dir(temp_directory.path()); | 859 set_history_dir(temp_directory.path()); |
860 | 860 |
861 URLIndexPrivateData& private_data(*GetPrivateData()); | 861 URLIndexPrivateData& private_data(*GetPrivateData()); |
862 | 862 |
863 // Ensure that there is really something there to be saved. | 863 // Ensure that there is really something there to be saved. |
864 EXPECT_FALSE(private_data.word_list_.empty()); | 864 EXPECT_FALSE(private_data.word_list_.empty()); |
865 // available_words_ will already be empty since we have freshly built the | 865 // available_words_ will already be empty since we have freshly built the |
866 // data set for this test. | 866 // data set for this test. |
867 EXPECT_TRUE(private_data.available_words_.empty()); | 867 EXPECT_TRUE(private_data.available_words_.empty()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
917 void set_history_dir(const FilePath& dir_path); | 917 void set_history_dir(const FilePath& dir_path); |
918 bool GetCacheFilePath(FilePath* file_path) const; | 918 bool GetCacheFilePath(FilePath* file_path) const; |
919 | 919 |
920 ScopedTempDir temp_dir_; | 920 base::ScopedTempDir temp_dir_; |
921 scoped_ptr<InMemoryURLIndex> url_index_; | 921 scoped_ptr<InMemoryURLIndex> url_index_; |
922 }; | 922 }; |
923 | 923 |
924 void InMemoryURLIndexCacheTest::SetUp() { | 924 void InMemoryURLIndexCacheTest::SetUp() { |
925 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 925 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
926 FilePath path(temp_dir_.path()); | 926 FilePath path(temp_dir_.path()); |
927 url_index_.reset( | 927 url_index_.reset( |
928 new InMemoryURLIndex(NULL, path, "en,ja,hi,zh")); | 928 new InMemoryURLIndex(NULL, path, "en,ja,hi,zh")); |
929 } | 929 } |
930 | 930 |
(...skipping 17 matching lines...) Expand all 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 |