| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 std::vector<PasswordForm*> result; | 198 std::vector<PasswordForm*> result; |
| 199 | 199 |
| 200 // Verify the database is empty. | 200 // Verify the database is empty. |
| 201 EXPECT_TRUE(db->GetAutofillableLogins(&result)); | 201 EXPECT_TRUE(db->GetAutofillableLogins(&result)); |
| 202 EXPECT_EQ(0U, result.size()); | 202 EXPECT_EQ(0U, result.size()); |
| 203 | 203 |
| 204 base::Time now = base::Time::Now(); | 204 base::Time now = base::Time::Now(); |
| 205 base::TimeDelta one_day = base::TimeDelta::FromDays(1); | 205 base::TimeDelta one_day = base::TimeDelta::FromDays(1); |
| 206 | 206 |
| 207 // Create one with a 0 time. | 207 // Create one with a 0 time. |
| 208 EXPECT_TRUE(AddTimestampedLogin(db.get(), "1", "foo1", base::Time())); | 208 EXPECT_TRUE(AddTimestampedLogin(db.get(), "http://1", "foo1", base::Time())); |
| 209 // Create one for now and +/- 1 day. | 209 // Create one for now and +/- 1 day. |
| 210 EXPECT_TRUE(AddTimestampedLogin(db.get(), "2", "foo2", now - one_day)); | 210 EXPECT_TRUE(AddTimestampedLogin(db.get(), "http://2", "foo2", now - one_day)); |
| 211 EXPECT_TRUE(AddTimestampedLogin(db.get(), "3", "foo3", now)); | 211 EXPECT_TRUE(AddTimestampedLogin(db.get(), "http://3", "foo3", now)); |
| 212 EXPECT_TRUE(AddTimestampedLogin(db.get(), "4", "foo4", now + one_day)); | 212 EXPECT_TRUE(AddTimestampedLogin(db.get(), "http://4", "foo4", now + one_day)); |
| 213 | 213 |
| 214 // Verify inserts worked. | 214 // Verify inserts worked. |
| 215 EXPECT_TRUE(db->GetAutofillableLogins(&result)); | 215 EXPECT_TRUE(db->GetAutofillableLogins(&result)); |
| 216 EXPECT_EQ(4U, result.size()); | 216 EXPECT_EQ(4U, result.size()); |
| 217 ClearResults(&result); | 217 ClearResults(&result); |
| 218 | 218 |
| 219 // Get everything from today's date and on. | 219 // Get everything from today's date and on. |
| 220 EXPECT_TRUE(db->GetLoginsCreatedBetween(now, base::Time(), &result)); | 220 EXPECT_TRUE(db->GetLoginsCreatedBetween(now, base::Time(), &result)); |
| 221 EXPECT_EQ(2U, result.size()); | 221 EXPECT_EQ(2U, result.size()); |
| 222 ClearResults(&result); | 222 ClearResults(&result); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 // GetLogins should give the blacklisted result. | 268 // GetLogins should give the blacklisted result. |
| 269 EXPECT_TRUE(db->GetLogins(form, &result)); | 269 EXPECT_TRUE(db->GetLogins(form, &result)); |
| 270 EXPECT_EQ(1U, result.size()); | 270 EXPECT_EQ(1U, result.size()); |
| 271 ClearResults(&result); | 271 ClearResults(&result); |
| 272 | 272 |
| 273 // So should GetAllBlacklistedLogins. | 273 // So should GetAllBlacklistedLogins. |
| 274 EXPECT_TRUE(db->GetBlacklistLogins(&result)); | 274 EXPECT_TRUE(db->GetBlacklistLogins(&result)); |
| 275 EXPECT_EQ(1U, result.size()); | 275 EXPECT_EQ(1U, result.size()); |
| 276 ClearResults(&result); | 276 ClearResults(&result); |
| 277 } | 277 } |
| OLD | NEW |