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

Side by Side Diff: chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc

Issue 10824402: Convert ui::MenuModel to use gfx::Image instead of ImageSkia. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another day, another rebase 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 "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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/back_forward_menu_model.cc ('k') | chrome/browser/ui/toolbar/wrench_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698