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

Side by Side Diff: ui/aura/test/event_generator.cc

Issue 11047030: Decouple EventClientImpl and root window. Check containers on the same root window as focused windo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix type in event_filter_unittest Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/event_filter_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "ui/aura/root_window.h" 8 #include "ui/aura/root_window.h"
9 #include "ui/base/events/event.h" 9 #include "ui/base/events/event.h"
10 10
11 #if defined(USE_X11) 11 #if defined(USE_X11)
12 #include <X11/Xlib.h> 12 #include <X11/Xlib.h>
13 #include "ui/base/x/x11_util.h" 13 #include "ui/base/x/x11_util.h"
14 #endif 14 #endif
15 15
16 #if defined(OS_WIN)
17 #include "ui/base/keycodes/keyboard_code_conversion.h"
18 #endif
19
16 namespace { 20 namespace {
17 21
18 class TestKeyEvent : public ui::KeyEvent { 22 class TestKeyEvent : public ui::KeyEvent {
19 public: 23 public:
20 TestKeyEvent(const base::NativeEvent& native_event, int flags) 24 TestKeyEvent(const base::NativeEvent& native_event, int flags, bool is_char)
21 : KeyEvent(native_event, false /* is_char */) { 25 : KeyEvent(native_event, is_char) {
22 set_flags(flags); 26 set_flags(flags);
23 } 27 }
24 }; 28 };
25 29
26 class TestTouchEvent : public ui::TouchEvent { 30 class TestTouchEvent : public ui::TouchEvent {
27 public: 31 public:
28 TestTouchEvent(ui::EventType type, 32 TestTouchEvent(ui::EventType type,
29 const gfx::Point& root_location, 33 const gfx::Point& root_location,
30 int flags) 34 int flags)
31 : TouchEvent(type, root_location, 0, 35 : TouchEvent(type, root_location, 0,
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 default: 306 default:
303 NOTIMPLEMENTED(); 307 NOTIMPLEMENTED();
304 break; 308 break;
305 } 309 }
306 } 310 }
307 311
308 void EventGenerator::DispatchKeyEvent(bool is_press, 312 void EventGenerator::DispatchKeyEvent(bool is_press,
309 ui::KeyboardCode key_code, 313 ui::KeyboardCode key_code,
310 int flags) { 314 int flags) {
311 #if defined(OS_WIN) 315 #if defined(OS_WIN)
316 UINT key_press = WM_KEYDOWN;
317 uint16 character = ui::GetCharacterFromKeyCode(key_code, flags);
318 if (is_press && character) {
319 MSG native_event = { NULL, WM_KEYDOWN, key_code, 0 };
320 TestKeyEvent keyev(native_event, flags, false);
321 Dispatch(keyev);
322 // On Windows, WM_KEYDOWN event is followed by WM_CHAR with a character
323 // if the key event cooresponds to a real character.
324 key_press = WM_CHAR;
325 key_code = static_cast<ui::KeyboardCode>(character);
326 }
312 MSG native_event = 327 MSG native_event =
313 { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, 0 }; 328 { NULL, (is_press ? key_press : WM_KEYUP), key_code, 0 };
314 TestKeyEvent keyev(native_event, flags); 329 TestKeyEvent keyev(native_event, flags, key_press == WM_CHAR);
315 #else 330 #else
316 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; 331 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
317 #if defined(USE_X11) 332 #if defined(USE_X11)
318 scoped_ptr<XEvent> native_event(new XEvent); 333 scoped_ptr<XEvent> native_event(new XEvent);
319 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get()); 334 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
320 TestKeyEvent keyev(native_event.get(), flags); 335 TestKeyEvent keyev(native_event.get(), flags, false);
321 #else 336 #else
322 ui::KeyEvent keyev(type, key_code, flags); 337 ui::KeyEvent keyev(type, key_code, flags, false);
323 #endif // USE_X11 338 #endif // USE_X11
324 #endif // OS_WIN 339 #endif // OS_WIN
325 Dispatch(keyev); 340 Dispatch(keyev);
326 } 341 }
327 342
328 } // namespace test 343 } // namespace test
329 } // namespace aura 344 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/event_filter_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698