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

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

Issue 7792048: WindowOpenDisposition should not be exposed in base and ui modules. (mac) (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed a bug... Created 9 years, 3 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 | « chrome/browser/ui/cocoa/event_utils.mm ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <objc/objc-class.h> 5 #import <objc/objc-class.h>
6 6
7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 7 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
8 #include "chrome/browser/ui/cocoa/event_utils.h" 8 #include "chrome/browser/ui/cocoa/event_utils.h"
9 #include "chrome/browser/ui/cocoa/test_event_utils.h" 9 #include "chrome/browser/ui/cocoa/test_event_utils.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/platform_test.h" 11 #include "testing/platform_test.h"
12 #include "ui/base/events.h"
12 13
13 // We provide a donor class with a specially modified |modifierFlags| 14 // We provide a donor class with a specially modified |modifierFlags|
14 // implementation that we swap with NSEvent's. This is because we can't create a 15 // implementation that we swap with NSEvent's. This is because we can't create a
15 // NSEvent that represents a middle click with modifiers. 16 // NSEvent that represents a middle click with modifiers.
16 @interface TestEvent : NSObject 17 @interface TestEvent : NSObject
17 @end 18 @end
18 @implementation TestEvent 19 @implementation TestEvent
19 - (NSUInteger)modifierFlags { return NSShiftKeyMask; } 20 - (NSUInteger)modifierFlags { return NSShiftKeyMask; }
20 @end 21 @end
21 22
(...skipping 29 matching lines...) Expand all
51 // Cmd+Shift+Left Click = new foreground tab. 52 // Cmd+Shift+Left Click = new foreground tab.
52 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif tKeyMask); 53 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif tKeyMask);
53 EXPECT_EQ(NEW_FOREGROUND_TAB, 54 EXPECT_EQ(NEW_FOREGROUND_TAB,
54 event_utils::WindowOpenDispositionFromNSEvent(me)); 55 event_utils::WindowOpenDispositionFromNSEvent(me));
55 56
56 // Shift+Left Click = new window 57 // Shift+Left Click = new window
57 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask); 58 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask);
58 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me)); 59 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me));
59 } 60 }
60 61
62
63 TEST_F(EventUtilsTest, TestEventFlagsFromNSEvent) {
64 // Left click.
65 NSEvent* left = test_event_utils::MakeMouseEvent(NSLeftMouseUp, 0);
66 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN,
67 event_utils::EventFlagsFromNSEvent(left));
68
69 // Right click.
70 NSEvent* right = test_event_utils::MakeMouseEvent(NSRightMouseUp, 0);
71 EXPECT_EQ(ui::EF_RIGHT_BUTTON_DOWN,
72 event_utils::EventFlagsFromNSEvent(right));
73
74 // Middle click.
75 NSEvent* middle = test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0);
76 EXPECT_EQ(ui::EF_MIDDLE_BUTTON_DOWN,
77 event_utils::EventFlagsFromNSEvent(middle));
78
79 // Caps + Left
80 NSEvent* caps = test_event_utils::MakeMouseEvent(
81 NSLeftMouseUp, NSAlphaShiftKeyMask);
82 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_CAPS_LOCK_DOWN,
83 event_utils::EventFlagsFromNSEvent(caps));
84
85 // Shift + Left
86 NSEvent* shift = test_event_utils::MakeMouseEvent(
87 NSLeftMouseUp, NSShiftKeyMask);
88 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_SHIFT_DOWN,
89 event_utils::EventFlagsFromNSEvent(shift));
90
91 // Ctrl + Left
92 NSEvent* ctrl = test_event_utils::MakeMouseEvent(
93 NSLeftMouseUp, NSControlKeyMask);
94 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_CONTROL_DOWN,
95 event_utils::EventFlagsFromNSEvent(ctrl));
96
97 // Alt + Left
98 NSEvent* alt = test_event_utils::MakeMouseEvent(
99 NSLeftMouseUp, NSAlternateKeyMask);
100 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_ALT_DOWN,
101 event_utils::EventFlagsFromNSEvent(alt));
102
103 // Cmd + Left
104 NSEvent* cmd = test_event_utils::MakeMouseEvent(
105 NSLeftMouseUp, NSCommandKeyMask);
106 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_COMMAND_DOWN,
107 event_utils::EventFlagsFromNSEvent(cmd));
108
109 // Shift + Ctrl + Left
110 NSEvent* shiftctrl = test_event_utils::MakeMouseEvent(
111 NSLeftMouseUp, NSShiftKeyMask | NSControlKeyMask);
112 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN,
113 event_utils::EventFlagsFromNSEvent(shiftctrl));
114
115 // Cmd + Alt + Right
116 NSEvent* cmdalt = test_event_utils::MakeMouseEvent(
117 NSLeftMouseUp, NSCommandKeyMask | NSAlternateKeyMask);
118 EXPECT_EQ(ui::EF_LEFT_BUTTON_DOWN | ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN,
119 event_utils::EventFlagsFromNSEvent(cmdalt));
120 }
121
61 } // namespace 122 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/event_utils.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698