| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" |
| 8 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" | 14 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 14 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 ->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, | 530 ->SetFavicons(url1, url1_favicon, favicon_base::FAVICON, |
| 530 gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); | 531 gfx::Image::CreateFrom1xBitmap(new_icon_bitmap)); |
| 531 | 532 |
| 532 // Will return the current icon (default) but start an anync call | 533 // Will return the current icon (default) but start an anync call |
| 533 // to retrieve the favicon from the favicon service. | 534 // to retrieve the favicon from the favicon service. |
| 534 gfx::Image default_icon; | 535 gfx::Image default_icon; |
| 535 back_model.GetIconAt(0, &default_icon); | 536 back_model.GetIconAt(0, &default_icon); |
| 536 | 537 |
| 537 // Make the favicon service run GetFavIconForURL, | 538 // Make the favicon service run GetFavIconForURL, |
| 538 // FaviconDelegate.OnIconChanged will be called. | 539 // FaviconDelegate.OnIconChanged will be called. |
| 539 base::MessageLoop::current()->Run(); | 540 base::RunLoop().Run(); |
| 540 | 541 |
| 541 // Verify that the callback executed. | 542 // Verify that the callback executed. |
| 542 EXPECT_TRUE(favicon_delegate.was_called()); | 543 EXPECT_TRUE(favicon_delegate.was_called()); |
| 543 | 544 |
| 544 // Verify the bitmaps match. | 545 // Verify the bitmaps match. |
| 545 gfx::Image valid_icon; | 546 gfx::Image valid_icon; |
| 546 // This time we will get the new favicon returned. | 547 // This time we will get the new favicon returned. |
| 547 back_model.GetIconAt(0, &valid_icon); | 548 back_model.GetIconAt(0, &valid_icon); |
| 548 | 549 |
| 549 SkBitmap default_icon_bitmap = *default_icon.ToSkBitmap(); | 550 SkBitmap default_icon_bitmap = *default_icon.ToSkBitmap(); |
| 550 SkBitmap valid_icon_bitmap = *valid_icon.ToSkBitmap(); | 551 SkBitmap valid_icon_bitmap = *valid_icon.ToSkBitmap(); |
| 551 | 552 |
| 552 SkAutoLockPixels a(new_icon_bitmap); | 553 SkAutoLockPixels a(new_icon_bitmap); |
| 553 SkAutoLockPixels b(valid_icon_bitmap); | 554 SkAutoLockPixels b(valid_icon_bitmap); |
| 554 SkAutoLockPixels c(default_icon_bitmap); | 555 SkAutoLockPixels c(default_icon_bitmap); |
| 555 // Verify we did not get the default favicon. | 556 // Verify we did not get the default favicon. |
| 556 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), | 557 EXPECT_NE(0, memcmp(default_icon_bitmap.getPixels(), |
| 557 valid_icon_bitmap.getPixels(), | 558 valid_icon_bitmap.getPixels(), |
| 558 default_icon_bitmap.getSize())); | 559 default_icon_bitmap.getSize())); |
| 559 // Verify we did get the expected favicon. | 560 // Verify we did get the expected favicon. |
| 560 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), | 561 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), |
| 561 valid_icon_bitmap.getPixels(), | 562 valid_icon_bitmap.getPixels(), |
| 562 new_icon_bitmap.getSize())); | 563 new_icon_bitmap.getSize())); |
| 563 | 564 |
| 564 // Make sure the browser deconstructor doesn't have problems. | 565 // Make sure the browser deconstructor doesn't have problems. |
| 565 browser->tab_strip_model()->CloseAllTabs(); | 566 browser->tab_strip_model()->CloseAllTabs(); |
| 566 // This is required to prevent the message loop from hanging. | 567 // This is required to prevent the message loop from hanging. |
| 567 profile()->DestroyHistoryService(); | 568 profile()->DestroyHistoryService(); |
| 568 } | 569 } |
| OLD | NEW |