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 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 EXPECT_TRUE(std::equal(expected_word_starts.title_word_starts_.begin(), | 426 EXPECT_TRUE(std::equal(expected_word_starts.title_word_starts_.begin(), |
427 expected_word_starts.title_word_starts_.end(), | 427 expected_word_starts.title_word_starts_.end(), |
428 actual_word_starts.title_word_starts_.begin())); | 428 actual_word_starts.title_word_starts_.begin())); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 //------------------------------------------------------------------------------ | 432 //------------------------------------------------------------------------------ |
433 | 433 |
434 class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest { | 434 class LimitedInMemoryURLIndexTest : public InMemoryURLIndexTest { |
435 protected: | 435 protected: |
436 virtual base::FilePath::StringType TestDBName() const override; | 436 base::FilePath::StringType TestDBName() const override; |
437 }; | 437 }; |
438 | 438 |
439 base::FilePath::StringType LimitedInMemoryURLIndexTest::TestDBName() const { | 439 base::FilePath::StringType LimitedInMemoryURLIndexTest::TestDBName() const { |
440 return FILE_PATH_LITERAL("url_history_provider_test_limited.db.txt"); | 440 return FILE_PATH_LITERAL("url_history_provider_test_limited.db.txt"); |
441 } | 441 } |
442 | 442 |
443 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { | 443 TEST_F(LimitedInMemoryURLIndexTest, Initialization) { |
444 // Verify that the database contains the expected number of items, which | 444 // Verify that the database contains the expected number of items, which |
445 // is the pre-filtered count, i.e. all of the items. | 445 // is the pre-filtered count, i.e. all of the items. |
446 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); | 446 sql::Statement statement(GetDB().GetUniqueStatement("SELECT * FROM urls;")); |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 full_file_path.GetComponents(&actual_parts); | 1229 full_file_path.GetComponents(&actual_parts); |
1230 ASSERT_EQ(expected_parts.size(), actual_parts.size()); | 1230 ASSERT_EQ(expected_parts.size(), actual_parts.size()); |
1231 size_t count = expected_parts.size(); | 1231 size_t count = expected_parts.size(); |
1232 for (size_t i = 0; i < count; ++i) | 1232 for (size_t i = 0; i < count; ++i) |
1233 EXPECT_EQ(expected_parts[i], actual_parts[i]); | 1233 EXPECT_EQ(expected_parts[i], actual_parts[i]); |
1234 // Must clear the history_dir_ to satisfy the dtor's DCHECK. | 1234 // Must clear the history_dir_ to satisfy the dtor's DCHECK. |
1235 set_history_dir(base::FilePath()); | 1235 set_history_dir(base::FilePath()); |
1236 } | 1236 } |
1237 | 1237 |
1238 } // namespace history | 1238 } // namespace history |
OLD | NEW |