| 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 "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 527 |
| 528 // Set the desired favicon for url1. | 528 // Set the desired favicon for url1. |
| 529 HistoryServiceFactory::GetForProfile( | 529 HistoryServiceFactory::GetForProfile( |
| 530 profile(), Profile::EXPLICIT_ACCESS)->AddPage( | 530 profile(), Profile::EXPLICIT_ACCESS)->AddPage( |
| 531 url1, history::SOURCE_BROWSED); | 531 url1, history::SOURCE_BROWSED); |
| 532 profile()->GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, | 532 profile()->GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, |
| 533 url1_favicon, icon_data, history::FAVICON); | 533 url1_favicon, icon_data, history::FAVICON); |
| 534 | 534 |
| 535 // Will return the current icon (default) but start an anync call | 535 // Will return the current icon (default) but start an anync call |
| 536 // to retrieve the favicon from the favicon service. | 536 // to retrieve the favicon from the favicon service. |
| 537 gfx::ImageSkia default_icon; | 537 gfx::Image default_icon; |
| 538 back_model.GetIconAt(0, &default_icon); | 538 back_model.GetIconAt(0, &default_icon); |
| 539 | 539 |
| 540 // Make the favicon service run GetFavIconForURL, | 540 // Make the favicon service run GetFavIconForURL, |
| 541 // FaviconDelegate.OnIconChanged will be called. | 541 // FaviconDelegate.OnIconChanged will be called. |
| 542 MessageLoop::current()->Run(); | 542 MessageLoop::current()->Run(); |
| 543 | 543 |
| 544 // Verify that the callback executed. | 544 // Verify that the callback executed. |
| 545 EXPECT_TRUE(favicon_delegate.was_called()); | 545 EXPECT_TRUE(favicon_delegate.was_called()); |
| 546 | 546 |
| 547 // Verify the bitmaps match. | 547 // Verify the bitmaps match. |
| 548 gfx::ImageSkia valid_icon; | 548 gfx::Image valid_icon; |
| 549 // This time we will get the new favicon returned. | 549 // This time we will get the new favicon returned. |
| 550 back_model.GetIconAt(0, &valid_icon); | 550 back_model.GetIconAt(0, &valid_icon); |
| 551 | 551 |
| 552 SkBitmap default_icon_bitmap = *default_icon.bitmap(); | 552 SkBitmap default_icon_bitmap = *default_icon.ToSkBitmap(); |
| 553 SkBitmap valid_icon_bitmap = *valid_icon.bitmap(); | 553 SkBitmap valid_icon_bitmap = *valid_icon.ToSkBitmap(); |
| 554 | 554 |
| 555 SkAutoLockPixels a(new_icon_bitmap); | 555 SkAutoLockPixels a(new_icon_bitmap); |
| 556 SkAutoLockPixels b(valid_icon_bitmap); | 556 SkAutoLockPixels b(valid_icon_bitmap); |
| 557 SkAutoLockPixels c(default_icon_bitmap); | 557 SkAutoLockPixels c(default_icon_bitmap); |
| 558 // Verify we did not get the default favicon. | 558 // Verify we did not get the default favicon. |
| 559 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), | 559 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), |
| 560 valid_icon_bitmap.getPixels(), | 560 valid_icon_bitmap.getPixels(), |
| 561 default_icon_bitmap.getSize())); | 561 default_icon_bitmap.getSize())); |
| 562 // Verify we did get the expected favicon. | 562 // Verify we did get the expected favicon. |
| 563 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), | 563 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), |
| 564 valid_icon_bitmap.getPixels(), | 564 valid_icon_bitmap.getPixels(), |
| 565 new_icon_bitmap.getSize())); | 565 new_icon_bitmap.getSize())); |
| 566 | 566 |
| 567 // Make sure the browser deconstructor doesn't have problems. | 567 // Make sure the browser deconstructor doesn't have problems. |
| 568 chrome::CloseAllTabs(browser.get()); | 568 chrome::CloseAllTabs(browser.get()); |
| 569 // This is required to prevent the message loop from hanging. | 569 // This is required to prevent the message loop from hanging. |
| 570 profile()->DestroyHistoryService(); | 570 profile()->DestroyHistoryService(); |
| 571 } | 571 } |
| OLD | NEW |