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/session_state_delegate.h" | 6 #include "ash/session_state_delegate.h" |
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 "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // Aura window below lock screen in z order. | 102 // Aura window below lock screen in z order. |
103 TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { | 103 TEST_F(NestedDispatcherTest, AssociatedWindowBelowLockScreen) { |
104 MockDispatcher inner_dispatcher; | 104 MockDispatcher inner_dispatcher; |
105 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(0)); | 105 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(0)); |
106 | 106 |
107 Shell::GetInstance()->session_state_delegate()->LockScreen(); | 107 Shell::GetInstance()->session_state_delegate()->LockScreen(); |
108 DispatchKeyReleaseA(); | 108 DispatchKeyReleaseA(); |
109 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); | 109 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); |
110 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 110 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
111 &inner_dispatcher, | 111 &inner_dispatcher, |
112 associated_window.get(), | 112 associated_window.get()); |
113 true /* nestable_tasks_allowed */); | |
114 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 113 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
115 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); | 114 Shell::GetInstance()->session_state_delegate()->UnlockScreen(); |
116 } | 115 } |
117 | 116 |
118 // Aura window above lock screen in z order. | 117 // Aura window above lock screen in z order. |
119 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { | 118 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { |
120 MockDispatcher inner_dispatcher; | 119 MockDispatcher inner_dispatcher; |
121 | 120 |
122 scoped_ptr<aura::Window> mock_lock_container( | 121 scoped_ptr<aura::Window> mock_lock_container( |
123 CreateTestWindowInShellWithId(0)); | 122 CreateTestWindowInShellWithId(0)); |
124 aura::test::CreateTestWindowWithId(1, mock_lock_container.get()); | 123 aura::test::CreateTestWindowWithId(1, mock_lock_container.get()); |
125 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(2)); | 124 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(2)); |
126 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), | 125 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), |
127 mock_lock_container.get())); | 126 mock_lock_container.get())); |
128 | 127 |
129 DispatchKeyReleaseA(); | 128 DispatchKeyReleaseA(); |
130 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); | 129 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); |
131 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 130 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
132 &inner_dispatcher, | 131 &inner_dispatcher, |
133 associated_window.get(), | 132 associated_window.get()); |
134 true /* nestable_tasks_allowed */); | |
135 EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); | 133 EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); |
136 } | 134 } |
137 | 135 |
138 // Test that the nested dispatcher handles accelerators. | 136 // Test that the nested dispatcher handles accelerators. |
139 TEST_F(NestedDispatcherTest, AcceleratorsHandled) { | 137 TEST_F(NestedDispatcherTest, AcceleratorsHandled) { |
140 MockDispatcher inner_dispatcher; | 138 MockDispatcher inner_dispatcher; |
141 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); | 139 aura::Window* root_window = ash::Shell::GetPrimaryRootWindow(); |
142 | 140 |
143 ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); | 141 ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); |
144 accelerator.set_type(ui::ET_KEY_RELEASED); | 142 accelerator.set_type(ui::ET_KEY_RELEASED); |
145 TestTarget target; | 143 TestTarget target; |
146 Shell::GetInstance()->accelerator_controller()->Register(accelerator, | 144 Shell::GetInstance()->accelerator_controller()->Register(accelerator, |
147 &target); | 145 &target); |
148 | 146 |
149 DispatchKeyReleaseA(); | 147 DispatchKeyReleaseA(); |
150 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 148 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
151 &inner_dispatcher, | 149 &inner_dispatcher, |
152 root_window, | 150 root_window); |
153 true /* nestable_tasks_allowed */); | |
154 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 151 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
155 EXPECT_EQ(1, target.accelerator_pressed_count()); | 152 EXPECT_EQ(1, target.accelerator_pressed_count()); |
156 } | 153 } |
157 | 154 |
158 } // namespace test | 155 } // namespace test |
159 } // namespace ash | 156 } // namespace ash |
OLD | NEW |