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

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

Issue 7492054: Don't send ViewMsg_ContextMenuClosed to the renderer process for submenus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 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"
(...skipping 22 matching lines...) Expand all
33 virtual bool IsCommandIdChecked(int command_id) const { return false; } 33 virtual bool IsCommandIdChecked(int command_id) const { return false; }
34 virtual bool IsCommandIdEnabled(int command_id) const { 34 virtual bool IsCommandIdEnabled(int command_id) const {
35 ++enable_count_; 35 ++enable_count_;
36 return true; 36 return true;
37 } 37 }
38 virtual bool GetAcceleratorForCommandId( 38 virtual bool GetAcceleratorForCommandId(
39 int command_id, 39 int command_id,
40 ui::Accelerator* accelerator) { return false; } 40 ui::Accelerator* accelerator) { return false; }
41 virtual void ExecuteCommand(int command_id) { ++execute_count_; } 41 virtual void ExecuteCommand(int command_id) { ++execute_count_; }
42 42
43 virtual void MenuWillShow() { 43 virtual void MenuWillShow(ui::SimpleMenuModel* /*source*/) {
44 EXPECT_FALSE(did_show_); 44 EXPECT_FALSE(did_show_);
45 EXPECT_FALSE(did_close_); 45 EXPECT_FALSE(did_close_);
46 did_show_ = true; 46 did_show_ = true;
47 NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode, 47 NSArray* modes = [NSArray arrayWithObjects:NSEventTrackingRunLoopMode,
48 NSDefaultRunLoopMode, 48 NSDefaultRunLoopMode,
49 nil]; 49 nil];
50 [menu_to_close_ performSelector:@selector(cancelTracking) 50 [menu_to_close_ performSelector:@selector(cancelTracking)
51 withObject:nil 51 withObject:nil
52 afterDelay:0.1 52 afterDelay:0.1
53 inModes:modes]; 53 inModes:modes];
54 } 54 }
55 55
56 virtual void MenuClosed() { 56 virtual void MenuClosed(ui::SimpleMenuModel* /*source*/) {
57 EXPECT_TRUE(did_show_); 57 EXPECT_TRUE(did_show_);
58 EXPECT_FALSE(did_close_); 58 EXPECT_FALSE(did_close_);
59 did_close_ = true; 59 did_close_ = true;
60 } 60 }
61 61
62 int execute_count_; 62 int execute_count_;
63 mutable int enable_count_; 63 mutable int enable_count_;
64 // The menu on which to call |-cancelTracking| after a short delay in 64 // The menu on which to call |-cancelTracking| after a short delay in
65 // MenuWillShow. 65 // MenuWillShow.
66 NSMenu* menu_to_close_; 66 NSMenu* menu_to_close_;
(...skipping 255 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, 322 // 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. 323 // |did_close_| will remain false until we pump the task manually.
324 EXPECT_FALSE(delegate.did_close_); 324 EXPECT_FALSE(delegate.did_close_);
325 325
326 // Pump the task that notifies the delegate. 326 // Pump the task that notifies the delegate.
327 message_loop.RunAllPending(); 327 message_loop.RunAllPending();
328 328
329 // Expect that the delegate got notified properly. 329 // Expect that the delegate got notified properly.
330 EXPECT_TRUE(delegate.did_close_); 330 EXPECT_TRUE(delegate.did_close_);
331 } 331 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/browser/ui/views/button_dropdown_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698