| 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 // Removing all elements since the beginning of this function should remove | 457 // Removing all elements since the beginning of this function should remove |
| 458 // everything from the database. | 458 // everything from the database. |
| 459 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time())); | 459 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time())); |
| 460 | 460 |
| 461 EXPECT_TRUE(db.GetIDAndCountOfFormElement( | 461 EXPECT_TRUE(db.GetIDAndCountOfFormElement( |
| 462 AutofillForm::Element(L"Name", L"Clark Kent"), &pair_id, &count)); | 462 AutofillForm::Element(L"Name", L"Clark Kent"), &pair_id, &count)); |
| 463 EXPECT_EQ(0, count); | 463 EXPECT_EQ(0, count); |
| 464 | 464 |
| 465 EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"", &v, 6)); | 465 EXPECT_TRUE(db.GetFormValuesForElementName(L"Name", L"", &v, 6)); |
| 466 EXPECT_EQ(0U, v.size()); | 466 EXPECT_EQ(0U, v.size()); |
| 467 |
| 468 // Now add some values with empty strings. |
| 469 const std::wstring kValue = L" toto "; |
| 470 EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", L""))); |
| 471 EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", |
| 472 L" "))); |
| 473 EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", |
| 474 L" "))); |
| 475 EXPECT_TRUE(db.AddAutofillFormElement(AutofillForm::Element(L"blank", |
| 476 kValue))); |
| 477 |
| 478 // They should be stored normally as the DB layer does not check for empty |
| 479 // values. |
| 480 v.clear(); |
| 481 EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10)); |
| 482 EXPECT_EQ(4U, v.size()); |
| 483 |
| 484 // Now we'll check that ClearAutofillEmptyValueElements() works as expected. |
| 485 db.ClearAutofillEmptyValueElements(); |
| 486 |
| 487 v.clear(); |
| 488 EXPECT_TRUE(db.GetFormValuesForElementName(L"blank", L"", &v, 10)); |
| 489 ASSERT_EQ(1U, v.size()); |
| 490 |
| 491 EXPECT_EQ(kValue, v[0]); |
| 467 } | 492 } |
| 468 | 493 |
| 469 static bool AddTimestampedLogin(WebDatabase* db, std::string url, | 494 static bool AddTimestampedLogin(WebDatabase* db, std::string url, |
| 470 std::wstring unique_string, const Time& time) { | 495 std::wstring unique_string, const Time& time) { |
| 471 // Example password form. | 496 // Example password form. |
| 472 PasswordForm form; | 497 PasswordForm form; |
| 473 form.origin = GURL(url + std::string("/LoginAuth")); | 498 form.origin = GURL(url + std::string("/LoginAuth")); |
| 474 form.username_element = unique_string.c_str(); | 499 form.username_element = unique_string.c_str(); |
| 475 form.username_value = unique_string.c_str(); | 500 form.username_value = unique_string.c_str(); |
| 476 form.password_element = unique_string.c_str(); | 501 form.password_element = unique_string.c_str(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 ASSERT_EQ(32, images[1].width()); | 670 ASSERT_EQ(32, images[1].width()); |
| 646 ASSERT_EQ(32, images[1].height()); | 671 ASSERT_EQ(32, images[1].height()); |
| 647 } else { | 672 } else { |
| 648 ASSERT_EQ(32, images[0].width()); | 673 ASSERT_EQ(32, images[0].width()); |
| 649 ASSERT_EQ(32, images[0].height()); | 674 ASSERT_EQ(32, images[0].height()); |
| 650 ASSERT_EQ(16, images[1].width()); | 675 ASSERT_EQ(16, images[1].width()); |
| 651 ASSERT_EQ(16, images[1].height()); | 676 ASSERT_EQ(16, images[1].height()); |
| 652 } | 677 } |
| 653 } | 678 } |
| 654 | 679 |
| OLD | NEW |