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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "chrome/browser/favicon/favicon_handler.h" | 6 #include "chrome/browser/favicon/favicon_handler.h" |
7 #include "chrome/browser/favicon/favicon_service_factory.h" | 7 #include "chrome/browser/favicon/favicon_service_factory.h" |
8 #include "chrome/browser/history/history_service_factory.h" | 8 #include "chrome/browser/history/history_service_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "ui/gfx/codec/png_codec.h" | 12 #include "ui/gfx/codec/png_codec.h" |
13 #include "ui/gfx/favicon_size.h" | 13 #include "ui/gfx/favicon_size.h" |
14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
15 | 15 |
16 class TestFaviconHandler; | 16 class TestFaviconHandler; |
17 | 17 |
18 using content::FaviconURL; | 18 using favicon::FaviconURL; |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Fill the given bmp with valid png data. | 22 // Fill the given bmp with valid png data. |
23 void FillDataToBitmap(int w, int h, SkBitmap* bmp) { | 23 void FillDataToBitmap(int w, int h, SkBitmap* bmp) { |
24 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 24 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
25 bmp->allocPixels(); | 25 bmp->allocPixels(); |
26 | 26 |
27 unsigned char* src_data = | 27 unsigned char* src_data = |
28 reinterpret_cast<unsigned char*>(bmp->getAddr32(0, 0)); | 28 reinterpret_cast<unsigned char*>(bmp->getAddr32(0, 0)); |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 496 |
497 // Send history response. | 497 // Send history response. |
498 history_handler->InvokeCallback(); | 498 history_handler->InvokeCallback(); |
499 // Verify FaviconHandler status | 499 // Verify FaviconHandler status |
500 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 500 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
501 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 501 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
502 | 502 |
503 // Simulates update favicon url. | 503 // Simulates update favicon url. |
504 std::vector<FaviconURL> urls; | 504 std::vector<FaviconURL> urls; |
505 urls.push_back( | 505 urls.push_back( |
506 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 506 FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
507 helper.OnUpdateFaviconURL(urls); | 507 helper.OnUpdateFaviconURL(urls); |
508 | 508 |
509 // Verify FaviconHandler status | 509 // Verify FaviconHandler status |
510 EXPECT_EQ(1U, helper.urls().size()); | 510 EXPECT_EQ(1U, helper.urls().size()); |
511 ASSERT_TRUE(helper.current_candidate()); | 511 ASSERT_TRUE(helper.current_candidate()); |
512 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); | 512 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); |
513 ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type); | 513 ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type); |
514 | 514 |
515 // Favicon shouldn't request to download icon. | 515 // Favicon shouldn't request to download icon. |
516 EXPECT_FALSE(helper.download_handler()->HasDownload()); | 516 EXPECT_FALSE(helper.download_handler()->HasDownload()); |
517 } | 517 } |
518 | 518 |
519 TEST_F(FaviconHandlerTest, DownloadFavicon) { | 519 TEST_F(FaviconHandlerTest, DownloadFavicon) { |
520 const GURL page_url("http://www.google.com"); | 520 const GURL page_url("http://www.google.com"); |
521 const GURL icon_url("http://www.google.com/favicon"); | 521 const GURL icon_url("http://www.google.com/favicon"); |
522 | 522 |
523 TestFaviconDriver driver; | 523 TestFaviconDriver driver; |
(...skipping 16 matching lines...) Expand all Loading... |
540 &history_handler->history_results_); | 540 &history_handler->history_results_); |
541 // Send history response. | 541 // Send history response. |
542 history_handler->InvokeCallback(); | 542 history_handler->InvokeCallback(); |
543 // Verify FaviconHandler status | 543 // Verify FaviconHandler status |
544 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 544 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
545 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 545 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
546 | 546 |
547 // Simulates update favicon url. | 547 // Simulates update favicon url. |
548 std::vector<FaviconURL> urls; | 548 std::vector<FaviconURL> urls; |
549 urls.push_back( | 549 urls.push_back( |
550 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 550 FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
551 helper.OnUpdateFaviconURL(urls); | 551 helper.OnUpdateFaviconURL(urls); |
552 | 552 |
553 // Verify FaviconHandler status | 553 // Verify FaviconHandler status |
554 EXPECT_EQ(1U, helper.urls().size()); | 554 EXPECT_EQ(1U, helper.urls().size()); |
555 ASSERT_TRUE(helper.current_candidate()); | 555 ASSERT_TRUE(helper.current_candidate()); |
556 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); | 556 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); |
557 ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type); | 557 ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type); |
558 | 558 |
559 // Favicon should request to download icon now. | 559 // Favicon should request to download icon now. |
560 DownloadHandler* download_handler = helper.download_handler(); | 560 DownloadHandler* download_handler = helper.download_handler(); |
561 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 561 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
562 | 562 |
563 // Verify the download request. | 563 // Verify the download request. |
564 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); | 564 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); |
565 | 565 |
566 // Reset the history_handler to verify whether favicon is set. | 566 // Reset the history_handler to verify whether favicon is set. |
567 helper.set_history_handler(NULL); | 567 helper.set_history_handler(NULL); |
568 | 568 |
569 // Smulates download done. | 569 // Smulates download done. |
570 download_handler->InvokeCallback(); | 570 download_handler->InvokeCallback(); |
571 | 571 |
572 // New icon should be saved to history backend and navigation entry. | 572 // New icon should be saved to history backend and navigation entry. |
573 history_handler = helper.history_handler(); | 573 history_handler = helper.history_handler(); |
574 ASSERT_TRUE(history_handler); | 574 ASSERT_TRUE(history_handler); |
575 EXPECT_EQ(icon_url, history_handler->icon_url_); | 575 EXPECT_EQ(icon_url, history_handler->icon_url_); |
576 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 576 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
577 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 577 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
578 EXPECT_EQ(page_url, history_handler->page_url_); | 578 EXPECT_EQ(page_url, history_handler->page_url_); |
579 | 579 |
580 // Verify NavigationEntry. | 580 // Verify NavigationEntry. |
581 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 581 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
582 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 582 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
583 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); | 583 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
584 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); | 584 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
585 } | 585 } |
586 | 586 |
(...skipping 23 matching lines...) Expand all Loading... |
610 // Verify FaviconHandler status. | 610 // Verify FaviconHandler status. |
611 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 611 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
612 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 612 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
613 | 613 |
614 // Reset the history_handler to verify whether new icon is requested from | 614 // Reset the history_handler to verify whether new icon is requested from |
615 // history. | 615 // history. |
616 helper.set_history_handler(NULL); | 616 helper.set_history_handler(NULL); |
617 | 617 |
618 // Simulates update with the different favicon url. | 618 // Simulates update with the different favicon url. |
619 std::vector<FaviconURL> urls; | 619 std::vector<FaviconURL> urls; |
620 urls.push_back( | 620 urls.push_back(FaviconURL( |
621 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 621 new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
622 helper.OnUpdateFaviconURL(urls); | 622 helper.OnUpdateFaviconURL(urls); |
623 | 623 |
624 // Verify FaviconHandler status. | 624 // Verify FaviconHandler status. |
625 EXPECT_EQ(1U, helper.urls().size()); | 625 EXPECT_EQ(1U, helper.urls().size()); |
626 ASSERT_TRUE(helper.current_candidate()); | 626 ASSERT_TRUE(helper.current_candidate()); |
627 ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url); | 627 ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url); |
628 ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type); | 628 ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type); |
629 | 629 |
630 // Favicon should be requested from history. | 630 // Favicon should be requested from history. |
631 history_handler = helper.history_handler(); | 631 history_handler = helper.history_handler(); |
632 ASSERT_TRUE(history_handler); | 632 ASSERT_TRUE(history_handler); |
633 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 633 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
634 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 634 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
635 EXPECT_EQ(page_url, history_handler->page_url_); | 635 EXPECT_EQ(page_url, history_handler->page_url_); |
636 | 636 |
637 // Simulate not find icon. | 637 // Simulate not find icon. |
638 history_handler->history_results_.clear(); | 638 history_handler->history_results_.clear(); |
639 history_handler->InvokeCallback(); | 639 history_handler->InvokeCallback(); |
640 | 640 |
641 // Favicon should request to download icon now. | 641 // Favicon should request to download icon now. |
642 DownloadHandler* download_handler = helper.download_handler(); | 642 DownloadHandler* download_handler = helper.download_handler(); |
643 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 643 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
644 | 644 |
645 // Verify the download request. | 645 // Verify the download request. |
646 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl()); | 646 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl()); |
647 | 647 |
648 // Reset the history_handler to verify whether favicon is set. | 648 // Reset the history_handler to verify whether favicon is set. |
649 helper.set_history_handler(NULL); | 649 helper.set_history_handler(NULL); |
650 | 650 |
651 // Smulates download done. | 651 // Smulates download done. |
652 download_handler->InvokeCallback(); | 652 download_handler->InvokeCallback(); |
653 | 653 |
654 // New icon should be saved to history backend and navigation entry. | 654 // New icon should be saved to history backend and navigation entry. |
655 history_handler = helper.history_handler(); | 655 history_handler = helper.history_handler(); |
656 ASSERT_TRUE(history_handler); | 656 ASSERT_TRUE(history_handler); |
657 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 657 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
658 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 658 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
659 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 659 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
660 EXPECT_EQ(page_url, history_handler->page_url_); | 660 EXPECT_EQ(page_url, history_handler->page_url_); |
661 | 661 |
662 // Verify NavigationEntry. | 662 // Verify NavigationEntry. |
663 EXPECT_EQ(new_icon_url, driver.GetActiveFaviconURL()); | 663 EXPECT_EQ(new_icon_url, driver.GetActiveFaviconURL()); |
664 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 664 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
665 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); | 665 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
666 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); | 666 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
667 } | 667 } |
668 | 668 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 EXPECT_FALSE(driver.GetActiveFaviconValidity()); | 700 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
701 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); | 701 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
702 | 702 |
703 // Reset the history_handler to verify whether new icon is requested from | 703 // Reset the history_handler to verify whether new icon is requested from |
704 // history. | 704 // history. |
705 helper.set_history_handler(NULL); | 705 helper.set_history_handler(NULL); |
706 | 706 |
707 // Simulates update with matching favicon URL. | 707 // Simulates update with matching favicon URL. |
708 std::vector<FaviconURL> urls; | 708 std::vector<FaviconURL> urls; |
709 urls.push_back( | 709 urls.push_back( |
710 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 710 FaviconURL(icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
711 helper.OnUpdateFaviconURL(urls); | 711 helper.OnUpdateFaviconURL(urls); |
712 | 712 |
713 // A download for the favicon should be requested, and we should not do | 713 // A download for the favicon should be requested, and we should not do |
714 // another history request. | 714 // another history request. |
715 DownloadHandler* download_handler = helper.download_handler(); | 715 DownloadHandler* download_handler = helper.download_handler(); |
716 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 716 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
717 EXPECT_EQ(NULL, helper.history_handler()); | 717 EXPECT_EQ(NULL, helper.history_handler()); |
718 | 718 |
719 // Verify the download request. | 719 // Verify the download request. |
720 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); | 720 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); |
721 | 721 |
722 // Simulates download done. | 722 // Simulates download done. |
723 download_handler->InvokeCallback(); | 723 download_handler->InvokeCallback(); |
724 | 724 |
725 // New icon should be saved to history backend and navigation entry. | 725 // New icon should be saved to history backend and navigation entry. |
726 history_handler = helper.history_handler(); | 726 history_handler = helper.history_handler(); |
727 ASSERT_TRUE(history_handler); | 727 ASSERT_TRUE(history_handler); |
728 EXPECT_EQ(icon_url, history_handler->icon_url_); | 728 EXPECT_EQ(icon_url, history_handler->icon_url_); |
729 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 729 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
730 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 730 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
731 EXPECT_EQ(page_url, history_handler->page_url_); | 731 EXPECT_EQ(page_url, history_handler->page_url_); |
732 | 732 |
733 // Verify NavigationEntry. | 733 // Verify NavigationEntry. |
734 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 734 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
735 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 735 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
736 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); | 736 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
737 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); | 737 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
738 } | 738 } |
739 | 739 |
(...skipping 22 matching lines...) Expand all Loading... |
762 // Verify FaviconHandler status. | 762 // Verify FaviconHandler status. |
763 EXPECT_TRUE(driver.GetActiveFaviconValidity()); | 763 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
764 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); | 764 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
765 | 765 |
766 // Reset the history_handler to verify whether new icon is requested from | 766 // Reset the history_handler to verify whether new icon is requested from |
767 // history. | 767 // history. |
768 helper.set_history_handler(NULL); | 768 helper.set_history_handler(NULL); |
769 | 769 |
770 // Simulates update with the different favicon url. | 770 // Simulates update with the different favicon url. |
771 std::vector<FaviconURL> urls; | 771 std::vector<FaviconURL> urls; |
772 urls.push_back( | 772 urls.push_back(FaviconURL( |
773 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 773 new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
774 helper.OnUpdateFaviconURL(urls); | 774 helper.OnUpdateFaviconURL(urls); |
775 | 775 |
776 // Verify FaviconHandler status. | 776 // Verify FaviconHandler status. |
777 EXPECT_EQ(1U, helper.urls().size()); | 777 EXPECT_EQ(1U, helper.urls().size()); |
778 ASSERT_TRUE(helper.current_candidate()); | 778 ASSERT_TRUE(helper.current_candidate()); |
779 ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url); | 779 ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url); |
780 ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type); | 780 ASSERT_EQ(favicon_base::FAVICON, helper.current_candidate()->icon_type); |
781 | 781 |
782 // Favicon should be requested from history. | 782 // Favicon should be requested from history. |
783 history_handler = helper.history_handler(); | 783 history_handler = helper.history_handler(); |
784 ASSERT_TRUE(history_handler); | 784 ASSERT_TRUE(history_handler); |
785 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 785 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
786 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 786 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
787 EXPECT_EQ(page_url, history_handler->page_url_); | 787 EXPECT_EQ(page_url, history_handler->page_url_); |
788 | 788 |
789 // Simulate find icon. | 789 // Simulate find icon. |
790 SetFaviconBitmapResult(new_icon_url, &history_handler->history_results_); | 790 SetFaviconBitmapResult(new_icon_url, &history_handler->history_results_); |
791 history_handler->InvokeCallback(); | 791 history_handler->InvokeCallback(); |
792 | 792 |
793 // Shouldn't request download favicon | 793 // Shouldn't request download favicon |
794 EXPECT_FALSE(helper.download_handler()->HasDownload()); | 794 EXPECT_FALSE(helper.download_handler()->HasDownload()); |
795 | 795 |
796 // Verify the favicon status. | 796 // Verify the favicon status. |
(...skipping 28 matching lines...) Expand all Loading... |
825 // Verify FaviconHandler status. | 825 // Verify FaviconHandler status. |
826 EXPECT_FALSE(driver.GetActiveFaviconValidity()); | 826 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
827 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); | 827 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
828 | 828 |
829 // Reset the history_handler to verify whether new icon is requested from | 829 // Reset the history_handler to verify whether new icon is requested from |
830 // history. | 830 // history. |
831 helper.set_history_handler(NULL); | 831 helper.set_history_handler(NULL); |
832 | 832 |
833 // Simulates update with the different favicon url. | 833 // Simulates update with the different favicon url. |
834 std::vector<FaviconURL> urls; | 834 std::vector<FaviconURL> urls; |
| 835 urls.push_back(FaviconURL(icon_url, |
| 836 favicon_base::TOUCH_PRECOMPOSED_ICON, |
| 837 std::vector<gfx::Size>())); |
835 urls.push_back(FaviconURL( | 838 urls.push_back(FaviconURL( |
836 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); | 839 new_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>())); |
837 urls.push_back(FaviconURL( | 840 urls.push_back(FaviconURL( |
838 new_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>())); | 841 new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
839 urls.push_back( | |
840 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | |
841 helper.OnUpdateFaviconURL(urls); | 842 helper.OnUpdateFaviconURL(urls); |
842 | 843 |
843 // Verify FaviconHandler status. | 844 // Verify FaviconHandler status. |
844 EXPECT_EQ(2U, helper.urls().size()); | 845 EXPECT_EQ(2U, helper.urls().size()); |
845 ASSERT_TRUE(helper.current_candidate()); | 846 ASSERT_TRUE(helper.current_candidate()); |
846 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); | 847 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); |
847 ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, | 848 ASSERT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, |
848 helper.current_candidate()->icon_type); | 849 helper.current_candidate()->icon_type); |
849 | 850 |
850 // Favicon should be requested from history. | 851 // Favicon should be requested from history. |
851 history_handler = helper.history_handler(); | 852 history_handler = helper.history_handler(); |
852 ASSERT_TRUE(history_handler); | 853 ASSERT_TRUE(history_handler); |
853 EXPECT_EQ(icon_url, history_handler->icon_url_); | 854 EXPECT_EQ(icon_url, history_handler->icon_url_); |
854 EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_); | 855 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_); |
855 EXPECT_EQ(page_url, history_handler->page_url_); | 856 EXPECT_EQ(page_url, history_handler->page_url_); |
856 | 857 |
857 // Simulate not find icon. | 858 // Simulate not find icon. |
858 history_handler->history_results_.clear(); | 859 history_handler->history_results_.clear(); |
859 history_handler->InvokeCallback(); | 860 history_handler->InvokeCallback(); |
860 | 861 |
861 // Should request download favicon. | 862 // Should request download favicon. |
862 DownloadHandler* download_handler = helper.download_handler(); | 863 DownloadHandler* download_handler = helper.download_handler(); |
863 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 864 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
864 | 865 |
865 // Verify the download request. | 866 // Verify the download request. |
866 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); | 867 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); |
867 | 868 |
868 // Reset the history_handler to verify whether favicon is request from | 869 // Reset the history_handler to verify whether favicon is request from |
869 // history. | 870 // history. |
870 helper.set_history_handler(NULL); | 871 helper.set_history_handler(NULL); |
871 // Smulates download failed. | 872 // Smulates download failed. |
872 download_handler->set_failed(true); | 873 download_handler->set_failed(true); |
873 download_handler->InvokeCallback(); | 874 download_handler->InvokeCallback(); |
874 | 875 |
875 // Left 1 url. | 876 // Left 1 url. |
876 EXPECT_EQ(1U, helper.urls().size()); | 877 EXPECT_EQ(1U, helper.urls().size()); |
877 ASSERT_TRUE(helper.current_candidate()); | 878 ASSERT_TRUE(helper.current_candidate()); |
878 EXPECT_EQ(new_icon_url, helper.current_candidate()->icon_url); | 879 EXPECT_EQ(new_icon_url, helper.current_candidate()->icon_url); |
879 EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type); | 880 EXPECT_EQ(favicon_base::TOUCH_ICON, helper.current_candidate()->icon_type); |
880 | 881 |
881 // Favicon should be requested from history. | 882 // Favicon should be requested from history. |
882 history_handler = helper.history_handler(); | 883 history_handler = helper.history_handler(); |
883 ASSERT_TRUE(history_handler); | 884 ASSERT_TRUE(history_handler); |
884 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 885 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
885 EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_); | 886 EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_); |
886 EXPECT_EQ(page_url, history_handler->page_url_); | 887 EXPECT_EQ(page_url, history_handler->page_url_); |
887 | 888 |
888 // Reset download handler | 889 // Reset download handler |
889 download_handler->Reset(); | 890 download_handler->Reset(); |
890 | 891 |
891 // Simulates getting a expired icon from history. | 892 // Simulates getting a expired icon from history. |
892 SetFaviconBitmapResult(new_icon_url, | 893 SetFaviconBitmapResult(new_icon_url, |
893 favicon_base::TOUCH_ICON, | 894 favicon_base::TOUCH_ICON, |
894 true /* expired */, | 895 true /* expired */, |
895 &history_handler->history_results_); | 896 &history_handler->history_results_); |
896 history_handler->InvokeCallback(); | 897 history_handler->InvokeCallback(); |
897 | 898 |
898 // Verify the download request. | 899 // Verify the download request. |
899 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 900 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
900 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl()); | 901 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl()); |
901 | 902 |
902 helper.set_history_handler(NULL); | 903 helper.set_history_handler(NULL); |
903 | 904 |
904 // Simulates icon being downloaded. | 905 // Simulates icon being downloaded. |
905 download_handler->InvokeCallback(); | 906 download_handler->InvokeCallback(); |
906 | 907 |
907 // New icon should be saved to history backend. | 908 // New icon should be saved to history backend. |
908 history_handler = helper.history_handler(); | 909 history_handler = helper.history_handler(); |
909 ASSERT_TRUE(history_handler); | 910 ASSERT_TRUE(history_handler); |
910 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 911 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
911 EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_); | 912 EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_); |
912 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 913 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
913 EXPECT_EQ(page_url, history_handler->page_url_); | 914 EXPECT_EQ(page_url, history_handler->page_url_); |
914 } | 915 } |
915 | 916 |
916 TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { | 917 TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { |
917 const GURL page_url("http://www.google.com"); | 918 const GURL page_url("http://www.google.com"); |
918 const GURL icon_url("http://www.google.com/favicon"); | 919 const GURL icon_url("http://www.google.com/favicon"); |
919 const GURL new_icon_url("http://www.google.com/new_favicon"); | 920 const GURL new_icon_url("http://www.google.com/new_favicon"); |
920 | 921 |
921 TestFaviconDriver driver; | 922 TestFaviconDriver driver; |
(...skipping 17 matching lines...) Expand all Loading... |
939 // Verify FaviconHandler status. | 940 // Verify FaviconHandler status. |
940 EXPECT_FALSE(driver.GetActiveFaviconValidity()); | 941 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
941 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); | 942 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
942 | 943 |
943 // Reset the history_handler to verify whether new icon is requested from | 944 // Reset the history_handler to verify whether new icon is requested from |
944 // history. | 945 // history. |
945 helper.set_history_handler(NULL); | 946 helper.set_history_handler(NULL); |
946 | 947 |
947 // Simulates update with the different favicon url. | 948 // Simulates update with the different favicon url. |
948 std::vector<FaviconURL> urls; | 949 std::vector<FaviconURL> urls; |
| 950 urls.push_back(FaviconURL(icon_url, |
| 951 favicon_base::TOUCH_PRECOMPOSED_ICON, |
| 952 std::vector<gfx::Size>())); |
949 urls.push_back(FaviconURL( | 953 urls.push_back(FaviconURL( |
950 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); | 954 new_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>())); |
951 urls.push_back(FaviconURL( | 955 urls.push_back(FaviconURL( |
952 new_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>())); | 956 new_icon_url, favicon_base::FAVICON, std::vector<gfx::Size>())); |
953 urls.push_back( | |
954 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | |
955 helper.OnUpdateFaviconURL(urls); | 957 helper.OnUpdateFaviconURL(urls); |
956 | 958 |
957 // Verify FaviconHandler status. | 959 // Verify FaviconHandler status. |
958 EXPECT_EQ(2U, helper.urls().size()); | 960 EXPECT_EQ(2U, helper.urls().size()); |
959 ASSERT_TRUE(helper.current_candidate()); | 961 ASSERT_TRUE(helper.current_candidate()); |
960 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); | 962 ASSERT_EQ(icon_url, helper.current_candidate()->icon_url); |
961 ASSERT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, | 963 ASSERT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, |
962 helper.current_candidate()->icon_type); | 964 helper.current_candidate()->icon_type); |
963 | 965 |
964 // Favicon should be requested from history. | 966 // Favicon should be requested from history. |
965 history_handler = helper.history_handler(); | 967 history_handler = helper.history_handler(); |
966 ASSERT_TRUE(history_handler); | 968 ASSERT_TRUE(history_handler); |
967 EXPECT_EQ(icon_url, history_handler->icon_url_); | 969 EXPECT_EQ(icon_url, history_handler->icon_url_); |
968 EXPECT_EQ(FaviconURL::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_); | 970 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON, history_handler->icon_type_); |
969 EXPECT_EQ(page_url, history_handler->page_url_); | 971 EXPECT_EQ(page_url, history_handler->page_url_); |
970 | 972 |
971 // Simulate not find icon. | 973 // Simulate not find icon. |
972 history_handler->history_results_.clear(); | 974 history_handler->history_results_.clear(); |
973 history_handler->InvokeCallback(); | 975 history_handler->InvokeCallback(); |
974 | 976 |
975 // Should request download favicon. | 977 // Should request download favicon. |
976 DownloadHandler* download_handler = helper.download_handler(); | 978 DownloadHandler* download_handler = helper.download_handler(); |
977 EXPECT_TRUE(helper.download_handler()->HasDownload()); | 979 EXPECT_TRUE(helper.download_handler()->HasDownload()); |
978 | 980 |
979 // Verify the download request. | 981 // Verify the download request. |
980 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); | 982 EXPECT_EQ(icon_url, download_handler->GetImageUrl()); |
981 | 983 |
982 // Reset the history_handler to verify whether favicon is request from | 984 // Reset the history_handler to verify whether favicon is request from |
983 // history. | 985 // history. |
984 helper.set_history_handler(NULL); | 986 helper.set_history_handler(NULL); |
985 const GURL latest_icon_url("http://www.google.com/latest_favicon"); | 987 const GURL latest_icon_url("http://www.google.com/latest_favicon"); |
986 std::vector<FaviconURL> latest_urls; | 988 std::vector<FaviconURL> latest_urls; |
987 latest_urls.push_back(FaviconURL( | 989 latest_urls.push_back(FaviconURL( |
988 latest_icon_url, FaviconURL::TOUCH_ICON, std::vector<gfx::Size>())); | 990 latest_icon_url, favicon_base::TOUCH_ICON, std::vector<gfx::Size>())); |
989 helper.OnUpdateFaviconURL(latest_urls); | 991 helper.OnUpdateFaviconURL(latest_urls); |
990 | 992 |
991 EXPECT_EQ(1U, helper.urls().size()); | 993 EXPECT_EQ(1U, helper.urls().size()); |
992 EXPECT_EQ(latest_icon_url, helper.current_candidate()->icon_url); | 994 EXPECT_EQ(latest_icon_url, helper.current_candidate()->icon_url); |
993 EXPECT_EQ(FaviconURL::TOUCH_ICON, helper.current_candidate()->icon_type); | 995 EXPECT_EQ(favicon_base::TOUCH_ICON, helper.current_candidate()->icon_type); |
994 | 996 |
995 // Whether new icon is requested from history | 997 // Whether new icon is requested from history |
996 history_handler = helper.history_handler(); | 998 history_handler = helper.history_handler(); |
997 ASSERT_TRUE(history_handler); | 999 ASSERT_TRUE(history_handler); |
998 EXPECT_EQ(latest_icon_url, history_handler->icon_url_); | 1000 EXPECT_EQ(latest_icon_url, history_handler->icon_url_); |
999 EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_); | 1001 EXPECT_EQ(favicon_base::TOUCH_ICON, history_handler->icon_type_); |
1000 EXPECT_EQ(page_url, history_handler->page_url_); | 1002 EXPECT_EQ(page_url, history_handler->page_url_); |
1001 | 1003 |
1002 // Reset the history_handler to verify whether favicon is request from | 1004 // Reset the history_handler to verify whether favicon is request from |
1003 // history. | 1005 // history. |
1004 // Save the callback for late use. | 1006 // Save the callback for late use. |
1005 FaviconService::FaviconResultsCallback callback = history_handler->callback_; | 1007 FaviconService::FaviconResultsCallback callback = history_handler->callback_; |
1006 helper.set_history_handler(NULL); | 1008 helper.set_history_handler(NULL); |
1007 | 1009 |
1008 // Simulates download succeed. | 1010 // Simulates download succeed. |
1009 download_handler->InvokeCallback(); | 1011 download_handler->InvokeCallback(); |
(...skipping 19 matching lines...) Expand all Loading... |
1029 #if !defined(OS_ANDROID) | 1031 #if !defined(OS_ANDROID) |
1030 | 1032 |
1031 // Test the favicon which is selected when the web page provides several | 1033 // Test the favicon which is selected when the web page provides several |
1032 // favicons and none of the favicons are cached in history. | 1034 // favicons and none of the favicons are cached in history. |
1033 // The goal of this test is to be more of an integration test than | 1035 // The goal of this test is to be more of an integration test than |
1034 // SelectFaviconFramesTest.*. | 1036 // SelectFaviconFramesTest.*. |
1035 TEST_F(FaviconHandlerTest, MultipleFavicons) { | 1037 TEST_F(FaviconHandlerTest, MultipleFavicons) { |
1036 const GURL kPageURL("http://www.google.com"); | 1038 const GURL kPageURL("http://www.google.com"); |
1037 const FaviconURL kSourceIconURLs[] = { | 1039 const FaviconURL kSourceIconURLs[] = { |
1038 FaviconURL(GURL("http://www.google.com/a"), | 1040 FaviconURL(GURL("http://www.google.com/a"), |
1039 FaviconURL::FAVICON, | 1041 favicon_base::FAVICON, |
1040 std::vector<gfx::Size>()), | 1042 std::vector<gfx::Size>()), |
1041 FaviconURL(GURL("http://www.google.com/b"), | 1043 FaviconURL(GURL("http://www.google.com/b"), |
1042 FaviconURL::FAVICON, | 1044 favicon_base::FAVICON, |
1043 std::vector<gfx::Size>()), | 1045 std::vector<gfx::Size>()), |
1044 FaviconURL(GURL("http://www.google.com/c"), | 1046 FaviconURL(GURL("http://www.google.com/c"), |
1045 FaviconURL::FAVICON, | 1047 favicon_base::FAVICON, |
1046 std::vector<gfx::Size>()), | 1048 std::vector<gfx::Size>()), |
1047 FaviconURL(GURL("http://www.google.com/d"), | 1049 FaviconURL(GURL("http://www.google.com/d"), |
1048 FaviconURL::FAVICON, | 1050 favicon_base::FAVICON, |
1049 std::vector<gfx::Size>()), | 1051 std::vector<gfx::Size>()), |
1050 FaviconURL(GURL("http://www.google.com/e"), | 1052 FaviconURL(GURL("http://www.google.com/e"), |
1051 FaviconURL::FAVICON, | 1053 favicon_base::FAVICON, |
1052 std::vector<gfx::Size>())}; | 1054 std::vector<gfx::Size>())}; |
1053 | 1055 |
1054 // Set the supported scale factors to 1x and 2x. This affects the behavior of | 1056 // Set the supported scale factors to 1x and 2x. This affects the behavior of |
1055 // SelectFaviconFrames(). | 1057 // SelectFaviconFrames(). |
1056 std::vector<ui::ScaleFactor> scale_factors; | 1058 std::vector<ui::ScaleFactor> scale_factors; |
1057 scale_factors.push_back(ui::SCALE_FACTOR_100P); | 1059 scale_factors.push_back(ui::SCALE_FACTOR_100P); |
1058 scale_factors.push_back(ui::SCALE_FACTOR_200P); | 1060 scale_factors.push_back(ui::SCALE_FACTOR_200P); |
1059 ui::test::ScopedSetSupportedScaleFactors scoped_supported(scale_factors); | 1061 ui::test::ScopedSetSupportedScaleFactors scoped_supported(scale_factors); |
1060 | 1062 |
1061 // 1) Test that if there are several single resolution favicons to choose from | 1063 // 1) Test that if there are several single resolution favicons to choose from |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 | 1139 |
1138 std::vector<gfx::Size> icon2; | 1140 std::vector<gfx::Size> icon2; |
1139 icon2.push_back(gfx::Size(15, 15)); | 1141 icon2.push_back(gfx::Size(15, 15)); |
1140 icon2.push_back(gfx::Size(16, 16)); | 1142 icon2.push_back(gfx::Size(16, 16)); |
1141 | 1143 |
1142 std::vector<gfx::Size> icon3; | 1144 std::vector<gfx::Size> icon3; |
1143 icon3.push_back(gfx::Size(16, 16)); | 1145 icon3.push_back(gfx::Size(16, 16)); |
1144 icon3.push_back(gfx::Size(14, 14)); | 1146 icon3.push_back(gfx::Size(14, 14)); |
1145 | 1147 |
1146 const FaviconURL kSourceIconURLs[] = { | 1148 const FaviconURL kSourceIconURLs[] = { |
1147 FaviconURL(GURL("http://www.google.com/a"), | 1149 FaviconURL(GURL("http://www.google.com/a"), favicon_base::FAVICON, icon1), |
1148 FaviconURL::FAVICON, | 1150 FaviconURL(GURL("http://www.google.com/b"), favicon_base::FAVICON, icon2), |
1149 icon1), | 1151 FaviconURL(GURL("http://www.google.com/c"), favicon_base::FAVICON, icon3), |
1150 FaviconURL(GURL("http://www.google.com/b"), | |
1151 FaviconURL::FAVICON, | |
1152 icon2), | |
1153 FaviconURL(GURL("http://www.google.com/c"), | |
1154 FaviconURL::FAVICON, | |
1155 icon3), | |
1156 FaviconURL(GURL("http://www.google.com/d"), | 1152 FaviconURL(GURL("http://www.google.com/d"), |
1157 FaviconURL::FAVICON, | 1153 favicon_base::FAVICON, |
1158 std::vector<gfx::Size>()), | 1154 std::vector<gfx::Size>()), |
1159 FaviconURL(GURL("http://www.google.com/e"), | 1155 FaviconURL(GURL("http://www.google.com/e"), |
1160 FaviconURL::FAVICON, | 1156 favicon_base::FAVICON, |
1161 std::vector<gfx::Size>())}; | 1157 std::vector<gfx::Size>())}; |
1162 | 1158 |
1163 TestFaviconClient client; | 1159 TestFaviconClient client; |
1164 TestFaviconDriver driver1; | 1160 TestFaviconDriver driver1; |
1165 TestFaviconHandler handler1( | 1161 TestFaviconHandler handler1( |
1166 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); | 1162 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); |
1167 std::vector<FaviconURL> urls1(kSourceIconURLs, | 1163 std::vector<FaviconURL> urls1(kSourceIconURLs, |
1168 kSourceIconURLs + arraysize(kSourceIconURLs)); | 1164 kSourceIconURLs + arraysize(kSourceIconURLs)); |
1169 UpdateFaviconURL(&handler1, kPageURL, urls1); | 1165 UpdateFaviconURL(&handler1, kPageURL, urls1); |
1170 | 1166 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 | 1198 |
1203 std::vector<gfx::Size> one_icon; | 1199 std::vector<gfx::Size> one_icon; |
1204 one_icon.push_back(gfx::Size(15, 15)); | 1200 one_icon.push_back(gfx::Size(15, 15)); |
1205 one_icon.push_back(gfx::Size(512, 512)); | 1201 one_icon.push_back(gfx::Size(512, 512)); |
1206 | 1202 |
1207 std::vector<gfx::Size> two_icons; | 1203 std::vector<gfx::Size> two_icons; |
1208 two_icons.push_back(gfx::Size(16, 16)); | 1204 two_icons.push_back(gfx::Size(16, 16)); |
1209 two_icons.push_back(gfx::Size(14, 14)); | 1205 two_icons.push_back(gfx::Size(14, 14)); |
1210 | 1206 |
1211 const FaviconURL kSourceIconURLs[] = { | 1207 const FaviconURL kSourceIconURLs[] = { |
1212 FaviconURL(GURL("http://www.google.com/a"), | 1208 FaviconURL( |
1213 FaviconURL::FAVICON, | 1209 GURL("http://www.google.com/a"), favicon_base::FAVICON, too_large), |
1214 too_large), | 1210 FaviconURL( |
1215 FaviconURL(GURL("http://www.google.com/b"), | 1211 GURL("http://www.google.com/b"), favicon_base::FAVICON, one_icon), |
1216 FaviconURL::FAVICON, | 1212 FaviconURL( |
1217 one_icon), | 1213 GURL("http://www.google.com/c"), favicon_base::FAVICON, two_icons), |
1218 FaviconURL(GURL("http://www.google.com/c"), | |
1219 FaviconURL::FAVICON, | |
1220 two_icons), | |
1221 FaviconURL(GURL("http://www.google.com/d"), | 1214 FaviconURL(GURL("http://www.google.com/d"), |
1222 FaviconURL::FAVICON, | 1215 favicon_base::FAVICON, |
1223 std::vector<gfx::Size>()), | 1216 std::vector<gfx::Size>()), |
1224 FaviconURL(GURL("http://www.google.com/e"), | 1217 FaviconURL(GURL("http://www.google.com/e"), |
1225 FaviconURL::FAVICON, | 1218 favicon_base::FAVICON, |
1226 std::vector<gfx::Size>())}; | 1219 std::vector<gfx::Size>())}; |
1227 | 1220 |
1228 TestFaviconClient client; | 1221 TestFaviconClient client; |
1229 TestFaviconDriver driver1; | 1222 TestFaviconDriver driver1; |
1230 TestFaviconHandler handler1( | 1223 TestFaviconHandler handler1( |
1231 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); | 1224 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); |
1232 std::vector<FaviconURL> urls1(kSourceIconURLs, | 1225 std::vector<FaviconURL> urls1(kSourceIconURLs, |
1233 kSourceIconURLs + arraysize(kSourceIconURLs)); | 1226 kSourceIconURLs + arraysize(kSourceIconURLs)); |
1234 UpdateFaviconURL(&handler1, kPageURL, urls1); | 1227 UpdateFaviconURL(&handler1, kPageURL, urls1); |
1235 | 1228 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 const GURL kPageURL("http://www.google.com"); | 1276 const GURL kPageURL("http://www.google.com"); |
1284 | 1277 |
1285 std::vector<gfx::Size> one_icon; | 1278 std::vector<gfx::Size> one_icon; |
1286 one_icon.push_back(gfx::Size(15, 15)); | 1279 one_icon.push_back(gfx::Size(15, 15)); |
1287 | 1280 |
1288 std::vector<gfx::Size> two_icons; | 1281 std::vector<gfx::Size> two_icons; |
1289 two_icons.push_back(gfx::Size(14, 14)); | 1282 two_icons.push_back(gfx::Size(14, 14)); |
1290 two_icons.push_back(gfx::Size(16, 16)); | 1283 two_icons.push_back(gfx::Size(16, 16)); |
1291 | 1284 |
1292 const FaviconURL kSourceIconURLs[] = { | 1285 const FaviconURL kSourceIconURLs[] = { |
1293 FaviconURL(GURL("http://www.google.com/b"), | 1286 FaviconURL( |
1294 FaviconURL::FAVICON, | 1287 GURL("http://www.google.com/b"), favicon_base::FAVICON, one_icon), |
1295 one_icon), | 1288 FaviconURL( |
1296 FaviconURL(GURL("http://www.google.com/c"), | 1289 GURL("http://www.google.com/c"), favicon_base::FAVICON, two_icons)}; |
1297 FaviconURL::FAVICON, | |
1298 two_icons)}; | |
1299 | 1290 |
1300 TestFaviconClient client; | 1291 TestFaviconClient client; |
1301 TestFaviconDriver driver1; | 1292 TestFaviconDriver driver1; |
1302 TestFaviconHandler handler1( | 1293 TestFaviconHandler handler1( |
1303 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); | 1294 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); |
1304 std::vector<FaviconURL> urls1(kSourceIconURLs, | 1295 std::vector<FaviconURL> urls1(kSourceIconURLs, |
1305 kSourceIconURLs + arraysize(kSourceIconURLs)); | 1296 kSourceIconURLs + arraysize(kSourceIconURLs)); |
1306 UpdateFaviconURL(&handler1, kPageURL, urls1); | 1297 UpdateFaviconURL(&handler1, kPageURL, urls1); |
1307 | 1298 |
1308 ASSERT_EQ(2u, handler1.urls().size()); | 1299 ASSERT_EQ(2u, handler1.urls().size()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1339 |
1349 std::vector<gfx::Size> icon1; | 1340 std::vector<gfx::Size> icon1; |
1350 icon1.push_back(gfx::Size(16, 16)); | 1341 icon1.push_back(gfx::Size(16, 16)); |
1351 const int actual_size1 = 10; | 1342 const int actual_size1 = 10; |
1352 | 1343 |
1353 std::vector<gfx::Size> icon2; | 1344 std::vector<gfx::Size> icon2; |
1354 icon2.push_back(gfx::Size(15, 15)); | 1345 icon2.push_back(gfx::Size(15, 15)); |
1355 const int actual_size2 = 12; | 1346 const int actual_size2 = 12; |
1356 | 1347 |
1357 const FaviconURL kSourceIconURLs[] = { | 1348 const FaviconURL kSourceIconURLs[] = { |
1358 FaviconURL(GURL("http://www.google.com/b"), | 1349 FaviconURL(GURL("http://www.google.com/b"), favicon_base::FAVICON, icon1), |
1359 FaviconURL::FAVICON, | 1350 FaviconURL(GURL("http://www.google.com/c"), favicon_base::FAVICON, icon2), |
1360 icon1), | |
1361 FaviconURL(GURL("http://www.google.com/c"), | |
1362 FaviconURL::FAVICON, | |
1363 icon2), | |
1364 FaviconURL(GURL("http://www.google.com/d"), | 1351 FaviconURL(GURL("http://www.google.com/d"), |
1365 FaviconURL::FAVICON, | 1352 favicon_base::FAVICON, |
1366 std::vector<gfx::Size>())}; | 1353 std::vector<gfx::Size>())}; |
1367 | 1354 |
1368 TestFaviconClient client; | 1355 TestFaviconClient client; |
1369 TestFaviconDriver driver1; | 1356 TestFaviconDriver driver1; |
1370 TestFaviconHandler handler1( | 1357 TestFaviconHandler handler1( |
1371 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); | 1358 kPageURL, &client, &driver1, FaviconHandler::FAVICON, true); |
1372 std::vector<FaviconURL> urls1(kSourceIconURLs, | 1359 std::vector<FaviconURL> urls1(kSourceIconURLs, |
1373 kSourceIconURLs + arraysize(kSourceIconURLs)); | 1360 kSourceIconURLs + arraysize(kSourceIconURLs)); |
1374 UpdateFaviconURL(&handler1, kPageURL, urls1); | 1361 UpdateFaviconURL(&handler1, kPageURL, urls1); |
1375 ASSERT_EQ(3u, handler1.urls().size()); | 1362 ASSERT_EQ(3u, handler1.urls().size()); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1493 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1480 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
1494 EXPECT_NE(0, download_id); | 1481 EXPECT_NE(0, download_id); |
1495 // Report download success with HTTP 200 status. | 1482 // Report download success with HTTP 200 status. |
1496 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1483 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
1497 empty_icons, empty_icon_sizes); | 1484 empty_icons, empty_icon_sizes); |
1498 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1485 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
1499 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1486 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
1500 } | 1487 } |
1501 | 1488 |
1502 } // namespace. | 1489 } // namespace. |
OLD | NEW |