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

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() {}
oshima 2016/06/16 19:54:14 According to the c++11 thread, this is still ok. (
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 TEST_F(SystemModalContainerLayoutManagerTest, BlockEvent) {
676 UpdateDisplay("500x500, 500x500");
677 InputTestDelegate delegate;
678 std::unique_ptr<aura::Window> window(CreateTestWindowInShellWithDelegate(
679 &delegate, 0, gfx::Rect(0, 0, 100, 100)));
680 window->SetName("blocked");
681 window->Show();
682 LOG(ERROR) << "container = " << window->parent()->name();
683
684 ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), window.get());
685 e1.ClickLeftButton();
686 EXPECT_EQ(2, delegate.mouse_event_count());
687
688 views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
689 new TestWindow(true), Shell::GetPrimaryRootWindow(),
690 gfx::Rect(200, 200, 100, 100));
691 widget->GetNativeWindow()->SetName("blocking");
692 widget->Show();
693 EXPECT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen());
694 LOG(ERROR) << "Start";
695 e1.ClickLeftButton();
696 LOG(ERROR) << "End";
697 EXPECT_EQ(2, delegate.mouse_event_count());
698 widget->Close();
699
700 EXPECT_FALSE(Shell::GetInstance()->IsSystemModalWindowOpen());
701 e1.ClickLeftButton();
702 EXPECT_EQ(4, delegate.mouse_event_count());
703
704 window.reset();
705 }
706
651 } // namespace test 707 } // namespace test
652 } // namespace ash 708 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698