| 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/wm/activation_controller.h" | 5 #include "ash/wm/activation_controller.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/test/test_activation_delegate.h" | 10 #include "ash/test/test_activation_delegate.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 aura::test::TestWindowDelegate wd; | 189 aura::test::TestWindowDelegate wd; |
| 190 TestActivationDelegate ad1; | 190 TestActivationDelegate ad1; |
| 191 TestActivationDelegate ad2(false); | 191 TestActivationDelegate ad2(false); |
| 192 | 192 |
| 193 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 193 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 194 &wd, 1, gfx::Rect(100, 100), NULL)); | 194 &wd, 1, gfx::Rect(100, 100), NULL)); |
| 195 ad1.SetWindow(w1.get()); | 195 ad1.SetWindow(w1.get()); |
| 196 EXPECT_EQ(NULL, wm::GetActiveWindow()); | 196 EXPECT_EQ(NULL, wm::GetActiveWindow()); |
| 197 | 197 |
| 198 // Clicking on an activatable window activtes the window. | 198 // Clicking on an activatable window activtes the window. |
| 199 aura::test::EventGenerator generator(Shell::GetRootWindow(), w1.get()); | 199 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), w1.get()); |
| 200 generator.ClickLeftButton(); | 200 generator.ClickLeftButton(); |
| 201 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 201 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 202 | 202 |
| 203 // Creates a menu that covers the transient parent. | 203 // Creates a menu that covers the transient parent. |
| 204 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( | 204 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( |
| 205 &wd, aura::client::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); | 205 &wd, aura::client::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); |
| 206 ad2.SetWindow(menu.get()); | 206 ad2.SetWindow(menu.get()); |
| 207 w1->AddTransientChild(menu.get()); | 207 w1->AddTransientChild(menu.get()); |
| 208 | 208 |
| 209 // Clicking on a menu whose transient parent is active window shouldn't | 209 // Clicking on a menu whose transient parent is active window shouldn't |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 314 } |
| 315 | 315 |
| 316 // Verifies that we prevent all attempts to focus a child of a non-activatable | 316 // Verifies that we prevent all attempts to focus a child of a non-activatable |
| 317 // window from claiming focus to that window. | 317 // window from claiming focus to that window. |
| 318 TEST_F(ActivationControllerTest, PreventFocusToNonActivatableWindow) { | 318 TEST_F(ActivationControllerTest, PreventFocusToNonActivatableWindow) { |
| 319 aura::test::TestWindowDelegate wd; | 319 aura::test::TestWindowDelegate wd; |
| 320 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 320 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 321 &wd, -1, gfx::Rect(50, 50), NULL)); | 321 &wd, -1, gfx::Rect(50, 50), NULL)); |
| 322 // The RootWindow is a non-activatable parent. | 322 // The RootWindow is a non-activatable parent. |
| 323 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 323 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
| 324 &wd, -2, gfx::Rect(50, 50), Shell::GetRootWindow())); | 324 &wd, -2, gfx::Rect(50, 50), Shell::GetPrimaryRootWindow())); |
| 325 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate( | 325 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate( |
| 326 &wd, -21, gfx::Rect(50, 50), w2.get())); | 326 &wd, -21, gfx::Rect(50, 50), w2.get())); |
| 327 | 327 |
| 328 wm::ActivateWindow(w1.get()); | 328 wm::ActivateWindow(w1.get()); |
| 329 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); | 329 EXPECT_TRUE(wm::IsActiveWindow(w1.get())); |
| 330 EXPECT_TRUE(w1->HasFocus()); | 330 EXPECT_TRUE(w1->HasFocus()); |
| 331 | 331 |
| 332 // Try activating |w2|. It's not a child of an activatable container, so it | 332 // Try activating |w2|. It's not a child of an activatable container, so it |
| 333 // should neither be activated nor get focus. | 333 // should neither be activated nor get focus. |
| 334 wm::ActivateWindow(w2.get()); | 334 wm::ActivateWindow(w2.get()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 355 { | 355 { |
| 356 aura::test::TestWindowDelegate wd; | 356 aura::test::TestWindowDelegate wd; |
| 357 | 357 |
| 358 // Normal Window | 358 // Normal Window |
| 359 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 359 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 360 &wd, -1, gfx::Rect(50, 50), NULL)); | 360 &wd, -1, gfx::Rect(50, 50), NULL)); |
| 361 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); | 361 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); |
| 362 | 362 |
| 363 // The RootWindow is a non-activatable parent. | 363 // The RootWindow is a non-activatable parent. |
| 364 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 364 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
| 365 &wd, -2, gfx::Rect(50, 50), Shell::GetRootWindow())); | 365 &wd, -2, gfx::Rect(50, 50), Shell::GetPrimaryRootWindow())); |
| 366 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate( | 366 scoped_ptr<aura::Window> w21(aura::test::CreateTestWindowWithDelegate( |
| 367 &wd, -21, gfx::Rect(50, 50), w2.get())); | 367 &wd, -21, gfx::Rect(50, 50), w2.get())); |
| 368 EXPECT_FALSE(wm::CanActivateWindow(w2.get())); | 368 EXPECT_FALSE(wm::CanActivateWindow(w2.get())); |
| 369 EXPECT_FALSE(wm::CanActivateWindow(w21.get())); | 369 EXPECT_FALSE(wm::CanActivateWindow(w21.get())); |
| 370 | 370 |
| 371 // The window has a transient child. | 371 // The window has a transient child. |
| 372 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate( | 372 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate( |
| 373 &wd, -3, gfx::Rect(50, 50), NULL)); | 373 &wd, -3, gfx::Rect(50, 50), NULL)); |
| 374 scoped_ptr<aura::Window> w31(aura::test::CreateTestWindowWithDelegate( | 374 scoped_ptr<aura::Window> w31(aura::test::CreateTestWindowWithDelegate( |
| 375 &wd, -31, gfx::Rect(50, 50), NULL)); | 375 &wd, -31, gfx::Rect(50, 50), NULL)); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 460 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
| 461 &wd, -1, gfx::Rect(50, 50, 50, 50), NULL)); | 461 &wd, -1, gfx::Rect(50, 50, 50, 50), NULL)); |
| 462 | 462 |
| 463 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); | 463 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); |
| 464 w1->layer()->SetVisible(false); | 464 w1->layer()->SetVisible(false); |
| 465 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); | 465 EXPECT_TRUE(wm::CanActivateWindow(w1.get())); |
| 466 } | 466 } |
| 467 | 467 |
| 468 } // namespace test | 468 } // namespace test |
| 469 } // namespace ash | 469 } // namespace ash |
| OLD | NEW |