| OLD | NEW |
| 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/cocoa/cocoa_test_helper.h" | 7 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 8 #include "chrome/browser/cocoa/event_utils.h" | 8 #include "chrome/browser/cocoa/event_utils.h" |
| 9 #include "chrome/browser/cocoa/test_event_utils.h" | 9 #include "chrome/browser/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 | 12 |
| 12 // We provide a donor class with a specially modified |modifierFlags| | 13 // We provide a donor class with a specially modified |modifierFlags| |
| 13 // implementation that we swap with NSEvent's. This is because we can't create a | 14 // implementation that we swap with NSEvent's. This is because we can't create a |
| 14 // NSEvent that represents a middle click with modifiers. | 15 // NSEvent that represents a middle click with modifiers. |
| 15 @interface TestEvent : NSObject | 16 @interface TestEvent : NSObject |
| 16 @end | 17 @end |
| 17 @implementation TestEvent | 18 @implementation TestEvent |
| 18 - (NSUInteger)modifierFlags { return NSShiftKeyMask; } | 19 - (NSUInteger)modifierFlags { return NSShiftKeyMask; } |
| 19 @end | 20 @end |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 class EventUtilsTest : public testing::Test { | 24 class EventUtilsTest : public PlatformTest { |
| 24 private: | 25 private: |
| 25 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | 26 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 TEST_F(EventUtilsTest, TestWindowOpenDispositionFromNSEvent) { | 29 TEST_F(EventUtilsTest, TestWindowOpenDispositionFromNSEvent) { |
| 29 // Left Click = same tab. | 30 // Left Click = same tab. |
| 30 NSEvent* me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, 0); | 31 NSEvent* me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, 0); |
| 31 EXPECT_EQ(CURRENT_TAB, event_utils::WindowOpenDispositionFromNSEvent(me)); | 32 EXPECT_EQ(CURRENT_TAB, event_utils::WindowOpenDispositionFromNSEvent(me)); |
| 32 | 33 |
| 33 // Middle Click = new background tab. | 34 // Middle Click = new background tab. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 53 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif
tKeyMask); | 54 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSCommandKeyMask | NSShif
tKeyMask); |
| 54 EXPECT_EQ(NEW_FOREGROUND_TAB, | 55 EXPECT_EQ(NEW_FOREGROUND_TAB, |
| 55 event_utils::WindowOpenDispositionFromNSEvent(me)); | 56 event_utils::WindowOpenDispositionFromNSEvent(me)); |
| 56 | 57 |
| 57 // Shift+Left Click = new window | 58 // Shift+Left Click = new window |
| 58 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask); | 59 me = test_event_utils::MakeMouseEvent(NSLeftMouseUp, NSShiftKeyMask); |
| 59 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me)); | 60 EXPECT_EQ(NEW_WINDOW, event_utils::WindowOpenDispositionFromNSEvent(me)); |
| 60 } | 61 } |
| 61 | 62 |
| 62 } // namespace | 63 } // namespace |
| OLD | NEW |