| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 343 |
| 344 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { | 344 TEST_F(WindowEventDispatcherTest, IgnoreUnknownKeys) { |
| 345 ConsumeKeyHandler handler; | 345 ConsumeKeyHandler handler; |
| 346 root_window()->AddPreTargetHandler(&handler); | 346 root_window()->AddPreTargetHandler(&handler); |
| 347 | 347 |
| 348 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false); | 348 ui::KeyEvent unknown_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0, false); |
| 349 DispatchEventUsingWindowDispatcher(&unknown_event); | 349 DispatchEventUsingWindowDispatcher(&unknown_event); |
| 350 EXPECT_FALSE(unknown_event.handled()); | 350 EXPECT_FALSE(unknown_event.handled()); |
| 351 EXPECT_EQ(0, handler.num_key_events()); | 351 EXPECT_EQ(0, handler.num_key_events()); |
| 352 | 352 |
| 353 handler.Reset(); |
| 353 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 354 ui::KeyEvent known_event(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); |
| 354 DispatchEventUsingWindowDispatcher(&known_event); | 355 DispatchEventUsingWindowDispatcher(&known_event); |
| 355 EXPECT_TRUE(known_event.handled()); | 356 EXPECT_TRUE(known_event.handled()); |
| 356 EXPECT_EQ(1, handler.num_key_events()); | 357 EXPECT_EQ(1, handler.num_key_events()); |
| 358 |
| 359 handler.Reset(); |
| 360 ui::KeyEvent ime_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, |
| 361 ui::EF_IME_FABRICATED_KEY, false); |
| 362 DispatchEventUsingWindowDispatcher(&ime_event); |
| 363 EXPECT_TRUE(ime_event.handled()); |
| 364 EXPECT_EQ(1, handler.num_key_events()); |
| 365 |
| 366 handler.Reset(); |
| 367 ui::KeyEvent unknown_key_with_char_event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, |
| 368 0, false); |
| 369 unknown_key_with_char_event.set_character(0x00e4 /* "รค" */); |
| 370 DispatchEventUsingWindowDispatcher(&unknown_key_with_char_event); |
| 371 EXPECT_TRUE(unknown_key_with_char_event.handled()); |
| 372 EXPECT_EQ(1, handler.num_key_events()); |
| 357 } | 373 } |
| 358 | 374 |
| 359 TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { | 375 TEST_F(WindowEventDispatcherTest, NoDelegateWindowReceivesKeyEvents) { |
| 360 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); | 376 scoped_ptr<Window> w1(CreateNormalWindow(1, root_window(), NULL)); |
| 361 w1->Show(); | 377 w1->Show(); |
| 362 w1->Focus(); | 378 w1->Focus(); |
| 363 | 379 |
| 364 ui::test::TestEventHandler handler; | 380 ui::test::TestEventHandler handler; |
| 365 w1->AddPreTargetHandler(&handler); | 381 w1->AddPreTargetHandler(&handler); |
| 366 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 382 ui::KeyEvent key_press(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); |
| (...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2094 delegate.GetMouseMotionCountsAndReset(); | 2110 delegate.GetMouseMotionCountsAndReset(); |
| 2095 | 2111 |
| 2096 // Notify both hosts that the cursor is now hidden. This should send a single | 2112 // Notify both hosts that the cursor is now hidden. This should send a single |
| 2097 // mouse-exit event to |window|. | 2113 // mouse-exit event to |window|. |
| 2098 host()->OnCursorVisibilityChanged(false); | 2114 host()->OnCursorVisibilityChanged(false); |
| 2099 second_host->OnCursorVisibilityChanged(false); | 2115 second_host->OnCursorVisibilityChanged(false); |
| 2100 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); | 2116 EXPECT_EQ("0 0 1", delegate.GetMouseMotionCountsAndReset()); |
| 2101 } | 2117 } |
| 2102 | 2118 |
| 2103 } // namespace aura | 2119 } // namespace aura |
| OLD | NEW |