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/events/event_utils.h" | 5 #include "ui/events/event_utils.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 | 8 |
9 #include "base/mac/scoped_cftyperef.h" | 9 #include "base/mac/scoped_cftyperef.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // Removing the border, and sending the same event should move it down in the | 281 // Removing the border, and sending the same event should move it down in the |
282 // toolkit-views coordinate system. | 282 // toolkit-views coordinate system. |
283 int height_change = NSHeight(frame_rect) - kTestHeight; | 283 int height_change = NSHeight(frame_rect) - kTestHeight; |
284 EXPECT_GT(height_change, 0); | 284 EXPECT_GT(height_change, 0); |
285 [test_window() setStyleMask:NSBorderlessWindowMask]; | 285 [test_window() setStyleMask:NSBorderlessWindowMask]; |
286 [test_window() setFrame:frame_rect display:YES]; | 286 [test_window() setFrame:frame_rect display:YES]; |
287 EXPECT_EQ(gfx::Point(0, kTestHeight + height_change), | 287 EXPECT_EQ(gfx::Point(0, kTestHeight + height_change), |
288 ui::EventLocationFromNative(event)); | 288 ui::EventLocationFromNative(event)); |
289 } | 289 } |
290 | 290 |
| 291 // Testing for ui::EventTypeFromNative() not covered by ButtonEvents. |
| 292 TEST_F(EventsMacTest, EventTypeFromNative) { |
| 293 NSEvent* event = cocoa_test_event_utils::KeyEventWithType(NSKeyDown, 0); |
| 294 EXPECT_EQ(ui::ET_KEY_PRESSED, ui::EventTypeFromNative(event)); |
| 295 |
| 296 event = cocoa_test_event_utils::KeyEventWithType(NSKeyUp, 0); |
| 297 EXPECT_EQ(ui::ET_KEY_RELEASED, ui::EventTypeFromNative(event)); |
| 298 |
| 299 event = cocoa_test_event_utils::MouseEventWithType(NSLeftMouseDragged, 0); |
| 300 EXPECT_EQ(ui::ET_MOUSE_DRAGGED, ui::EventTypeFromNative(event)); |
| 301 event = cocoa_test_event_utils::MouseEventWithType(NSRightMouseDragged, 0); |
| 302 EXPECT_EQ(ui::ET_MOUSE_DRAGGED, ui::EventTypeFromNative(event)); |
| 303 event = cocoa_test_event_utils::MouseEventWithType(NSOtherMouseDragged, 0); |
| 304 EXPECT_EQ(ui::ET_MOUSE_DRAGGED, ui::EventTypeFromNative(event)); |
| 305 |
| 306 event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0); |
| 307 EXPECT_EQ(ui::ET_MOUSE_MOVED, ui::EventTypeFromNative(event)); |
| 308 |
| 309 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseEntered); |
| 310 EXPECT_EQ(ui::ET_MOUSE_ENTERED, ui::EventTypeFromNative(event)); |
| 311 event = cocoa_test_event_utils::EnterExitEventWithType(NSMouseExited); |
| 312 EXPECT_EQ(ui::ET_MOUSE_EXITED, ui::EventTypeFromNative(event)); |
| 313 } |
| 314 |
291 } // namespace ui | 315 } // namespace ui |
OLD | NEW |