OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/gfx/jpeg_codec.h" | 9 #include "base/gfx/jpeg_codec.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 EXPECT_FALSE(archived_db_->GetRowForURL(temp_row.url(), NULL)); | 688 EXPECT_FALSE(archived_db_->GetRowForURL(temp_row.url(), NULL)); |
689 } | 689 } |
690 | 690 |
691 // Tests the return values from ArchiveSomeOldHistory. The rest of the | 691 // Tests the return values from ArchiveSomeOldHistory. The rest of the |
692 // functionality of this function is tested by the ArchiveHistoryBefore* | 692 // functionality of this function is tested by the ArchiveHistoryBefore* |
693 // tests which use this function internally. | 693 // tests which use this function internally. |
694 TEST_F(ExpireHistoryTest, ArchiveSomeOldHistory) { | 694 TEST_F(ExpireHistoryTest, ArchiveSomeOldHistory) { |
695 URLID url_ids[3]; | 695 URLID url_ids[3]; |
696 Time visit_times[4]; | 696 Time visit_times[4]; |
697 AddExampleData(url_ids, visit_times); | 697 AddExampleData(url_ids, visit_times); |
| 698 const ExpiringVisitsReader* reader = expirer_.GetAllVisitsReader(); |
| 699 |
| 700 // Deleting a time range with no URLs should return false (nothing found). |
| 701 EXPECT_FALSE(expirer_.ArchiveSomeOldHistory( |
| 702 visit_times[0] - TimeDelta::FromDays(100), reader, 1)); |
| 703 |
| 704 // Deleting a time range with not up the the max results should also return |
| 705 // false (there will only be one visit deleted in this range). |
| 706 EXPECT_FALSE(expirer_.ArchiveSomeOldHistory(visit_times[0], reader, 2)); |
| 707 |
| 708 // Deleting a time range with the max number of results should return true |
| 709 // (max deleted). |
| 710 EXPECT_TRUE(expirer_.ArchiveSomeOldHistory(visit_times[2], reader, 1)); |
| 711 } |
| 712 |
| 713 TEST_F(ExpireHistoryTest, ExpiringVisitsReader) { |
| 714 URLID url_ids[3]; |
| 715 Time visit_times[4]; |
| 716 AddExampleData(url_ids, visit_times); |
698 | 717 |
699 // Deleting a time range with no URLs should return false (nothing found). | 718 const ExpiringVisitsReader* all = expirer_.GetAllVisitsReader(); |
700 EXPECT_FALSE(expirer_.ArchiveSomeOldHistory( | 719 const ExpiringVisitsReader* auto_subframes = |
701 visit_times[0] - TimeDelta::FromDays(100), 1)); | 720 expirer_.GetAutoSubframeVisitsReader(); |
702 | 721 |
703 // Deleting a time range with not up the the max results should also return | 722 VisitVector visits; |
704 // false (there will only be one visit deleted in this range). | 723 Time now = Time::Now(); |
705 EXPECT_FALSE(expirer_.ArchiveSomeOldHistory(visit_times[0], 2)); | |
706 | 724 |
707 // Deleting a time range with the max number of results should return true | 725 // Verify that the early expiration threshold, stored in the meta table is |
708 // (max deleted). | 726 // initialized. |
709 EXPECT_TRUE(expirer_.ArchiveSomeOldHistory(visit_times[2], 1)); | 727 EXPECT_TRUE(main_db_->GetEarlyExpirationThreshold() == |
| 728 Time::FromInternalValue(1L)); |
| 729 |
| 730 // First, attempt reading AUTO_SUBFRAME visits. We should get none. |
| 731 EXPECT_FALSE(auto_subframes->Read(now, main_db_.get(), &visits, 1)); |
| 732 EXPECT_EQ(0U, visits.size()); |
| 733 |
| 734 // Verify that the early expiration threshold was updated, since there are no |
| 735 // AUTO_SUBFRAME visits in the given time range. |
| 736 EXPECT_TRUE(now <= main_db_->GetEarlyExpirationThreshold()); |
| 737 |
| 738 // Now, read all visits and verify that there's at least one. |
| 739 EXPECT_TRUE(all->Read(now, main_db_.get(), &visits, 1)); |
| 740 EXPECT_EQ(1U, visits.size()); |
710 } | 741 } |
711 | 742 |
712 // TODO(brettw) add some visits with no URL to make sure everything is updated | 743 // TODO(brettw) add some visits with no URL to make sure everything is updated |
713 // properly. Have the visits also refer to nonexistant FTS rows. | 744 // properly. Have the visits also refer to nonexistant FTS rows. |
714 // | 745 // |
715 // Maybe also refer to invalid favicons. | 746 // Maybe also refer to invalid favicons. |
716 | 747 |
717 } // namespace history | 748 } // namespace history |
OLD | NEW |