Chromium Code Reviews| Index: ash/wm/system_modal_container_layout_manager_unittest.cc |
| diff --git a/ash/wm/system_modal_container_layout_manager_unittest.cc b/ash/wm/system_modal_container_layout_manager_unittest.cc |
| index c1579cff48ca90f923b6b0f40b06053a3eccaabb..4fe89be1737bb5f733bbaba0eea3ecfab68cbd2d 100644 |
| --- a/ash/wm/system_modal_container_layout_manager_unittest.cc |
| +++ b/ash/wm/system_modal_container_layout_manager_unittest.cc |
| @@ -4,6 +4,8 @@ |
| #include "ash/wm/system_modal_container_layout_manager.h" |
| +#include <memory> |
| + |
| #include "ash/common/session/session_state_delegate.h" |
| #include "ash/common/shell_window_ids.h" |
| #include "ash/root_window_controller.h" |
| @@ -13,6 +15,8 @@ |
| #include "base/command_line.h" |
| #include "base/compiler_specific.h" |
| #include "base/run_loop.h" |
| +#include "ui/aura/client/aura_constants.h" |
| +#include "ui/aura/test/test_window_delegate.h" |
| #include "ui/aura/window.h" |
| #include "ui/aura/window_event_dispatcher.h" |
| #include "ui/compositor/layer.h" |
| @@ -648,5 +652,56 @@ TEST_F(SystemModalContainerLayoutManagerTest, |
| ShowKeyboard(false); |
| } |
| +namespace { |
| + |
| +class InputTestDelegate : public aura::test::TestWindowDelegate { |
| + public: |
| + InputTestDelegate() {} |
| + ~InputTestDelegate() override {} |
| + |
| + // ui::EventHandler: |
| + void OnMouseEvent(ui::MouseEvent* event) override { mouse_event_count_++; } |
| + |
| + int mouse_event_count() const { return mouse_event_count_; } |
| + |
| + private: |
| + int mouse_event_count_ = 0; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(InputTestDelegate); |
| +}; |
| + |
| +} // namespace |
| + |
| +// Make sure that events are properly blocked in multi displays environment. |
| +TEST_F(SystemModalContainerLayoutManagerTest, BlockEvent) { |
| + UpdateDisplay("500x500, 500x500"); |
| + InputTestDelegate delegate; |
| + std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| + &delegate, 0, gfx::Rect(0, 0, 100, 100))); |
| + window->Show(); |
| + |
| + ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), window.get()); |
|
James Cook
2016/06/16 20:31:36
nit: e1 -> generator, or event_generator, or somet
oshima
2016/06/17 00:06:12
Done.
|
| + e1.ClickLeftButton(); |
|
James Cook
2016/06/16 20:31:36
optional: Do you need to do this click? It might b
oshima
2016/06/17 00:06:12
I want to make sure I can receive the event first,
James Cook
2016/06/17 16:04:43
No, this is fine.
|
| + EXPECT_EQ(2, delegate.mouse_event_count()); |
| + |
| + views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| + new TestWindow(true), Shell::GetPrimaryRootWindow(), |
| + gfx::Rect(200, 200, 100, 100)); |
| + widget->Show(); |
| + EXPECT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen()); |
| + |
| + // Events should be blocked. |
| + e1.ClickLeftButton(); |
| + EXPECT_EQ(2, delegate.mouse_event_count()); |
| + widget->Close(); |
| + |
| + EXPECT_FALSE(Shell::GetInstance()->IsSystemModalWindowOpen()); |
| + e1.ClickLeftButton(); |
| + EXPECT_EQ(4, delegate.mouse_event_count()); |
| + |
| + // We need to delete window here because delegate is on the stack. |
| + window.reset(); |
| +} |
| + |
| } // namespace test |
| } // namespace ash |