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

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

Issue 191153004: Provide access to the WindowEventDispatcher as a ui::EventProcessor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/aura/test/aura_test_helper.cc ('k') | ui/aura/test/event_generator.cc » ('j') | 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 #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_ 5 #ifndef UI_AURA_TEST_EVENT_GENERATOR_H_
6 #define UI_AURA_TEST_EVENT_GENERATOR_H_ 6 #define UI_AURA_TEST_EVENT_GENERATOR_H_
7 7
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "ui/events/event_constants.h" 14 #include "ui/events/event_constants.h"
15 #include "ui/events/keycodes/keyboard_codes.h" 15 #include "ui/events/keycodes/keyboard_codes.h"
16 #include "ui/gfx/point.h" 16 #include "ui/gfx/point.h"
17 17
18 namespace base { 18 namespace base {
19 class TimeDelta; 19 class TimeDelta;
20 } 20 }
21 21
22 namespace ui { 22 namespace ui {
23 class Event; 23 class Event;
24 class EventProcessor;
24 class KeyEvent; 25 class KeyEvent;
25 class MouseEvent; 26 class MouseEvent;
26 class ScrollEvent; 27 class ScrollEvent;
27 class TouchEvent; 28 class TouchEvent;
28 } 29 }
29 30
30 namespace aura { 31 namespace aura {
31 class Window; 32 class Window;
32 class WindowEventDispatcher; 33 class WindowTreeHost;
33 34
34 namespace client { 35 namespace client {
35 class ScreenPositionClient; 36 class ScreenPositionClient;
36 } 37 }
37 38
38 namespace test { 39 namespace test {
39 40
40 typedef base::Callback<void(ui::EventType, const gfx::Vector2dF&)> 41 typedef base::Callback<void(ui::EventType, const gfx::Vector2dF&)>
41 ScrollStepCallback; 42 ScrollStepCallback;
42 43
43 // A delegate interface for EventGenerator that provides a way to 44 // A delegate interface for EventGenerator that provides a way to
44 // locate aura root window for given point. 45 // locate aura root window for given point.
45 class EventGeneratorDelegate { 46 class EventGeneratorDelegate {
46 public: 47 public:
47 virtual ~EventGeneratorDelegate() {} 48 virtual ~EventGeneratorDelegate() {}
48 49
49 // Returns a root window for given point. 50 // Returns the host for given point.
50 virtual WindowEventDispatcher* GetDispatcherAt( 51 virtual WindowTreeHost* GetHostAt(const gfx::Point& point) const = 0;
51 const gfx::Point& point) const = 0;
52 52
53 // Returns the screen position client that determines the 53 // Returns the screen position client that determines the
54 // coordinates used in EventGenerator. EventGenerator uses 54 // coordinates used in EventGenerator. EventGenerator uses
55 // root Window's coordinate if this returns NULL. 55 // root Window's coordinate if this returns NULL.
56 virtual client::ScreenPositionClient* GetScreenPositionClient( 56 virtual client::ScreenPositionClient* GetScreenPositionClient(
57 const aura::Window* window) const = 0; 57 const aura::Window* window) const = 0;
58 }; 58 };
59 59
60 // EventGenerator is a tool that generates and dispatch events. 60 // EventGenerator is a tool that generates and dispatch events.
61 // Unlike |ui_controls| package in ui/base/test, this does not generate platform 61 // Unlike |ui_controls| package in ui/base/test, this does not generate platform
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 303
304 // Generates a key release event. On platforms except Windows and X11, a key 304 // Generates a key release event. On platforms except Windows and X11, a key
305 // event without native_event() is generated. Note that ui::EF_ flags should 305 // event without native_event() is generated. Note that ui::EF_ flags should
306 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>. 306 // be passed as |flags|, not the native ones like 'ShiftMask' in <X11/X.h>.
307 // TODO(yusukes): Support native_event() on all platforms. 307 // TODO(yusukes): Support native_event() on all platforms.
308 void ReleaseKey(ui::KeyboardCode key_code, int flags); 308 void ReleaseKey(ui::KeyboardCode key_code, int flags);
309 309
310 // Dispatch the event to the WindowEventDispatcher. 310 // Dispatch the event to the WindowEventDispatcher.
311 void Dispatch(ui::Event* event); 311 void Dispatch(ui::Event* event);
312 312
313 void set_current_dispatcher(WindowEventDispatcher* dispatcher) { 313 void set_current_host(WindowTreeHost* host) {
314 current_dispatcher_ = dispatcher; 314 current_host_ = host;
315 } 315 }
316 316
317 private: 317 private:
318 // Dispatch a key event to the WindowEventDispatcher. 318 // Dispatch a key event to the WindowEventDispatcher.
319 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags); 319 void DispatchKeyEvent(bool is_press, ui::KeyboardCode key_code, int flags);
320 320
321 void UpdateCurrentDispatcher(const gfx::Point& point); 321 void UpdateCurrentDispatcher(const gfx::Point& point);
322 void PressButton(int flag); 322 void PressButton(int flag);
323 void ReleaseButton(int flag); 323 void ReleaseButton(int flag);
324 324
325 // Convert a point between API's coordinates and 325 // Convert a point between API's coordinates and
326 // |target|'s coordinates. 326 // |target|'s coordinates.
327 void ConvertPointFromTarget(const aura::Window* target, 327 void ConvertPointFromTarget(const aura::Window* target,
328 gfx::Point* point) const; 328 gfx::Point* point) const;
329 void ConvertPointToTarget(const aura::Window* target, 329 void ConvertPointToTarget(const aura::Window* target,
330 gfx::Point* point) const; 330 gfx::Point* point) const;
331 331
332 gfx::Point GetLocationInCurrentRoot() const; 332 gfx::Point GetLocationInCurrentRoot() const;
333 gfx::Point CenterOfWindow(const Window* window) const; 333 gfx::Point CenterOfWindow(const Window* window) const;
334 334
335 void DispatchNextPendingEvent(); 335 void DispatchNextPendingEvent();
336 void DoDispatchEvent(ui::Event* event, bool async); 336 void DoDispatchEvent(ui::Event* event, bool async);
337 337
338 scoped_ptr<EventGeneratorDelegate> delegate_; 338 scoped_ptr<EventGeneratorDelegate> delegate_;
339 gfx::Point current_location_; 339 gfx::Point current_location_;
340 WindowEventDispatcher* current_dispatcher_; 340 WindowTreeHost* current_host_;
341 int flags_; 341 int flags_;
342 bool grab_; 342 bool grab_;
343 std::list<ui::Event*> pending_events_; 343 std::list<ui::Event*> pending_events_;
344 // Set to true to cause events to be posted asynchronously. 344 // Set to true to cause events to be posted asynchronously.
345 bool async_; 345 bool async_;
346 346
347 DISALLOW_COPY_AND_ASSIGN(EventGenerator); 347 DISALLOW_COPY_AND_ASSIGN(EventGenerator);
348 }; 348 };
349 349
350 } // namespace test 350 } // namespace test
351 } // namespace aura 351 } // namespace aura
352 352
353 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_ 353 #endif // UI_AURA_TEST_EVENT_GENERATOR_H_
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_helper.cc ('k') | ui/aura/test/event_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698