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..475185ac90647387bec4643762a297c1353849c7 100644 |
--- a/ash/wm/window_manager_unittest.cc |
+++ b/ash/wm/window_manager_unittest.cc |
@@ -8,6 +8,7 @@ |
#include "ash/test/ash_test_base.h" |
#include "ash/test/test_activation_delegate.h" |
#include "ash/wm/window_util.h" |
+#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/client/cursor_client_observer.h" |
#include "ui/aura/client/focus_client.h" |
#include "ui/aura/env.h" |
@@ -349,6 +350,51 @@ TEST_F(WindowManagerTest, ActivateOnMouse) { |
} |
} |
+// Tests that Set window property |kActivateOnClickKey| to false could properly |
+// ignore mouse click window activation. |
+TEST_F(WindowManagerTest, ActivateOnClickWindowProperty) { |
+ aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
+ |
+ // 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. |
+ w2->SetProperty(aura::client::kActivateOnClickKey, false); |
+ // Click on window2. |
+ ui::test::EventGenerator generator(root_window, 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()); |
+ 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. |
+ w2->SetProperty(aura::client::kActivateOnClickKey, 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( |