| 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/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 // Observer class so the unit tests can wait while the cache is being saved. | 59 // Observer class so the unit tests can wait while the cache is being saved. |
| 60 class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver { | 60 class CacheFileSaverObserver : public InMemoryURLIndex::SaveCacheObserver { |
| 61 public: | 61 public: |
| 62 explicit CacheFileSaverObserver(const base::Closure& task); | 62 explicit CacheFileSaverObserver(const base::Closure& task); |
| 63 | 63 |
| 64 bool succeeded() { return succeeded_; } | 64 bool succeeded() { return succeeded_; } |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 // SaveCacheObserver implementation. | 67 // SaveCacheObserver implementation. |
| 68 virtual void OnCacheSaveFinished(bool succeeded) OVERRIDE; | 68 virtual void OnCacheSaveFinished(bool succeeded) override; |
| 69 | 69 |
| 70 base::Closure task_; | 70 base::Closure task_; |
| 71 bool succeeded_; | 71 bool succeeded_; |
| 72 | 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(CacheFileSaverObserver); | 73 DISALLOW_COPY_AND_ASSIGN(CacheFileSaverObserver); |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 CacheFileSaverObserver::CacheFileSaverObserver(const base::Closure& task) | 76 CacheFileSaverObserver::CacheFileSaverObserver(const base::Closure& task) |
| 77 : task_(task), | 77 : task_(task), |
| 78 succeeded_(false) { | 78 succeeded_(false) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 EXPECT_TRUE(std::equal(expected_word_starts.title_word_starts_.begin(), | 424 EXPECT_TRUE(std::equal(expected_word_starts.title_word_starts_.begin(), |
| 425 expected_word_starts.title_word_starts_.end(), | 425 expected_word_starts.title_word_starts_.end(), |
| 426 actual_word_starts.title_word_starts_.begin())); | 426 actual_word_starts.title_word_starts_.begin())); |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 //------------------------------------------------------------------------------ | 430 //------------------------------------------------------------------------------ |
| 431 | 431 |
| 432 class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest { | 432 class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest { |
| 433 protected: | 433 protected: |
| 434 virtual base::FilePath::StringType TestDBName() const OVERRIDE; | 434 virtual base::FilePath::StringType TestDBName() const override; |
| 435 }; | 435 }; |
| 436 | 436 |
| 437 base::FilePath::StringType LimitedInMemoryURLIndexTest::TestDBName() const { | 437 base::FilePath::StringType LimitedInMemoryURLIndexTest::TestDBName() const { |
| 438 return FILE_PATH_LITERAL("url_history_provider_test_limited.db.txt"); | 438 return FILE_PATH_LITERAL("url_history_provider_test_limited.db.txt"); |
| 439 } | 439 } |
| 440 | 440 |
| 441 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { | 441 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { |
| 442 // Verify that the database contains the expected number of items, which | 442 // Verify that the database contains the expected number of items, which |
| 443 // is the pre-filtered count, i.e. all of the items. | 443 // is the pre-filtered count, i.e. all of the items. |
| 444 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); | 444 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 | 1178 |
| 1179 // Compare the captured and restored for equality. | 1179 // Compare the captured and restored for equality. |
| 1180 ExpectPrivateDataEqual(*old_data.get(), new_data); | 1180 ExpectPrivateDataEqual(*old_data.get(), new_data); |
| 1181 } | 1181 } |
| 1182 | 1182 |
| 1183 class InMemoryURLIndexCacheTest : public testing::Test { | 1183 class InMemoryURLIndexCacheTest : public testing::Test { |
| 1184 public: | 1184 public: |
| 1185 InMemoryURLIndexCacheTest() {} | 1185 InMemoryURLIndexCacheTest() {} |
| 1186 | 1186 |
| 1187 protected: | 1187 protected: |
| 1188 virtual void SetUp() OVERRIDE; | 1188 virtual void SetUp() override; |
| 1189 | 1189 |
| 1190 // Pass-through functions to simplify our friendship with InMemoryURLIndex. | 1190 // Pass-through functions to simplify our friendship with InMemoryURLIndex. |
| 1191 void set_history_dir(const base::FilePath& dir_path); | 1191 void set_history_dir(const base::FilePath& dir_path); |
| 1192 bool GetCacheFilePath(base::FilePath* file_path) const; | 1192 bool GetCacheFilePath(base::FilePath* file_path) const; |
| 1193 | 1193 |
| 1194 base::ScopedTempDir temp_dir_; | 1194 base::ScopedTempDir temp_dir_; |
| 1195 scoped_ptr<InMemoryURLIndex> url_index_; | 1195 scoped_ptr<InMemoryURLIndex> url_index_; |
| 1196 }; | 1196 }; |
| 1197 | 1197 |
| 1198 void InMemoryURLIndexCacheTest::SetUp() { | 1198 void InMemoryURLIndexCacheTest::SetUp() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1225 full_file_path.GetComponents(&actual_parts); | 1225 full_file_path.GetComponents(&actual_parts); |
| 1226 ASSERT_EQ(expected_parts.size(), actual_parts.size()); | 1226 ASSERT_EQ(expected_parts.size(), actual_parts.size()); |
| 1227 size_t count = expected_parts.size(); | 1227 size_t count = expected_parts.size(); |
| 1228 for (size_t i = 0; i < count; ++i) | 1228 for (size_t i = 0; i < count; ++i) |
| 1229 EXPECT_EQ(expected_parts[i], actual_parts[i]); | 1229 EXPECT_EQ(expected_parts[i], actual_parts[i]); |
| 1230 // Must clear the history_dir_ to satisfy the dtor's DCHECK. | 1230 // Must clear the history_dir_ to satisfy the dtor's DCHECK. |
| 1231 set_history_dir(base::FilePath()); | 1231 set_history_dir(base::FilePath()); |
| 1232 } | 1232 } |
| 1233 | 1233 |
| 1234 } // namespace history | 1234 } // namespace history |
| OLD | NEW |