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" |
11 #include "base/event_types.h" | 11 #include "base/event_types.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "ui/aura/test/test_windows.h" | 13 #include "ui/aura/test/test_windows.h" |
14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
16 #include "ui/base/accelerators/accelerator.h" | 16 #include "ui/base/accelerators/accelerator.h" |
17 #include "ui/events/event_constants.h" | 17 #include "ui/events/event_constants.h" |
18 #include "ui/events/event_utils.h" | 18 #include "ui/events/event_utils.h" |
| 19 #include "ui/events/platform/platform_event_source.h" |
19 #include "ui/wm/public/dispatcher_client.h" | 20 #include "ui/wm/public/dispatcher_client.h" |
20 | 21 |
21 #if defined(USE_X11) | 22 #if defined(USE_X11) |
22 #include <X11/Xlib.h> | 23 #include <X11/Xlib.h> |
23 #include "ui/events/test/events_test_utils_x11.h" | 24 #include "ui/events/test/events_test_utils_x11.h" |
24 #endif // USE_X11 | 25 #endif // USE_X11 |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
27 namespace test { | 28 namespace test { |
28 | 29 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 native_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); | 90 native_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); |
90 host->PostNativeEvent(native_event); | 91 host->PostNativeEvent(native_event); |
91 #endif | 92 #endif |
92 // Make sure the inner message-loop terminates after dispatching the events. | 93 // Make sure the inner message-loop terminates after dispatching the events. |
93 base::MessageLoop::current()->PostTask(FROM_HERE, | 94 base::MessageLoop::current()->PostTask(FROM_HERE, |
94 base::MessageLoop::current()->QuitClosure()); | 95 base::MessageLoop::current()->QuitClosure()); |
95 } | 96 } |
96 | 97 |
97 } // namespace | 98 } // namespace |
98 | 99 |
99 typedef AshTestBase NestedDispatcherTest; | 100 class NestedDispatcherTest : public AshTestBase { |
| 101 public: |
| 102 NestedDispatcherTest() {} |
| 103 virtual ~NestedDispatcherTest() {} |
| 104 |
| 105 // AshTestBase: |
| 106 virtual void SetUp() OVERRIDE { |
| 107 event_source_ = ui::PlatformEventSource::CreateDefault(); |
| 108 AshTestBase::SetUp(); |
| 109 } |
| 110 |
| 111 private: |
| 112 scoped_ptr<ui::PlatformEventSource> event_source_; |
| 113 |
| 114 DISALLOW_COPY_AND_ASSIGN(NestedDispatcherTest); |
| 115 }; |
100 | 116 |
101 // Aura window above lock screen in z order. | 117 // Aura window above lock screen in z order. |
102 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { | 118 TEST_F(NestedDispatcherTest, AssociatedWindowAboveLockScreen) { |
103 MockDispatcher inner_dispatcher; | 119 MockDispatcher inner_dispatcher; |
104 | 120 |
105 scoped_ptr<aura::Window> mock_lock_container( | 121 scoped_ptr<aura::Window> mock_lock_container( |
106 CreateTestWindowInShellWithId(0)); | 122 CreateTestWindowInShellWithId(0)); |
107 aura::test::CreateTestWindowWithId(1, mock_lock_container.get()); | 123 aura::test::CreateTestWindowWithId(1, mock_lock_container.get()); |
108 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(2)); | 124 scoped_ptr<aura::Window> associated_window(CreateTestWindowInShellWithId(2)); |
109 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), | 125 EXPECT_TRUE(aura::test::WindowIsAbove(associated_window.get(), |
(...skipping 19 matching lines...) Expand all Loading... |
129 | 145 |
130 DispatchKeyReleaseA(); | 146 DispatchKeyReleaseA(); |
131 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( | 147 aura::client::GetDispatcherClient(root_window)->RunWithDispatcher( |
132 &inner_dispatcher); | 148 &inner_dispatcher); |
133 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); | 149 EXPECT_EQ(0, inner_dispatcher.num_key_events_dispatched()); |
134 EXPECT_EQ(1, target.accelerator_pressed_count()); | 150 EXPECT_EQ(1, target.accelerator_pressed_count()); |
135 } | 151 } |
136 | 152 |
137 } // namespace test | 153 } // namespace test |
138 } // namespace ash | 154 } // namespace ash |
OLD | NEW |