| Index: chrome/browser/webdata/autofill_entry_unittest.cc
|
| diff --git a/chrome/browser/webdata/autofill_entry_unittest.cc b/chrome/browser/webdata/autofill_entry_unittest.cc
|
| index 36c158a1946b48a393f928d3bd7051a8cf60f311..c6986967e75410fc614fd15b6c8240df27ea60ef 100644
|
| --- a/chrome/browser/webdata/autofill_entry_unittest.cc
|
| +++ b/chrome/browser/webdata/autofill_entry_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include <algorithm>
|
|
|
| #include "base/time.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "chrome/browser/webdata/autofill_entry.h"
|
|
|
| @@ -46,3 +47,55 @@ TEST(AutofillEntryTest, Culling) {
|
| --count;
|
| }
|
| }
|
| +
|
| +TEST(AutofillEntryTest, CullByTime) {
|
| + base::Time current = base::Time::Now();
|
| + base::TimeDelta one_day = base::TimeDelta::FromDays(1);
|
| + base::TimeDelta one_hour = base::TimeDelta::FromHours(1);
|
| +
|
| + std::vector<base::Time> timestamps;
|
| + base::Time cutoff_time = current - one_day;
|
| +
|
| + // Within the time limit.
|
| + timestamps.push_back(cutoff_time + one_hour);
|
| +
|
| + AutofillKey key(UTF8ToUTF16("test_key"), UTF8ToUTF16("test_value"));
|
| +
|
| + AutofillEntry entry_within_the_limits(key, timestamps);
|
| + EXPECT_FALSE(entry_within_the_limits.HasTimestampsOlder(cutoff_time));
|
| + EXPECT_FALSE(entry_within_the_limits.CullExpiredTimeStamps(cutoff_time));
|
| + EXPECT_FALSE(entry_within_the_limits.timestamps_culled());
|
| + EXPECT_EQ(1U, entry_within_the_limits.timestamps().size());
|
| +
|
| + // One within the time limit, one outside.
|
| + timestamps.push_back(cutoff_time - one_hour);
|
| +
|
| + AutofillEntry entry_partially_within_the_limits(key, timestamps);
|
| + EXPECT_TRUE(
|
| + entry_partially_within_the_limits.HasTimestampsOlder(cutoff_time));
|
| + EXPECT_TRUE(
|
| + entry_partially_within_the_limits.CullExpiredTimeStamps(cutoff_time));
|
| + EXPECT_TRUE(entry_partially_within_the_limits.timestamps_culled());
|
| + EXPECT_EQ(1U, entry_partially_within_the_limits.timestamps().size());
|
| +
|
| + // All outside the time limit.
|
| + timestamps.clear();
|
| + timestamps.push_back(cutoff_time - one_hour);
|
| + timestamps.push_back(cutoff_time - one_hour * 2);
|
| + timestamps.push_back(cutoff_time - one_hour * 3);
|
| +
|
| + AutofillEntry entry_outside_the_limits(key, timestamps);
|
| + EXPECT_TRUE(entry_outside_the_limits.HasTimestampsOlder(cutoff_time));
|
| + EXPECT_TRUE(entry_outside_the_limits.CullExpiredTimeStamps(cutoff_time));
|
| + EXPECT_TRUE(entry_outside_the_limits.timestamps_culled());
|
| + EXPECT_TRUE(entry_outside_the_limits.timestamps().empty());
|
| +
|
| + // Timestamp is on the edge.
|
| + timestamps.clear();
|
| + timestamps.push_back(cutoff_time);
|
| + AutofillEntry entry_on_the_edge(key, timestamps);
|
| + EXPECT_FALSE(entry_on_the_edge.HasTimestampsOlder(cutoff_time));
|
| + EXPECT_FALSE(entry_on_the_edge.CullExpiredTimeStamps(cutoff_time));
|
| + EXPECT_FALSE(entry_on_the_edge.timestamps_culled());
|
| + EXPECT_EQ(1U, entry_on_the_edge.timestamps().size());
|
| +}
|
|
|