| 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 "content/public/browser/favicon_status.h" | |
| 12 #include "content/public/browser/invalidate_type.h" | |
| 13 #include "content/public/browser/navigation_entry.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 #include "third_party/skia/include/core/SkBitmap.h" | 11 #include "third_party/skia/include/core/SkBitmap.h" |
| 16 #include "ui/gfx/codec/png_codec.h" | 12 #include "ui/gfx/codec/png_codec.h" |
| 17 #include "ui/gfx/favicon_size.h" | 13 #include "ui/gfx/favicon_size.h" |
| 18 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
| 19 | 15 |
| 20 class TestFaviconHandler; | 16 class TestFaviconHandler; |
| 21 | 17 |
| 22 using content::FaviconURL; | 18 using content::FaviconURL; |
| 23 using content::NavigationEntry; | |
| 24 using content::WebContents; | |
| 25 | 19 |
| 26 namespace { | 20 namespace { |
| 27 | 21 |
| 28 // Fill the given bmp with valid png data. | 22 // Fill the given bmp with valid png data. |
| 29 void FillDataToBitmap(int w, int h, SkBitmap* bmp) { | 23 void FillDataToBitmap(int w, int h, SkBitmap* bmp) { |
| 30 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 24 bmp->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 31 bmp->allocPixels(); | 25 bmp->allocPixels(); |
| 32 | 26 |
| 33 unsigned char* src_data = | 27 unsigned char* src_data = |
| 34 reinterpret_cast<unsigned char*>(bmp->getAddr32(0, 0)); | 28 reinterpret_cast<unsigned char*>(bmp->getAddr32(0, 0)); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 virtual FaviconService* GetFaviconService() OVERRIDE { | 178 virtual FaviconService* GetFaviconService() OVERRIDE { |
| 185 // Just give none NULL value, so overridden methods can be hit. | 179 // Just give none NULL value, so overridden methods can be hit. |
| 186 return (FaviconService*)(1); | 180 return (FaviconService*)(1); |
| 187 } | 181 } |
| 188 | 182 |
| 189 virtual bool IsBookmarked(const GURL& url) OVERRIDE { return false; } | 183 virtual bool IsBookmarked(const GURL& url) OVERRIDE { return false; } |
| 190 }; | 184 }; |
| 191 | 185 |
| 192 class TestFaviconDriver : public FaviconDriver { | 186 class TestFaviconDriver : public FaviconDriver { |
| 193 public: | 187 public: |
| 194 TestFaviconDriver() { | 188 TestFaviconDriver() : favicon_validity_(false) {} |
| 195 } | |
| 196 | 189 |
| 197 virtual ~TestFaviconDriver() { | 190 virtual ~TestFaviconDriver() { |
| 198 } | 191 } |
| 199 | 192 |
| 200 virtual bool IsOffTheRecord() OVERRIDE { return false; } | 193 virtual bool IsOffTheRecord() OVERRIDE { return false; } |
| 201 | 194 |
| 202 virtual NavigationEntry* GetActiveEntry() OVERRIDE { | 195 virtual const gfx::Image GetActiveFaviconImage() OVERRIDE { return image_; } |
| 203 ADD_FAILURE() << "TestFaviconDriver::GetActiveEntry() " | 196 |
| 204 << "should never be called in tests."; | 197 virtual const GURL GetActiveFaviconURL() OVERRIDE { return favicon_url_; } |
| 205 return NULL; | 198 |
| 199 virtual bool GetActiveFaviconValidity() OVERRIDE { return favicon_validity_; } |
| 200 |
| 201 virtual const GURL GetActiveURL() OVERRIDE { return url_; } |
| 202 |
| 203 virtual void SetActiveFaviconImage(gfx::Image image) OVERRIDE { |
| 204 image_ = image; |
| 205 } |
| 206 |
| 207 virtual void SetActiveFaviconURL(GURL favicon_url) OVERRIDE { |
| 208 favicon_url_ = favicon_url; |
| 209 } |
| 210 |
| 211 virtual void SetActiveFaviconValidity(bool favicon_validity) OVERRIDE { |
| 212 favicon_validity_ = favicon_validity; |
| 206 } | 213 } |
| 207 | 214 |
| 208 virtual int StartDownload(const GURL& url, | 215 virtual int StartDownload(const GURL& url, |
| 209 int max_bitmap_size) OVERRIDE { | 216 int max_bitmap_size) OVERRIDE { |
| 210 ADD_FAILURE() << "TestFaviconDriver::StartDownload() " | 217 ADD_FAILURE() << "TestFaviconDriver::StartDownload() " |
| 211 << "should never be called in tests."; | 218 << "should never be called in tests."; |
| 212 return -1; | 219 return -1; |
| 213 } | 220 } |
| 214 | 221 |
| 215 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE { | 222 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE { |
| 216 ADD_FAILURE() << "TestFaviconDriver::NotifyFaviconUpdated() " | 223 ADD_FAILURE() << "TestFaviconDriver::NotifyFaviconUpdated() " |
| 217 << "should never be called in tests."; | 224 << "should never be called in tests."; |
| 218 } | 225 } |
| 219 | 226 |
| 227 void SetActiveURL(GURL url) { url_ = url; } |
| 228 |
| 220 private: | 229 private: |
| 230 GURL favicon_url_; |
| 231 GURL url_; |
| 232 gfx::Image image_; |
| 233 bool favicon_validity_; |
| 221 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver); | 234 DISALLOW_COPY_AND_ASSIGN(TestFaviconDriver); |
| 222 }; | 235 }; |
| 223 | 236 |
| 224 // This class is used to catch the FaviconHandler's download and history | 237 // This class is used to catch the FaviconHandler's download and history |
| 225 // request, and also provide the methods to access the FaviconHandler | 238 // request, and also provide the methods to access the FaviconHandler |
| 226 // internals. | 239 // internals. |
| 227 class TestFaviconHandler : public FaviconHandler { | 240 class TestFaviconHandler : public FaviconHandler { |
| 228 public: | 241 public: |
| 229 TestFaviconHandler(const GURL& page_url, | 242 TestFaviconHandler(const GURL& page_url, |
| 230 FaviconClient* client, | 243 FaviconClient* client, |
| 231 FaviconDriver* driver, | 244 TestFaviconDriver* driver, |
| 232 Type type, | 245 Type type, |
| 233 bool download_largest_icon) | 246 bool download_largest_icon) |
| 234 : FaviconHandler(client, driver, type, | 247 : FaviconHandler(client, driver, type, download_largest_icon), |
| 235 download_largest_icon), | |
| 236 entry_(NavigationEntry::Create()), | |
| 237 download_id_(0), | 248 download_id_(0), |
| 238 num_favicon_updates_(0) { | 249 num_favicon_updates_(0) { |
| 239 entry_->SetURL(page_url); | 250 driver->SetActiveURL(page_url); |
| 240 download_handler_.reset(new DownloadHandler(this)); | 251 download_handler_.reset(new DownloadHandler(this)); |
| 241 } | 252 } |
| 242 | 253 |
| 243 virtual ~TestFaviconHandler() { | 254 virtual ~TestFaviconHandler() { |
| 244 } | 255 } |
| 245 | 256 |
| 246 HistoryRequestHandler* history_handler() { | 257 HistoryRequestHandler* history_handler() { |
| 247 return history_handler_.get(); | 258 return history_handler_.get(); |
| 248 } | 259 } |
| 249 | 260 |
| 250 // This method will take the ownership of the given handler. | 261 // This method will take the ownership of the given handler. |
| 251 void set_history_handler(HistoryRequestHandler* handler) { | 262 void set_history_handler(HistoryRequestHandler* handler) { |
| 252 history_handler_.reset(handler); | 263 history_handler_.reset(handler); |
| 253 } | 264 } |
| 254 | 265 |
| 255 DownloadHandler* download_handler() { | 266 DownloadHandler* download_handler() { |
| 256 return download_handler_.get(); | 267 return download_handler_.get(); |
| 257 } | 268 } |
| 258 | 269 |
| 259 size_t num_favicon_update_notifications() const { | 270 size_t num_favicon_update_notifications() const { |
| 260 return num_favicon_updates_; | 271 return num_favicon_updates_; |
| 261 } | 272 } |
| 262 | 273 |
| 263 void ResetNumFaviconUpdateNotifications() { | 274 void ResetNumFaviconUpdateNotifications() { |
| 264 num_favicon_updates_ = 0; | 275 num_favicon_updates_ = 0; |
| 265 } | 276 } |
| 266 | 277 |
| 267 // Methods to access favicon internals. | 278 // Methods to access favicon internals. |
| 268 virtual NavigationEntry* GetEntry() OVERRIDE { | |
| 269 return entry_.get(); | |
| 270 } | |
| 271 | |
| 272 const std::vector<FaviconURL>& urls() { | 279 const std::vector<FaviconURL>& urls() { |
| 273 return image_urls_; | 280 return image_urls_; |
| 274 } | 281 } |
| 275 | 282 |
| 276 FaviconURL* current_candidate() { | 283 FaviconURL* current_candidate() { |
| 277 return FaviconHandler::current_candidate(); | 284 return FaviconHandler::current_candidate(); |
| 278 } | 285 } |
| 279 | 286 |
| 280 const FaviconCandidate& best_favicon_candidate() { | 287 const FaviconCandidate& best_favicon_candidate() { |
| 281 return best_favicon_candidate_; | 288 return best_favicon_candidate_; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 return true; | 342 return true; |
| 336 } | 343 } |
| 337 | 344 |
| 338 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE { | 345 virtual void NotifyFaviconUpdated(bool icon_url_changed) OVERRIDE { |
| 339 ++num_favicon_updates_; | 346 ++num_favicon_updates_; |
| 340 } | 347 } |
| 341 | 348 |
| 342 GURL page_url_; | 349 GURL page_url_; |
| 343 | 350 |
| 344 private: | 351 private: |
| 345 scoped_ptr<NavigationEntry> entry_; | |
| 346 | 352 |
| 347 // The unique id of a download request. It will be returned to a | 353 // The unique id of a download request. It will be returned to a |
| 348 // FaviconHandler. | 354 // FaviconHandler. |
| 349 int download_id_; | 355 int download_id_; |
| 350 | 356 |
| 351 scoped_ptr<DownloadHandler> download_handler_; | 357 scoped_ptr<DownloadHandler> download_handler_; |
| 352 scoped_ptr<HistoryRequestHandler> history_handler_; | 358 scoped_ptr<HistoryRequestHandler> history_handler_; |
| 353 | 359 |
| 354 // The number of times that NotifyFaviconUpdated() has been called. | 360 // The number of times that NotifyFaviconUpdated() has been called. |
| 355 size_t num_favicon_updates_; | 361 size_t num_favicon_updates_; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 ASSERT_TRUE(history_handler); | 490 ASSERT_TRUE(history_handler); |
| 485 EXPECT_EQ(page_url, history_handler->page_url_); | 491 EXPECT_EQ(page_url, history_handler->page_url_); |
| 486 EXPECT_EQ(GURL(), history_handler->icon_url_); | 492 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 487 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); | 493 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
| 488 | 494 |
| 489 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); | 495 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); |
| 490 | 496 |
| 491 // Send history response. | 497 // Send history response. |
| 492 history_handler->InvokeCallback(); | 498 history_handler->InvokeCallback(); |
| 493 // Verify FaviconHandler status | 499 // Verify FaviconHandler status |
| 494 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); | 500 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 495 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); | 501 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 496 | 502 |
| 497 // Simulates update favicon url. | 503 // Simulates update favicon url. |
| 498 std::vector<FaviconURL> urls; | 504 std::vector<FaviconURL> urls; |
| 499 urls.push_back( | 505 urls.push_back( |
| 500 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 506 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); |
| 501 helper.OnUpdateFaviconURL(urls); | 507 helper.OnUpdateFaviconURL(urls); |
| 502 | 508 |
| 503 // Verify FaviconHandler status | 509 // Verify FaviconHandler status |
| 504 EXPECT_EQ(1U, helper.urls().size()); | 510 EXPECT_EQ(1U, helper.urls().size()); |
| 505 ASSERT_TRUE(helper.current_candidate()); | 511 ASSERT_TRUE(helper.current_candidate()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 528 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); | 534 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
| 529 | 535 |
| 530 // Set icon data expired | 536 // Set icon data expired |
| 531 SetFaviconBitmapResult(icon_url, | 537 SetFaviconBitmapResult(icon_url, |
| 532 favicon_base::FAVICON, | 538 favicon_base::FAVICON, |
| 533 true /* expired */, | 539 true /* expired */, |
| 534 &history_handler->history_results_); | 540 &history_handler->history_results_); |
| 535 // Send history response. | 541 // Send history response. |
| 536 history_handler->InvokeCallback(); | 542 history_handler->InvokeCallback(); |
| 537 // Verify FaviconHandler status | 543 // Verify FaviconHandler status |
| 538 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); | 544 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 539 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); | 545 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 540 | 546 |
| 541 // Simulates update favicon url. | 547 // Simulates update favicon url. |
| 542 std::vector<FaviconURL> urls; | 548 std::vector<FaviconURL> urls; |
| 543 urls.push_back( | 549 urls.push_back( |
| 544 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 550 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); |
| 545 helper.OnUpdateFaviconURL(urls); | 551 helper.OnUpdateFaviconURL(urls); |
| 546 | 552 |
| 547 // Verify FaviconHandler status | 553 // Verify FaviconHandler status |
| 548 EXPECT_EQ(1U, helper.urls().size()); | 554 EXPECT_EQ(1U, helper.urls().size()); |
| 549 ASSERT_TRUE(helper.current_candidate()); | 555 ASSERT_TRUE(helper.current_candidate()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 565 | 571 |
| 566 // New icon should be saved to history backend and navigation entry. | 572 // New icon should be saved to history backend and navigation entry. |
| 567 history_handler = helper.history_handler(); | 573 history_handler = helper.history_handler(); |
| 568 ASSERT_TRUE(history_handler); | 574 ASSERT_TRUE(history_handler); |
| 569 EXPECT_EQ(icon_url, history_handler->icon_url_); | 575 EXPECT_EQ(icon_url, history_handler->icon_url_); |
| 570 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 576 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); |
| 571 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 577 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
| 572 EXPECT_EQ(page_url, history_handler->page_url_); | 578 EXPECT_EQ(page_url, history_handler->page_url_); |
| 573 | 579 |
| 574 // Verify NavigationEntry. | 580 // Verify NavigationEntry. |
| 575 content::FaviconStatus favicon_status = helper.GetEntry()->GetFavicon(); | 581 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 576 EXPECT_EQ(icon_url, favicon_status.url); | 582 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 577 EXPECT_TRUE(favicon_status.valid); | 583 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
| 578 EXPECT_FALSE(favicon_status.image.IsEmpty()); | 584 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
| 579 EXPECT_EQ(gfx::kFaviconSize, favicon_status.image.Width()); | |
| 580 } | 585 } |
| 581 | 586 |
| 582 TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) { | 587 TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) { |
| 583 const GURL page_url("http://www.google.com"); | 588 const GURL page_url("http://www.google.com"); |
| 584 const GURL icon_url("http://www.google.com/favicon"); | 589 const GURL icon_url("http://www.google.com/favicon"); |
| 585 const GURL new_icon_url("http://www.google.com/new_favicon"); | 590 const GURL new_icon_url("http://www.google.com/new_favicon"); |
| 586 | 591 |
| 587 TestFaviconDriver driver; | 592 TestFaviconDriver driver; |
| 588 TestFaviconClient client; | 593 TestFaviconClient client; |
| 589 TestFaviconHandler helper( | 594 TestFaviconHandler helper( |
| 590 page_url, &client, &driver, FaviconHandler::FAVICON, false); | 595 page_url, &client, &driver, FaviconHandler::FAVICON, false); |
| 591 | 596 |
| 592 helper.FetchFavicon(page_url); | 597 helper.FetchFavicon(page_url); |
| 593 HistoryRequestHandler* history_handler = helper.history_handler(); | 598 HistoryRequestHandler* history_handler = helper.history_handler(); |
| 594 // Ensure the data given to history is correct. | 599 // Ensure the data given to history is correct. |
| 595 ASSERT_TRUE(history_handler); | 600 ASSERT_TRUE(history_handler); |
| 596 EXPECT_EQ(page_url, history_handler->page_url_); | 601 EXPECT_EQ(page_url, history_handler->page_url_); |
| 597 EXPECT_EQ(GURL(), history_handler->icon_url_); | 602 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 598 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); | 603 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
| 599 | 604 |
| 600 // Set valid icon data. | 605 // Set valid icon data. |
| 601 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); | 606 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); |
| 602 | 607 |
| 603 // Send history response. | 608 // Send history response. |
| 604 history_handler->InvokeCallback(); | 609 history_handler->InvokeCallback(); |
| 605 // Verify FaviconHandler status. | 610 // Verify FaviconHandler status. |
| 606 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); | 611 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 607 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); | 612 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 608 | 613 |
| 609 // 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 |
| 610 // history. | 615 // history. |
| 611 helper.set_history_handler(NULL); | 616 helper.set_history_handler(NULL); |
| 612 | 617 |
| 613 // Simulates update with the different favicon url. | 618 // Simulates update with the different favicon url. |
| 614 std::vector<FaviconURL> urls; | 619 std::vector<FaviconURL> urls; |
| 615 urls.push_back( | 620 urls.push_back( |
| 616 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 621 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); |
| 617 helper.OnUpdateFaviconURL(urls); | 622 helper.OnUpdateFaviconURL(urls); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 648 | 653 |
| 649 // New icon should be saved to history backend and navigation entry. | 654 // New icon should be saved to history backend and navigation entry. |
| 650 history_handler = helper.history_handler(); | 655 history_handler = helper.history_handler(); |
| 651 ASSERT_TRUE(history_handler); | 656 ASSERT_TRUE(history_handler); |
| 652 EXPECT_EQ(new_icon_url, history_handler->icon_url_); | 657 EXPECT_EQ(new_icon_url, history_handler->icon_url_); |
| 653 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 658 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); |
| 654 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 659 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
| 655 EXPECT_EQ(page_url, history_handler->page_url_); | 660 EXPECT_EQ(page_url, history_handler->page_url_); |
| 656 | 661 |
| 657 // Verify NavigationEntry. | 662 // Verify NavigationEntry. |
| 658 content::FaviconStatus favicon_status = helper.GetEntry()->GetFavicon(); | 663 EXPECT_EQ(new_icon_url, driver.GetActiveFaviconURL()); |
| 659 EXPECT_EQ(new_icon_url, favicon_status.url); | 664 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 660 EXPECT_TRUE(favicon_status.valid); | 665 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
| 661 EXPECT_FALSE(favicon_status.image.IsEmpty()); | 666 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
| 662 EXPECT_EQ(gfx::kFaviconSize, favicon_status.image.Width()); | |
| 663 } | 667 } |
| 664 | 668 |
| 665 TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) { | 669 TEST_F(FaviconHandlerTest, FaviconInHistoryInvalid) { |
| 666 const GURL page_url("http://www.google.com"); | 670 const GURL page_url("http://www.google.com"); |
| 667 const GURL icon_url("http://www.google.com/favicon"); | 671 const GURL icon_url("http://www.google.com/favicon"); |
| 668 | 672 |
| 669 TestFaviconDriver driver; | 673 TestFaviconDriver driver; |
| 670 TestFaviconClient client; | 674 TestFaviconClient client; |
| 671 TestFaviconHandler helper( | 675 TestFaviconHandler helper( |
| 672 page_url, &client, &driver, FaviconHandler::FAVICON, false); | 676 page_url, &client, &driver, FaviconHandler::FAVICON, false); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 686 bitmap_result.bitmap_data = new base::RefCountedBytes(); | 690 bitmap_result.bitmap_data = new base::RefCountedBytes(); |
| 687 bitmap_result.pixel_size = gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); | 691 bitmap_result.pixel_size = gfx::Size(gfx::kFaviconSize, gfx::kFaviconSize); |
| 688 bitmap_result.icon_type = favicon_base::FAVICON; | 692 bitmap_result.icon_type = favicon_base::FAVICON; |
| 689 bitmap_result.icon_url = icon_url; | 693 bitmap_result.icon_url = icon_url; |
| 690 history_handler->history_results_.clear(); | 694 history_handler->history_results_.clear(); |
| 691 history_handler->history_results_.push_back(bitmap_result); | 695 history_handler->history_results_.push_back(bitmap_result); |
| 692 | 696 |
| 693 // Send history response. | 697 // Send history response. |
| 694 history_handler->InvokeCallback(); | 698 history_handler->InvokeCallback(); |
| 695 // The NavigationEntry should not be set yet as the history data is invalid. | 699 // The NavigationEntry should not be set yet as the history data is invalid. |
| 696 EXPECT_FALSE(helper.GetEntry()->GetFavicon().valid); | 700 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
| 697 EXPECT_EQ(GURL(), helper.GetEntry()->GetFavicon().url); | 701 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
| 698 | 702 |
| 699 // 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 |
| 700 // history. | 704 // history. |
| 701 helper.set_history_handler(NULL); | 705 helper.set_history_handler(NULL); |
| 702 | 706 |
| 703 // Simulates update with matching favicon URL. | 707 // Simulates update with matching favicon URL. |
| 704 std::vector<FaviconURL> urls; | 708 std::vector<FaviconURL> urls; |
| 705 urls.push_back( | 709 urls.push_back( |
| 706 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 710 FaviconURL(icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); |
| 707 helper.OnUpdateFaviconURL(urls); | 711 helper.OnUpdateFaviconURL(urls); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 720 | 724 |
| 721 // New icon should be saved to history backend and navigation entry. | 725 // New icon should be saved to history backend and navigation entry. |
| 722 history_handler = helper.history_handler(); | 726 history_handler = helper.history_handler(); |
| 723 ASSERT_TRUE(history_handler); | 727 ASSERT_TRUE(history_handler); |
| 724 EXPECT_EQ(icon_url, history_handler->icon_url_); | 728 EXPECT_EQ(icon_url, history_handler->icon_url_); |
| 725 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); | 729 EXPECT_EQ(FaviconURL::FAVICON, history_handler->icon_type_); |
| 726 EXPECT_LT(0U, history_handler->bitmap_data_.size()); | 730 EXPECT_LT(0U, history_handler->bitmap_data_.size()); |
| 727 EXPECT_EQ(page_url, history_handler->page_url_); | 731 EXPECT_EQ(page_url, history_handler->page_url_); |
| 728 | 732 |
| 729 // Verify NavigationEntry. | 733 // Verify NavigationEntry. |
| 730 content::FaviconStatus favicon_status = helper.GetEntry()->GetFavicon(); | 734 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 731 EXPECT_EQ(icon_url, favicon_status.url); | 735 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 732 EXPECT_TRUE(favicon_status.valid); | 736 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
| 733 EXPECT_FALSE(favicon_status.image.IsEmpty()); | 737 EXPECT_EQ(gfx::kFaviconSize, driver.GetActiveFaviconImage().Width()); |
| 734 EXPECT_EQ(gfx::kFaviconSize, favicon_status.image.Width()); | |
| 735 } | 738 } |
| 736 | 739 |
| 737 TEST_F(FaviconHandlerTest, UpdateFavicon) { | 740 TEST_F(FaviconHandlerTest, UpdateFavicon) { |
| 738 const GURL page_url("http://www.google.com"); | 741 const GURL page_url("http://www.google.com"); |
| 739 const GURL icon_url("http://www.google.com/favicon"); | 742 const GURL icon_url("http://www.google.com/favicon"); |
| 740 const GURL new_icon_url("http://www.google.com/new_favicon"); | 743 const GURL new_icon_url("http://www.google.com/new_favicon"); |
| 741 | 744 |
| 742 TestFaviconDriver driver; | 745 TestFaviconDriver driver; |
| 743 TestFaviconClient client; | 746 TestFaviconClient client; |
| 744 TestFaviconHandler helper( | 747 TestFaviconHandler helper( |
| 745 page_url, &client, &driver, FaviconHandler::FAVICON, false); | 748 page_url, &client, &driver, FaviconHandler::FAVICON, false); |
| 746 | 749 |
| 747 helper.FetchFavicon(page_url); | 750 helper.FetchFavicon(page_url); |
| 748 HistoryRequestHandler* history_handler = helper.history_handler(); | 751 HistoryRequestHandler* history_handler = helper.history_handler(); |
| 749 // Ensure the data given to history is correct. | 752 // Ensure the data given to history is correct. |
| 750 ASSERT_TRUE(history_handler); | 753 ASSERT_TRUE(history_handler); |
| 751 EXPECT_EQ(page_url, history_handler->page_url_); | 754 EXPECT_EQ(page_url, history_handler->page_url_); |
| 752 EXPECT_EQ(GURL(), history_handler->icon_url_); | 755 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 753 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); | 756 EXPECT_EQ(favicon_base::FAVICON, history_handler->icon_type_); |
| 754 | 757 |
| 755 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); | 758 SetFaviconBitmapResult(icon_url, &history_handler->history_results_); |
| 756 | 759 |
| 757 // Send history response. | 760 // Send history response. |
| 758 history_handler->InvokeCallback(); | 761 history_handler->InvokeCallback(); |
| 759 // Verify FaviconHandler status. | 762 // Verify FaviconHandler status. |
| 760 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); | 763 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 761 EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url); | 764 EXPECT_EQ(icon_url, driver.GetActiveFaviconURL()); |
| 762 | 765 |
| 763 // 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 |
| 764 // history. | 767 // history. |
| 765 helper.set_history_handler(NULL); | 768 helper.set_history_handler(NULL); |
| 766 | 769 |
| 767 // Simulates update with the different favicon url. | 770 // Simulates update with the different favicon url. |
| 768 std::vector<FaviconURL> urls; | 771 std::vector<FaviconURL> urls; |
| 769 urls.push_back( | 772 urls.push_back( |
| 770 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); | 773 FaviconURL(new_icon_url, FaviconURL::FAVICON, std::vector<gfx::Size>())); |
| 771 helper.OnUpdateFaviconURL(urls); | 774 helper.OnUpdateFaviconURL(urls); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 784 EXPECT_EQ(page_url, history_handler->page_url_); | 787 EXPECT_EQ(page_url, history_handler->page_url_); |
| 785 | 788 |
| 786 // Simulate find icon. | 789 // Simulate find icon. |
| 787 SetFaviconBitmapResult(new_icon_url, &history_handler->history_results_); | 790 SetFaviconBitmapResult(new_icon_url, &history_handler->history_results_); |
| 788 history_handler->InvokeCallback(); | 791 history_handler->InvokeCallback(); |
| 789 | 792 |
| 790 // Shouldn't request download favicon | 793 // Shouldn't request download favicon |
| 791 EXPECT_FALSE(helper.download_handler()->HasDownload()); | 794 EXPECT_FALSE(helper.download_handler()->HasDownload()); |
| 792 | 795 |
| 793 // Verify the favicon status. | 796 // Verify the favicon status. |
| 794 EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url); | 797 EXPECT_EQ(new_icon_url, driver.GetActiveFaviconURL()); |
| 795 EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid); | 798 EXPECT_TRUE(driver.GetActiveFaviconValidity()); |
| 796 EXPECT_FALSE(helper.GetEntry()->GetFavicon().image.IsEmpty()); | 799 EXPECT_FALSE(driver.GetActiveFaviconImage().IsEmpty()); |
| 797 } | 800 } |
| 798 | 801 |
| 799 TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { | 802 TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) { |
| 800 const GURL page_url("http://www.google.com"); | 803 const GURL page_url("http://www.google.com"); |
| 801 const GURL icon_url("http://www.google.com/favicon"); | 804 const GURL icon_url("http://www.google.com/favicon"); |
| 802 const GURL new_icon_url("http://www.google.com/new_favicon"); | 805 const GURL new_icon_url("http://www.google.com/new_favicon"); |
| 803 | 806 |
| 804 TestFaviconDriver driver; | 807 TestFaviconDriver driver; |
| 805 TestFaviconClient client; | 808 TestFaviconClient client; |
| 806 TestFaviconHandler helper( | 809 TestFaviconHandler helper( |
| 807 page_url, &client, &driver, FaviconHandler::TOUCH, false); | 810 page_url, &client, &driver, FaviconHandler::TOUCH, false); |
| 808 | 811 |
| 809 helper.FetchFavicon(page_url); | 812 helper.FetchFavicon(page_url); |
| 810 HistoryRequestHandler* history_handler = helper.history_handler(); | 813 HistoryRequestHandler* history_handler = helper.history_handler(); |
| 811 // Ensure the data given to history is correct. | 814 // Ensure the data given to history is correct. |
| 812 ASSERT_TRUE(history_handler); | 815 ASSERT_TRUE(history_handler); |
| 813 EXPECT_EQ(page_url, history_handler->page_url_); | 816 EXPECT_EQ(page_url, history_handler->page_url_); |
| 814 EXPECT_EQ(GURL(), history_handler->icon_url_); | 817 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 815 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, | 818 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, |
| 816 history_handler->icon_type_); | 819 history_handler->icon_type_); |
| 817 | 820 |
| 818 // Icon not found. | 821 // Icon not found. |
| 819 history_handler->history_results_.clear(); | 822 history_handler->history_results_.clear(); |
| 820 // Send history response. | 823 // Send history response. |
| 821 history_handler->InvokeCallback(); | 824 history_handler->InvokeCallback(); |
| 822 // Verify FaviconHandler status. | 825 // Verify FaviconHandler status. |
| 823 EXPECT_FALSE(helper.GetEntry()->GetFavicon().valid); | 826 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
| 824 EXPECT_EQ(GURL(), helper.GetEntry()->GetFavicon().url); | 827 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
| 825 | 828 |
| 826 // 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 |
| 827 // history. | 830 // history. |
| 828 helper.set_history_handler(NULL); | 831 helper.set_history_handler(NULL); |
| 829 | 832 |
| 830 // Simulates update with the different favicon url. | 833 // Simulates update with the different favicon url. |
| 831 std::vector<FaviconURL> urls; | 834 std::vector<FaviconURL> urls; |
| 832 urls.push_back(FaviconURL( | 835 urls.push_back(FaviconURL( |
| 833 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); | 836 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); |
| 834 urls.push_back(FaviconURL( | 837 urls.push_back(FaviconURL( |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 EXPECT_EQ(page_url, history_handler->page_url_); | 930 EXPECT_EQ(page_url, history_handler->page_url_); |
| 928 EXPECT_EQ(GURL(), history_handler->icon_url_); | 931 EXPECT_EQ(GURL(), history_handler->icon_url_); |
| 929 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, | 932 EXPECT_EQ(favicon_base::TOUCH_PRECOMPOSED_ICON | favicon_base::TOUCH_ICON, |
| 930 history_handler->icon_type_); | 933 history_handler->icon_type_); |
| 931 | 934 |
| 932 // Icon not found. | 935 // Icon not found. |
| 933 history_handler->history_results_.clear(); | 936 history_handler->history_results_.clear(); |
| 934 // Send history response. | 937 // Send history response. |
| 935 history_handler->InvokeCallback(); | 938 history_handler->InvokeCallback(); |
| 936 // Verify FaviconHandler status. | 939 // Verify FaviconHandler status. |
| 937 EXPECT_FALSE(helper.GetEntry()->GetFavicon().valid); | 940 EXPECT_FALSE(driver.GetActiveFaviconValidity()); |
| 938 EXPECT_EQ(GURL(), helper.GetEntry()->GetFavicon().url); | 941 EXPECT_EQ(GURL(), driver.GetActiveFaviconURL()); |
| 939 | 942 |
| 940 // Reset the history_handler to verify whether new icon is requested from | 943 // Reset the history_handler to verify whether new icon is requested from |
| 941 // history. | 944 // history. |
| 942 helper.set_history_handler(NULL); | 945 helper.set_history_handler(NULL); |
| 943 | 946 |
| 944 // Simulates update with the different favicon url. | 947 // Simulates update with the different favicon url. |
| 945 std::vector<FaviconURL> urls; | 948 std::vector<FaviconURL> urls; |
| 946 urls.push_back(FaviconURL( | 949 urls.push_back(FaviconURL( |
| 947 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); | 950 icon_url, FaviconURL::TOUCH_PRECOMPOSED_ICON, std::vector<gfx::Size>())); |
| 948 urls.push_back(FaviconURL( | 951 urls.push_back(FaviconURL( |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 TestFaviconDriver driver1; | 1063 TestFaviconDriver driver1; |
| 1061 TestFaviconClient client; | 1064 TestFaviconClient client; |
| 1062 TestFaviconHandler handler1( | 1065 TestFaviconHandler handler1( |
| 1063 kPageURL, &client, &driver1, FaviconHandler::FAVICON, false); | 1066 kPageURL, &client, &driver1, FaviconHandler::FAVICON, false); |
| 1064 | 1067 |
| 1065 const int kSizes1[] = { 16, 24, 32, 48, 256 }; | 1068 const int kSizes1[] = { 16, 24, 32, 48, 256 }; |
| 1066 std::vector<FaviconURL> urls1(kSourceIconURLs, | 1069 std::vector<FaviconURL> urls1(kSourceIconURLs, |
| 1067 kSourceIconURLs + arraysize(kSizes1)); | 1070 kSourceIconURLs + arraysize(kSizes1)); |
| 1068 DownloadTillDoneIgnoringHistory(&handler1, kPageURL, urls1, kSizes1); | 1071 DownloadTillDoneIgnoringHistory(&handler1, kPageURL, urls1, kSizes1); |
| 1069 | 1072 |
| 1070 content::FaviconStatus favicon_status1(handler1.GetEntry()->GetFavicon()); | |
| 1071 EXPECT_EQ(0u, handler1.image_urls().size()); | 1073 EXPECT_EQ(0u, handler1.image_urls().size()); |
| 1072 EXPECT_TRUE(favicon_status1.valid); | 1074 EXPECT_TRUE(driver1.GetActiveFaviconValidity()); |
| 1073 EXPECT_FALSE(favicon_status1.image.IsEmpty()); | 1075 EXPECT_FALSE(driver1.GetActiveFaviconImage().IsEmpty()); |
| 1074 EXPECT_EQ(gfx::kFaviconSize, favicon_status1.image.Width()); | 1076 EXPECT_EQ(gfx::kFaviconSize, driver1.GetActiveFaviconImage().Width()); |
| 1075 | 1077 |
| 1076 size_t expected_index = 2u; | 1078 size_t expected_index = 2u; |
| 1077 EXPECT_EQ(32, kSizes1[expected_index]); | 1079 EXPECT_EQ(32, kSizes1[expected_index]); |
| 1078 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, | 1080 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, |
| 1079 handler1.GetEntry()->GetFavicon().url); | 1081 driver1.GetActiveFaviconURL()); |
| 1080 | 1082 |
| 1081 // 2) Test that if there are several single resolution favicons to choose | 1083 // 2) Test that if there are several single resolution favicons to choose |
| 1082 // from, the exact match is preferred even if it results in upsampling. | 1084 // from, the exact match is preferred even if it results in upsampling. |
| 1083 TestFaviconDriver driver2; | 1085 TestFaviconDriver driver2; |
| 1084 TestFaviconHandler handler2( | 1086 TestFaviconHandler handler2( |
| 1085 kPageURL, &client, &driver2, FaviconHandler::FAVICON, false); | 1087 kPageURL, &client, &driver2, FaviconHandler::FAVICON, false); |
| 1086 | 1088 |
| 1087 const int kSizes2[] = { 16, 24, 48, 256 }; | 1089 const int kSizes2[] = { 16, 24, 48, 256 }; |
| 1088 std::vector<FaviconURL> urls2(kSourceIconURLs, | 1090 std::vector<FaviconURL> urls2(kSourceIconURLs, |
| 1089 kSourceIconURLs + arraysize(kSizes2)); | 1091 kSourceIconURLs + arraysize(kSizes2)); |
| 1090 DownloadTillDoneIgnoringHistory(&handler2, kPageURL, urls2, kSizes2); | 1092 DownloadTillDoneIgnoringHistory(&handler2, kPageURL, urls2, kSizes2); |
| 1091 EXPECT_TRUE(handler2.GetEntry()->GetFavicon().valid); | 1093 EXPECT_TRUE(driver2.GetActiveFaviconValidity()); |
| 1092 expected_index = 0u; | 1094 expected_index = 0u; |
| 1093 EXPECT_EQ(16, kSizes2[expected_index]); | 1095 EXPECT_EQ(16, kSizes2[expected_index]); |
| 1094 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, | 1096 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, |
| 1095 handler2.GetEntry()->GetFavicon().url); | 1097 driver2.GetActiveFaviconURL()); |
| 1096 | 1098 |
| 1097 // 3) Test that favicons which need to be upsampled a little or downsampled | 1099 // 3) Test that favicons which need to be upsampled a little or downsampled |
| 1098 // a little are preferred over huge favicons. | 1100 // a little are preferred over huge favicons. |
| 1099 TestFaviconDriver driver3; | 1101 TestFaviconDriver driver3; |
| 1100 TestFaviconHandler handler3( | 1102 TestFaviconHandler handler3( |
| 1101 kPageURL, &client, &driver3, FaviconHandler::FAVICON, false); | 1103 kPageURL, &client, &driver3, FaviconHandler::FAVICON, false); |
| 1102 | 1104 |
| 1103 const int kSizes3[] = { 256, 48 }; | 1105 const int kSizes3[] = { 256, 48 }; |
| 1104 std::vector<FaviconURL> urls3(kSourceIconURLs, | 1106 std::vector<FaviconURL> urls3(kSourceIconURLs, |
| 1105 kSourceIconURLs + arraysize(kSizes3)); | 1107 kSourceIconURLs + arraysize(kSizes3)); |
| 1106 DownloadTillDoneIgnoringHistory(&handler3, kPageURL, urls3, kSizes3); | 1108 DownloadTillDoneIgnoringHistory(&handler3, kPageURL, urls3, kSizes3); |
| 1107 EXPECT_TRUE(handler3.GetEntry()->GetFavicon().valid); | 1109 EXPECT_TRUE(driver3.GetActiveFaviconValidity()); |
| 1108 expected_index = 1u; | 1110 expected_index = 1u; |
| 1109 EXPECT_EQ(48, kSizes3[expected_index]); | 1111 EXPECT_EQ(48, kSizes3[expected_index]); |
| 1110 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, | 1112 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, |
| 1111 handler3.GetEntry()->GetFavicon().url); | 1113 driver3.GetActiveFaviconURL()); |
| 1112 | 1114 |
| 1113 TestFaviconDriver driver4; | 1115 TestFaviconDriver driver4; |
| 1114 TestFaviconHandler handler4( | 1116 TestFaviconHandler handler4( |
| 1115 kPageURL, &client, &driver4, FaviconHandler::FAVICON, false); | 1117 kPageURL, &client, &driver4, FaviconHandler::FAVICON, false); |
| 1116 | 1118 |
| 1117 const int kSizes4[] = { 17, 256 }; | 1119 const int kSizes4[] = { 17, 256 }; |
| 1118 std::vector<FaviconURL> urls4(kSourceIconURLs, | 1120 std::vector<FaviconURL> urls4(kSourceIconURLs, |
| 1119 kSourceIconURLs + arraysize(kSizes4)); | 1121 kSourceIconURLs + arraysize(kSizes4)); |
| 1120 DownloadTillDoneIgnoringHistory(&handler4, kPageURL, urls4, kSizes4); | 1122 DownloadTillDoneIgnoringHistory(&handler4, kPageURL, urls4, kSizes4); |
| 1121 EXPECT_TRUE(handler4.GetEntry()->GetFavicon().valid); | 1123 EXPECT_TRUE(driver4.GetActiveFaviconValidity()); |
| 1122 expected_index = 0u; | 1124 expected_index = 0u; |
| 1123 EXPECT_EQ(17, kSizes4[expected_index]); | 1125 EXPECT_EQ(17, kSizes4[expected_index]); |
| 1124 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, | 1126 EXPECT_EQ(kSourceIconURLs[expected_index].icon_url, |
| 1125 handler4.GetEntry()->GetFavicon().url); | 1127 driver4.GetActiveFaviconURL()); |
| 1126 } | 1128 } |
| 1127 | 1129 |
| 1128 #endif | 1130 #endif |
| 1129 | 1131 |
| 1130 TEST_F(FaviconHandlerTest, TestSortFavicon) { | 1132 TEST_F(FaviconHandlerTest, TestSortFavicon) { |
| 1131 const GURL kPageURL("http://www.google.com"); | 1133 const GURL kPageURL("http://www.google.com"); |
| 1132 std::vector<gfx::Size> icon1; | 1134 std::vector<gfx::Size> icon1; |
| 1133 icon1.push_back(gfx::Size(1024, 1024)); | 1135 icon1.push_back(gfx::Size(1024, 1024)); |
| 1134 icon1.push_back(gfx::Size(512, 512)); | 1136 icon1.push_back(gfx::Size(512, 512)); |
| 1135 | 1137 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); | 1493 download_id = favicon_tab_helper->StartDownload(missing_icon_url, 0); |
| 1492 EXPECT_NE(0, download_id); | 1494 EXPECT_NE(0, download_id); |
| 1493 // Report download success with HTTP 200 status. | 1495 // Report download success with HTTP 200 status. |
| 1494 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, | 1496 favicon_tab_helper->DidDownloadFavicon(download_id, 200, missing_icon_url, |
| 1495 empty_icons, empty_icon_sizes); | 1497 empty_icons, empty_icon_sizes); |
| 1496 // Icon is not marked as UnableToDownload as HTTP status is not 404. | 1498 // Icon is not marked as UnableToDownload as HTTP status is not 404. |
| 1497 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); | 1499 EXPECT_FALSE(favicon_service->WasUnableToDownloadFavicon(missing_icon_url)); |
| 1498 } | 1500 } |
| 1499 | 1501 |
| 1500 } // namespace. | 1502 } // namespace. |
| OLD | NEW |