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

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

Issue 9241007: Fix the Windows implementation of EventGenerator::PressKey(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 11 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/test/event_generator.h ('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) 2011 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/event.h" 8 #include "ui/aura/event.h"
9 #include "ui/aura/root_window.h" 9 #include "ui/aura/root_window.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 namespace { 16 namespace {
17 17
18 class TestKeyEvent : public aura::KeyEvent {
19 public:
20 TestKeyEvent(const base::NativeEvent& native_event, int flags)
21 : KeyEvent(native_event, false /* is_char */) {
22 set_flags(flags);
23 }
24 };
25
18 gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) { 26 gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) {
19 gfx::Point center = window->bounds().CenterPoint(); 27 gfx::Point center = window->bounds().CenterPoint();
20 aura::RootWindow* root_window = aura::RootWindow::GetInstance(); 28 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
21 aura::Window::ConvertPointToWindow(window->parent(), root_window, &center); 29 aura::Window::ConvertPointToWindow(window->parent(), root_window, &center);
22 return center; 30 return center;
23 } 31 }
24 32
25 } // namespace 33 } // namespace
26 34
27 namespace aura { 35 namespace aura {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 NOTIMPLEMENTED(); 170 NOTIMPLEMENTED();
163 break; 171 break;
164 } 172 }
165 } 173 }
166 174
167 void EventGenerator::DispatchKeyEvent(bool is_press, 175 void EventGenerator::DispatchKeyEvent(bool is_press,
168 ui::KeyboardCode key_code, 176 ui::KeyboardCode key_code,
169 int flags) { 177 int flags) {
170 #if defined(OS_WIN) 178 #if defined(OS_WIN)
171 MSG native_event = 179 MSG native_event =
172 { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, flags }; 180 { NULL, (is_press ? WM_KEYDOWN : WM_KEYUP), key_code, 0 };
173 KeyEvent keyev(native_event, false /* is_char */); 181 TestKeyEvent keyev(native_event, flags);
174 #else 182 #else
175 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED; 183 ui::EventType type = is_press ? ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED;
176 #if defined(USE_X11) 184 #if defined(USE_X11)
177 scoped_ptr<XEvent> native_event(new XEvent); 185 scoped_ptr<XEvent> native_event(new XEvent);
178 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get()); 186 ui::InitXKeyEventForTesting(type, key_code, flags, native_event.get());
179 KeyEvent keyev(native_event.get(), false); 187 TestKeyEvent keyev(native_event.get(), flags);
180 #else 188 #else
181 KeyEvent keyev(type, key_code, flags); 189 KeyEvent keyev(type, key_code, flags);
182 #endif // USE_X11 190 #endif // USE_X11
183 #endif // OS_WIN 191 #endif // OS_WIN
184 Dispatch(keyev); 192 Dispatch(keyev);
185 } 193 }
186 194
187 } // namespace test 195 } // namespace test
188 } // namespace aura 196 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698