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

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

Issue 8771015: Rename Desktop->RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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_base.cc ('k') | ui/aura/test/test_stacking_client.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura/desktop.h"
8 #include "ui/aura/event.h" 7 #include "ui/aura/event.h"
8 #include "ui/aura/root_window.h"
9 9
10 namespace { 10 namespace {
11 11
12 gfx::Point CenterOfWindowInDesktopCoordinate(aura::Window* window) { 12 gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) {
13 gfx::Point center = window->bounds().CenterPoint(); 13 gfx::Point center = window->bounds().CenterPoint();
14 aura::Desktop* desktop = aura::Desktop::GetInstance(); 14 aura::RootWindow* root_window = aura::RootWindow::GetInstance();
15 aura::Window::ConvertPointToWindow(window->parent(), desktop, &center); 15 aura::Window::ConvertPointToWindow(window->parent(), root_window, &center);
16 return center; 16 return center;
17 } 17 }
18 18
19 } // namespace 19 } // namespace
20 20
21 namespace aura { 21 namespace aura {
22 namespace test { 22 namespace test {
23 23
24 EventGenerator::EventGenerator() : flags_(0) { 24 EventGenerator::EventGenerator() : flags_(0) {
25 } 25 }
26 26
27 EventGenerator::EventGenerator(const gfx::Point& point) 27 EventGenerator::EventGenerator(const gfx::Point& point)
28 : flags_(0), 28 : flags_(0),
29 current_location_(point) { 29 current_location_(point) {
30 } 30 }
31 31
32 EventGenerator::EventGenerator(Window* window) 32 EventGenerator::EventGenerator(Window* window)
33 : flags_(0), 33 : flags_(0),
34 current_location_(CenterOfWindowInDesktopCoordinate(window)) { 34 current_location_(CenterOfWindowInRootWindowCoordinate(window)) {
35 } 35 }
36 36
37 EventGenerator::~EventGenerator() { 37 EventGenerator::~EventGenerator() {
38 } 38 }
39 39
40 void EventGenerator::PressLeftButton() { 40 void EventGenerator::PressLeftButton() {
41 if ((flags_ & ui::EF_LEFT_BUTTON_DOWN) == 0) { 41 if ((flags_ & ui::EF_LEFT_BUTTON_DOWN) == 0) {
42 flags_ |= ui::EF_LEFT_BUTTON_DOWN; 42 flags_ |= ui::EF_LEFT_BUTTON_DOWN;
43 MouseEvent mouseev(ui::ET_MOUSE_PRESSED, current_location_, flags_); 43 MouseEvent mouseev(ui::ET_MOUSE_PRESSED, current_location_, flags_);
44 Dispatch(mouseev); 44 Dispatch(mouseev);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void EventGenerator::DragMouseTo(const gfx::Point& point) { 87 void EventGenerator::DragMouseTo(const gfx::Point& point) {
88 PressLeftButton(); 88 PressLeftButton();
89 MoveMouseTo(point); 89 MoveMouseTo(point);
90 ReleaseLeftButton(); 90 ReleaseLeftButton();
91 } 91 }
92 92
93 void EventGenerator::Dispatch(Event& event) { 93 void EventGenerator::Dispatch(Event& event) {
94 switch (event.type()) { 94 switch (event.type()) {
95 case ui::ET_KEY_PRESSED: 95 case ui::ET_KEY_PRESSED:
96 case ui::ET_KEY_RELEASED: 96 case ui::ET_KEY_RELEASED:
97 aura::Desktop::GetInstance()->DispatchKeyEvent( 97 aura::RootWindow::GetInstance()->DispatchKeyEvent(
98 static_cast<KeyEvent*>(&event)); 98 static_cast<KeyEvent*>(&event));
99 break; 99 break;
100 case ui::ET_MOUSE_PRESSED: 100 case ui::ET_MOUSE_PRESSED:
101 case ui::ET_MOUSE_DRAGGED: 101 case ui::ET_MOUSE_DRAGGED:
102 case ui::ET_MOUSE_RELEASED: 102 case ui::ET_MOUSE_RELEASED:
103 case ui::ET_MOUSE_MOVED: 103 case ui::ET_MOUSE_MOVED:
104 case ui::ET_MOUSE_ENTERED: 104 case ui::ET_MOUSE_ENTERED:
105 case ui::ET_MOUSE_EXITED: 105 case ui::ET_MOUSE_EXITED:
106 case ui::ET_MOUSEWHEEL: 106 case ui::ET_MOUSEWHEEL:
107 aura::Desktop::GetInstance()->DispatchMouseEvent( 107 aura::RootWindow::GetInstance()->DispatchMouseEvent(
108 static_cast<MouseEvent*>(&event)); 108 static_cast<MouseEvent*>(&event));
109 break; 109 break;
110 default: 110 default:
111 NOTIMPLEMENTED(); 111 NOTIMPLEMENTED();
112 break; 112 break;
113 } 113 }
114 } 114 }
115 115
116 void EventGenerator::MoveMouseToCenterOf(Window* window) { 116 void EventGenerator::MoveMouseToCenterOf(Window* window) {
117 MoveMouseTo(CenterOfWindowInDesktopCoordinate(window)); 117 MoveMouseTo(CenterOfWindowInRootWindowCoordinate(window));
118 } 118 }
119 119
120 } // namespace test 120 } // namespace test
121 } // namespace aura 121 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/test/aura_test_base.cc ('k') | ui/aura/test/test_stacking_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698