| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 | 
| OLD | NEW | 
|---|