| 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 "ui/aura/window_event_dispatcher.h" | 5 #include "ui/aura/window_event_dispatcher.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 // Prevent w3 from being deleted by the hierarchy since its delegate is owned | 340 // Prevent w3 from being deleted by the hierarchy since its delegate is owned |
| 341 // by this scope. | 341 // by this scope. |
| 342 w3->parent()->RemoveChild(w3.get()); | 342 w3->parent()->RemoveChild(w3.get()); |
| 343 } | 343 } |
| 344 | 344 |
| 345 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { | 345 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { |
| 346 ConsumeKeyHandler handler; | 346 ConsumeKeyHandler handler; |
| 347 root_window()->AddPreTargetHandler(&handler); | 347 root_window()->AddPreTargetHandler(&handler); |
| 348 | 348 |
| 349 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false); | 349 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, ui::EF_NONE); |
| 350 DispatchEventUsingWindowDispatcher(&unknown_event); | 350 DispatchEventUsingWindowDispatcher(&unknown_event); |
| 351 EXPECT_FALSE(unknown_event.handled()); | 351 EXPECT_FALSE(unknown_event.handled()); |
| 352 EXPECT_EQ(0, handler.num_key_events()); | 352 EXPECT_EQ(0, handler.num_key_events()); |
| 353 | 353 |
| 354 handler.Reset(); | 354 handler.Reset(); |
| 355 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 355 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 356 DispatchEventUsingWindowDispatcher(&known_event); | 356 DispatchEventUsingWindowDispatcher(&known_event); |
| 357 EXPECT_TRUE(known_event.handled()); | 357 EXPECT_TRUE(known_event.handled()); |
| 358 EXPECT_EQ(1, handler.num_key_events()); | 358 EXPECT_EQ(1, handler.num_key_events()); |
| 359 | 359 |
| 360 handler.Reset(); | 360 handler.Reset(); |
| 361 ui::KeyEvent ime_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, | 361 ui::KeyEvent ime_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, |
| 362 ui::EF_IME_FABRICATED_KEY, false); | 362 ui::EF_IME_FABRICATED_KEY); |
| 363 DispatchEventUsingWindowDispatcher(&ime_event); | 363 DispatchEventUsingWindowDispatcher(&ime_event); |
| 364 EXPECT_TRUE(ime_event.handled()); | 364 EXPECT_TRUE(ime_event.handled()); |
| 365 EXPECT_EQ(1, handler.num_key_events()); | 365 EXPECT_EQ(1, handler.num_key_events()); |
| 366 | 366 |
| 367 handler.Reset(); | 367 handler.Reset(); |
| 368 ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, | 368 ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, |
| 369 0, false); | 369 ui::EF_NONE); |
| 370 unknown_key_with_char_event.set_character(0x00e4 /* "ä" */); | 370 unknown_key_with_char_event.set_character(0x00e4 /* "ä" */); |
| 371 DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event); | 371 DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event); |
| 372 EXPECT_TRUE(unknown_key_with_char_event.handled()); | 372 EXPECT_TRUE(unknown_key_with_char_event.handled()); |
| 373 EXPECT_EQ(1, handler.num_key_events()); | 373 EXPECT_EQ(1, handler.num_key_events()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { | 376 TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { |
| 377 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 377 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 378 w1->Show(); | 378 w1->Show(); |
| 379 w1->Focus(); | 379 w1->Focus(); |
| 380 | 380 |
| 381 ui::test::TestEventHandler handler; | 381 ui::test::TestEventHandler handler; |
| 382 w1->AddPreTargetHandler(&handler); | 382 w1->AddPreTargetHandler(&handler); |
| 383 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 383 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 384 DispatchEventUsingWindowDispatcher(&key_press); | 384 DispatchEventUsingWindowDispatcher(&key_press); |
| 385 EXPECT_TRUE(key_press.handled()); | 385 EXPECT_TRUE(key_press.handled()); |
| 386 EXPECT_EQ(1, handler.num_key_events()); | 386 EXPECT_EQ(1, handler.num_key_events()); |
| 387 | 387 |
| 388 w1->RemovePreTargetHandler(&handler); | 388 w1->RemovePreTargetHandler(&handler); |
| 389 } | 389 } |
| 390 | 390 |
| 391 // Tests that touch-events that are beyond the bounds of the root-window do get | 391 // Tests that touch-events that are beyond the bounds of the root-window do get |
| 392 // propagated to the event filters correctly with the root as the target. | 392 // propagated to the event filters correctly with the root as the target. |
| 393 TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) { | 393 TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) { |
| (...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2263 ui::EF_LEFT_MOUSE_BUTTON); | 2263 ui::EF_LEFT_MOUSE_BUTTON); |
| 2264 DispatchEventUsingWindowDispatcher(&mouse); | 2264 DispatchEventUsingWindowDispatcher(&mouse); |
| 2265 EXPECT_TRUE(recorder_first.events().empty()); | 2265 EXPECT_TRUE(recorder_first.events().empty()); |
| 2266 ASSERT_EQ(1u, recorder_second.events().size()); | 2266 ASSERT_EQ(1u, recorder_second.events().size()); |
| 2267 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder_second.events()[0]); | 2267 EXPECT_EQ(ui::ET_MOUSE_PRESSED, recorder_second.events()[0]); |
| 2268 EXPECT_EQ(event_location.ToString(), | 2268 EXPECT_EQ(event_location.ToString(), |
| 2269 recorder_second.mouse_locations()[0].ToString()); | 2269 recorder_second.mouse_locations()[0].ToString()); |
| 2270 } | 2270 } |
| 2271 | 2271 |
| 2272 } // namespace aura | 2272 } // namespace aura |
| OLD | NEW |