| 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/shell.h" | 5 #include "ash/shell.h" |
| 6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
| 7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
| 8 #include "ash/test/shell_test_api.h" | 8 #include "ash/test/shell_test_api.h" |
| 9 #include "ash/test/test_activation_delegate.h" | 9 #include "ash/test/test_activation_delegate.h" |
| 10 #include "ash/wm/activation_controller.h" | 10 #include "ash/wm/activation_controller.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); | 340 EXPECT_EQ(w2.get(), focus_client->GetFocusedWindow()); |
| 341 EXPECT_FALSE(w11->CanFocus()); | 341 EXPECT_FALSE(w11->CanFocus()); |
| 342 | 342 |
| 343 // Click on |w11|. This should focus w1. | 343 // Click on |w11|. This should focus w1. |
| 344 generator.MoveMouseToCenterOf(w11.get()); | 344 generator.MoveMouseToCenterOf(w11.get()); |
| 345 generator.ClickLeftButton(); | 345 generator.ClickLeftButton(); |
| 346 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); | 346 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 TEST_F(WindowManagerTest, PanelActivation) { |
| 351 aura::test::TestWindowDelegate wd; |
| 352 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( |
| 353 &wd, -1, gfx::Rect(10, 10, 50, 50))); |
| 354 aura::test::TestWindowDelegate pd; |
| 355 scoped_ptr<aura::Window> p1(CreateTestWindowInShellWithDelegateAndType( |
| 356 &pd, aura::client::WINDOW_TYPE_PANEL, -1, gfx::Rect(10, 10, 50, 50))); |
| 357 aura::client::FocusClient* focus_client = |
| 358 aura::client::GetFocusClient(w1.get()); |
| 359 |
| 360 // Activate w1. |
| 361 wm::ActivateWindow(w1.get()); |
| 362 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 363 |
| 364 // Activate p1. |
| 365 wm::ActivateWindow(p1.get()); |
| 366 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
| 367 EXPECT_EQ(p1.get(), focus_client->GetFocusedWindow()); |
| 368 |
| 369 // Activate w1. |
| 370 wm::ActivateWindow(w1.get()); |
| 371 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 372 EXPECT_EQ(w1.get(), focus_client->GetFocusedWindow()); |
| 373 |
| 374 // Clicking on a non-activatable window should not change the active window. |
| 375 { |
| 376 NonFocusableDelegate nfd; |
| 377 scoped_ptr<aura::Window> w3(CreateTestWindowInShellWithDelegate( |
| 378 &nfd, -1, gfx::Rect(70, 70, 50, 50))); |
| 379 aura::test::EventGenerator generator3(Shell::GetPrimaryRootWindow(), |
| 380 w3.get()); |
| 381 wm::ActivateWindow(p1.get()); |
| 382 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
| 383 generator3.ClickLeftButton(); |
| 384 EXPECT_TRUE(wm::IsActiveWindow(p1.get())); |
| 385 } |
| 386 } |
| 387 |
| 350 // Essentially the same as ActivateOnMouse, but for touch events. | 388 // Essentially the same as ActivateOnMouse, but for touch events. |
| 351 TEST_F(WindowManagerTest, ActivateOnTouch) { | 389 TEST_F(WindowManagerTest, ActivateOnTouch) { |
| 352 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 390 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
| 353 | 391 |
| 354 test::TestActivationDelegate d1; | 392 test::TestActivationDelegate d1; |
| 355 aura::test::TestWindowDelegate wd; | 393 aura::test::TestWindowDelegate wd; |
| 356 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( | 394 scoped_ptr<aura::Window> w1(CreateTestWindowInShellWithDelegate( |
| 357 &wd, -1, gfx::Rect(10, 10, 50, 50))); | 395 &wd, -1, gfx::Rect(10, 10, 50, 50))); |
| 358 d1.SetWindow(w1.get()); | 396 d1.SetWindow(w1.get()); |
| 359 test::TestActivationDelegate d2; | 397 test::TestActivationDelegate d2; |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); | 747 generator.ReleaseKey(ui::VKEY_A, ui::EF_NONE); |
| 710 EXPECT_FALSE(cursor_manager->IsCursorVisible()); | 748 EXPECT_FALSE(cursor_manager->IsCursorVisible()); |
| 711 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 749 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 712 // Moving mouse shows the cursor again. | 750 // Moving mouse shows the cursor again. |
| 713 generator.MoveMouseTo(gfx::Point(0, 0)); | 751 generator.MoveMouseTo(gfx::Point(0, 0)); |
| 714 EXPECT_TRUE(cursor_manager->IsCursorVisible()); | 752 EXPECT_TRUE(cursor_manager->IsCursorVisible()); |
| 715 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); | 753 EXPECT_TRUE(cursor_manager->IsMouseEventsEnabled()); |
| 716 } | 754 } |
| 717 | 755 |
| 718 } // namespace ash | 756 } // namespace ash |
| OLD | NEW |