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

Unified Diff: ui/aura/test/event_generator.cc

Issue 9421016: Change EventGenerator to take a RootWindow at construction instead of just assuming one via RootWin… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/aura/test/event_generator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/event_generator.cc
===================================================================
--- ui/aura/test/event_generator.cc (revision 122697)
+++ ui/aura/test/event_generator.cc (working copy)
@@ -23,9 +23,9 @@
}
};
-gfx::Point CenterOfWindowInRootWindowCoordinate(aura::Window* window) {
+gfx::Point CenterOfWindowInRootWindowCoordinate(aura::RootWindow* root_window,
+ aura::Window* window) {
gfx::Point center = window->bounds().CenterPoint();
- aura::RootWindow* root_window = aura::RootWindow::GetInstance();
aura::Window::ConvertPointToWindow(window->parent(), root_window, &center);
return center;
}
@@ -35,17 +35,22 @@
namespace aura {
namespace test {
-EventGenerator::EventGenerator() : flags_(0) {
+EventGenerator::EventGenerator(RootWindow* root_window)
+ : root_window_(root_window),
+ flags_(0) {
}
-EventGenerator::EventGenerator(const gfx::Point& point)
- : flags_(0),
+EventGenerator::EventGenerator(RootWindow* root_window, const gfx::Point& point)
+ : root_window_(root_window),
+ flags_(0),
current_location_(point) {
}
-EventGenerator::EventGenerator(Window* window)
- : flags_(0),
- current_location_(CenterOfWindowInRootWindowCoordinate(window)) {
+EventGenerator::EventGenerator(RootWindow* root_window, Window* window)
+ : root_window_(root_window),
+ flags_(0),
+ current_location_(CenterOfWindowInRootWindowCoordinate(root_window,
+ window)) {
}
EventGenerator::~EventGenerator() {
@@ -98,8 +103,7 @@
void EventGenerator::MoveMouseRelativeTo(const Window* window,
const gfx::Point& point) {
gfx::Point root_point(point);
- aura::RootWindow* root_window = aura::RootWindow::GetInstance();
- aura::Window::ConvertPointToWindow(window, root_window, &root_point);
+ aura::Window::ConvertPointToWindow(window, root_window_, &root_point);
MoveMouseTo(root_point);
}
@@ -111,7 +115,7 @@
}
void EventGenerator::MoveMouseToCenterOf(Window* window) {
- MoveMouseTo(CenterOfWindowInRootWindowCoordinate(window));
+ MoveMouseTo(CenterOfWindowInRootWindowCoordinate(root_window_, window));
}
void EventGenerator::PressTouch() {
@@ -136,7 +140,8 @@
}
void EventGenerator::PressMoveAndReleaseTouchToCenterOf(Window* window) {
- PressMoveAndReleaseTouchTo(CenterOfWindowInRootWindowCoordinate(window));
+ PressMoveAndReleaseTouchTo(CenterOfWindowInRootWindowCoordinate(root_window_,
+ window));
}
void EventGenerator::PressKey(ui::KeyboardCode key_code, int flags) {
@@ -151,8 +156,7 @@
switch (event.type()) {
case ui::ET_KEY_PRESSED:
case ui::ET_KEY_RELEASED:
- aura::RootWindow::GetInstance()->DispatchKeyEvent(
- static_cast<KeyEvent*>(&event));
+ root_window_->DispatchKeyEvent(static_cast<KeyEvent*>(&event));
break;
case ui::ET_MOUSE_PRESSED:
case ui::ET_MOUSE_DRAGGED:
@@ -161,16 +165,14 @@
case ui::ET_MOUSE_ENTERED:
case ui::ET_MOUSE_EXITED:
case ui::ET_MOUSEWHEEL:
- aura::RootWindow::GetInstance()->DispatchMouseEvent(
- static_cast<MouseEvent*>(&event));
+ root_window_->DispatchMouseEvent(static_cast<MouseEvent*>(&event));
break;
case ui::ET_TOUCH_RELEASED:
case ui::ET_TOUCH_PRESSED:
case ui::ET_TOUCH_MOVED:
case ui::ET_TOUCH_STATIONARY:
case ui::ET_TOUCH_CANCELLED:
- aura::RootWindow::GetInstance()->DispatchTouchEvent(
- static_cast<TouchEvent*>(&event));
+ root_window_->DispatchTouchEvent(static_cast<TouchEvent*>(&event));
break;
default:
NOTIMPLEMENTED();
« 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