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