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

Side by Side Diff: chrome/browser/ui/cocoa/menu_controller_unittest.mm

Issue 10437006: Converts ui/views/controls, ui/views/examples, ui/base/models to ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 7 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 10 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
11 #include "chrome/browser/ui/cocoa/menu_controller.h" 11 #include "chrome/browser/ui/cocoa/menu_controller.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "grit/ui_resources.h" 13 #include "grit/ui_resources.h"
14 #include "third_party/skia/include/core/SkBitmap.h" 14 #include "third_party/skia/include/core/SkBitmap.h"
15 #include "ui/base/models/simple_menu_model.h" 15 #include "ui/base/models/simple_menu_model.h"
16 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image_skia.h"
17 18
18 class MenuControllerTest : public CocoaTest { 19 class MenuControllerTest : public CocoaTest {
19 }; 20 };
20 21
21 // A menu delegate that counts the number of times certain things are called 22 // A menu delegate that counts the number of times certain things are called
22 // to make sure things are hooked up properly. 23 // to make sure things are hooked up properly.
23 class Delegate : public ui::SimpleMenuModel::Delegate { 24 class Delegate : public ui::SimpleMenuModel::Delegate {
24 public: 25 public:
25 Delegate() 26 Delegate()
26 : execute_count_(0), 27 : execute_count_(0),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 bool did_close_; 69 bool did_close_;
69 }; 70 };
70 71
71 // Just like Delegate, except the items are treated as "dynamic" so updates to 72 // Just like Delegate, except the items are treated as "dynamic" so updates to
72 // the label/icon in the model are reflected in the menu. 73 // the label/icon in the model are reflected in the menu.
73 class DynamicDelegate : public Delegate { 74 class DynamicDelegate : public Delegate {
74 public: 75 public:
75 DynamicDelegate() : icon_(NULL) {} 76 DynamicDelegate() : icon_(NULL) {}
76 virtual bool IsItemForCommandIdDynamic(int command_id) const { return true; } 77 virtual bool IsItemForCommandIdDynamic(int command_id) const { return true; }
77 virtual string16 GetLabelForCommandId(int command_id) const { return label_; } 78 virtual string16 GetLabelForCommandId(int command_id) const { return label_; }
78 virtual bool GetIconForCommandId(int command_id, SkBitmap* icon) const { 79 virtual bool GetIconForCommandId(int command_id, gfx::ImageSkia* icon) const {
79 if (icon_) { 80 if (icon_) {
80 *icon = *icon_; 81 *icon = *icon_;
81 return true; 82 return true;
82 } else { 83 } else {
83 return false; 84 return false;
84 } 85 }
85 } 86 }
86 void SetDynamicLabel(string16 label) { label_ = label; } 87 void SetDynamicLabel(string16 label) { label_ = label; }
87 void SetDynamicIcon(SkBitmap* icon) { icon_ = icon; } 88 void SetDynamicIcon(SkBitmap* icon) { icon_ = icon; }
88 89
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // the delegate. But since this is a test and there's no running MessageLoop, 323 // the delegate. But since this is a test and there's no running MessageLoop,
323 // |did_close_| will remain false until we pump the task manually. 324 // |did_close_| will remain false until we pump the task manually.
324 EXPECT_FALSE(delegate.did_close_); 325 EXPECT_FALSE(delegate.did_close_);
325 326
326 // Pump the task that notifies the delegate. 327 // Pump the task that notifies the delegate.
327 message_loop.RunAllPending(); 328 message_loop.RunAllPending();
328 329
329 // Expect that the delegate got notified properly. 330 // Expect that the delegate got notified properly.
330 EXPECT_TRUE(delegate.did_close_); 331 EXPECT_TRUE(delegate.did_close_);
331 } 332 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698