OLD | NEW |
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 Loading... |
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 |kActivateOnPointerKey| to false could |
| 354 // properly ignore pointer window activation. |
| 355 TEST_F(WindowManagerTest, ActivateOnPointerWindowProperty) { |
| 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 pointer activatable. |
| 369 wm::AshFocusRules::SetActivateOnPointer(w2.get(), false); |
| 370 // Mouse 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 // Gesture a tap at window2. |
| 378 generator.GestureTapAt(w2->bounds().CenterPoint()); |
| 379 // Window2 should not become active. |
| 380 EXPECT_FALSE(wm::IsActiveWindow(w2.get())); |
| 381 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 382 |
| 383 // Set window2 now pointer activatable. |
| 384 wm::AshFocusRules::SetActivateOnPointer(w2.get(), true); |
| 385 // Mouse click on window2. |
| 386 generator.ClickLeftButton(); |
| 387 // Window2 should become active. |
| 388 EXPECT_TRUE(wm::IsActiveWindow(w2.get())); |
| 389 EXPECT_FALSE(wm::IsActiveWindow(w1.get())); |
| 390 } |
| 391 |
352 TEST_F(WindowManagerTest, PanelActivation) { | 392 TEST_F(WindowManagerTest, PanelActivation) { |
353 aura::test::TestWindowDelegate wd; | 393 aura::test::TestWindowDelegate wd; |
354 std::unique_ptr<aura::Window> w1( | 394 std::unique_ptr<aura::Window> w1( |
355 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); | 395 CreateTestWindowInShellWithDelegate(&wd, -1, gfx::Rect(10, 10, 50, 50))); |
356 aura::test::TestWindowDelegate pd; | 396 aura::test::TestWindowDelegate pd; |
357 std::unique_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( | 397 std::unique_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( |
358 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); | 398 &pd, ui::wm::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); |
359 aura::client::FocusClient* focus_client = | 399 aura::client::FocusClient* focus_client = |
360 aura::client::GetFocusClient(w1.get()); | 400 aura::client::GetFocusClient(w1.get()); |
361 | 401 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 observer_b.reset(); | 893 observer_b.reset(); |
854 generator.MoveMouseTo(50, 50); | 894 generator.MoveMouseTo(50, 50); |
855 EXPECT_TRUE(observer_a.did_visibility_change()); | 895 EXPECT_TRUE(observer_a.did_visibility_change()); |
856 EXPECT_FALSE(observer_b.did_visibility_change()); | 896 EXPECT_FALSE(observer_b.did_visibility_change()); |
857 EXPECT_TRUE(observer_a.is_cursor_visible()); | 897 EXPECT_TRUE(observer_a.is_cursor_visible()); |
858 | 898 |
859 cursor_manager->RemoveObserver(&observer_a); | 899 cursor_manager->RemoveObserver(&observer_a); |
860 } | 900 } |
861 | 901 |
862 } // namespace ash | 902 } // namespace ash |
OLD | NEW |