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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
« no previous file with comments | « services/navigation/view_impl.cc ('k') | ui/base/window_open_disposition.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/base/cocoa/cocoa_base_utils.h" 5 #include "ui/base/cocoa/cocoa_base_utils.h"
6 6
7 #import <objc/objc-class.h> 7 #import <objc/objc-class.h>
8 8
9 #import "base/mac/scoped_objc_class_swizzler.h" 9 #import "base/mac/scoped_objc_class_swizzler.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 14 matching lines...) Expand all
25 namespace ui { 25 namespace ui {
26 26
27 namespace { 27 namespace {
28 28
29 class CocoaBaseUtilsTest : public CocoaTest { 29 class CocoaBaseUtilsTest : public CocoaTest {
30 }; 30 };
31 31
32 TEST_F(CocoaBaseUtilsTest, WindowOpenDispositionFromNSEvent) { 32 TEST_F(CocoaBaseUtilsTest, WindowOpenDispositionFromNSEvent) {
33 // Left Click = same tab. 33 // Left Click = same tab.
34 NSEvent* me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 0); 34 NSEvent* me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 0);
35 EXPECT_EQ(CURRENT_TAB, WindowOpenDispositionFromNSEvent(me)); 35 EXPECT_EQ(WindowOpenDisposition::CURRENT_TAB,
36 WindowOpenDispositionFromNSEvent(me));
36 37
37 // Middle Click = new background tab. 38 // Middle Click = new background tab.
38 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0); 39 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0);
39 EXPECT_EQ(NEW_BACKGROUND_TAB, WindowOpenDispositionFromNSEvent(me)); 40 EXPECT_EQ(WindowOpenDisposition::NEW_BACKGROUND_TAB,
41 WindowOpenDispositionFromNSEvent(me));
40 42
41 // Shift+Middle Click = new foreground tab. 43 // Shift+Middle Click = new foreground tab.
42 { 44 {
43 base::mac::ScopedObjCClassSwizzler swizzler( 45 base::mac::ScopedObjCClassSwizzler swizzler(
44 [NSEvent class], [TestEvent class], @selector(modifierFlags)); 46 [NSEvent class], [TestEvent class], @selector(modifierFlags));
45 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 47 me = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp,
46 NSShiftKeyMask); 48 NSShiftKeyMask);
47 EXPECT_EQ(NEW_FOREGROUND_TAB, WindowOpenDispositionFromNSEvent(me)); 49 EXPECT_EQ(WindowOpenDisposition::NEW_FOREGROUND_TAB,
50 WindowOpenDispositionFromNSEvent(me));
48 } 51 }
49 52
50 // Cmd+Left Click = new background tab. 53 // Cmd+Left Click = new background tab.
51 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 54 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp,
52 NSCommandKeyMask); 55 NSCommandKeyMask);
53 EXPECT_EQ(NEW_BACKGROUND_TAB, WindowOpenDispositionFromNSEvent(me)); 56 EXPECT_EQ(WindowOpenDisposition::NEW_BACKGROUND_TAB,
57 WindowOpenDispositionFromNSEvent(me));
54 58
55 // Cmd+Shift+Left Click = new foreground tab. 59 // Cmd+Shift+Left Click = new foreground tab.
56 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 60 me = cocoa_test_event_utils::MouseEventWithType(
57 NSCommandKeyMask | 61 NSLeftMouseUp, NSCommandKeyMask | NSShiftKeyMask);
58 NSShiftKeyMask); 62 EXPECT_EQ(WindowOpenDisposition::NEW_FOREGROUND_TAB,
59 EXPECT_EQ(NEW_FOREGROUND_TAB, WindowOpenDispositionFromNSEvent(me)); 63 WindowOpenDispositionFromNSEvent(me));
60 64
61 // Shift+Left Click = new window 65 // Shift+Left Click = new window
62 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp, 66 me = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseUp,
63 NSShiftKeyMask); 67 NSShiftKeyMask);
64 EXPECT_EQ(NEW_WINDOW, WindowOpenDispositionFromNSEvent(me)); 68 EXPECT_EQ(WindowOpenDisposition::NEW_WINDOW,
69 WindowOpenDispositionFromNSEvent(me));
65 } 70 }
66 71
67 } // namespace 72 } // namespace
68 73
69 } // namespace ui 74 } // namespace ui
OLDNEW
« no previous file with comments | « services/navigation/view_impl.cc ('k') | ui/base/window_open_disposition.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698