| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/favicon/favicon_handler.h" | 5 #include "chrome/browser/favicon/favicon_handler.h" |
| 6 #include "content/browser/renderer_host/test_render_view_host.h" | 6 #include "content/browser/renderer_host/test_render_view_host.h" |
| 7 #include "content/browser/tab_contents/navigation_entry.h" | 7 #include "content/browser/tab_contents/navigation_entry.h" |
| 8 #include "content/browser/tab_contents/test_tab_contents.h" | 8 #include "content/browser/tab_contents/test_tab_contents.h" |
| 9 #include "ui/gfx/codec/png_codec.h" | 9 #include "ui/gfx/codec/png_codec.h" |
| 10 #include "ui/gfx/favicon_size.h" | 10 #include "ui/gfx/favicon_size.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 EXPECT_EQ(page_url, history_handler->page_url_); | 322 EXPECT_EQ(page_url, history_handler->page_url_); |
| 323 EXPECT_EQ(GURL(), history_handler->icon_url_); | 323 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 324 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); | 324 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); |
| 325 | 325 |
| 326 // Set valid icon data. | 326 // Set valid icon data. |
| 327 history_handler->favicon_data_.known_icon = true; | 327 history_handler->favicon_data_.known_icon = true; |
| 328 history_handler->favicon_data_.icon_type = history::FAVICON; | 328 history_handler->favicon_data_.icon_type = history::FAVICON; |
| 329 history_handler->favicon_data_.expired = false; | 329 history_handler->favicon_data_.expired = false; |
| 330 history_handler->favicon_data_.icon_url = icon_url; | 330 history_handler->favicon_data_.icon_url = icon_url; |
| 331 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); | 331 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); |
| 332 FillBitmap(kFaviconSize, kFaviconSize, &data->data); | 332 FillBitmap(kFaviconSize, kFaviconSize, &data->data()); |
| 333 history_handler->favicon_data_.image_data = data; | 333 history_handler->favicon_data_.image_data = data; |
| 334 | 334 |
| 335 // Send history response. | 335 // Send history response. |
| 336 history_handler->InvokeCallback(); | 336 history_handler->InvokeCallback(); |
| 337 // Verify FaviconHandler status | 337 // Verify FaviconHandler status |
| 338 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); | 338 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); |
| 339 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); | 339 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); |
| 340 | 340 |
| 341 // Simulates update favicon url. | 341 // Simulates update favicon url. |
| 342 std::vector<FaviconURL> urls; | 342 std::vector<FaviconURL> urls; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 EXPECT_EQ(page_url, history_handler->page_url_); | 435 EXPECT_EQ(page_url, history_handler->page_url_); |
| 436 EXPECT_EQ(GURL(), history_handler->icon_url_); | 436 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 437 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); | 437 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); |
| 438 | 438 |
| 439 // Set valid icon data. | 439 // Set valid icon data. |
| 440 history_handler->favicon_data_.known_icon = true; | 440 history_handler->favicon_data_.known_icon = true; |
| 441 history_handler->favicon_data_.icon_type = history::FAVICON; | 441 history_handler->favicon_data_.icon_type = history::FAVICON; |
| 442 history_handler->favicon_data_.expired = false; | 442 history_handler->favicon_data_.expired = false; |
| 443 history_handler->favicon_data_.icon_url = icon_url; | 443 history_handler->favicon_data_.icon_url = icon_url; |
| 444 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); | 444 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); |
| 445 FillBitmap(kFaviconSize, kFaviconSize, &data->data); | 445 FillBitmap(kFaviconSize, kFaviconSize, &data->data()); |
| 446 history_handler->favicon_data_.image_data = data; | 446 history_handler->favicon_data_.image_data = data; |
| 447 | 447 |
| 448 // Send history response. | 448 // Send history response. |
| 449 history_handler->InvokeCallback(); | 449 history_handler->InvokeCallback(); |
| 450 // Verify FaviconHandler status. | 450 // Verify FaviconHandler status. |
| 451 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); | 451 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); |
| 452 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); | 452 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); |
| 453 | 453 |
| 454 // Reset the history_handler to verify whether new icon is requested from | 454 // Reset the history_handler to verify whether new icon is requested from |
| 455 // history. | 455 // history. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 EXPECT_EQ(page_url, history_handler->page_url_); | 522 EXPECT_EQ(page_url, history_handler->page_url_); |
| 523 EXPECT_EQ(GURL(), history_handler->icon_url_); | 523 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 524 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); | 524 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); |
| 525 | 525 |
| 526 // Set valid icon data. | 526 // Set valid icon data. |
| 527 history_handler->favicon_data_.known_icon = true; | 527 history_handler->favicon_data_.known_icon = true; |
| 528 history_handler->favicon_data_.icon_type = history::FAVICON; | 528 history_handler->favicon_data_.icon_type = history::FAVICON; |
| 529 history_handler->favicon_data_.expired = false; | 529 history_handler->favicon_data_.expired = false; |
| 530 history_handler->favicon_data_.icon_url = icon_url; | 530 history_handler->favicon_data_.icon_url = icon_url; |
| 531 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); | 531 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); |
| 532 FillBitmap(kFaviconSize, kFaviconSize, &data->data); | 532 FillBitmap(kFaviconSize, kFaviconSize, &data->data()); |
| 533 history_handler->favicon_data_.image_data = data; | 533 history_handler->favicon_data_.image_data = data; |
| 534 | 534 |
| 535 // Send history response. | 535 // Send history response. |
| 536 history_handler->InvokeCallback(); | 536 history_handler->InvokeCallback(); |
| 537 // Verify FaviconHandler status. | 537 // Verify FaviconHandler status. |
| 538 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); | 538 EXPECT_TRUE(helper.GetEntry()->favicon().is_valid()); |
| 539 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); | 539 EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url()); |
| 540 | 540 |
| 541 // Reset the history_handler to verify whether new icon is requested from | 541 // Reset the history_handler to verify whether new icon is requested from |
| 542 // history. | 542 // history. |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 664 |
| 665 // Reset download handler | 665 // Reset download handler |
| 666 helper.set_download_handler(NULL); | 666 helper.set_download_handler(NULL); |
| 667 | 667 |
| 668 // Smulates getting a expired icon from history. | 668 // Smulates getting a expired icon from history. |
| 669 history_handler->favicon_data_.known_icon = true; | 669 history_handler->favicon_data_.known_icon = true; |
| 670 history_handler->favicon_data_.icon_type = history::TOUCH_ICON; | 670 history_handler->favicon_data_.icon_type = history::TOUCH_ICON; |
| 671 history_handler->favicon_data_.expired = true; | 671 history_handler->favicon_data_.expired = true; |
| 672 history_handler->favicon_data_.icon_url = new_icon_url; | 672 history_handler->favicon_data_.icon_url = new_icon_url; |
| 673 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); | 673 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); |
| 674 FillBitmap(kFaviconSize, kFaviconSize, &data->data); | 674 FillBitmap(kFaviconSize, kFaviconSize, &data->data()); |
| 675 history_handler->favicon_data_.image_data = data; | 675 history_handler->favicon_data_.image_data = data; |
| 676 history_handler->InvokeCallback(); | 676 history_handler->InvokeCallback(); |
| 677 | 677 |
| 678 // Verify the download request. | 678 // Verify the download request. |
| 679 download_handler = helper.download_handler(); | 679 download_handler = helper.download_handler(); |
| 680 EXPECT_TRUE(download_handler); | 680 EXPECT_TRUE(download_handler); |
| 681 EXPECT_EQ(new_icon_url, download_handler->image_url_); | 681 EXPECT_EQ(new_icon_url, download_handler->image_url_); |
| 682 EXPECT_EQ(0, download_handler->image_size_); | 682 EXPECT_EQ(0, download_handler->image_size_); |
| 683 | 683 |
| 684 helper.set_history_handler(NULL); | 684 helper.set_history_handler(NULL); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 793 |
| 794 // Smulates getting the icon from history. | 794 // Smulates getting the icon from history. |
| 795 scoped_ptr<HistoryRequestHandler> handler; | 795 scoped_ptr<HistoryRequestHandler> handler; |
| 796 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, | 796 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, |
| 797 history::TOUCH_ICON, callback)); | 797 history::TOUCH_ICON, callback)); |
| 798 handler->favicon_data_.known_icon = true; | 798 handler->favicon_data_.known_icon = true; |
| 799 handler->favicon_data_.expired = false; | 799 handler->favicon_data_.expired = false; |
| 800 handler->favicon_data_.icon_type = history::TOUCH_ICON; | 800 handler->favicon_data_.icon_type = history::TOUCH_ICON; |
| 801 handler->favicon_data_.icon_url = latest_icon_url; | 801 handler->favicon_data_.icon_url = latest_icon_url; |
| 802 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); | 802 scoped_refptr<RefCountedBytes> data = new RefCountedBytes(); |
| 803 FillBitmap(kFaviconSize, kFaviconSize, &data->data); | 803 FillBitmap(kFaviconSize, kFaviconSize, &data->data()); |
| 804 handler->favicon_data_.image_data = data; | 804 handler->favicon_data_.image_data = data; |
| 805 | 805 |
| 806 handler->InvokeCallback(); | 806 handler->InvokeCallback(); |
| 807 | 807 |
| 808 // No download request. | 808 // No download request. |
| 809 EXPECT_FALSE(helper.download_handler()); | 809 EXPECT_FALSE(helper.download_handler()); |
| 810 } | 810 } |
| 811 | 811 |
| 812 } // namespace. | 812 } // namespace. |
| OLD | NEW |