Chromium Code Reviews| Index: ash/test/ash_test_base.cc |
| diff --git a/ash/test/ash_test_base.cc b/ash/test/ash_test_base.cc |
| index 27f39cf092827eb16c635e78ec36c843ebb672f8..a81a66e8c87f8b497a75cbfaa89043a215418705 100644 |
| --- a/ash/test/ash_test_base.cc |
| +++ b/ash/test/ash_test_base.cc |
| @@ -17,6 +17,8 @@ |
| #include "ash/display/unified_mouse_warp_controller.h" |
| #include "ash/display/window_tree_host_manager.h" |
| #include "ash/ime/input_method_event_handler.h" |
| +#include "ash/mus/window_manager.h" |
| +#include "ash/mus/window_manager_application.h" |
| #include "ash/root_window_controller.h" |
| #include "ash/shell.h" |
| #include "ash/shell/toplevel_window.h" |
| @@ -50,12 +52,14 @@ |
| namespace ash { |
| namespace test { |
| -namespace { |
| class AshEventGeneratorDelegate |
| : public aura::test::EventGeneratorDelegateAura { |
| public: |
| - AshEventGeneratorDelegate() {} |
| + explicit AshEventGeneratorDelegate(AshTestHelper* ash_test_helper) |
| + : ash_test_helper_(ash_test_helper) { |
| + DCHECK(ash_test_helper_); |
| + } |
| ~AshEventGeneratorDelegate() override {} |
| // aura::test::EventGeneratorDelegateAura overrides: |
| @@ -80,12 +84,26 @@ class AshEventGeneratorDelegate |
| // first. |
| } |
| + void DispatchEventToPointerWatchers(ui::EventTarget* target, |
| + const ui::PointerEvent& event) override { |
|
sadrul
2017/03/16 03:22:47
Instead of doing this here, can you override this
James Cook
2017/03/16 19:13:32
Great idea! By doing that I was able to inject the
|
| + // In classic ash PointerWatchers are triggered by an EventHandler on |
| + // ash::Shell and don't need special handling. |
| + if (!WmShell::Get()->IsRunningInMash()) |
| + return; |
| + |
| + // Route events though WindowManager similar to production mash. Does |
| + // nothing if there are no pointer watchers installed. |
| + ash_test_helper_->window_manager_app() |
| + ->window_manager() |
| + ->OnPointerEventObserved(event, static_cast<aura::Window*>(target)); |
|
James Cook
2017/03/15 19:01:19
I think this cast is OK -- aura::test::EventGenera
|
| + } |
| + |
| private: |
| + AshTestHelper* const ash_test_helper_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(AshEventGeneratorDelegate); |
| }; |
| -} // namespace |
| - |
| ///////////////////////////////////////////////////////////////////////////// |
| AshTestBase::AshTestBase() |
| @@ -177,8 +195,8 @@ SystemTray* AshTestBase::GetPrimarySystemTray() { |
| ui::test::EventGenerator& AshTestBase::GetEventGenerator() { |
| if (!event_generator_) { |
| - event_generator_.reset( |
| - new ui::test::EventGenerator(new AshEventGeneratorDelegate())); |
| + event_generator_.reset(new ui::test::EventGenerator( |
| + new AshEventGeneratorDelegate(ash_test_helper_.get()))); |
| } |
| return *event_generator_.get(); |
| } |