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 #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/strings/sys_string_conversions.h" | 8 #include "base/strings/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" |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // Now get rid of the icon and make sure it goes away. | 301 // Now get rid of the icon and make sure it goes away. |
302 delegate.SetDynamicIcon(gfx::Image()); | 302 delegate.SetDynamicIcon(gfx::Image()); |
303 Validate(menu.get(), [menu menu]); | 303 Validate(menu.get(), [menu menu]); |
304 EXPECT_EQ(second, base::SysNSStringToUTF16([item title])); | 304 EXPECT_EQ(second, base::SysNSStringToUTF16([item title])); |
305 EXPECT_EQ(nil, [item image]); | 305 EXPECT_EQ(nil, [item image]); |
306 } | 306 } |
307 | 307 |
308 TEST_F(MenuControllerTest, OpenClose) { | 308 TEST_F(MenuControllerTest, OpenClose) { |
309 // ui::SimpleMenuModel posts a task that calls Delegate::MenuClosed. Create | 309 // ui::SimpleMenuModel posts a task that calls Delegate::MenuClosed. Create |
310 // a MessageLoop for that purpose. | 310 // a MessageLoop for that purpose. |
311 MessageLoop message_loop(MessageLoop::TYPE_UI); | 311 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
312 | 312 |
313 // Create the model. | 313 // Create the model. |
314 Delegate delegate; | 314 Delegate delegate; |
315 ui::SimpleMenuModel model(&delegate); | 315 ui::SimpleMenuModel model(&delegate); |
316 model.AddItem(1, ASCIIToUTF16("allays")); | 316 model.AddItem(1, ASCIIToUTF16("allays")); |
317 model.AddItem(2, ASCIIToUTF16("i")); | 317 model.AddItem(2, ASCIIToUTF16("i")); |
318 model.AddItem(3, ASCIIToUTF16("bf")); | 318 model.AddItem(3, ASCIIToUTF16("bf")); |
319 | 319 |
320 // Create the controller. | 320 // Create the controller. |
321 scoped_nsobject<MenuController> menu( | 321 scoped_nsobject<MenuController> menu( |
(...skipping 25 matching lines...) Expand all Loading... |
347 EXPECT_FALSE(delegate.did_close_); | 347 EXPECT_FALSE(delegate.did_close_); |
348 | 348 |
349 // Pump the task that notifies the delegate. | 349 // Pump the task that notifies the delegate. |
350 message_loop.RunUntilIdle(); | 350 message_loop.RunUntilIdle(); |
351 | 351 |
352 // Expect that the delegate got notified properly. | 352 // Expect that the delegate got notified properly. |
353 EXPECT_TRUE(delegate.did_close_); | 353 EXPECT_TRUE(delegate.did_close_); |
354 } | 354 } |
355 | 355 |
356 } // namespace | 356 } // namespace |
OLD | NEW |