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, ¢er); |
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(); |