OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "components/autofill/core/browser/webdata/autofill_entry.h" | 9 #include "components/autofill/core/browser/webdata/autofill_entry.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 TEST(AutofillEntryTest, CullByTime) { | 50 TEST(AutofillEntryTest, CullByTime) { |
51 base::TimeDelta one_hour = base::TimeDelta::FromHours(1); | 51 base::TimeDelta one_hour = base::TimeDelta::FromHours(1); |
52 | 52 |
53 std::vector<base::Time> timestamps; | 53 std::vector<base::Time> timestamps; |
54 base::Time cutoff_time = AutofillEntry::ExpirationTime(); | 54 base::Time cutoff_time = AutofillEntry::ExpirationTime(); |
55 | 55 |
56 // Within the time limit. | 56 // Within the time limit. |
57 timestamps.push_back(cutoff_time + one_hour); | 57 timestamps.push_back(cutoff_time + one_hour); |
58 | 58 |
59 AutofillKey key(UTF8ToUTF16("test_key"), UTF8ToUTF16("test_value")); | 59 AutofillKey key(base::UTF8ToUTF16("test_key"), |
| 60 base::UTF8ToUTF16("test_value")); |
60 | 61 |
61 AutofillEntry entry_within_the_limits(key, timestamps); | 62 AutofillEntry entry_within_the_limits(key, timestamps); |
62 EXPECT_FALSE(entry_within_the_limits.IsExpired()); | 63 EXPECT_FALSE(entry_within_the_limits.IsExpired()); |
63 | 64 |
64 // One within the time limit, one outside. | 65 // One within the time limit, one outside. |
65 timestamps.push_back(cutoff_time - one_hour); | 66 timestamps.push_back(cutoff_time - one_hour); |
66 | 67 |
67 AutofillEntry entry_partially_within_the_limits(key, timestamps); | 68 AutofillEntry entry_partially_within_the_limits(key, timestamps); |
68 EXPECT_TRUE( | 69 EXPECT_TRUE( |
69 entry_partially_within_the_limits.IsExpired()); | 70 entry_partially_within_the_limits.IsExpired()); |
70 | 71 |
71 // All outside the time limit. | 72 // All outside the time limit. |
72 timestamps.clear(); | 73 timestamps.clear(); |
73 timestamps.push_back(cutoff_time - one_hour); | 74 timestamps.push_back(cutoff_time - one_hour); |
74 timestamps.push_back(cutoff_time - one_hour * 2); | 75 timestamps.push_back(cutoff_time - one_hour * 2); |
75 timestamps.push_back(cutoff_time - one_hour * 3); | 76 timestamps.push_back(cutoff_time - one_hour * 3); |
76 | 77 |
77 AutofillEntry entry_outside_the_limits(key, timestamps); | 78 AutofillEntry entry_outside_the_limits(key, timestamps); |
78 EXPECT_TRUE(entry_outside_the_limits.IsExpired()); | 79 EXPECT_TRUE(entry_outside_the_limits.IsExpired()); |
79 EXPECT_TRUE(entry_outside_the_limits.timestamps_culled()); | 80 EXPECT_TRUE(entry_outside_the_limits.timestamps_culled()); |
80 } | 81 } |
81 | 82 |
82 } // namespace autofill | 83 } // namespace autofill |
OLD | NEW |