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

Side by Side Diff: ui/events/cocoa/events_mac_unittest.mm

Issue 1777653002: Prepare ui/ module for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile errors. Created 4 years, 9 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
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/events/event_utils.h" 5 #include "ui/events/event_utils.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/mac/scoped_cftyperef.h" 10 #include "base/mac/scoped_cftyperef.h"
11 #import "base/mac/scoped_objc_class_swizzler.h" 11 #import "base/mac/scoped_objc_class_swizzler.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/cocoa/cocoa_base_utils.h"
15 #include "ui/events/event_constants.h" 16 #include "ui/events/event_constants.h"
16 #import "ui/events/test/cocoa_test_event_utils.h" 17 #import "ui/events/test/cocoa_test_event_utils.h"
17 #include "ui/gfx/geometry/point.h" 18 #include "ui/gfx/geometry/point.h"
18 #import "ui/gfx/test/ui_cocoa_test_helper.h" 19 #import "ui/gfx/test/ui_cocoa_test_helper.h"
19 20
20 namespace { 21 namespace {
21 22
22 NSWindow* g_test_window = nil; 23 NSWindow* g_test_window = nil;
23 24
24 } // namespace 25 } // namespace
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 CGEventCreateScrollWheelEvent(NULL, 103 CGEventCreateScrollWheelEvent(NULL,
103 kCGScrollEventUnitLine, 104 kCGScrollEventUnitLine,
104 2, 105 2,
105 delta_y, 106 delta_y,
106 delta_x)); 107 delta_x));
107 // CGEvents are always in global display coordinates. These are like screen 108 // CGEvents are always in global display coordinates. These are like screen
108 // coordinates, but flipped. But first the point needs to be converted out 109 // coordinates, but flipped. But first the point needs to be converted out
109 // of window coordinates (which also requires flipping). 110 // of window coordinates (which also requires flipping).
110 NSPoint window_point = 111 NSPoint window_point =
111 NSPointFromCGPoint(Flip(window_location).ToCGPoint()); 112 NSPointFromCGPoint(Flip(window_location).ToCGPoint());
112 NSPoint screen_point = [test_window() convertBaseToScreen:window_point]; 113 NSPoint screen_point =
114 ui::ConvertPointFromWindowToScreen(test_window(), window_point);
113 CGFloat primary_screen_height = 115 CGFloat primary_screen_height =
114 NSHeight([[[NSScreen screens] firstObject] frame]); 116 NSHeight([[[NSScreen screens] firstObject] frame]);
115 screen_point.y = primary_screen_height - screen_point.y; 117 screen_point.y = primary_screen_height - screen_point.y;
116 CGEventSetLocation(scroll, NSPointToCGPoint(screen_point)); 118 CGEventSetLocation(scroll, NSPointToCGPoint(screen_point));
117 return [NSEvent eventWithCGEvent:scroll]; 119 return [NSEvent eventWithCGEvent:scroll];
118 } 120 }
119 121
120 private: 122 private:
121 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_; 123 scoped_ptr<base::mac::ScopedObjCClassSwizzler> swizzler_;
122 124
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0); 308 event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0);
307 EXPECT_EQ(ui::ET_MOUSE_MOVED, ui::EventTypeFromNative(event)); 309 EXPECT_EQ(ui::ET_MOUSE_MOVED, ui::EventTypeFromNative(event));
308 310
309 event = cocoa_test_event_utils::EnterEvent(); 311 event = cocoa_test_event_utils::EnterEvent();
310 EXPECT_EQ(ui::ET_MOUSE_ENTERED, ui::EventTypeFromNative(event)); 312 EXPECT_EQ(ui::ET_MOUSE_ENTERED, ui::EventTypeFromNative(event));
311 event = cocoa_test_event_utils::ExitEvent(); 313 event = cocoa_test_event_utils::ExitEvent();
312 EXPECT_EQ(ui::ET_MOUSE_EXITED, ui::EventTypeFromNative(event)); 314 EXPECT_EQ(ui::ET_MOUSE_EXITED, ui::EventTypeFromNative(event));
313 } 315 }
314 316
315 } // namespace ui 317 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698