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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f9b53e0f164fccfe093240a43b1846d170c0a0e0..28730623c0f9a7c4872560e86a26f625e656dde8 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/common/wm_shell.h"
@@ -15,6 +17,7 @@
#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"
@@ -676,5 +679,57 @@ TEST_F(SystemModalContainerLayoutManagerTest, UpdateModalType) {
EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen());
}
+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 event_generator(Shell::GetPrimaryRootWindow(),
+ window.get());
+ event_generator.ClickLeftButton();
+ 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(WmShell::Get()->IsSystemModalWindowOpen());
+
+ // Events should be blocked.
+ event_generator.ClickLeftButton();
+ EXPECT_EQ(2, delegate.mouse_event_count());
+ widget->Close();
+
+ EXPECT_FALSE(WmShell::Get()->IsSystemModalWindowOpen());
+ event_generator.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
« no previous file with comments | « ash/wm/system_modal_container_layout_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698