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

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: 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 side-by-side diff with in-line comments
Download patch
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..84103aace9a8c994bd62a98fcb17b29fafea33a4 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,57 @@ TEST_F(SystemModalContainerLayoutManagerTest,
ShowKeyboard(false);
}
+namespace {
+
+class InputTestDelegate : public aura::test::TestWindowDelegate {
+ public:
+ InputTestDelegate() {}
oshima 2016/06/16 19:54:14 According to the c++11 thread, this is still ok. (
+ ~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
+
+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->SetName("blocked");
+ window->Show();
+ LOG(ERROR) << "container = " << window->parent()->name();
+
+ ui::test::EventGenerator e1(Shell::GetPrimaryRootWindow(), window.get());
+ e1.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->GetNativeWindow()->SetName("blocking");
+ widget->Show();
+ EXPECT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen());
+ LOG(ERROR) << "Start";
+ e1.ClickLeftButton();
+ LOG(ERROR) << "End";
+ EXPECT_EQ(2, delegate.mouse_event_count());
+ widget->Close();
+
+ EXPECT_FALSE(Shell::GetInstance()->IsSystemModalWindowOpen());
+ e1.ClickLeftButton();
+ EXPECT_EQ(4, delegate.mouse_event_count());
+
+ window.reset();
+}
+
} // namespace test
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698