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

Unified Diff: chrome/browser/ui/cocoa/menu_controller_unittest.mm

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/menu_controller_unittest.mm
diff --git a/chrome/browser/ui/cocoa/menu_controller_unittest.mm b/chrome/browser/ui/cocoa/menu_controller_unittest.mm
index 0fd9a87a0a842fea26ef2fc3b450574dea4d9507..c275005260724b0ee70039fc7ed60616a58a30da 100644
--- a/chrome/browser/ui/cocoa/menu_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/menu_controller_unittest.mm
@@ -14,7 +14,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image.h"
namespace {
@@ -75,23 +75,23 @@ class Delegate : public ui::SimpleMenuModel::Delegate {
// the label/icon in the model are reflected in the menu.
class DynamicDelegate : public Delegate {
public:
- DynamicDelegate() : icon_(NULL) {}
+ DynamicDelegate() {}
virtual bool IsItemForCommandIdDynamic(int command_id) const { return true; }
virtual string16 GetLabelForCommandId(int command_id) const { return label_; }
- virtual bool GetIconForCommandId(int command_id, gfx::ImageSkia* icon) const {
- if (icon_) {
- *icon = *icon_;
- return true;
- } else {
+ virtual bool GetIconForCommandId(int command_id, gfx::Image* icon) const {
+ if (icon_.IsEmpty()) {
return false;
+ } else {
+ *icon = icon_;
+ return true;
}
}
void SetDynamicLabel(string16 label) { label_ = label; }
- void SetDynamicIcon(SkBitmap* icon) { icon_ = icon; }
+ void SetDynamicIcon(const gfx::Image& icon) { icon_ = icon; }
private:
string16 label_;
- SkBitmap* icon_;
+ gfx::Image icon_;
};
TEST_F(MenuControllerTest, EmptyMenu) {
@@ -280,16 +280,16 @@ TEST_F(MenuControllerTest, Dynamic) {
// Now update the item to have a label of "second" and an icon.
string16 second = ASCIIToUTF16("second");
delegate.SetDynamicLabel(second);
- SkBitmap* bitmap =
- ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_THROBBER);
- delegate.SetDynamicIcon(bitmap);
+ const gfx::Image& icon =
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(IDR_THROBBER);
+ delegate.SetDynamicIcon(icon);
// Simulate opening the menu and validate that the item label + icon changes.
Validate(menu.get(), [menu menu]);
EXPECT_EQ(second, base::SysNSStringToUTF16([item title]));
EXPECT_TRUE([item image] != nil);
// Now get rid of the icon and make sure it goes away.
- delegate.SetDynamicIcon(NULL);
+ delegate.SetDynamicIcon(gfx::Image());
Validate(menu.get(), [menu menu]);
EXPECT_EQ(second, base::SysNSStringToUTF16([item title]));
EXPECT_EQ(nil, [item image]);
« no previous file with comments | « chrome/browser/ui/cocoa/menu_controller.mm ('k') | chrome/browser/ui/cocoa/toolbar/back_forward_menu_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698