| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/aura/test/event_generator.h" | 5 #include "ui/aura/test/event_generator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| 11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
| 12 #include "ui/aura/window_tree_host.h" | 12 #include "ui/aura/window_tree_host.h" |
| 13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/event_utils.h" | 14 #include "ui/events/event_utils.h" |
| 15 #include "ui/gfx/vector2d_conversions.h" | 15 #include "ui/gfx/vector2d_conversions.h" |
| 16 | 16 |
| 17 #if defined(USE_X11) | 17 #if defined(USE_X11) |
| 18 #include <X11/Xlib.h> | 18 #include <X11/Xlib.h> |
| 19 #include "ui/base/x/x11_util.h" | 19 #include "ui/base/x/x11_util.h" |
| 20 #include "ui/events/event_utils.h" |
| 21 #include "ui/events/test/events_test_utils_x11.h" |
| 20 #endif | 22 #endif |
| 21 | 23 |
| 22 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 23 #include "ui/events/keycodes/keyboard_code_conversion.h" | 25 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 24 #endif | 26 #endif |
| 25 | 27 |
| 26 namespace aura { | 28 namespace aura { |
| 27 namespace test { | 29 namespace test { |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 TestKeyEvent keyev(native_event, flags, false); | 491 TestKeyEvent keyev(native_event, flags, false); |
| 490 Dispatch(&keyev); | 492 Dispatch(&keyev); |
| 491 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character | 493 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character |
| 492 // if the key event cooresponds to a real character. | 494 // if the key event cooresponds to a real character. |
| 493 key_press = WM_CHAR; | 495 key_press = WM_CHAR; |
| 494 key_code = static_cast<ui::KeyboardCode>(character); | 496 key_code = static_cast<ui::KeyboardCode>(character); |
| 495 } | 497 } |
| 496 MSG native_event = | 498 MSG native_event = |
| 497 { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 }; | 499 { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 }; |
| 498 TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR); | 500 TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR); |
| 501 #elif defined(USE_X11) |
| 502 ui::ScopedXI2Event xevent; |
| 503 xevent.InitKeyEvent(is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED, |
| 504 key_code, |
| 505 flags); |
| 506 ui::KeyEvent keyev(xevent, false); |
| 499 #else | 507 #else |
| 500 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; | 508 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; |
| 501 ui::KeyEvent keyev(type, key_code, flags, false); | 509 ui::KeyEvent keyev(type, key_code, flags, false); |
| 502 #endif // OS_WIN | 510 #endif // OS_WIN |
| 503 Dispatch(&keyev); | 511 Dispatch(&keyev); |
| 504 } | 512 } |
| 505 | 513 |
| 506 void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) { | 514 void EventGenerator::UpdateCurrentRootWindow(const gfx::Point& point) { |
| 507 current_root_window_ = delegate_->GetRootWindowAt(point); | 515 current_root_window_ = delegate_->GetRootWindowAt(point); |
| 508 } | 516 } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 base::MessageLoopProxy::current()->PostTask( | 611 base::MessageLoopProxy::current()->PostTask( |
| 604 FROM_HERE, | 612 FROM_HERE, |
| 605 base::Bind(&EventGenerator::DispatchNextPendingEvent, | 613 base::Bind(&EventGenerator::DispatchNextPendingEvent, |
| 606 base::Unretained(this))); | 614 base::Unretained(this))); |
| 607 } | 615 } |
| 608 } | 616 } |
| 609 | 617 |
| 610 | 618 |
| 611 } // namespace test | 619 } // namespace test |
| 612 } // namespace aura | 620 } // namespace aura |
| OLD | NEW |