OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/stacking_controller.h" | 5 #include "ui/aura_shell/stacking_controller.h" |
6 | 6 |
7 #include "ui/aura/desktop.h" | 7 #include "ui/aura/root_window.h" |
8 #include "ui/aura/test/event_generator.h" | 8 #include "ui/aura/test/event_generator.h" |
9 #include "ui/aura/test/test_windows.h" | 9 #include "ui/aura/test/test_windows.h" |
10 #include "ui/aura/test/test_window_delegate.h" | 10 #include "ui/aura/test/test_window_delegate.h" |
11 #include "ui/aura_shell/test/aura_shell_test_base.h" | 11 #include "ui/aura_shell/test/aura_shell_test_base.h" |
12 | 12 |
13 namespace aura_shell { | 13 namespace aura_shell { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 typedef aura_shell::test::AuraShellTestBase StackingControllerTest; | 16 typedef aura_shell::test::AuraShellTestBase StackingControllerTest; |
17 | 17 |
18 TEST_F(StackingControllerTest, GetTopmostWindowToActivate) { | 18 TEST_F(StackingControllerTest, GetTopmostWindowToActivate) { |
19 aura::test::ActivateWindowDelegate activate; | 19 aura::test::ActivateWindowDelegate activate; |
20 aura::test::ActivateWindowDelegate non_activate(false); | 20 aura::test::ActivateWindowDelegate non_activate(false); |
21 | 21 |
22 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 22 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
23 &non_activate, 1, gfx::Rect(), NULL)); | 23 &non_activate, 1, gfx::Rect(), NULL)); |
24 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( | 24 scoped_ptr<aura::Window> w2(aura::test::CreateTestWindowWithDelegate( |
25 &activate, 2, gfx::Rect(), NULL)); | 25 &activate, 2, gfx::Rect(), NULL)); |
26 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate( | 26 scoped_ptr<aura::Window> w3(aura::test::CreateTestWindowWithDelegate( |
27 &non_activate, 3, gfx::Rect(), NULL)); | 27 &non_activate, 3, gfx::Rect(), NULL)); |
28 EXPECT_EQ(w2.get(), aura::Desktop::GetInstance()->stacking_client()-> | 28 EXPECT_EQ(w2.get(), aura::RootWindow::GetInstance()->stacking_client()-> |
29 GetTopmostWindowToActivate(NULL)); | 29 GetTopmostWindowToActivate(NULL)); |
30 } | 30 } |
31 | 31 |
32 // Test if the clicking on a menu picks the transient parent as activatable | 32 // Test if the clicking on a menu picks the transient parent as activatable |
33 // window. | 33 // window. |
34 TEST_F(StackingControllerTest, ClickOnMenu) { | 34 TEST_F(StackingControllerTest, ClickOnMenu) { |
35 aura::test::ActivateWindowDelegate activate; | 35 aura::test::ActivateWindowDelegate activate; |
36 aura::test::ActivateWindowDelegate non_activate(false); | 36 aura::test::ActivateWindowDelegate non_activate(false); |
37 | 37 |
38 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( | 38 scoped_ptr<aura::Window> w1(aura::test::CreateTestWindowWithDelegate( |
39 &activate, 1, gfx::Rect(100, 100), NULL)); | 39 &activate, 1, gfx::Rect(100, 100), NULL)); |
40 EXPECT_EQ(NULL, aura::Desktop::GetInstance()->active_window()); | 40 EXPECT_EQ(NULL, aura::RootWindow::GetInstance()->active_window()); |
41 | 41 |
42 // Clicking on an activatable window activtes the window. | 42 // Clicking on an activatable window activtes the window. |
43 aura::test::EventGenerator generator(w1.get()); | 43 aura::test::EventGenerator generator(w1.get()); |
44 generator.ClickLeftButton(); | 44 generator.ClickLeftButton(); |
45 EXPECT_EQ(w1.get(), aura::Desktop::GetInstance()->active_window()); | 45 EXPECT_EQ(w1.get(), aura::RootWindow::GetInstance()->active_window()); |
46 | 46 |
47 // Creates a menu that covers the transient parent. | 47 // Creates a menu that covers the transient parent. |
48 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( | 48 scoped_ptr<aura::Window> menu(aura::test::CreateTestWindowWithDelegateAndType( |
49 &non_activate, aura::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); | 49 &non_activate, aura::WINDOW_TYPE_MENU, 2, gfx::Rect(100, 100), NULL)); |
50 w1->AddTransientChild(menu.get()); | 50 w1->AddTransientChild(menu.get()); |
51 | 51 |
52 // Clicking on a menu whose transient parent is active window shouldn't | 52 // Clicking on a menu whose transient parent is active window shouldn't |
53 // change the active window. | 53 // change the active window. |
54 generator.ClickLeftButton(); | 54 generator.ClickLeftButton(); |
55 EXPECT_EQ(w1.get(), aura::Desktop::GetInstance()->active_window()); | 55 EXPECT_EQ(w1.get(), aura::RootWindow::GetInstance()->active_window()); |
56 } | 56 } |
57 | 57 |
58 } // namespace test | 58 } // namespace test |
59 } // namespace aura_shell | 59 } // namespace aura_shell |
OLD | NEW |