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

Side by Side Diff: ash/wm/system_modal_container_layout_manager_unittest.cc

Issue 2070163002: Fix "modal isn't modal in multi displays" issue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modal fix Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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/root_window_controller.h" 11 #include "ash/root_window_controller.h"
10 #include "ash/shell.h" 12 #include "ash/shell.h"
11 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
12 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
13 #include "base/command_line.h" 15 #include "base/command_line.h"
14 #include "base/compiler_specific.h" 16 #include "base/compiler_specific.h"
15 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "ui/aura/client/aura_constants.h"
19 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
17 #include "ui/aura/window_event_dispatcher.h" 21 #include "ui/aura/window_event_dispatcher.h"
18 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
19 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
20 #include "ui/compositor/test/layer_animator_test_controller.h" 24 #include "ui/compositor/test/layer_animator_test_controller.h"
21 #include "ui/events/test/event_generator.h" 25 #include "ui/events/test/event_generator.h"
22 #include "ui/keyboard/keyboard_controller.h" 26 #include "ui/keyboard/keyboard_controller.h"
23 #include "ui/keyboard/keyboard_switches.h" 27 #include "ui/keyboard/keyboard_switches.h"
24 #include "ui/keyboard/keyboard_ui.h" 28 #include "ui/keyboard/keyboard_ui.h"
25 #include "ui/keyboard/keyboard_util.h" 29 #include "ui/keyboard/keyboard_util.h"
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 // The keyboard gets shown and the dialog should get pushed up, but not get 645 // The keyboard gets shown and the dialog should get pushed up, but not get
642 // cropped (and aligned to the top). 646 // cropped (and aligned to the top).
643 ShowKeyboard(true); 647 ShowKeyboard(true);
644 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString()); 648 EXPECT_EQ(modal_size.ToString(), modal_window->bounds().size().ToString());
645 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x()); 649 EXPECT_EQ(modal_origin.x(), modal_window->bounds().x());
646 EXPECT_EQ(0, modal_window->bounds().y()); 650 EXPECT_EQ(0, modal_window->bounds().y());
647 651
648 ShowKeyboard(false); 652 ShowKeyboard(false);
649 } 653 }
650 654
655 namespace {
656
657 class InputTestDelegate : public aura::test::TestWindowDelegate {
658 public:
659 InputTestDelegate() {}
660 ~InputTestDelegate() override {}
661
662 // ui::EventHandler:
663 void OnMouseEvent(ui::MouseEvent* event) override { mouse_event_count_++; }
664
665 int mouse_event_count() const { return mouse_event_count_; }
666
667 private:
668 int mouse_event_count_ = 0;
669
670 DISALLOW_COPY_AND_ASSIGN(InputTestDelegate);
671 };
672
673 } // namespace
674
675 // Make sure that events are properly blocked in multi displays environment.
676 TEST_F(SystemModalContainerLayoutManagerTest, BlockEvent) {
677 UpdateDisplay("500x500, 500x500");
678 InputTestDelegate delegate;
679 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
680 &delegate, 0, gfx::Rect(0, 0, 100, 100)));
681 window->Show();
682
683 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.
684 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.
685 EXPECT_EQ(2, delegate.mouse_event_count());
686
687 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
688 new TestWindow(true), Shell::GetPrimaryRootWindow(),
689 gfx::Rect(200, 200, 100, 100));
690 widget->Show();
691 EXPECT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen());
692
693 // Events should be blocked.
694 e1.ClickLeftButton();
695 EXPECT_EQ(2, delegate.mouse_event_count());
696 widget->Close();
697
698 EXPECT_FALSE(Shell::GetInstance()->IsSystemModalWindowOpen());
699 e1.ClickLeftButton();
700 EXPECT_EQ(4, delegate.mouse_event_count());
701
702 // We need to delete window here because delegate is on the stack.
703 window.reset();
704 }
705
651 } // namespace test 706 } // namespace test
652 } // namespace ash 707 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698