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

Side by Side Diff: ui/base/cocoa/cocoa_base_utils_unittest.mm

Issue 160083003: Split cocoa_event_utils in two parts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: still works? Created 6 years, 10 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 | « ui/base/cocoa/cocoa_base_utils.mm ('k') | ui/base/cocoa/cocoa_event_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/cocoa/cocoa_base_utils.h"
6
7 #import <objc/objc-class.h>
8
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h"
11 #include "ui/events/event_constants.h"
12 #import "ui/events/test/cocoa_test_event_utils.h"
13 #import "ui/gfx/test/ui_cocoa_test_helper.h"
14
15 // We provide a donor class with a specially modified |modifierFlags|
16 // implementation that we swap with NSEvent's. This is because we can't create a
17 // NSEvent that represents a middle click with modifiers.
18 @interface TestEvent : NSObject
19 @end
20 @implementation TestEvent
21 - (NSUInteger)modifierFlags { return NSShiftKeyMask; }
22 @end
23
24 namespace ui {
25
26 namespace {
27
28 class CocoaBaseUtilsTest : public CocoaTest {
29 };
30
31 TEST_F(CocoaBaseUtilsTest, WindowOpenDispositionFromNSEvent) {
32 // Left Click = same tab.
33 NSEvent* me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 0);
34 EXPECT_EQ(CURRENT_TAB, WindowOpenDispositionFromNSEvent(me));
35
36 // Middle Click = new background tab.
37 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0);
38 EXPECT_EQ(NEW_BACKGROUND_TAB, WindowOpenDispositionFromNSEvent(me));
39
40 // Shift+Middle Click = new foreground tab.
41 {
42 ScopedClassSwizzler swizzler([NSEvent class], [TestEvent class],
43 @selector(modifierFlags));
44 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp,
45 NSShiftKeyMask);
46 EXPECT_EQ(NEW_FOREGROUND_TAB, WindowOpenDispositionFromNSEvent(me));
47 }
48
49 // Cmd+Left Click = new background tab.
50 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp,
51 NSCommandKeyMask);
52 EXPECT_EQ(NEW_BACKGROUND_TAB, WindowOpenDispositionFromNSEvent(me));
53
54 // Cmd+Shift+Left Click = new foreground tab.
55 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp,
56 NSCommandKeyMask |
57 NSShiftKeyMask);
58 EXPECT_EQ(NEW_FOREGROUND_TAB, WindowOpenDispositionFromNSEvent(me));
59
60 // Shift+Left Click = new window
61 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp,
62 NSShiftKeyMask);
63 EXPECT_EQ(NEW_WINDOW, WindowOpenDispositionFromNSEvent(me));
64 }
65
66 } // namespace
67
68 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/cocoa/cocoa_base_utils.mm ('k') | ui/base/cocoa/cocoa_event_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698