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

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

Issue 7031014: Support for better integration between OCMock and gtest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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
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 #import "third_party/ocmock/OCMock/OCMock.h" 15 #import "third_party/ocmock/OCMock/OCMock.h"
15 16
16 namespace { 17 namespace {
17 18
18 NSEvent* KeyEvent(const NSUInteger flags, const NSUInteger keyCode) { 19 NSEvent* KeyEvent(const NSUInteger flags, const NSUInteger keyCode) {
19 return [NSEvent keyEventWithType:NSKeyDown 20 return [NSEvent keyEventWithType:NSKeyDown
20 location:NSZeroPoint 21 location:NSZeroPoint
21 modifierFlags:flags 22 modifierFlags:flags
22 timestamp:0.0 23 timestamp:0.0
23 windowNumber:0 24 windowNumber:0
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 NSEvent* event = KeyEvent(NSCommandKeyMask, kVK_ANSI_1); 77 NSEvent* event = KeyEvent(NSCommandKeyMask, kVK_ANSI_1);
77 78
78 id delegate = CreateBrowserWindowControllerMock(); 79 id delegate = CreateBrowserWindowControllerMock();
79 [[delegate expect] executeCommand:IDC_SELECT_TAB_0]; 80 [[delegate expect] executeCommand:IDC_SELECT_TAB_0];
80 81
81 [window_ setDelegate:delegate]; 82 [window_ setDelegate:delegate];
82 [window_ performKeyEquivalent:event]; 83 [window_ performKeyEquivalent:event];
83 84
84 // Don't wish to mock all the way down... 85 // Don't wish to mock all the way down...
85 [window_ setDelegate:nil]; 86 [window_ setDelegate:nil];
86 [delegate verify]; 87 EXPECT_OCMOCK_VERIFY(delegate);
87 } 88 }
88 89
89 // Verify that an unhandled shortcut does not get forwarded via 90 // Verify that an unhandled shortcut does not get forwarded via
90 // -executeCommand:. 91 // -executeCommand:.
91 // TODO(shess) Think of a way to test that it is sent to the 92 // TODO(shess) Think of a way to test that it is sent to the
92 // superclass. 93 // superclass.
93 TEST_F(ChromeEventProcessingWindowTest, PerformKeyEquivalentNoForward) { 94 TEST_F(ChromeEventProcessingWindowTest, PerformKeyEquivalentNoForward) {
94 NSEvent* event = KeyEvent(0, 0); 95 NSEvent* event = KeyEvent(0, 0);
95 96
96 id delegate = CreateBrowserWindowControllerMock(); 97 id delegate = CreateBrowserWindowControllerMock();
97 98
98 [window_ setDelegate:delegate]; 99 [window_ setDelegate:delegate];
99 [window_ performKeyEquivalent:event]; 100 [window_ performKeyEquivalent:event];
100 101
101 // Don't wish to mock all the way down... 102 // Don't wish to mock all the way down...
102 [window_ setDelegate:nil]; 103 [window_ setDelegate:nil];
103 [delegate verify]; 104 EXPECT_OCMOCK_VERIFY(delegate);
104 } 105 }
105 106
106 } // namespace 107 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698