| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
| 12 #include "chrome/browser/webdata/autofill_change.h" |
| 13 #include "chrome/browser/webdata/autofill_entry.h" |
| 12 #include "chrome/browser/webdata/web_database.h" | 14 #include "chrome/browser/webdata/web_database.h" |
| 13 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 14 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "webkit/glue/form_field.h" | 18 #include "webkit/glue/form_field.h" |
| 17 #include "webkit/glue/password_form.h" | 19 #include "webkit/glue/password_form.h" |
| 18 | 20 |
| 19 using base::Time; | 21 using base::Time; |
| 20 using base::TimeDelta; | 22 using base::TimeDelta; |
| 21 using webkit_glue::FormField; | 23 using webkit_glue::FormField; |
| 22 using webkit_glue::PasswordForm; | 24 using webkit_glue::PasswordForm; |
| 23 | 25 |
| 26 // So we can compare AutofillKeys with EXPECT_EQ(). |
| 27 std::ostream& operator<<(std::ostream& os, const AutofillKey& key) { |
| 28 return os << UTF16ToASCII(key.name()) << ", " << UTF16ToASCII(key.value()); |
| 29 } |
| 30 |
| 31 // So we can compare AutofillChanges with EXPECT_EQ(). |
| 32 std::ostream& operator<<(std::ostream& os, const AutofillChange& change) { |
| 33 switch (change.type()) { |
| 34 case AutofillChange::ADD: { |
| 35 os << "ADD"; |
| 36 break; |
| 37 } |
| 38 case AutofillChange::UPDATE: { |
| 39 os << "UPDATE"; |
| 40 break; |
| 41 } |
| 42 case AutofillChange::REMOVE: { |
| 43 os << "REMOVE"; |
| 44 break; |
| 45 } |
| 46 } |
| 47 return os << " " << change.key(); |
| 48 } |
| 49 |
| 24 class WebDatabaseTest : public testing::Test { | 50 class WebDatabaseTest : public testing::Test { |
| 25 protected: | 51 protected: |
| 26 | 52 |
| 27 virtual void SetUp() { | 53 virtual void SetUp() { |
| 28 PathService::Get(chrome::DIR_TEST_DATA, &file_); | 54 PathService::Get(chrome::DIR_TEST_DATA, &file_); |
| 29 const std::string test_db = "TestWebDatabase" + | 55 const std::string test_db = "TestWebDatabase" + |
| 30 Int64ToString(base::Time::Now().ToInternalValue()) + | 56 Int64ToString(base::Time::Now().ToInternalValue()) + |
| 31 ".db"; | 57 ".db"; |
| 32 file_ = file_.AppendASCII(test_db); | 58 file_ = file_.AppendASCII(test_db); |
| 33 file_util::Delete(file_, false); | 59 file_util::Delete(file_, false); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 static void set_prepopulate_id(TemplateURL* url, int id) { | 106 static void set_prepopulate_id(TemplateURL* url, int id) { |
| 81 url->set_prepopulate_id(id); | 107 url->set_prepopulate_id(id); |
| 82 } | 108 } |
| 83 | 109 |
| 84 FilePath file_; | 110 FilePath file_; |
| 85 }; | 111 }; |
| 86 | 112 |
| 87 TEST_F(WebDatabaseTest, Keywords) { | 113 TEST_F(WebDatabaseTest, Keywords) { |
| 88 WebDatabase db; | 114 WebDatabase db; |
| 89 | 115 |
| 90 EXPECT_TRUE(db.Init(file_)); | 116 ASSERT_TRUE(db.Init(file_)); |
| 91 | 117 |
| 92 TemplateURL template_url; | 118 TemplateURL template_url; |
| 93 template_url.set_short_name(L"short_name"); | 119 template_url.set_short_name(L"short_name"); |
| 94 template_url.set_keyword(L"keyword"); | 120 template_url.set_keyword(L"keyword"); |
| 95 GURL favicon_url("http://favicon.url/"); | 121 GURL favicon_url("http://favicon.url/"); |
| 96 GURL originating_url("http://google.com/"); | 122 GURL originating_url("http://google.com/"); |
| 97 template_url.SetFavIconURL(favicon_url); | 123 template_url.SetFavIconURL(favicon_url); |
| 98 template_url.SetURL(L"http://url/", 0, 0); | 124 template_url.SetURL(L"http://url/", 0, 0); |
| 99 template_url.set_safe_for_autoreplace(true); | 125 template_url.set_safe_for_autoreplace(true); |
| 100 template_url.set_show_in_default_list(true); | 126 template_url.set_show_in_default_list(true); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 EXPECT_TRUE(db.GetKeywords(&template_urls)); | 167 EXPECT_TRUE(db.GetKeywords(&template_urls)); |
| 142 | 168 |
| 143 EXPECT_EQ(0U, template_urls.size()); | 169 EXPECT_EQ(0U, template_urls.size()); |
| 144 | 170 |
| 145 delete restored_url; | 171 delete restored_url; |
| 146 } | 172 } |
| 147 | 173 |
| 148 TEST_F(WebDatabaseTest, KeywordMisc) { | 174 TEST_F(WebDatabaseTest, KeywordMisc) { |
| 149 WebDatabase db; | 175 WebDatabase db; |
| 150 | 176 |
| 151 EXPECT_TRUE(db.Init(file_)); | 177 ASSERT_TRUE(db.Init(file_)); |
| 152 | 178 |
| 153 ASSERT_EQ(0, db.GetDefaulSearchProviderID()); | 179 ASSERT_EQ(0, db.GetDefaulSearchProviderID()); |
| 154 ASSERT_EQ(0, db.GetBuitinKeywordVersion()); | 180 ASSERT_EQ(0, db.GetBuitinKeywordVersion()); |
| 155 | 181 |
| 156 db.SetDefaultSearchProviderID(10); | 182 db.SetDefaultSearchProviderID(10); |
| 157 db.SetBuitinKeywordVersion(11); | 183 db.SetBuitinKeywordVersion(11); |
| 158 | 184 |
| 159 ASSERT_EQ(10, db.GetDefaulSearchProviderID()); | 185 ASSERT_EQ(10, db.GetDefaulSearchProviderID()); |
| 160 ASSERT_EQ(11, db.GetBuitinKeywordVersion()); | 186 ASSERT_EQ(11, db.GetBuitinKeywordVersion()); |
| 161 } | 187 } |
| 162 | 188 |
| 163 TEST_F(WebDatabaseTest, UpdateKeyword) { | 189 TEST_F(WebDatabaseTest, UpdateKeyword) { |
| 164 WebDatabase db; | 190 WebDatabase db; |
| 165 | 191 |
| 166 EXPECT_TRUE(db.Init(file_)); | 192 ASSERT_TRUE(db.Init(file_)); |
| 167 | 193 |
| 168 TemplateURL template_url; | 194 TemplateURL template_url; |
| 169 template_url.set_short_name(L"short_name"); | 195 template_url.set_short_name(L"short_name"); |
| 170 template_url.set_keyword(L"keyword"); | 196 template_url.set_keyword(L"keyword"); |
| 171 GURL favicon_url("http://favicon.url/"); | 197 GURL favicon_url("http://favicon.url/"); |
| 172 GURL originating_url("http://originating.url/"); | 198 GURL originating_url("http://originating.url/"); |
| 173 template_url.SetFavIconURL(favicon_url); | 199 template_url.SetFavIconURL(favicon_url); |
| 174 template_url.SetURL(L"http://url/", 0, 0); | 200 template_url.SetURL(L"http://url/", 0, 0); |
| 175 template_url.set_safe_for_autoreplace(true); | 201 template_url.set_safe_for_autoreplace(true); |
| 176 template_url.set_show_in_default_list(true); | 202 template_url.set_show_in_default_list(true); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 EXPECT_EQ(template_url.id(), restored_url->id()); | 244 EXPECT_EQ(template_url.id(), restored_url->id()); |
| 219 | 245 |
| 220 EXPECT_EQ(template_url.prepopulate_id(), restored_url->prepopulate_id()); | 246 EXPECT_EQ(template_url.prepopulate_id(), restored_url->prepopulate_id()); |
| 221 | 247 |
| 222 delete restored_url; | 248 delete restored_url; |
| 223 } | 249 } |
| 224 | 250 |
| 225 TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { | 251 TEST_F(WebDatabaseTest, KeywordWithNoFavicon) { |
| 226 WebDatabase db; | 252 WebDatabase db; |
| 227 | 253 |
| 228 EXPECT_TRUE(db.Init(file_)); | 254 ASSERT_TRUE(db.Init(file_)); |
| 229 | 255 |
| 230 TemplateURL template_url; | 256 TemplateURL template_url; |
| 231 template_url.set_short_name(L"short_name"); | 257 template_url.set_short_name(L"short_name"); |
| 232 template_url.set_keyword(L"keyword"); | 258 template_url.set_keyword(L"keyword"); |
| 233 template_url.SetURL(L"http://url/", 0, 0); | 259 template_url.SetURL(L"http://url/", 0, 0); |
| 234 template_url.set_safe_for_autoreplace(true); | 260 template_url.set_safe_for_autoreplace(true); |
| 235 SetID(-100, &template_url); | 261 SetID(-100, &template_url); |
| 236 | 262 |
| 237 EXPECT_TRUE(db.AddKeyword(template_url)); | 263 EXPECT_TRUE(db.AddKeyword(template_url)); |
| 238 | 264 |
| 239 std::vector<TemplateURL*> template_urls; | 265 std::vector<TemplateURL*> template_urls; |
| 240 EXPECT_TRUE(db.GetKeywords(&template_urls)); | 266 EXPECT_TRUE(db.GetKeywords(&template_urls)); |
| 241 EXPECT_EQ(1U, template_urls.size()); | 267 EXPECT_EQ(1U, template_urls.size()); |
| 242 const TemplateURL* restored_url = template_urls.front(); | 268 const TemplateURL* restored_url = template_urls.front(); |
| 243 | 269 |
| 244 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); | 270 EXPECT_EQ(template_url.short_name(), restored_url->short_name()); |
| 245 EXPECT_EQ(template_url.keyword(), restored_url->keyword()); | 271 EXPECT_EQ(template_url.keyword(), restored_url->keyword()); |
| 246 EXPECT_TRUE(!restored_url->GetFavIconURL().is_valid()); | 272 EXPECT_TRUE(!restored_url->GetFavIconURL().is_valid()); |
| 247 EXPECT_TRUE(restored_url->safe_for_autoreplace()); | 273 EXPECT_TRUE(restored_url->safe_for_autoreplace()); |
| 248 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); | 274 EXPECT_EQ(GetID(&template_url), GetID(restored_url)); |
| 249 delete restored_url; | 275 delete restored_url; |
| 250 } | 276 } |
| 251 | 277 |
| 252 TEST_F(WebDatabaseTest, Logins) { | 278 TEST_F(WebDatabaseTest, Logins) { |
| 253 WebDatabase db; | 279 WebDatabase db; |
| 254 | 280 |
| 255 EXPECT_TRUE(db.Init(file_)); | 281 ASSERT_TRUE(db.Init(file_)); |
| 256 | 282 |
| 257 std::vector<PasswordForm*> result; | 283 std::vector<PasswordForm*> result; |
| 258 | 284 |
| 259 // Verify the database is empty. | 285 // Verify the database is empty. |
| 260 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 286 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 261 EXPECT_EQ(0U, result.size()); | 287 EXPECT_EQ(0U, result.size()); |
| 262 | 288 |
| 263 // Example password form. | 289 // Example password form. |
| 264 PasswordForm form; | 290 PasswordForm form; |
| 265 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); | 291 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 404 |
| 379 // Make sure everything can disappear. | 405 // Make sure everything can disappear. |
| 380 EXPECT_TRUE(db.RemoveLogin(form4)); | 406 EXPECT_TRUE(db.RemoveLogin(form4)); |
| 381 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 407 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 382 EXPECT_EQ(0U, result.size()); | 408 EXPECT_EQ(0U, result.size()); |
| 383 } | 409 } |
| 384 | 410 |
| 385 TEST_F(WebDatabaseTest, Autofill) { | 411 TEST_F(WebDatabaseTest, Autofill) { |
| 386 WebDatabase db; | 412 WebDatabase db; |
| 387 | 413 |
| 388 EXPECT_TRUE(db.Init(file_)); | 414 ASSERT_TRUE(db.Init(file_)); |
| 389 | 415 |
| 390 Time t1 = Time::Now(); | 416 Time t1 = Time::Now(); |
| 391 | 417 |
| 392 // Simulate the submission of a handful of entries in a field called "Name", | 418 // Simulate the submission of a handful of entries in a field called "Name", |
| 393 // some more often than others. | 419 // some more often than others. |
| 394 EXPECT_TRUE(db.AddFormFieldValue( | 420 EXPECT_TRUE(db.AddFormFieldValue( |
| 395 FormField(string16(), | 421 FormField(string16(), |
| 396 ASCIIToUTF16("Name"), | 422 ASCIIToUTF16("Name"), |
| 397 string16(), | 423 string16(), |
| 398 ASCIIToUTF16("Superman")))); | 424 ASCIIToUTF16("Superman")))); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 EXPECT_TRUE(db.GetFormValuesForElementName( | 504 EXPECT_TRUE(db.GetFormValuesForElementName( |
| 479 ASCIIToUTF16("Name"), ASCIIToUTF16("cLa"), &v, 6)); | 505 ASCIIToUTF16("Name"), ASCIIToUTF16("cLa"), &v, 6)); |
| 480 EXPECT_EQ(2U, v.size()); | 506 EXPECT_EQ(2U, v.size()); |
| 481 if (v.size() == 2) { | 507 if (v.size() == 2) { |
| 482 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]); | 508 EXPECT_EQ(ASCIIToUTF16("Clark Kent"), v[0]); |
| 483 EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]); | 509 EXPECT_EQ(ASCIIToUTF16("Clark Sutter"), v[1]); |
| 484 } | 510 } |
| 485 | 511 |
| 486 // Removing all elements since the beginning of this function should remove | 512 // Removing all elements since the beginning of this function should remove |
| 487 // everything from the database. | 513 // everything from the database. |
| 488 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time())); | 514 std::vector<AutofillChange> changes; |
| 515 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, Time(), &changes)); |
| 516 |
| 517 const AutofillChange expected_changes[] = { |
| 518 AutofillChange(AutofillChange::REMOVE, |
| 519 AutofillKey(ASCIIToUTF16("Name"), |
| 520 ASCIIToUTF16("Superman"))), |
| 521 AutofillChange(AutofillChange::REMOVE, |
| 522 AutofillKey(ASCIIToUTF16("Name"), |
| 523 ASCIIToUTF16("Clark Kent"))), |
| 524 AutofillChange(AutofillChange::REMOVE, |
| 525 AutofillKey(ASCIIToUTF16("Name"), |
| 526 ASCIIToUTF16("Clark Sutter"))), |
| 527 AutofillChange(AutofillChange::REMOVE, |
| 528 AutofillKey(ASCIIToUTF16("Favorite Color"), |
| 529 ASCIIToUTF16("Green"))), |
| 530 }; |
| 531 EXPECT_EQ(arraysize(expected_changes), changes.size()); |
| 532 for (size_t i = 0; i < arraysize(expected_changes); i++) { |
| 533 EXPECT_EQ(expected_changes[i], changes[i]); |
| 534 } |
| 489 | 535 |
| 490 EXPECT_TRUE(db.GetIDAndCountOfFormElement( | 536 EXPECT_TRUE(db.GetIDAndCountOfFormElement( |
| 491 FormField(string16(), | 537 FormField(string16(), |
| 492 ASCIIToUTF16("Name"), | 538 ASCIIToUTF16("Name"), |
| 493 string16(), | 539 string16(), |
| 494 ASCIIToUTF16("Clark Kent")), | 540 ASCIIToUTF16("Clark Kent")), |
| 495 &pair_id, &count)); | 541 &pair_id, &count)); |
| 496 EXPECT_EQ(0, count); | 542 EXPECT_EQ(0, count); |
| 497 | 543 |
| 498 EXPECT_TRUE( | 544 EXPECT_TRUE( |
| (...skipping 30 matching lines...) Expand all Loading... |
| 529 db.ClearAutofillEmptyValueElements(); | 575 db.ClearAutofillEmptyValueElements(); |
| 530 | 576 |
| 531 v.clear(); | 577 v.clear(); |
| 532 EXPECT_TRUE(db.GetFormValuesForElementName(ASCIIToUTF16("blank"), | 578 EXPECT_TRUE(db.GetFormValuesForElementName(ASCIIToUTF16("blank"), |
| 533 string16(), &v, 10)); | 579 string16(), &v, 10)); |
| 534 ASSERT_EQ(1U, v.size()); | 580 ASSERT_EQ(1U, v.size()); |
| 535 | 581 |
| 536 EXPECT_EQ(kValue, v[0]); | 582 EXPECT_EQ(kValue, v[0]); |
| 537 } | 583 } |
| 538 | 584 |
| 585 TEST_F(WebDatabaseTest, Autofill_RemoveBetweenChanges) { |
| 586 WebDatabase db; |
| 587 ASSERT_TRUE(db.Init(file_)); |
| 588 |
| 589 TimeDelta one_day(TimeDelta::FromDays(1)); |
| 590 Time t1 = Time::Now(); |
| 591 Time t2 = t1 + one_day; |
| 592 |
| 593 EXPECT_TRUE(db.AddFormFieldValueTime( |
| 594 FormField(string16(), |
| 595 ASCIIToUTF16("Name"), |
| 596 string16(), |
| 597 ASCIIToUTF16("Superman")), |
| 598 t1)); |
| 599 EXPECT_TRUE(db.AddFormFieldValueTime( |
| 600 FormField(string16(), |
| 601 ASCIIToUTF16("Name"), |
| 602 string16(), |
| 603 ASCIIToUTF16("Superman")), |
| 604 t2)); |
| 605 |
| 606 std::vector<AutofillChange> changes; |
| 607 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t1, t2, &changes)); |
| 608 ASSERT_EQ(1U, changes.size()); |
| 609 EXPECT_EQ(AutofillChange(AutofillChange::UPDATE, |
| 610 AutofillKey(ASCIIToUTF16("Name"), |
| 611 ASCIIToUTF16("Superman"))), |
| 612 changes[0]); |
| 613 changes.clear(); |
| 614 |
| 615 EXPECT_TRUE(db.RemoveFormElementsAddedBetween(t2, t2 + one_day, &changes)); |
| 616 ASSERT_EQ(1U, changes.size()); |
| 617 EXPECT_EQ(AutofillChange(AutofillChange::REMOVE, |
| 618 AutofillKey(ASCIIToUTF16("Name"), |
| 619 ASCIIToUTF16("Superman"))), |
| 620 changes[0]); |
| 621 } |
| 622 |
| 539 static bool AddTimestampedLogin(WebDatabase* db, std::string url, | 623 static bool AddTimestampedLogin(WebDatabase* db, std::string url, |
| 540 const std::string& unique_string, | 624 const std::string& unique_string, |
| 541 const Time& time) { | 625 const Time& time) { |
| 542 // Example password form. | 626 // Example password form. |
| 543 PasswordForm form; | 627 PasswordForm form; |
| 544 form.origin = GURL(url + std::string("/LoginAuth")); | 628 form.origin = GURL(url + std::string("/LoginAuth")); |
| 545 form.username_element = ASCIIToUTF16(unique_string); | 629 form.username_element = ASCIIToUTF16(unique_string); |
| 546 form.username_value = ASCIIToUTF16(unique_string); | 630 form.username_value = ASCIIToUTF16(unique_string); |
| 547 form.password_element = ASCIIToUTF16(unique_string); | 631 form.password_element = ASCIIToUTF16(unique_string); |
| 548 form.submit_element = ASCIIToUTF16("signIn"); | 632 form.submit_element = ASCIIToUTF16("signIn"); |
| 549 form.signon_realm = url; | 633 form.signon_realm = url; |
| 550 form.date_created = time; | 634 form.date_created = time; |
| 551 return db->AddLogin(form); | 635 return db->AddLogin(form); |
| 552 } | 636 } |
| 553 | 637 |
| 554 static void ClearResults(std::vector<PasswordForm*>* results) { | 638 static void ClearResults(std::vector<PasswordForm*>* results) { |
| 555 for (size_t i = 0; i < results->size(); ++i) { | 639 for (size_t i = 0; i < results->size(); ++i) { |
| 556 delete (*results)[i]; | 640 delete (*results)[i]; |
| 557 } | 641 } |
| 558 results->clear(); | 642 results->clear(); |
| 559 } | 643 } |
| 560 | 644 |
| 561 TEST_F(WebDatabaseTest, ClearPrivateData_SavedPasswords) { | 645 TEST_F(WebDatabaseTest, ClearPrivateData_SavedPasswords) { |
| 562 WebDatabase db; | 646 WebDatabase db; |
| 563 | 647 |
| 564 EXPECT_TRUE(db.Init(file_)); | 648 ASSERT_TRUE(db.Init(file_)); |
| 565 | 649 |
| 566 std::vector<PasswordForm*> result; | 650 std::vector<PasswordForm*> result; |
| 567 | 651 |
| 568 // Verify the database is empty. | 652 // Verify the database is empty. |
| 569 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 653 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 570 EXPECT_EQ(0U, result.size()); | 654 EXPECT_EQ(0U, result.size()); |
| 571 | 655 |
| 572 Time now = Time::Now(); | 656 Time now = Time::Now(); |
| 573 TimeDelta one_day = TimeDelta::FromDays(1); | 657 TimeDelta one_day = TimeDelta::FromDays(1); |
| 574 | 658 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 596 db.RemoveLoginsCreatedBetween(Time(), Time()); | 680 db.RemoveLoginsCreatedBetween(Time(), Time()); |
| 597 | 681 |
| 598 // Verify nothing is left. | 682 // Verify nothing is left. |
| 599 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 683 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 600 EXPECT_EQ(0U, result.size()); | 684 EXPECT_EQ(0U, result.size()); |
| 601 } | 685 } |
| 602 | 686 |
| 603 TEST_F(WebDatabaseTest, BlacklistedLogins) { | 687 TEST_F(WebDatabaseTest, BlacklistedLogins) { |
| 604 WebDatabase db; | 688 WebDatabase db; |
| 605 | 689 |
| 606 EXPECT_TRUE(db.Init(file_)); | 690 ASSERT_TRUE(db.Init(file_)); |
| 607 std::vector<PasswordForm*> result; | 691 std::vector<PasswordForm*> result; |
| 608 | 692 |
| 609 // Verify the database is empty. | 693 // Verify the database is empty. |
| 610 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 694 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 611 ASSERT_EQ(0U, result.size()); | 695 ASSERT_EQ(0U, result.size()); |
| 612 | 696 |
| 613 // Save a form as blacklisted. | 697 // Save a form as blacklisted. |
| 614 PasswordForm form; | 698 PasswordForm form; |
| 615 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); | 699 form.origin = GURL("http://www.google.com/accounts/LoginAuth"); |
| 616 form.action = GURL("http://www.google.com/accounts/Login"); | 700 form.action = GURL("http://www.google.com/accounts/Login"); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 635 | 719 |
| 636 // So should GetAll including blacklisted. | 720 // So should GetAll including blacklisted. |
| 637 EXPECT_TRUE(db.GetAllLogins(&result, true)); | 721 EXPECT_TRUE(db.GetAllLogins(&result, true)); |
| 638 EXPECT_EQ(1U, result.size()); | 722 EXPECT_EQ(1U, result.size()); |
| 639 ClearResults(&result); | 723 ClearResults(&result); |
| 640 } | 724 } |
| 641 | 725 |
| 642 TEST_F(WebDatabaseTest, WebAppHasAllImages) { | 726 TEST_F(WebDatabaseTest, WebAppHasAllImages) { |
| 643 WebDatabase db; | 727 WebDatabase db; |
| 644 | 728 |
| 645 EXPECT_TRUE(db.Init(file_)); | 729 ASSERT_TRUE(db.Init(file_)); |
| 646 GURL url("http://google.com/"); | 730 GURL url("http://google.com/"); |
| 647 | 731 |
| 648 // Initial value for unknown web app should be false. | 732 // Initial value for unknown web app should be false. |
| 649 EXPECT_FALSE(db.GetWebAppHasAllImages(url)); | 733 EXPECT_FALSE(db.GetWebAppHasAllImages(url)); |
| 650 | 734 |
| 651 // Set the value and make sure it took. | 735 // Set the value and make sure it took. |
| 652 EXPECT_TRUE(db.SetWebAppHasAllImages(url, true)); | 736 EXPECT_TRUE(db.SetWebAppHasAllImages(url, true)); |
| 653 EXPECT_TRUE(db.GetWebAppHasAllImages(url)); | 737 EXPECT_TRUE(db.GetWebAppHasAllImages(url)); |
| 654 | 738 |
| 655 // Remove the app and make sure value reverts to default. | 739 // Remove the app and make sure value reverts to default. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 ASSERT_EQ(16, images[0].height()); | 807 ASSERT_EQ(16, images[0].height()); |
| 724 ASSERT_EQ(32, images[1].width()); | 808 ASSERT_EQ(32, images[1].width()); |
| 725 ASSERT_EQ(32, images[1].height()); | 809 ASSERT_EQ(32, images[1].height()); |
| 726 } else { | 810 } else { |
| 727 ASSERT_EQ(32, images[0].width()); | 811 ASSERT_EQ(32, images[0].width()); |
| 728 ASSERT_EQ(32, images[0].height()); | 812 ASSERT_EQ(32, images[0].height()); |
| 729 ASSERT_EQ(16, images[1].width()); | 813 ASSERT_EQ(16, images[1].width()); |
| 730 ASSERT_EQ(16, images[1].height()); | 814 ASSERT_EQ(16, images[1].height()); |
| 731 } | 815 } |
| 732 } | 816 } |
| OLD | NEW |