Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/browser/favicon/favicon_handler_unittest.cc

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 8 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
9 #include "content/public/browser/invalidate_type.h" 9 #include "content/public/browser/invalidate_type.h"
10 #include "content/public/browser/navigation_entry.h" 10 #include "content/public/browser/navigation_entry.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 const FaviconService::FaviconDataCallback& callback) 102 const FaviconService::FaviconDataCallback& callback)
103 : page_url_(page_url), 103 : page_url_(page_url),
104 icon_url_(icon_url), 104 icon_url_(icon_url),
105 icon_type_(icon_type), 105 icon_type_(icon_type),
106 callback_(callback) { 106 callback_(callback) {
107 } 107 }
108 108
109 HistoryRequestHandler(const GURL& page_url, 109 HistoryRequestHandler(const GURL& page_url,
110 const GURL& icon_url, 110 const GURL& icon_url,
111 int icon_type, 111 int icon_type,
112 const std::vector<unsigned char>& image_data, 112 const std::vector<unsigned char>& bitmap_data,
113 const FaviconService::FaviconDataCallback& callback) 113 const FaviconService::FaviconDataCallback& callback)
114 : page_url_(page_url), 114 : page_url_(page_url),
115 icon_url_(icon_url), 115 icon_url_(icon_url),
116 icon_type_(icon_type), 116 icon_type_(icon_type),
117 image_data_(image_data), 117 bitmap_data_(bitmap_data),
118 callback_(callback) { 118 callback_(callback) {
119 } 119 }
120 120
121 virtual ~HistoryRequestHandler() {} 121 virtual ~HistoryRequestHandler() {}
122 void InvokeCallback(); 122 void InvokeCallback();
123 123
124 const GURL page_url_; 124 const GURL page_url_;
125 const GURL icon_url_; 125 const GURL icon_url_;
126 const int icon_type_; 126 const int icon_type_;
127 const std::vector<unsigned char> image_data_; 127 const std::vector<unsigned char> bitmap_data_;
128 history::FaviconData favicon_data_; 128 history::FaviconData favicon_data_;
129 FaviconService::FaviconDataCallback callback_; 129 FaviconService::FaviconDataCallback callback_;
130 130
131 private: 131 private:
132 DISALLOW_COPY_AND_ASSIGN(HistoryRequestHandler); 132 DISALLOW_COPY_AND_ASSIGN(HistoryRequestHandler);
133 }; 133 };
134 134
135 } // namespace 135 } // namespace
136 136
137 137
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 245 }
246 246
247 virtual int DownloadFavicon(const GURL& image_url, int image_size) OVERRIDE { 247 virtual int DownloadFavicon(const GURL& image_url, int image_size) OVERRIDE {
248 download_id_++; 248 download_id_++;
249 download_handler_->AddDownload(download_id_, image_url, image_size); 249 download_handler_->AddDownload(download_id_, image_url, image_size);
250 return download_id_; 250 return download_id_;
251 } 251 }
252 252
253 virtual void SetHistoryFavicon(const GURL& page_url, 253 virtual void SetHistoryFavicon(const GURL& page_url,
254 const GURL& icon_url, 254 const GURL& icon_url,
255 const std::vector<unsigned char>& image_data, 255 const std::vector<unsigned char>& bitmap_data,
256 history::IconType icon_type) OVERRIDE { 256 history::IconType icon_type) OVERRIDE {
257 history_handler_.reset(new HistoryRequestHandler( 257 history_handler_.reset(new HistoryRequestHandler(
258 page_url, icon_url,icon_type, image_data, 258 page_url, icon_url,icon_type, bitmap_data,
259 FaviconService::FaviconDataCallback())); 259 FaviconService::FaviconDataCallback()));
260 } 260 }
261 261
262 virtual FaviconService* GetFaviconService() OVERRIDE { 262 virtual FaviconService* GetFaviconService() OVERRIDE {
263 // Just give none NULL value, so overridden methods can be hit. 263 // Just give none NULL value, so overridden methods can be hit.
264 return (FaviconService*)(1); 264 return (FaviconService*)(1);
265 } 265 }
266 266
267 virtual bool ShouldSaveFavicon(const GURL& url) OVERRIDE { 267 virtual bool ShouldSaveFavicon(const GURL& url) OVERRIDE {
268 return true; 268 return true;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 EXPECT_EQ(GURL(), history_handler->icon_url_); 324 EXPECT_EQ(GURL(), history_handler->icon_url_);
325 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); 325 EXPECT_EQ(history::FAVICON, history_handler->icon_type_);
326 326
327 // Set valid icon data. 327 // Set valid icon data.
328 history_handler->favicon_data_.known_icon = true; 328 history_handler->favicon_data_.known_icon = true;
329 history_handler->favicon_data_.icon_type = history::FAVICON; 329 history_handler->favicon_data_.icon_type = history::FAVICON;
330 history_handler->favicon_data_.expired = false; 330 history_handler->favicon_data_.expired = false;
331 history_handler->favicon_data_.icon_url = icon_url; 331 history_handler->favicon_data_.icon_url = icon_url;
332 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 332 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
333 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 333 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
334 history_handler->favicon_data_.image_data = data; 334 history_handler->favicon_data_.bitmap_data = data;
335 335
336 // Send history response. 336 // Send history response.
337 history_handler->InvokeCallback(); 337 history_handler->InvokeCallback();
338 // Verify FaviconHandler status 338 // Verify FaviconHandler status
339 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 339 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
340 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); 340 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
341 341
342 // Simulates update favicon url. 342 // Simulates update favicon url.
343 std::vector<FaviconURL> urls; 343 std::vector<FaviconURL> urls;
344 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON)); 344 urls.push_back(FaviconURL(icon_url, FaviconURL::FAVICON));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 helper.set_history_handler(NULL); 406 helper.set_history_handler(NULL);
407 407
408 // Smulates download done. 408 // Smulates download done.
409 download_handler->InvokeCallback(); 409 download_handler->InvokeCallback();
410 410
411 // New icon should be saved to history backend and navigation entry. 411 // New icon should be saved to history backend and navigation entry.
412 history_handler = helper.history_handler(); 412 history_handler = helper.history_handler();
413 ASSERT_TRUE(history_handler); 413 ASSERT_TRUE(history_handler);
414 EXPECT_EQ(icon_url, history_handler->icon_url_); 414 EXPECT_EQ(icon_url, history_handler->icon_url_);
415 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); 415 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
416 EXPECT_LT(0U, history_handler->image_data_.size()); 416 EXPECT_LT(0U, history_handler->bitmap_data_.size());
417 EXPECT_EQ(page_url, history_handler->page_url_); 417 EXPECT_EQ(page_url, history_handler->page_url_);
418 418
419 // Verify NavigationEntry. 419 // Verify NavigationEntry.
420 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); 420 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
421 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 421 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
422 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty()); 422 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
423 } 423 }
424 424
425 TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) { 425 TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
426 const GURL page_url("http://www.google.com"); 426 const GURL page_url("http://www.google.com");
(...skipping 14 matching lines...) Expand all
441 EXPECT_EQ(GURL(), history_handler->icon_url_); 441 EXPECT_EQ(GURL(), history_handler->icon_url_);
442 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); 442 EXPECT_EQ(history::FAVICON, history_handler->icon_type_);
443 443
444 // Set valid icon data. 444 // Set valid icon data.
445 history_handler->favicon_data_.known_icon = true; 445 history_handler->favicon_data_.known_icon = true;
446 history_handler->favicon_data_.icon_type = history::FAVICON; 446 history_handler->favicon_data_.icon_type = history::FAVICON;
447 history_handler->favicon_data_.expired = false; 447 history_handler->favicon_data_.expired = false;
448 history_handler->favicon_data_.icon_url = icon_url; 448 history_handler->favicon_data_.icon_url = icon_url;
449 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 449 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
450 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 450 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
451 history_handler->favicon_data_.image_data = data; 451 history_handler->favicon_data_.bitmap_data = data;
452 452
453 // Send history response. 453 // Send history response.
454 history_handler->InvokeCallback(); 454 history_handler->InvokeCallback();
455 // Verify FaviconHandler status. 455 // Verify FaviconHandler status.
456 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 456 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
457 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); 457 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
458 458
459 // Reset the history_handler to verify whether new icon is requested from 459 // Reset the history_handler to verify whether new icon is requested from
460 // history. 460 // history.
461 helper.set_history_handler(NULL); 461 helper.set_history_handler(NULL);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 helper.set_history_handler(NULL); 496 helper.set_history_handler(NULL);
497 497
498 // Smulates download done. 498 // Smulates download done.
499 download_handler->InvokeCallback(); 499 download_handler->InvokeCallback();
500 500
501 // New icon should be saved to history backend and navigation entry. 501 // New icon should be saved to history backend and navigation entry.
502 history_handler = helper.history_handler(); 502 history_handler = helper.history_handler();
503 ASSERT_TRUE(history_handler); 503 ASSERT_TRUE(history_handler);
504 EXPECT_EQ(new_icon_url, history_handler->icon_url_); 504 EXPECT_EQ(new_icon_url, history_handler->icon_url_);
505 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); 505 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
506 EXPECT_LT(0U, history_handler->image_data_.size()); 506 EXPECT_LT(0U, history_handler->bitmap_data_.size());
507 EXPECT_EQ(page_url, history_handler->page_url_); 507 EXPECT_EQ(page_url, history_handler->page_url_);
508 508
509 // Verify NavigationEntry. 509 // Verify NavigationEntry.
510 EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url); 510 EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
511 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 511 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
512 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty()); 512 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
513 } 513 }
514 514
515 TEST_F(FaviconHandlerTest, UpdateFavicon) { 515 TEST_F(FaviconHandlerTest, UpdateFavicon) {
516 const GURL page_url("http://www.google.com"); 516 const GURL page_url("http://www.google.com");
(...skipping 14 matching lines...) Expand all
531 EXPECT_EQ(GURL(), history_handler->icon_url_); 531 EXPECT_EQ(GURL(), history_handler->icon_url_);
532 EXPECT_EQ(history::FAVICON, history_handler->icon_type_); 532 EXPECT_EQ(history::FAVICON, history_handler->icon_type_);
533 533
534 // Set valid icon data. 534 // Set valid icon data.
535 history_handler->favicon_data_.known_icon = true; 535 history_handler->favicon_data_.known_icon = true;
536 history_handler->favicon_data_.icon_type = history::FAVICON; 536 history_handler->favicon_data_.icon_type = history::FAVICON;
537 history_handler->favicon_data_.expired = false; 537 history_handler->favicon_data_.expired = false;
538 history_handler->favicon_data_.icon_url = icon_url; 538 history_handler->favicon_data_.icon_url = icon_url;
539 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 539 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
540 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 540 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
541 history_handler->favicon_data_.image_data = data; 541 history_handler->favicon_data_.bitmap_data = data;
542 542
543 // Send history response. 543 // Send history response.
544 history_handler->InvokeCallback(); 544 history_handler->InvokeCallback();
545 // Verify FaviconHandler status. 545 // Verify FaviconHandler status.
546 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 546 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
547 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); 547 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
548 548
549 // Reset the history_handler to verify whether new icon is requested from 549 // Reset the history_handler to verify whether new icon is requested from
550 // history. 550 // history.
551 helper.set_history_handler(NULL); 551 helper.set_history_handler(NULL);
(...skipping 16 matching lines...) Expand all
568 ASSERT_TRUE(history_handler); 568 ASSERT_TRUE(history_handler);
569 EXPECT_EQ(new_icon_url, history_handler->icon_url_); 569 EXPECT_EQ(new_icon_url, history_handler->icon_url_);
570 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); 570 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_);
571 EXPECT_EQ(page_url, history_handler->page_url_); 571 EXPECT_EQ(page_url, history_handler->page_url_);
572 572
573 // Simulate find icon. 573 // Simulate find icon.
574 history_handler->favicon_data_.known_icon = true; 574 history_handler->favicon_data_.known_icon = true;
575 history_handler->favicon_data_.icon_type = history::FAVICON; 575 history_handler->favicon_data_.icon_type = history::FAVICON;
576 history_handler->favicon_data_.expired = false; 576 history_handler->favicon_data_.expired = false;
577 history_handler->favicon_data_.icon_url = new_icon_url; 577 history_handler->favicon_data_.icon_url = new_icon_url;
578 history_handler->favicon_data_.image_data = data; 578 history_handler->favicon_data_.bitmap_data = data;
579 history_handler->InvokeCallback(); 579 history_handler->InvokeCallback();
580 580
581 // Shouldn't request download favicon 581 // Shouldn't request download favicon
582 EXPECT_FALSE(helper.download_handler()->HasDownload()); 582 EXPECT_FALSE(helper.download_handler()->HasDownload());
583 583
584 // Verify the favicon status. 584 // Verify the favicon status.
585 EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url); 585 EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
586 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); 586 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
587 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty()); 587 EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
588 } 588 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 // Reset download handler 675 // Reset download handler
676 download_handler->Reset(); 676 download_handler->Reset();
677 677
678 // Smulates getting a expired icon from history. 678 // Smulates getting a expired icon from history.
679 history_handler->favicon_data_.known_icon = true; 679 history_handler->favicon_data_.known_icon = true;
680 history_handler->favicon_data_.icon_type = history::TOUCH_ICON; 680 history_handler->favicon_data_.icon_type = history::TOUCH_ICON;
681 history_handler->favicon_data_.expired = true; 681 history_handler->favicon_data_.expired = true;
682 history_handler->favicon_data_.icon_url = new_icon_url; 682 history_handler->favicon_data_.icon_url = new_icon_url;
683 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 683 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
684 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 684 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
685 history_handler->favicon_data_.image_data = data; 685 history_handler->favicon_data_.bitmap_data = data;
686 history_handler->InvokeCallback(); 686 history_handler->InvokeCallback();
687 687
688 // Verify the download request. 688 // Verify the download request.
689 EXPECT_TRUE(helper.download_handler()->HasDownload()); 689 EXPECT_TRUE(helper.download_handler()->HasDownload());
690 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl()); 690 EXPECT_EQ(new_icon_url, download_handler->GetImageUrl());
691 EXPECT_EQ(0, download_handler->GetImageSize()); 691 EXPECT_EQ(0, download_handler->GetImageSize());
692 692
693 helper.set_history_handler(NULL); 693 helper.set_history_handler(NULL);
694 694
695 // Simulates icon being downloaded. 695 // Simulates icon being downloaded.
696 download_handler->InvokeCallback(); 696 download_handler->InvokeCallback();
697 697
698 // New icon should be saved to history backend. 698 // New icon should be saved to history backend.
699 history_handler = helper.history_handler(); 699 history_handler = helper.history_handler();
700 ASSERT_TRUE(history_handler); 700 ASSERT_TRUE(history_handler);
701 EXPECT_EQ(new_icon_url, history_handler->icon_url_); 701 EXPECT_EQ(new_icon_url, history_handler->icon_url_);
702 EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_); 702 EXPECT_EQ(FaviconURL::TOUCH_ICON, history_handler->icon_type_);
703 EXPECT_LT(0U, history_handler->image_data_.size()); 703 EXPECT_LT(0U, history_handler->bitmap_data_.size());
704 EXPECT_EQ(page_url, history_handler->page_url_); 704 EXPECT_EQ(page_url, history_handler->page_url_);
705 } 705 }
706 706
707 TEST_F(FaviconHandlerTest, UpdateDuringDownloading) { 707 TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
708 const GURL page_url("http://www.google.com"); 708 const GURL page_url("http://www.google.com");
709 const GURL icon_url("http://www.google.com/favicon"); 709 const GURL icon_url("http://www.google.com/favicon");
710 const GURL new_icon_url("http://www.google.com/new_favicon"); 710 const GURL new_icon_url("http://www.google.com/new_favicon");
711 711
712 TestFaviconHandlerDelegate delegate(contents()); 712 TestFaviconHandlerDelegate delegate(contents());
713 Profile* profile = Profile::FromBrowserContext( 713 Profile* profile = Profile::FromBrowserContext(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // Simulates getting the icon from history. 804 // Simulates getting the icon from history.
805 scoped_ptr<HistoryRequestHandler> handler; 805 scoped_ptr<HistoryRequestHandler> handler;
806 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url, 806 handler.reset(new HistoryRequestHandler(page_url, latest_icon_url,
807 history::TOUCH_ICON, callback)); 807 history::TOUCH_ICON, callback));
808 handler->favicon_data_.known_icon = true; 808 handler->favicon_data_.known_icon = true;
809 handler->favicon_data_.expired = false; 809 handler->favicon_data_.expired = false;
810 handler->favicon_data_.icon_type = history::TOUCH_ICON; 810 handler->favicon_data_.icon_type = history::TOUCH_ICON;
811 handler->favicon_data_.icon_url = latest_icon_url; 811 handler->favicon_data_.icon_url = latest_icon_url;
812 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 812 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
813 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 813 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
814 handler->favicon_data_.image_data = data; 814 handler->favicon_data_.bitmap_data = data;
815 815
816 handler->InvokeCallback(); 816 handler->InvokeCallback();
817 817
818 // No download request. 818 // No download request.
819 EXPECT_FALSE(download_handler->HasDownload()); 819 EXPECT_FALSE(download_handler->HasDownload());
820 } 820 }
821 821
822 TEST_F(FaviconHandlerTest, MultipleFavicon) { 822 TEST_F(FaviconHandlerTest, MultipleFavicon) {
823 const GURL page_url("http://www.google.com"); 823 const GURL page_url("http://www.google.com");
824 const GURL icon_url("http://www.google.com/favicon"); 824 const GURL icon_url("http://www.google.com/favicon");
(...skipping 11 matching lines...) Expand all
836 handler.FetchFavicon(page_url); 836 handler.FetchFavicon(page_url);
837 HistoryRequestHandler* history_handler = handler.history_handler(); 837 HistoryRequestHandler* history_handler = handler.history_handler();
838 838
839 // Set valid icon data. 839 // Set valid icon data.
840 history_handler->favicon_data_.known_icon = true; 840 history_handler->favicon_data_.known_icon = true;
841 history_handler->favicon_data_.icon_type = history::FAVICON; 841 history_handler->favicon_data_.icon_type = history::FAVICON;
842 history_handler->favicon_data_.expired = false; 842 history_handler->favicon_data_.expired = false;
843 history_handler->favicon_data_.icon_url = icon_url; 843 history_handler->favicon_data_.icon_url = icon_url;
844 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 844 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
845 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 845 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
846 history_handler->favicon_data_.image_data = data; 846 history_handler->favicon_data_.bitmap_data = data;
847 847
848 // Send history response. 848 // Send history response.
849 history_handler->InvokeCallback(); 849 history_handler->InvokeCallback();
850 850
851 // Simulates update with the different favicon url. 851 // Simulates update with the different favicon url.
852 std::vector<FaviconURL> urls; 852 std::vector<FaviconURL> urls;
853 // Note: the code will stop making requests when an icon matching the 853 // Note: the code will stop making requests when an icon matching the
854 // preferred size is found, so icon_url_preferred must be last. 854 // preferred size is found, so icon_url_preferred must be last.
855 urls.push_back(FaviconURL(icon_url_small, FaviconURL::FAVICON)); 855 urls.push_back(FaviconURL(icon_url_small, FaviconURL::FAVICON));
856 urls.push_back(FaviconURL(icon_url_large, FaviconURL::FAVICON)); 856 urls.push_back(FaviconURL(icon_url_large, FaviconURL::FAVICON));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 handler.FetchFavicon(page_url); 911 handler.FetchFavicon(page_url);
912 HistoryRequestHandler* history_handler = handler.history_handler(); 912 HistoryRequestHandler* history_handler = handler.history_handler();
913 913
914 // Set valid icon data. 914 // Set valid icon data.
915 history_handler->favicon_data_.known_icon = true; 915 history_handler->favicon_data_.known_icon = true;
916 history_handler->favicon_data_.icon_type = history::FAVICON; 916 history_handler->favicon_data_.icon_type = history::FAVICON;
917 history_handler->favicon_data_.expired = false; 917 history_handler->favicon_data_.expired = false;
918 history_handler->favicon_data_.icon_url = icon_url; 918 history_handler->favicon_data_.icon_url = icon_url;
919 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes(); 919 scoped_refptr<base::RefCountedBytes> data = new base::RefCountedBytes();
920 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data()); 920 FillBitmap(gfx::kFaviconSize, gfx::kFaviconSize, &data->data());
921 history_handler->favicon_data_.image_data = data; 921 history_handler->favicon_data_.bitmap_data = data;
922 922
923 // Send history response. 923 // Send history response.
924 history_handler->InvokeCallback(); 924 history_handler->InvokeCallback();
925 925
926 // Simulates update with the different favicon url. 926 // Simulates update with the different favicon url.
927 std::vector<FaviconURL> urls; 927 std::vector<FaviconURL> urls;
928 // Note: the code will stop making requests when an icon matching the 928 // Note: the code will stop making requests when an icon matching the
929 // preferred size is found, so icon_url_preferred must be last. 929 // preferred size is found, so icon_url_preferred must be last.
930 urls.push_back(FaviconURL(icon_url_preferred1, FaviconURL::FAVICON)); 930 urls.push_back(FaviconURL(icon_url_preferred1, FaviconURL::FAVICON));
931 urls.push_back(FaviconURL(icon_url_large, FaviconURL::FAVICON)); 931 urls.push_back(FaviconURL(icon_url_large, FaviconURL::FAVICON));
(...skipping 13 matching lines...) Expand all
945 EXPECT_EQ(0U, handler.image_urls().size()); 945 EXPECT_EQ(0U, handler.image_urls().size());
946 946
947 // Verify correct icon size chosen. 947 // Verify correct icon size chosen.
948 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url); 948 EXPECT_EQ(icon_url_preferred1, handler.GetEntry()->GetFavicon().url);
949 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid); 949 EXPECT_TRUE(handler.GetEntry()->GetFavicon().valid);
950 EXPECT_FALSE(handler.GetEntry()->GetFavicon().bitmap.empty()); 950 EXPECT_FALSE(handler.GetEntry()->GetFavicon().bitmap.empty());
951 EXPECT_EQ(gfx::kFaviconSize, handler.GetEntry()->GetFavicon().bitmap.width()); 951 EXPECT_EQ(gfx::kFaviconSize, handler.GetEntry()->GetFavicon().bitmap.width());
952 } 952 }
953 953
954 } // namespace. 954 } // namespace.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698