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

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

Issue 7004036: Added some enhancements to OCMock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed up protocol stuff Created 9 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <Carbon/Carbon.h> 5 #include <Carbon/Carbon.h>
6 6
7 #include "base/debug/debugger.h" 7 #include "base/debug/debugger.h"
8 #include "base/memory/scoped_nsobject.h" 8 #include "base/memory/scoped_nsobject.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 10 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 11 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
12 #import "chrome/browser/ui/cocoa/browser_frame_view.h" 12 #import "chrome/browser/ui/cocoa/browser_frame_view.h"
13 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 13 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
14 #include "third_party/ocmock/gtest_support.h" 14 #include "third_party/ocmock/gtest_support.h"
15 #import "third_party/ocmock/OCMock/OCMock.h" 15 #import "third_party/ocmock/OCMock/OCMock.h"
16 #import "third_party/ocmock/ocmock_extensions.h"
16 17
17 namespace { 18 namespace {
18 19
19 NSEvent* KeyEvent(const NSUInteger flags, const NSUInteger keyCode) { 20 NSEvent* KeyEvent(const NSUInteger flags, const NSUInteger keyCode) {
20 return [NSEvent keyEventWithType:NSKeyDown 21 return [NSEvent keyEventWithType:NSKeyDown
21 location:NSZeroPoint 22 location:NSZeroPoint
22 modifierFlags:flags 23 modifierFlags:flags
23 timestamp:0.0 24 timestamp:0.0
24 windowNumber:0 25 windowNumber:0
25 context:nil 26 context:nil
(...skipping 27 matching lines...) Expand all
53 CocoaTest::TearDown(); 54 CocoaTest::TearDown();
54 } 55 }
55 56
56 ChromeEventProcessingWindow* window_; 57 ChromeEventProcessingWindow* window_;
57 }; 58 };
58 59
59 id CreateBrowserWindowControllerMock() { 60 id CreateBrowserWindowControllerMock() {
60 id delegate = [OCMockObject mockForClass:[BrowserWindowController class]]; 61 id delegate = [OCMockObject mockForClass:[BrowserWindowController class]];
61 // Make conformsToProtocol return YES for @protocol(BrowserCommandExecutor) 62 // Make conformsToProtocol return YES for @protocol(BrowserCommandExecutor)
62 // to satisfy the DCHECK() in handleExtraKeyboardShortcut. 63 // to satisfy the DCHECK() in handleExtraKeyboardShortcut.
63 // 64 [[[delegate stub] andReturnBool:YES]
64 // TODO(akalin): Figure out how to replace OCMOCK_ANY below with 65 conformsToProtocol:[OCMArg conformsToProtocol:
65 // @protocol(BrowserCommandExecutor) and have it work. 66 @protocol(BrowserCommandExecutor)]];
66 BOOL yes = YES;
67 [[[delegate stub] andReturnValue:OCMOCK_VALUE(yes)]
68 conformsToProtocol:OCMOCK_ANY];
69 return delegate; 67 return delegate;
70 } 68 }
71 69
72 // Verify that the window intercepts a particular key event and 70 // Verify that the window intercepts a particular key event and
73 // forwards it to [delegate executeCommand:]. Assume that other 71 // forwards it to [delegate executeCommand:]. Assume that other
74 // CommandForKeyboardShortcut() will work the same for the rest. 72 // CommandForKeyboardShortcut() will work the same for the rest.
75 TEST_F(ChromeEventProcessingWindowTest, 73 TEST_F(ChromeEventProcessingWindowTest,
76 PerformKeyEquivalentForwardToExecuteCommand) { 74 PerformKeyEquivalentForwardToExecuteCommand) {
77 NSEvent* event = KeyEvent(NSCommandKeyMask, kVK_ANSI_1); 75 NSEvent* event = KeyEvent(NSCommandKeyMask, kVK_ANSI_1);
78 76
(...skipping 19 matching lines...) Expand all
98 96
99 [window_ setDelegate:delegate]; 97 [window_ setDelegate:delegate];
100 [window_ performKeyEquivalent:event]; 98 [window_ performKeyEquivalent:event];
101 99
102 // Don't wish to mock all the way down... 100 // Don't wish to mock all the way down...
103 [window_ setDelegate:nil]; 101 [window_ setDelegate:nil];
104 EXPECT_OCMOCK_VERIFY(delegate); 102 EXPECT_OCMOCK_VERIFY(delegate);
105 } 103 }
106 104
107 } // namespace 105 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698