OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/wm/core/nested_accelerator_controller.h" | 5 #include "ui/wm/core/nested_accelerator_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/event_types.h" | 8 #include "base/event_types.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "ui/aura/test/aura_test_base.h" | 10 #include "ui/aura/test/aura_test_base.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 scoped_ptr<aura::Window> associated_window( | 174 scoped_ptr<aura::Window> associated_window( |
175 CreateNormalWindow(2, root_window(), NULL)); | 175 CreateNormalWindow(2, root_window(), NULL)); |
176 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), | 176 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), |
177 mock_lock_container.get())); | 177 mock_lock_container.get())); |
178 | 178 |
179 DispatchKeyReleaseA(root_window()); | 179 DispatchKeyReleaseA(root_window()); |
180 scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = | 180 scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = |
181 ui::PlatformEventSource::GetInstance()->OverrideDispatcher( | 181 ui::PlatformEventSource::GetInstance()->OverrideDispatcher( |
182 &inner_dispatcher); | 182 &inner_dispatcher); |
183 aura::client::GetDispatcherClient(root_window())->RunWithDispatcher(NULL); | 183 aura::client::DispatcherRunLoop run_loop( |
| 184 aura::client::GetDispatcherClient(root_window()), NULL); |
| 185 run_loop.Run(); |
184 EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); | 186 EXPECT_EQ(1, inner_dispatcher.num_key_events_dispatched()); |
185 } | 187 } |
186 | 188 |
187 // Test that the nested dispatcher handles accelerators. | 189 // Test that the nested dispatcher handles accelerators. |
188 TEST_F(NestedAcceleratorTest, AcceleratorsHandled) { | 190 TEST_F(NestedAcceleratorTest, AcceleratorsHandled) { |
189 // TODO(oshima|sadrul): remove when Win implements PES. | 191 // TODO(oshima|sadrul): remove when Win implements PES. |
190 if (!ui::PlatformEventSource::GetInstance()) | 192 if (!ui::PlatformEventSource::GetInstance()) |
191 return; | 193 return; |
192 MockDispatcher inner_dispatcher; | 194 MockDispatcher inner_dispatcher; |
193 ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); | 195 ui::Accelerator accelerator(ui::VKEY_A, ui::EF_NONE); |
194 accelerator.set_type(ui::ET_KEY_RELEASED); | 196 accelerator.set_type(ui::ET_KEY_RELEASED); |
195 TestTarget target; | 197 TestTarget target; |
196 delegate()->Register(accelerator, &target); | 198 delegate()->Register(accelerator, &target); |
197 | 199 |
198 DispatchKeyReleaseA(root_window()); | 200 DispatchKeyReleaseA(root_window()); |
199 scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = | 201 scoped_ptr<ui::ScopedEventDispatcher> override_dispatcher = |
200 ui::PlatformEventSource::GetInstance()->OverrideDispatcher( | 202 ui::PlatformEventSource::GetInstance()->OverrideDispatcher( |
201 &inner_dispatcher); | 203 &inner_dispatcher); |
202 aura::client::GetDispatcherClient(root_window())->RunWithDispatcher(NULL); | 204 aura::client::DispatcherRunLoop run_loop( |
| 205 aura::client::GetDispatcherClient(root_window()), NULL); |
| 206 run_loop.Run(); |
203 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 207 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
204 EXPECT_EQ(1, target.accelerator_pressed_count()); | 208 EXPECT_EQ(1, target.accelerator_pressed_count()); |
205 } | 209 } |
206 | 210 |
207 } // namespace test | 211 } // namespace test |
208 } // namespace wm | 212 } // namespace wm |
OLD | NEW |