| 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 #include "ash/shell.h" | 6 #include "ash/shell.h" |
| 7 #include "ash/shell_delegate.h" |
| 7 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 8 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/event_types.h" | 11 #include "base/event_types.h" |
| 11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 12 #include "ui/aura/client/dispatcher_client.h" | 13 #include "ui/aura/client/dispatcher_client.h" |
| 13 #include "ui/aura/root_window.h" | 14 #include "ui/aura/root_window.h" |
| 14 #include "ui/aura/test/test_windows.h" | 15 #include "ui/aura/test/test_windows.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/base/accelerators/accelerator.h" | 17 #include "ui/base/accelerators/accelerator.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 108 |
| 108 } // namespace | 109 } // namespace |
| 109 | 110 |
| 110 typedef AshTestBase NestedDispatcherTest; | 111 typedef AshTestBase NestedDispatcherTest; |
| 111 | 112 |
| 112 // Aura window below lock screen in z order. | 113 // Aura window below lock screen in z order. |
| 113 TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { | 114 TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { |
| 114 MockDispatcher inner_dispatcher; | 115 MockDispatcher inner_dispatcher; |
| 115 aura::Window* default_container = Shell::GetInstance()->GetContainer( | 116 aura::Window* default_container = Shell::GetInstance()->GetContainer( |
| 116 internal::kShellWindowId_DefaultContainer); | 117 internal::kShellWindowId_DefaultContainer); |
| 117 scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId( | 118 scoped_ptr<aura::Window> associated_window(aura::test::CreateTestWindowWithId( |
| 118 0, default_container)); | 119 0, default_container)); |
| 119 scoped_ptr<aura::Window>mock_lock_container( | 120 |
| 120 aura::test::CreateTestWindowWithId(0, default_container)); | 121 Shell::GetInstance()->delegate()->LockScreen(); |
| 121 mock_lock_container->set_stops_event_propagation(true); | |
| 122 aura::test::CreateTestWindowWithId(0, mock_lock_container.get()); | |
| 123 EXPECT_TRUE(aura::test::WindowIsAbove(mock_lock_container.get(), | |
| 124 associated_window.get())); | |
| 125 DispatchKeyReleaseA(); | 122 DispatchKeyReleaseA(); |
| 126 aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow(); | 123 aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow(); |
| 127 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 124 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
| 128 &inner_dispatcher, | 125 &inner_dispatcher, |
| 129 associated_window.get(), | 126 associated_window.get(), |
| 130 true /* nestable_tasks_allowed */); | 127 true /* nestable_tasks_allowed */); |
| 131 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 128 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
| 129 Shell::GetInstance()->delegate()->UnlockScreen(); |
| 132 } | 130 } |
| 133 | 131 |
| 134 // Aura window above lock screen in z order. | 132 // Aura window above lock screen in z order. |
| 135 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { | 133 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { |
| 136 MockDispatcher inner_dispatcher; | 134 MockDispatcher inner_dispatcher; |
| 137 | 135 |
| 138 aura::Window* default_container = Shell::GetInstance()->GetContainer( | 136 aura::Window* default_container = Shell::GetInstance()->GetContainer( |
| 139 internal::kShellWindowId_DefaultContainer); | 137 internal::kShellWindowId_DefaultContainer); |
| 140 scoped_ptr<aura::Window>mock_lock_container( | 138 scoped_ptr<aura::Window>mock_lock_container( |
| 141 aura::test::CreateTestWindowWithId(0, default_container)); | 139 aura::test::CreateTestWindowWithId(0, default_container)); |
| 142 mock_lock_container->set_stops_event_propagation(true); | |
| 143 aura::test::CreateTestWindowWithId(0, mock_lock_container.get()); | 140 aura::test::CreateTestWindowWithId(0, mock_lock_container.get()); |
| 144 scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId( | 141 scoped_ptr<aura::Window>associated_window(aura::test::CreateTestWindowWithId( |
| 145 0, default_container)); | 142 0, default_container)); |
| 146 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), | 143 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), |
| 147 mock_lock_container.get())); | 144 mock_lock_container.get())); |
| 148 | 145 |
| 149 DispatchKeyReleaseA(); | 146 DispatchKeyReleaseA(); |
| 150 aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow(); | 147 aura::RootWindow* root_window = ash::Shell::GetInstance()->GetRootWindow(); |
| 151 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 148 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
| 152 &inner_dispatcher, | 149 &inner_dispatcher, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 171 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 168 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
| 172 &inner_dispatcher, | 169 &inner_dispatcher, |
| 173 root_window, | 170 root_window, |
| 174 true /* nestable_tasks_allowed */); | 171 true /* nestable_tasks_allowed */); |
| 175 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 172 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
| 176 EXPECT_EQ(1, target.accelerator_pressed_count()); | 173 EXPECT_EQ(1, target.accelerator_pressed_count()); |
| 177 } | 174 } |
| 178 | 175 |
| 179 } // namespace test | 176 } // namespace test |
| 180 } // namespace ash | 177 } // namespace ash |
| OLD | NEW |