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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/guid.h" | 8 #include "base/guid.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" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/autofill/autofill_profile.h" | 14 #include "chrome/browser/autofill/autofill_profile.h" |
15 #include "chrome/browser/autofill/autofill_type.h" | 15 #include "chrome/browser/autofill/autofill_type.h" |
16 #include "chrome/browser/autofill/credit_card.h" | 16 #include "chrome/browser/autofill/credit_card.h" |
17 #include "chrome/browser/password_manager/encryptor.h" | 17 #include "chrome/browser/password_manager/encryptor.h" |
18 #include "chrome/browser/webdata/autofill_change.h" | 18 #include "chrome/browser/webdata/autofill_change.h" |
19 #include "chrome/browser/webdata/autofill_entry.h" | 19 #include "chrome/browser/webdata/autofill_entry.h" |
20 #include "chrome/browser/webdata/autofill_table.h" | 20 #include "chrome/browser/webdata/autofill_table.h" |
21 #include "chrome/browser/webdata/web_database.h" | 21 #include "chrome/browser/webdata/web_database.h" |
22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/form_field_data.h" |
23 #include "sql/statement.h" | 24 #include "sql/statement.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/forms/form_field.h" | |
26 | 26 |
27 using base::Time; | 27 using base::Time; |
28 using base::TimeDelta; | 28 using base::TimeDelta; |
29 using webkit::forms::FormField; | |
30 | 29 |
31 // So we can compare AutofillKeys with EXPECT_EQ(). | 30 // So we can compare AutofillKeys with EXPECT_EQ(). |
32 std::ostream& operator<<(std::ostream& os, const AutofillKey& key) { | 31 std::ostream& operator<<(std::ostream& os, const AutofillKey& key) { |
33 return os << UTF16ToASCII(key.name()) << ", " << UTF16ToASCII(key.value()); | 32 return os << UTF16ToASCII(key.name()) << ", " << UTF16ToASCII(key.value()); |
34 } | 33 } |
35 | 34 |
36 // So we can compare AutofillChanges with EXPECT_EQ(). | 35 // So we can compare AutofillChanges with EXPECT_EQ(). |
37 std::ostream& operator<<(std::ostream& os, const AutofillChange& change) { | 36 std::ostream& operator<<(std::ostream& os, const AutofillChange& change) { |
38 switch (change.type()) { | 37 switch (change.type()) { |
39 case AutofillChange::ADD: { | 38 case AutofillChange::ADD: { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 TEST_F(AutofillTableTest, Autofill) { | 124 TEST_F(AutofillTableTest, Autofill) { |
126 WebDatabase db; | 125 WebDatabase db; |
127 | 126 |
128 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 127 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
129 | 128 |
130 Time t1 = Time::Now(); | 129 Time t1 = Time::Now(); |
131 | 130 |
132 // Simulate the submission of a handful of entries in a field called "Name", | 131 // Simulate the submission of a handful of entries in a field called "Name", |
133 // some more often than others. | 132 // some more often than others. |
134 AutofillChangeList changes; | 133 AutofillChangeList changes; |
135 FormField field; | 134 FormFieldData field; |
136 field.name = ASCIIToUTF16("Name"); | 135 field.name = ASCIIToUTF16("Name"); |
137 field.value = ASCIIToUTF16("Superman"); | 136 field.value = ASCIIToUTF16("Superman"); |
138 base::Time now = base::Time::Now(); | 137 base::Time now = base::Time::Now(); |
139 base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2); | 138 base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2); |
140 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); | 139 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); |
141 std::vector<string16> v; | 140 std::vector<string16> v; |
142 for (int i = 0; i < 5; i++) { | 141 for (int i = 0; i < 5; i++) { |
143 field.value = ASCIIToUTF16("Clark Kent"); | 142 field.value = ASCIIToUTF16("Clark Kent"); |
144 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, | 143 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, |
145 now + i * two_seconds)); | 144 now + i * two_seconds)); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 282 |
284 TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { | 283 TEST_F(AutofillTableTest, Autofill_RemoveBetweenChanges) { |
285 WebDatabase db; | 284 WebDatabase db; |
286 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 285 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
287 | 286 |
288 TimeDelta one_day(TimeDelta::FromDays(1)); | 287 TimeDelta one_day(TimeDelta::FromDays(1)); |
289 Time t1 = Time::Now(); | 288 Time t1 = Time::Now(); |
290 Time t2 = t1 + one_day; | 289 Time t2 = t1 + one_day; |
291 | 290 |
292 AutofillChangeList changes; | 291 AutofillChangeList changes; |
293 FormField field; | 292 FormFieldData field; |
294 field.name = ASCIIToUTF16("Name"); | 293 field.name = ASCIIToUTF16("Name"); |
295 field.value = ASCIIToUTF16("Superman"); | 294 field.value = ASCIIToUTF16("Superman"); |
296 EXPECT_TRUE( | 295 EXPECT_TRUE( |
297 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t1)); | 296 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t1)); |
298 EXPECT_TRUE( | 297 EXPECT_TRUE( |
299 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t2)); | 298 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t2)); |
300 | 299 |
301 changes.clear(); | 300 changes.clear(); |
302 EXPECT_TRUE(db.GetAutofillTable()->RemoveFormElementsAddedBetween( | 301 EXPECT_TRUE(db.GetAutofillTable()->RemoveFormElementsAddedBetween( |
303 t1, t2, &changes)); | 302 t1, t2, &changes)); |
(...skipping 15 matching lines...) Expand all Loading... |
319 | 318 |
320 TEST_F(AutofillTableTest, Autofill_AddChanges) { | 319 TEST_F(AutofillTableTest, Autofill_AddChanges) { |
321 WebDatabase db; | 320 WebDatabase db; |
322 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 321 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
323 | 322 |
324 TimeDelta one_day(TimeDelta::FromDays(1)); | 323 TimeDelta one_day(TimeDelta::FromDays(1)); |
325 Time t1 = Time::Now(); | 324 Time t1 = Time::Now(); |
326 Time t2 = t1 + one_day; | 325 Time t2 = t1 + one_day; |
327 | 326 |
328 AutofillChangeList changes; | 327 AutofillChangeList changes; |
329 FormField field; | 328 FormFieldData field; |
330 field.name = ASCIIToUTF16("Name"); | 329 field.name = ASCIIToUTF16("Name"); |
331 field.value = ASCIIToUTF16("Superman"); | 330 field.value = ASCIIToUTF16("Superman"); |
332 EXPECT_TRUE( | 331 EXPECT_TRUE( |
333 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t1)); | 332 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t1)); |
334 ASSERT_EQ(1U, changes.size()); | 333 ASSERT_EQ(1U, changes.size()); |
335 EXPECT_EQ(AutofillChange(AutofillChange::ADD, | 334 EXPECT_EQ(AutofillChange(AutofillChange::ADD, |
336 AutofillKey(ASCIIToUTF16("Name"), | 335 AutofillKey(ASCIIToUTF16("Name"), |
337 ASCIIToUTF16("Superman"))), | 336 ASCIIToUTF16("Superman"))), |
338 changes[0]); | 337 changes[0]); |
339 | 338 |
340 changes.clear(); | 339 changes.clear(); |
341 EXPECT_TRUE( | 340 EXPECT_TRUE( |
342 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t2)); | 341 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t2)); |
343 ASSERT_EQ(1U, changes.size()); | 342 ASSERT_EQ(1U, changes.size()); |
344 EXPECT_EQ(AutofillChange(AutofillChange::UPDATE, | 343 EXPECT_EQ(AutofillChange(AutofillChange::UPDATE, |
345 AutofillKey(ASCIIToUTF16("Name"), | 344 AutofillKey(ASCIIToUTF16("Name"), |
346 ASCIIToUTF16("Superman"))), | 345 ASCIIToUTF16("Superman"))), |
347 changes[0]); | 346 changes[0]); |
348 } | 347 } |
349 | 348 |
350 TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { | 349 TEST_F(AutofillTableTest, Autofill_UpdateOneWithOneTimestamp) { |
351 WebDatabase db; | 350 WebDatabase db; |
352 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 351 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
353 | 352 |
354 AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, -1)); | 353 AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, -1)); |
355 std::vector<AutofillEntry> entries; | 354 std::vector<AutofillEntry> entries; |
356 entries.push_back(entry); | 355 entries.push_back(entry); |
357 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); | 356 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); |
358 | 357 |
359 FormField field; | 358 FormFieldData field; |
360 field.name = ASCIIToUTF16("foo"); | 359 field.name = ASCIIToUTF16("foo"); |
361 field.value = ASCIIToUTF16("bar"); | 360 field.value = ASCIIToUTF16("bar"); |
362 int64 pair_id; | 361 int64 pair_id; |
363 int count; | 362 int count; |
364 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( | 363 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( |
365 field, &pair_id, &count)); | 364 field, &pair_id, &count)); |
366 EXPECT_LE(0, pair_id); | 365 EXPECT_LE(0, pair_id); |
367 EXPECT_EQ(1, count); | 366 EXPECT_EQ(1, count); |
368 | 367 |
369 std::vector<AutofillEntry> all_entries; | 368 std::vector<AutofillEntry> all_entries; |
370 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); | 369 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); |
371 ASSERT_EQ(1U, all_entries.size()); | 370 ASSERT_EQ(1U, all_entries.size()); |
372 EXPECT_TRUE(entry == all_entries[0]); | 371 EXPECT_TRUE(entry == all_entries[0]); |
373 } | 372 } |
374 | 373 |
375 TEST_F(AutofillTableTest, Autofill_UpdateOneWithTwoTimestamps) { | 374 TEST_F(AutofillTableTest, Autofill_UpdateOneWithTwoTimestamps) { |
376 WebDatabase db; | 375 WebDatabase db; |
377 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 376 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
378 | 377 |
379 AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, 2)); | 378 AutofillEntry entry(MakeAutofillEntry("foo", "bar", 1, 2)); |
380 std::vector<AutofillEntry> entries; | 379 std::vector<AutofillEntry> entries; |
381 entries.push_back(entry); | 380 entries.push_back(entry); |
382 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); | 381 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); |
383 | 382 |
384 FormField field; | 383 FormFieldData field; |
385 field.name = ASCIIToUTF16("foo"); | 384 field.name = ASCIIToUTF16("foo"); |
386 field.value = ASCIIToUTF16("bar"); | 385 field.value = ASCIIToUTF16("bar"); |
387 int64 pair_id; | 386 int64 pair_id; |
388 int count; | 387 int count; |
389 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( | 388 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( |
390 field, &pair_id, &count)); | 389 field, &pair_id, &count)); |
391 EXPECT_LE(0, pair_id); | 390 EXPECT_LE(0, pair_id); |
392 EXPECT_EQ(2, count); | 391 EXPECT_EQ(2, count); |
393 | 392 |
394 std::vector<AutofillEntry> all_entries; | 393 std::vector<AutofillEntry> all_entries; |
(...skipping 24 matching lines...) Expand all Loading... |
419 WebDatabase db; | 418 WebDatabase db; |
420 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 419 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
421 | 420 |
422 AutofillEntry entry0(MakeAutofillEntry("foo", "bar0", 1, -1)); | 421 AutofillEntry entry0(MakeAutofillEntry("foo", "bar0", 1, -1)); |
423 AutofillEntry entry1(MakeAutofillEntry("foo", "bar1", 2, 3)); | 422 AutofillEntry entry1(MakeAutofillEntry("foo", "bar1", 2, 3)); |
424 std::vector<AutofillEntry> entries; | 423 std::vector<AutofillEntry> entries; |
425 entries.push_back(entry0); | 424 entries.push_back(entry0); |
426 entries.push_back(entry1); | 425 entries.push_back(entry1); |
427 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); | 426 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); |
428 | 427 |
429 FormField field0; | 428 FormFieldData field0; |
430 field0.name = ASCIIToUTF16("foo"); | 429 field0.name = ASCIIToUTF16("foo"); |
431 field0.value = ASCIIToUTF16("bar0"); | 430 field0.value = ASCIIToUTF16("bar0"); |
432 int64 pair_id; | 431 int64 pair_id; |
433 int count; | 432 int count; |
434 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( | 433 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( |
435 field0, &pair_id, &count)); | 434 field0, &pair_id, &count)); |
436 EXPECT_LE(0, pair_id); | 435 EXPECT_LE(0, pair_id); |
437 EXPECT_EQ(1, count); | 436 EXPECT_EQ(1, count); |
438 | 437 |
439 FormField field1; | 438 FormFieldData field1; |
440 field1.name = ASCIIToUTF16("foo"); | 439 field1.name = ASCIIToUTF16("foo"); |
441 field1.value = ASCIIToUTF16("bar1"); | 440 field1.value = ASCIIToUTF16("bar1"); |
442 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( | 441 ASSERT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement( |
443 field1, &pair_id, &count)); | 442 field1, &pair_id, &count)); |
444 EXPECT_LE(0, pair_id); | 443 EXPECT_LE(0, pair_id); |
445 EXPECT_EQ(2, count); | 444 EXPECT_EQ(2, count); |
446 } | 445 } |
447 | 446 |
448 TEST_F(AutofillTableTest, Autofill_UpdateReplace) { | 447 TEST_F(AutofillTableTest, Autofill_UpdateReplace) { |
449 WebDatabase db; | 448 WebDatabase db; |
450 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 449 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
451 | 450 |
452 AutofillChangeList changes; | 451 AutofillChangeList changes; |
453 // Add a form field. This will be replaced. | 452 // Add a form field. This will be replaced. |
454 FormField field; | 453 FormFieldData field; |
455 field.name = ASCIIToUTF16("Name"); | 454 field.name = ASCIIToUTF16("Name"); |
456 field.value = ASCIIToUTF16("Superman"); | 455 field.value = ASCIIToUTF16("Superman"); |
457 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); | 456 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); |
458 | 457 |
459 AutofillEntry entry(MakeAutofillEntry("Name", "Superman", 1, 2)); | 458 AutofillEntry entry(MakeAutofillEntry("Name", "Superman", 1, 2)); |
460 std::vector<AutofillEntry> entries; | 459 std::vector<AutofillEntry> entries; |
461 entries.push_back(entry); | 460 entries.push_back(entry); |
462 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); | 461 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); |
463 | 462 |
464 std::vector<AutofillEntry> all_entries; | 463 std::vector<AutofillEntry> all_entries; |
465 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); | 464 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); |
466 ASSERT_EQ(1U, all_entries.size()); | 465 ASSERT_EQ(1U, all_entries.size()); |
467 EXPECT_TRUE(entry == all_entries[0]); | 466 EXPECT_TRUE(entry == all_entries[0]); |
468 } | 467 } |
469 | 468 |
470 TEST_F(AutofillTableTest, Autofill_UpdateDontReplace) { | 469 TEST_F(AutofillTableTest, Autofill_UpdateDontReplace) { |
471 WebDatabase db; | 470 WebDatabase db; |
472 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 471 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
473 | 472 |
474 Time t = Time::Now(); | 473 Time t = Time::Now(); |
475 AutofillEntry existing( | 474 AutofillEntry existing( |
476 MakeAutofillEntry("Name", "Superman", t.ToTimeT(), -1)); | 475 MakeAutofillEntry("Name", "Superman", t.ToTimeT(), -1)); |
477 | 476 |
478 AutofillChangeList changes; | 477 AutofillChangeList changes; |
479 // Add a form field. This will NOT be replaced. | 478 // Add a form field. This will NOT be replaced. |
480 FormField field; | 479 FormFieldData field; |
481 field.name = existing.key().name(); | 480 field.name = existing.key().name(); |
482 field.value = existing.key().value(); | 481 field.value = existing.key().value(); |
483 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t)); | 482 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, t)); |
484 AutofillEntry entry(MakeAutofillEntry("Name", "Clark Kent", 1, 2)); | 483 AutofillEntry entry(MakeAutofillEntry("Name", "Clark Kent", 1, 2)); |
485 std::vector<AutofillEntry> entries; | 484 std::vector<AutofillEntry> entries; |
486 entries.push_back(entry); | 485 entries.push_back(entry); |
487 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); | 486 ASSERT_TRUE(db.GetAutofillTable()->UpdateAutofillEntries(entries)); |
488 | 487 |
489 std::vector<AutofillEntry> all_entries; | 488 std::vector<AutofillEntry> all_entries; |
490 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); | 489 ASSERT_TRUE(db.GetAutofillTable()->GetAllAutofillEntries(&all_entries)); |
491 ASSERT_EQ(2U, all_entries.size()); | 490 ASSERT_EQ(2U, all_entries.size()); |
492 AutofillEntrySet expected_entries(all_entries.begin(), | 491 AutofillEntrySet expected_entries(all_entries.begin(), |
493 all_entries.end(), | 492 all_entries.end(), |
494 CompareAutofillEntries); | 493 CompareAutofillEntries); |
495 EXPECT_EQ(1U, expected_entries.count(existing)); | 494 EXPECT_EQ(1U, expected_entries.count(existing)); |
496 EXPECT_EQ(1U, expected_entries.count(entry)); | 495 EXPECT_EQ(1U, expected_entries.count(entry)); |
497 } | 496 } |
498 | 497 |
499 TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { | 498 TEST_F(AutofillTableTest, Autofill_AddFormFieldValues) { |
500 WebDatabase db; | 499 WebDatabase db; |
501 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 500 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
502 | 501 |
503 Time t = Time::Now(); | 502 Time t = Time::Now(); |
504 | 503 |
505 // Add multiple values for "firstname" and "lastname" names. Test that only | 504 // Add multiple values for "firstname" and "lastname" names. Test that only |
506 // first value of each gets added. Related to security issue: | 505 // first value of each gets added. Related to security issue: |
507 // http://crbug.com/51727. | 506 // http://crbug.com/51727. |
508 std::vector<FormField> elements; | 507 std::vector<FormFieldData> elements; |
509 FormField field; | 508 FormFieldData field; |
510 field.name = ASCIIToUTF16("firstname"); | 509 field.name = ASCIIToUTF16("firstname"); |
511 field.value = ASCIIToUTF16("Joe"); | 510 field.value = ASCIIToUTF16("Joe"); |
512 elements.push_back(field); | 511 elements.push_back(field); |
513 | 512 |
514 field.name = ASCIIToUTF16("firstname"); | 513 field.name = ASCIIToUTF16("firstname"); |
515 field.value = ASCIIToUTF16("Jane"); | 514 field.value = ASCIIToUTF16("Jane"); |
516 elements.push_back(field); | 515 elements.push_back(field); |
517 | 516 |
518 field.name = ASCIIToUTF16("lastname"); | 517 field.name = ASCIIToUTF16("lastname"); |
519 field.value = ASCIIToUTF16("Smith"); | 518 field.value = ASCIIToUTF16("Smith"); |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { | 1297 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_OneResult) { |
1299 WebDatabase db; | 1298 WebDatabase db; |
1300 | 1299 |
1301 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 1300 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
1302 | 1301 |
1303 AutofillChangeList changes; | 1302 AutofillChangeList changes; |
1304 std::map<std::string, std::vector<Time> > name_value_times_map; | 1303 std::map<std::string, std::vector<Time> > name_value_times_map; |
1305 | 1304 |
1306 time_t start = 0; | 1305 time_t start = 0; |
1307 std::vector<Time> timestamps1; | 1306 std::vector<Time> timestamps1; |
1308 FormField field; | 1307 FormFieldData field; |
1309 field.name = ASCIIToUTF16("Name"); | 1308 field.name = ASCIIToUTF16("Name"); |
1310 field.value = ASCIIToUTF16("Superman"); | 1309 field.value = ASCIIToUTF16("Superman"); |
1311 EXPECT_TRUE( | 1310 EXPECT_TRUE( |
1312 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, | 1311 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, |
1313 Time::FromTimeT(start))); | 1312 Time::FromTimeT(start))); |
1314 timestamps1.push_back(Time::FromTimeT(start)); | 1313 timestamps1.push_back(Time::FromTimeT(start)); |
1315 std::string key1("NameSuperman"); | 1314 std::string key1("NameSuperman"); |
1316 name_value_times_map.insert(std::pair<std::string, | 1315 name_value_times_map.insert(std::pair<std::string, |
1317 std::vector<Time> > (key1, timestamps1)); | 1316 std::vector<Time> > (key1, timestamps1)); |
1318 | 1317 |
(...skipping 21 matching lines...) Expand all Loading... |
1340 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { | 1339 TEST_F(AutofillTableTest, Autofill_GetAllAutofillEntries_TwoDistinct) { |
1341 WebDatabase db; | 1340 WebDatabase db; |
1342 | 1341 |
1343 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 1342 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
1344 | 1343 |
1345 AutofillChangeList changes; | 1344 AutofillChangeList changes; |
1346 std::map<std::string, std::vector<Time> > name_value_times_map; | 1345 std::map<std::string, std::vector<Time> > name_value_times_map; |
1347 time_t start = 0; | 1346 time_t start = 0; |
1348 | 1347 |
1349 std::vector<Time> timestamps1; | 1348 std::vector<Time> timestamps1; |
1350 FormField field; | 1349 FormFieldData field; |
1351 field.name = ASCIIToUTF16("Name"); | 1350 field.name = ASCIIToUTF16("Name"); |
1352 field.value = ASCIIToUTF16("Superman"); | 1351 field.value = ASCIIToUTF16("Superman"); |
1353 EXPECT_TRUE( | 1352 EXPECT_TRUE( |
1354 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, | 1353 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, |
1355 Time::FromTimeT(start))); | 1354 Time::FromTimeT(start))); |
1356 timestamps1.push_back(Time::FromTimeT(start)); | 1355 timestamps1.push_back(Time::FromTimeT(start)); |
1357 std::string key1("NameSuperman"); | 1356 std::string key1("NameSuperman"); |
1358 name_value_times_map.insert(std::pair<std::string, | 1357 name_value_times_map.insert(std::pair<std::string, |
1359 std::vector<Time> > (key1, timestamps1)); | 1358 std::vector<Time> > (key1, timestamps1)); |
1360 | 1359 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 WebDatabase db; | 1397 WebDatabase db; |
1399 | 1398 |
1400 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); | 1399 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); |
1401 | 1400 |
1402 AutofillChangeList changes; | 1401 AutofillChangeList changes; |
1403 std::map<std::string, std::vector<Time> > name_value_times_map; | 1402 std::map<std::string, std::vector<Time> > name_value_times_map; |
1404 | 1403 |
1405 time_t start = 0; | 1404 time_t start = 0; |
1406 std::vector<Time> timestamps; | 1405 std::vector<Time> timestamps; |
1407 for (int i = 0; i < 2; i++) { | 1406 for (int i = 0; i < 2; i++) { |
1408 FormField field; | 1407 FormFieldData field; |
1409 field.name = ASCIIToUTF16("Name"); | 1408 field.name = ASCIIToUTF16("Name"); |
1410 field.value = ASCIIToUTF16("Superman"); | 1409 field.value = ASCIIToUTF16("Superman"); |
1411 EXPECT_TRUE( | 1410 EXPECT_TRUE( |
1412 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, | 1411 db.GetAutofillTable()->AddFormFieldValueTime(field, &changes, |
1413 Time::FromTimeT(start))); | 1412 Time::FromTimeT(start))); |
1414 timestamps.push_back(Time::FromTimeT(start)); | 1413 timestamps.push_back(Time::FromTimeT(start)); |
1415 start++; | 1414 start++; |
1416 } | 1415 } |
1417 | 1416 |
1418 std::string key("NameSuperman"); | 1417 std::string key("NameSuperman"); |
(...skipping 13 matching lines...) Expand all Loading... |
1432 | 1431 |
1433 // make sure the lists of entries match | 1432 // make sure the lists of entries match |
1434 ASSERT_EQ(expected_entries.size(), entry_set.size()); | 1433 ASSERT_EQ(expected_entries.size(), entry_set.size()); |
1435 AutofillEntrySetIterator it; | 1434 AutofillEntrySetIterator it; |
1436 for (it = entry_set.begin(); it != entry_set.end(); it++) { | 1435 for (it = entry_set.begin(); it != entry_set.end(); it++) { |
1437 expected_entries.erase(*it); | 1436 expected_entries.erase(*it); |
1438 } | 1437 } |
1439 | 1438 |
1440 EXPECT_EQ(0U, expected_entries.size()); | 1439 EXPECT_EQ(0U, expected_entries.size()); |
1441 } | 1440 } |
OLD | NEW |