| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/ime/remote_input_method_win.h" | 5 #include "ui/base/ime/remote_input_method_win.h" |
| 6 | 6 |
| 7 #include <InputScope.h> | 7 #include <InputScope.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 541 } |
| 542 | 542 |
| 543 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeKeyEvent) { | 543 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeKeyEvent) { |
| 544 // Basically RemoteInputMethodWin does not handle native keydown event. | 544 // Basically RemoteInputMethodWin does not handle native keydown event. |
| 545 | 545 |
| 546 MockInputMethodDelegate delegate_; | 546 MockInputMethodDelegate delegate_; |
| 547 MockTextInputClient mock_text_input_client; | 547 MockTextInputClient mock_text_input_client; |
| 548 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 548 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
| 549 | 549 |
| 550 const MSG wm_keydown = { NULL, WM_KEYDOWN, ui::VKEY_A }; | 550 const MSG wm_keydown = { NULL, WM_KEYDOWN, ui::VKEY_A }; |
| 551 ui::KeyEvent native_keydown(wm_keydown, false); | 551 ui::KeyEvent native_keydown(wm_keydown); |
| 552 | 552 |
| 553 // This must not cause a crash. | 553 // This must not cause a crash. |
| 554 EXPECT_FALSE(input_method->DispatchKeyEvent(native_keydown)); | 554 EXPECT_FALSE(input_method->DispatchKeyEvent(native_keydown)); |
| 555 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); | 555 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); |
| 556 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); | 556 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); |
| 557 delegate_.Reset(); | 557 delegate_.Reset(); |
| 558 mock_text_input_client.Reset(); | 558 mock_text_input_client.Reset(); |
| 559 | 559 |
| 560 RemoteInputMethodPrivateWin* private_ptr = | 560 RemoteInputMethodPrivateWin* private_ptr = |
| 561 RemoteInputMethodPrivateWin::Get(input_method.get()); | 561 RemoteInputMethodPrivateWin::Get(input_method.get()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 583 } | 583 } |
| 584 | 584 |
| 585 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeCharEvent) { | 585 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_NativeCharEvent) { |
| 586 // RemoteInputMethodWin handles native char event if possible. | 586 // RemoteInputMethodWin handles native char event if possible. |
| 587 | 587 |
| 588 MockInputMethodDelegate delegate_; | 588 MockInputMethodDelegate delegate_; |
| 589 MockTextInputClient mock_text_input_client; | 589 MockTextInputClient mock_text_input_client; |
| 590 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 590 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
| 591 | 591 |
| 592 const MSG wm_char = { NULL, WM_CHAR, 'A', 0 }; | 592 const MSG wm_char = { NULL, WM_CHAR, 'A', 0 }; |
| 593 ui::KeyEvent native_char(wm_char, true); | 593 ui::KeyEvent native_char(wm_char); |
| 594 | 594 |
| 595 // This must not cause a crash. | 595 // This must not cause a crash. |
| 596 EXPECT_FALSE(input_method->DispatchKeyEvent(native_char)); | 596 EXPECT_FALSE(input_method->DispatchKeyEvent(native_char)); |
| 597 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); | 597 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); |
| 598 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); | 598 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); |
| 599 delegate_.Reset(); | 599 delegate_.Reset(); |
| 600 mock_text_input_client.Reset(); | 600 mock_text_input_client.Reset(); |
| 601 | 601 |
| 602 RemoteInputMethodPrivateWin* private_ptr = | 602 RemoteInputMethodPrivateWin* private_ptr = |
| 603 RemoteInputMethodPrivateWin::Get(input_method.get()); | 603 RemoteInputMethodPrivateWin::Get(input_method.get()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 626 | 626 |
| 627 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedKeyDown) { | 627 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedKeyDown) { |
| 628 // Fabricated non-char event will be delegated to | 628 // Fabricated non-char event will be delegated to |
| 629 // InputMethodDelegate::DispatchFabricatedKeyEventPostIME as long as the | 629 // InputMethodDelegate::DispatchFabricatedKeyEventPostIME as long as the |
| 630 // delegate is installed. | 630 // delegate is installed. |
| 631 | 631 |
| 632 MockInputMethodDelegate delegate_; | 632 MockInputMethodDelegate delegate_; |
| 633 MockTextInputClient mock_text_input_client; | 633 MockTextInputClient mock_text_input_client; |
| 634 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 634 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
| 635 | 635 |
| 636 ui::KeyEvent fabricated_keydown(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, false); | 636 ui::KeyEvent fabricated_keydown(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE); |
| 637 fabricated_keydown.set_character(L'A'); | 637 fabricated_keydown.set_character(L'A'); |
| 638 | 638 |
| 639 // This must not cause a crash. | 639 // This must not cause a crash. |
| 640 EXPECT_TRUE(input_method->DispatchKeyEvent(fabricated_keydown)); | 640 EXPECT_TRUE(input_method->DispatchKeyEvent(fabricated_keydown)); |
| 641 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); | 641 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); |
| 642 ASSERT_EQ(1, delegate_.fabricated_key_events().size()); | 642 ASSERT_EQ(1, delegate_.fabricated_key_events().size()); |
| 643 EXPECT_EQ(L'A', delegate_.fabricated_key_events()[0]); | 643 EXPECT_EQ(L'A', delegate_.fabricated_key_events()[0]); |
| 644 delegate_.Reset(); | 644 delegate_.Reset(); |
| 645 mock_text_input_client.Reset(); | 645 mock_text_input_client.Reset(); |
| 646 | 646 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 677 } | 677 } |
| 678 | 678 |
| 679 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedChar) { | 679 TEST(RemoteInputMethodWinTest, DispatchKeyEvent_FabricatedChar) { |
| 680 // Note: RemoteInputMethodWin::DispatchKeyEvent should always return true | 680 // Note: RemoteInputMethodWin::DispatchKeyEvent should always return true |
| 681 // for fabricated character events. | 681 // for fabricated character events. |
| 682 | 682 |
| 683 MockInputMethodDelegate delegate_; | 683 MockInputMethodDelegate delegate_; |
| 684 MockTextInputClient mock_text_input_client; | 684 MockTextInputClient mock_text_input_client; |
| 685 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 685 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
| 686 | 686 |
| 687 ui::KeyEvent fabricated_char(ui::ET_KEY_PRESSED, ui::VKEY_A, 0, true); | 687 ui::KeyEvent fabricated_char(L'A', ui::VKEY_A, ui::EF_NONE); |
| 688 fabricated_char.set_character(L'A'); | |
| 689 | 688 |
| 690 // This must not cause a crash. | 689 // This must not cause a crash. |
| 691 EXPECT_TRUE(input_method->DispatchKeyEvent(fabricated_char)); | 690 EXPECT_TRUE(input_method->DispatchKeyEvent(fabricated_char)); |
| 692 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); | 691 EXPECT_TRUE(mock_text_input_client.inserted_text().empty()); |
| 693 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); | 692 EXPECT_TRUE(delegate_.fabricated_key_events().empty()); |
| 694 delegate_.Reset(); | 693 delegate_.Reset(); |
| 695 mock_text_input_client.Reset(); | 694 mock_text_input_client.Reset(); |
| 696 | 695 |
| 697 RemoteInputMethodPrivateWin* private_ptr = | 696 RemoteInputMethodPrivateWin* private_ptr = |
| 698 RemoteInputMethodPrivateWin::Get(input_method.get()); | 697 RemoteInputMethodPrivateWin::Get(input_method.get()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); | 837 scoped_ptr<InputMethod> input_method(CreateRemoteInputMethodWin(&delegate_)); |
| 839 input_method->AddObserver(&input_method_observer); | 838 input_method->AddObserver(&input_method_observer); |
| 840 | 839 |
| 841 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed()); | 840 EXPECT_EQ(0u, input_method_observer.on_input_method_destroyed_changed()); |
| 842 input_method.reset(); | 841 input_method.reset(); |
| 843 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed()); | 842 EXPECT_EQ(1u, input_method_observer.on_input_method_destroyed_changed()); |
| 844 } | 843 } |
| 845 | 844 |
| 846 } // namespace | 845 } // namespace |
| 847 } // namespace ui | 846 } // namespace ui |
| OLD | NEW |