Chromium Code Reviews| Index: ash/wm/window_manager_unittest.cc |
| diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc |
| index 52c06a188543368460badf5a0c810b55d43aae22..b6175ffc9a7d44b30b0fe71ae101117cb1b8d1ee 100644 |
| --- a/ash/wm/window_manager_unittest.cc |
| +++ b/ash/wm/window_manager_unittest.cc |
| @@ -7,6 +7,7 @@ |
| #include "ash/shell_port.h" |
| #include "ash/test/ash_test_base.h" |
| #include "ash/test/test_activation_delegate.h" |
| +#include "ash/wm/ash_focus_rules.h" |
| #include "ash/wm/window_util.h" |
| #include "ui/aura/client/cursor_client_observer.h" |
| #include "ui/aura/client/focus_client.h" |
| @@ -349,6 +350,49 @@ TEST_F(WindowManagerTest, ActivateOnMouse) { |
| } |
| } |
| +// Tests that Set window property |kActivateOnClickKey| to false could properly |
| +// ignore mouse click window activation. |
| +TEST_F(WindowManagerTest, ActivateOnClickWindowProperty) { |
| + // Create two test windows, window1 and window2. |
| + aura::test::TestWindowDelegate wd; |
| + std::unique_ptr<aura::Window> w1( |
| + CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); |
| + std::unique_ptr<aura::Window> w2( |
| + CreateTestWindowInShellWithDelegate(&wd, -2, gfx::Rect(70, 70, 50, 50))); |
| + |
| + // Activate window1. |
| + wm::ActivateWindow(w1.get()); |
| + EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| + |
| + // Set window2 not click activatable. |
| + wm::AshFocusRules::SetActivateOnClick(w2.get(), false); |
| + // Click on window2. |
| + ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get()); |
| + generator.ClickLeftButton(); |
| + // Window2 should not become active. |
| + EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| + EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| + |
| + // Other input events, like a gesture tap on window2 should activate window2. |
| + generator.GestureTapAt(w2->bounds().CenterPoint()); |
|
oshima
2017/04/11 20:54:40
We may want to include gesture. I'm to exclude it
Qiang(Joe) Xu
2017/04/12 19:00:02
Touch dragging is needed. So I include the gesture
|
| + EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(w1.get())); |
| + |
| + // Activate window1 again to deactivate window2. |
| + wm::ActivateWindow(w1.get()); |
| + EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| + |
| + // Set window2 now click activatable. |
| + wm::AshFocusRules::SetActivateOnClick(w2.get(), true); |
| + // Click on window2. |
| + generator.ClickLeftButton(); |
| + // Window2 should become active. |
| + EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| + EXPECT_FALSE(wm::IsActiveWindow(w1.get())); |
| +} |
| + |
| TEST_F(WindowManagerTest, PanelActivation) { |
| aura::test::TestWindowDelegate wd; |
| std::unique_ptr<aura::Window> w1( |