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

Unified Diff: ash/wm/window_manager_unittest.cc

Issue 2809073002: cros: allow aura window not considered activatable for pointer event (Closed)
Patch Set: Created 3 years, 8 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/window_manager_unittest.cc
diff --git a/ash/wm/window_manager_unittest.cc b/ash/wm/window_manager_unittest.cc
index cefeec70d5b585c0c9e35ebb764ee26efb50af6f..823f494576f71fc7c7e24897c6cf653e2d78cc93 100644
--- a/ash/wm/window_manager_unittest.cc
+++ b/ash/wm/window_manager_unittest.cc
@@ -8,6 +8,7 @@
#include "ash/test/test_activation_delegate.h"
#include "ash/wm/window_util.h"
#include "ash/wm_shell.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(

Powered by Google App Engine
This is Rietveld 408576698