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/shell.h" | 5 #include "ash/shell.h" |
6 #include "ash/shell_window_ids.h" | 6 #include "ash/shell_window_ids.h" |
7 #include "ash/test/ash_test_base.h" | 7 #include "ash/test/ash_test_base.h" |
8 #include "ash/test/shell_test_api.h" | 8 #include "ash/test/shell_test_api.h" |
9 #include "ash/test/test_activation_delegate.h" | 9 #include "ash/test/test_activation_delegate.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // Touch on a sub-window (w122) to focus it. | 192 // Touch on a sub-window (w122) to focus it. |
193 gfx::Point click_point = w122->bounds().CenterPoint(); | 193 gfx::Point click_point = w122->bounds().CenterPoint(); |
194 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); | 194 aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point); |
195 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); | 195 ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime()); |
196 details = dispatcher->OnEventFromSource(&touchev); | 196 details = dispatcher->OnEventFromSource(&touchev); |
197 ASSERT_FALSE(details.dispatcher_destroyed); | 197 ASSERT_FALSE(details.dispatcher_destroyed); |
198 focus_client = aura::client::GetFocusClient(w122.get()); | 198 focus_client = aura::client::GetFocusClient(w122.get()); |
199 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); | 199 EXPECT_EQ(w122.get(), focus_client->GetFocusedWindow()); |
200 | 200 |
201 // The key press should be sent to the focused sub-window. | 201 // The key press should be sent to the focused sub-window. |
| 202 keyev = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE); |
202 details = dispatcher->OnEventFromSource(&keyev); | 203 details = dispatcher->OnEventFromSource(&keyev); |
203 ASSERT_FALSE(details.dispatcher_destroyed); | 204 ASSERT_FALSE(details.dispatcher_destroyed); |
204 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); | 205 EXPECT_EQ(ui::VKEY_E, w122delegate->last_key_code()); |
205 | 206 |
206 // Hiding the focused window will set the focus to its parent if | 207 // Hiding the focused window will set the focus to its parent if |
207 // it's focusable. | 208 // it's focusable. |
208 w122->Hide(); | 209 w122->Hide(); |
209 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), | 210 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), |
210 aura::client::GetFocusClient(w122.get())); | 211 aura::client::GetFocusClient(w122.get())); |
211 EXPECT_EQ(w12.get(), | 212 EXPECT_EQ(w12.get(), |
(...skipping 18 matching lines...) Expand all Loading... |
230 EXPECT_EQ(w123.get(), | 231 EXPECT_EQ(w123.get(), |
231 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 232 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
232 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); | 233 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); |
233 | 234 |
234 // Hiding the focused window will set the focus to NULL because | 235 // Hiding the focused window will set the focus to NULL because |
235 // parent window is not focusable. | 236 // parent window is not focusable. |
236 w123->Hide(); | 237 w123->Hide(); |
237 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), | 238 EXPECT_EQ(aura::client::GetFocusClient(w12.get()), |
238 aura::client::GetFocusClient(w123.get())); | 239 aura::client::GetFocusClient(w123.get())); |
239 EXPECT_EQ(NULL, aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 240 EXPECT_EQ(NULL, aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
| 241 keyev = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE); |
240 details = dispatcher->OnEventFromSource(&keyev); | 242 details = dispatcher->OnEventFromSource(&keyev); |
241 EXPECT_FALSE(keyev.handled() || details.dispatcher_destroyed); | 243 EXPECT_FALSE(keyev.handled() || details.dispatcher_destroyed); |
242 | 244 |
243 // Set the focus back to w123 | 245 // Set the focus back to w123 |
244 aura::client::SetActivationDelegate(w1.get(), NULL); | 246 aura::client::SetActivationDelegate(w1.get(), NULL); |
245 w123->Show(); | 247 w123->Show(); |
246 w123->Focus(); | 248 w123->Focus(); |
247 EXPECT_EQ(w123.get(), | 249 EXPECT_EQ(w123.get(), |
248 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); | 250 aura::client::GetFocusClient(w12.get())->GetFocusedWindow()); |
249 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); | 251 aura::client::SetActivationDelegate(w1.get(), &activation_delegate); |
250 | 252 |
251 // Removing the focused window will set the focus to NULL because | 253 // Removing the focused window will set the focus to NULL because |
252 // parent window is not focusable. | 254 // parent window is not focusable. |
253 w12->RemoveChild(w123.get()); | 255 w12->RemoveChild(w123.get()); |
254 EXPECT_EQ(NULL, aura::client::GetFocusClient(w123.get())); | 256 EXPECT_EQ(NULL, aura::client::GetFocusClient(w123.get())); |
| 257 keyev = ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_E, ui::EF_NONE); |
255 details = dispatcher->OnEventFromSource(&keyev); | 258 details = dispatcher->OnEventFromSource(&keyev); |
256 EXPECT_FALSE(keyev.handled() || details.dispatcher_destroyed); | 259 EXPECT_FALSE(keyev.handled() || details.dispatcher_destroyed); |
257 } | 260 } |
258 | 261 |
259 // Various assertion testing for activating windows. | 262 // Various assertion testing for activating windows. |
260 TEST_F(WindowManagerTest, ActivateOnMouse) { | 263 TEST_F(WindowManagerTest, ActivateOnMouse) { |
261 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 264 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
262 | 265 |
263 test::TestActivationDelegate d1; | 266 test::TestActivationDelegate d1; |
264 aura::test::TestWindowDelegate wd; | 267 aura::test::TestWindowDelegate wd; |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 observer_a.reset(); | 831 observer_a.reset(); |
829 observer_b.reset(); | 832 observer_b.reset(); |
830 generator.MoveMouseTo(50, 50); | 833 generator.MoveMouseTo(50, 50); |
831 EXPECT_TRUE(observer_a.did_visibility_change()); | 834 EXPECT_TRUE(observer_a.did_visibility_change()); |
832 EXPECT_FALSE(observer_b.did_visibility_change()); | 835 EXPECT_FALSE(observer_b.did_visibility_change()); |
833 EXPECT_TRUE(observer_a.is_cursor_visible()); | 836 EXPECT_TRUE(observer_a.is_cursor_visible()); |
834 } | 837 } |
835 #endif // defined(OS_CHROMEOS) | 838 #endif // defined(OS_CHROMEOS) |
836 | 839 |
837 } // namespace ash | 840 } // namespace ash |
OLD | NEW |