| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/wm/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/shell_window_ids.h" | 10 #include "ash/common/shell_window_ids.h" |
| 9 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 10 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
| 11 #include "ash/shell.h" | 13 #include "ash/shell.h" |
| 12 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
| 16 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 17 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
| 20 #include "ui/aura/test/test_window_delegate.h" |
| 18 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
| 21 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 22 #include "ui/compositor/test/layer_animator_test_controller.h" | 25 #include "ui/compositor/test/layer_animator_test_controller.h" |
| 23 #include "ui/events/test/event_generator.h" | 26 #include "ui/events/test/event_generator.h" |
| 24 #include "ui/keyboard/keyboard_controller.h" | 27 #include "ui/keyboard/keyboard_controller.h" |
| 25 #include "ui/keyboard/keyboard_switches.h" | 28 #include "ui/keyboard/keyboard_switches.h" |
| 26 #include "ui/keyboard/keyboard_ui.h" | 29 #include "ui/keyboard/keyboard_ui.h" |
| 27 #include "ui/keyboard/keyboard_util.h" | 30 #include "ui/keyboard/keyboard_util.h" |
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_NONE); | 672 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_NONE); |
| 670 EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen()); | 673 EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 671 | 674 |
| 672 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 675 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 673 EXPECT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); | 676 EXPECT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 674 | 677 |
| 675 widget->Close(); | 678 widget->Close(); |
| 676 EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen()); | 679 EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 677 } | 680 } |
| 678 | 681 |
| 682 namespace { |
| 683 |
| 684 class InputTestDelegate : public aura::test::TestWindowDelegate { |
| 685 public: |
| 686 InputTestDelegate() {} |
| 687 ~InputTestDelegate() override {} |
| 688 |
| 689 // ui::EventHandler: |
| 690 void OnMouseEvent(ui::MouseEvent* event) override { mouse_event_count_++; } |
| 691 |
| 692 int mouse_event_count() const { return mouse_event_count_; } |
| 693 |
| 694 private: |
| 695 int mouse_event_count_ = 0; |
| 696 |
| 697 DISALLOW_COPY_AND_ASSIGN(InputTestDelegate); |
| 698 }; |
| 699 |
| 700 } // namespace |
| 701 |
| 702 // Make sure that events are properly blocked in multi displays environment. |
| 703 TEST_F(SystemModalContainerLayoutManagerTest, BlockEvent) { |
| 704 UpdateDisplay("500x500, 500x500"); |
| 705 InputTestDelegate delegate; |
| 706 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate( |
| 707 &delegate, 0, gfx::Rect(0, 0, 100, 100))); |
| 708 window->Show(); |
| 709 |
| 710 ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow(), |
| 711 window.get()); |
| 712 event_generator.ClickLeftButton(); |
| 713 EXPECT_EQ(2, delegate.mouse_event_count()); |
| 714 |
| 715 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds( |
| 716 new TestWindow(true), Shell::GetPrimaryRootWindow(), |
| 717 gfx::Rect(200, 200, 100, 100)); |
| 718 widget->Show(); |
| 719 EXPECT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 720 |
| 721 // Events should be blocked. |
| 722 event_generator.ClickLeftButton(); |
| 723 EXPECT_EQ(2, delegate.mouse_event_count()); |
| 724 widget->Close(); |
| 725 |
| 726 EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 727 event_generator.ClickLeftButton(); |
| 728 EXPECT_EQ(4, delegate.mouse_event_count()); |
| 729 |
| 730 // We need to delete window here because delegate is on the stack. |
| 731 window.reset(); |
| 732 } |
| 733 |
| 679 } // namespace test | 734 } // namespace test |
| 680 } // namespace ash | 735 } // namespace ash |
| OLD | NEW |