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

Side by Side Diff: ash/wm/window_manager_unittest.cc

Issue 2809073002: cros: allow aura window not considered activatable for pointer event (Closed)
Patch Set: feedback 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/public/cpp/shell_window_ids.h" 5 #include "ash/public/cpp/shell_window_ids.h"
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "ash/shell_port.h" 7 #include "ash/shell_port.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/test/test_activation_delegate.h" 9 #include "ash/test/test_activation_delegate.h"
10 #include "ash/wm/ash_focus_rules.h"
10 #include "ash/wm/window_util.h" 11 #include "ash/wm/window_util.h"
11 #include "ui/aura/client/cursor_client_observer.h" 12 #include "ui/aura/client/cursor_client_observer.h"
12 #include "ui/aura/client/focus_client.h" 13 #include "ui/aura/client/focus_client.h"
13 #include "ui/aura/env.h" 14 #include "ui/aura/env.h"
14 #include "ui/aura/test/aura_test_base.h" 15 #include "ui/aura/test/aura_test_base.h"
15 #include "ui/aura/test/test_window_delegate.h" 16 #include "ui/aura/test/test_window_delegate.h"
16 #include "ui/aura/test/test_windows.h" 17 #include "ui/aura/test/test_windows.h"
17 #include "ui/base/cursor/cursor.h" 18 #include "ui/base/cursor/cursor.h"
18 #include "ui/base/hit_test.h" 19 #include "ui/base/hit_test.h"
19 #include "ui/display/screen.h" 20 #include "ui/display/screen.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); 343 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow());
343 EXPECT_FALSE(w11->CanFocus()); 344 EXPECT_FALSE(w11->CanFocus());
344 345
345 // Click on |w11|. This should focus w1. 346 // Click on |w11|. This should focus w1.
346 generator.MoveMouseToCenterOf(w11.get()); 347 generator.MoveMouseToCenterOf(w11.get());
347 generator.ClickLeftButton(); 348 generator.ClickLeftButton();
348 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); 349 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow());
349 } 350 }
350 } 351 }
351 352
353 // Tests that Set window property |kActivateOnClickKey| to false could properly
354 // ignore mouse click window activation.
355 TEST_F(WindowManagerTest, ActivateOnClickWindowProperty) {
356 // Create two test windows, window1 and window2.
357 aura::test::TestWindowDelegate wd;
358 std::unique_ptr<aura::Window> w1(
359 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50)));
360 std::unique_ptr<aura::Window> w2(
361 CreateTestWindowInShellWithDelegate(&wd, -2, gfx::Rect(70, 70, 50, 50)));
362
363 // Activate window1.
364 wm::ActivateWindow(w1.get());
365 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
366 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
367
368 // Set window2 not click activatable.
369 wm::AshFocusRules::SetActivateOnClick(w2.get(), false);
370 // Click on window2.
371 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w2.get());
372 generator.ClickLeftButton();
373 // Window2 should not become active.
374 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
375 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
376
377 // Other input events, like a gesture tap on window2 should activate window2.
378 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
379 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
380 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
381
382 // Activate window1 again to deactivate window2.
383 wm::ActivateWindow(w1.get());
384 EXPECT_TRUE(wm::IsActiveWindow(w1.get()));
385 EXPECT_FALSE(wm::IsActiveWindow(w2.get()));
386
387 // Set window2 now click activatable.
388 wm::AshFocusRules::SetActivateOnClick(w2.get(), true);
389 // Click on window2.
390 generator.ClickLeftButton();
391 // Window2 should become active.
392 EXPECT_TRUE(wm::IsActiveWindow(w2.get()));
393 EXPECT_FALSE(wm::IsActiveWindow(w1.get()));
394 }
395
352 TEST_F(WindowManagerTest, PanelActivation) { 396 TEST_F(WindowManagerTest, PanelActivation) {
353 aura::test::TestWindowDelegate wd; 397 aura::test::TestWindowDelegate wd;
354 std::unique_ptr<aura::Window> w1( 398 std::unique_ptr<aura::Window> w1(
355 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); 399 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50)));
356 aura::test::TestWindowDelegate pd; 400 aura::test::TestWindowDelegate pd;
357 std::unique_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( 401 std::unique_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType(
358 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); 402 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50)));
359 aura::client::FocusClient* focus_client = 403 aura::client::FocusClient* focus_client =
360 aura::client::GetFocusClient(w1.get()); 404 aura::client::GetFocusClient(w1.get());
361 405
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 observer_b.reset(); 897 observer_b.reset();
854 generator.MoveMouseTo(50, 50); 898 generator.MoveMouseTo(50, 50);
855 EXPECT_TRUE(observer_a.did_visibility_change()); 899 EXPECT_TRUE(observer_a.did_visibility_change());
856 EXPECT_FALSE(observer_b.did_visibility_change()); 900 EXPECT_FALSE(observer_b.did_visibility_change());
857 EXPECT_TRUE(observer_a.is_cursor_visible()); 901 EXPECT_TRUE(observer_a.is_cursor_visible());
858 902
859 cursor_manager->RemoveObserver(&observer_a); 903 cursor_manager->RemoveObserver(&observer_a);
860 } 904 }
861 905
862 } // namespace ash 906 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698