OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/test/ui_controls.h" | 5 #include "ui/base/test/ui_controls.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <mach/mach_time.h> | 8 #include <mach/mach_time.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // Win and Linux implement a SendKeyPress() this as a | 234 // Win and Linux implement a SendKeyPress() this as a |
235 // SendKeyPressAndRelease(), so we should as well (despite the name). | 235 // SendKeyPressAndRelease(), so we should as well (despite the name). |
236 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, | 236 bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, |
237 ui::KeyboardCode key, | 237 ui::KeyboardCode key, |
238 bool control, | 238 bool control, |
239 bool shift, | 239 bool shift, |
240 bool alt, | 240 bool alt, |
241 bool command, | 241 bool command, |
242 const base::Closure& task) { | 242 const base::Closure& task) { |
243 CHECK(g_ui_controls_enabled); | 243 CHECK(g_ui_controls_enabled); |
244 DCHECK_EQ(base::MessageLoop::TYPE_UI, base::MessageLoop::current()->type()); | 244 DCHECK(base::MessageLoopForUI::IsCurrent()); |
245 | 245 |
246 std::vector<NSEvent*> events; | 246 std::vector<NSEvent*> events; |
247 SynthesizeKeyEventsSequence( | 247 SynthesizeKeyEventsSequence( |
248 window, key, control, shift, alt, command, &events); | 248 window, key, control, shift, alt, command, &events); |
249 | 249 |
250 // TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes | 250 // TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes |
251 // BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270 | 251 // BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270 |
252 // But using [NSApplication sendEvent:] should be safe for keyboard events, | 252 // But using [NSApplication sendEvent:] should be safe for keyboard events, |
253 // because until now, no code wants to retrieve the next event when handling | 253 // because until now, no code wants to retrieve the next event when handling |
254 // a keyboard event. | 254 // a keyboard event. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 | 364 |
365 return true; | 365 return true; |
366 } | 366 } |
367 | 367 |
368 bool SendMouseClick(MouseButton type) { | 368 bool SendMouseClick(MouseButton type) { |
369 CHECK(g_ui_controls_enabled); | 369 CHECK(g_ui_controls_enabled); |
370 return SendMouseEventsNotifyWhenDone(type, UP|DOWN, base::Closure()); | 370 return SendMouseEventsNotifyWhenDone(type, UP|DOWN, base::Closure()); |
371 } | 371 } |
372 | 372 |
373 } // namespace ui_controls | 373 } // namespace ui_controls |
OLD | NEW |