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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/shared_memory.h" | 7 #include "base/shared_memory.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "content/common/intents_messages.h" | 10 #include "content/common/intents_messages.h" |
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 const int kRepeatCount = 10; | 756 const int kRepeatCount = 10; |
757 for (int i = 0; i < kRepeatCount; i++) { | 757 for (int i = 0; i < kRepeatCount; i++) { |
758 // Move the input focus to the first <input> element, where we should | 758 // Move the input focus to the first <input> element, where we should |
759 // activate IMEs. | 759 // activate IMEs. |
760 ExecuteJavaScript("document.getElementById('test1').focus();"); | 760 ExecuteJavaScript("document.getElementById('test1').focus();"); |
761 ProcessPendingMessages(); | 761 ProcessPendingMessages(); |
762 render_thread_->sink().ClearMessages(); | 762 render_thread_->sink().ClearMessages(); |
763 | 763 |
764 // Update the IME status and verify if our IME backend sends an IPC message | 764 // Update the IME status and verify if our IME backend sends an IPC message |
765 // to activate IMEs. | 765 // to activate IMEs. |
766 view()->UpdateTextInputState(); | 766 view()->UpdateTextInputState(RenderWidget::DO_NOT_SHOW_IME); |
767 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 767 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
768 EXPECT_TRUE(msg != NULL); | 768 EXPECT_TRUE(msg != NULL); |
769 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 769 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
770 ViewHostMsg_TextInputStateChanged::Param params; | 770 ViewHostMsg_TextInputStateChanged::Param params; |
771 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 771 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
772 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, params.a.type); | 772 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, params.a.type); |
773 EXPECT_EQ(true, params.a.can_compose_inline); | 773 EXPECT_EQ(true, params.a.can_compose_inline); |
774 EXPECT_EQ("some text", params.a.value); | 774 EXPECT_EQ("some text", params.a.value); |
775 EXPECT_EQ(0, params.a.selection_start); | 775 EXPECT_EQ(0, params.a.selection_start); |
776 EXPECT_EQ(9, params.a.selection_end); | 776 EXPECT_EQ(9, params.a.selection_end); |
777 EXPECT_EQ(-1, params.a.composition_start); | 777 EXPECT_EQ(-1, params.a.composition_start); |
778 EXPECT_EQ(-1, params.a.composition_end); | 778 EXPECT_EQ(-1, params.a.composition_end); |
779 | 779 |
780 // Move the input focus to the second <input> element, where we should | 780 // Move the input focus to the second <input> element, where we should |
781 // de-activate IMEs. | 781 // de-activate IMEs. |
782 ExecuteJavaScript("document.getElementById('test2').focus();"); | 782 ExecuteJavaScript("document.getElementById('test2').focus();"); |
783 ProcessPendingMessages(); | 783 ProcessPendingMessages(); |
784 render_thread_->sink().ClearMessages(); | 784 render_thread_->sink().ClearMessages(); |
785 | 785 |
786 // Update the IME status and verify if our IME backend sends an IPC message | 786 // Update the IME status and verify if our IME backend sends an IPC message |
787 // to de-activate IMEs. | 787 // to de-activate IMEs. |
788 view()->UpdateTextInputState(); | 788 view()->UpdateTextInputState(RenderWidget::DO_NOT_SHOW_IME); |
789 msg = render_thread_->sink().GetMessageAt(0); | 789 msg = render_thread_->sink().GetMessageAt(0); |
790 EXPECT_TRUE(msg != NULL); | 790 EXPECT_TRUE(msg != NULL); |
791 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 791 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
792 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 792 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
793 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, params.a.type); | 793 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, params.a.type); |
794 } | 794 } |
795 } | 795 } |
796 | 796 |
797 // Test that our IME backend can compose CJK words. | 797 // Test that our IME backend can compose CJK words. |
798 // Our IME front-end sends many platform-independent messages to the IME backend | 798 // Our IME front-end sends many platform-independent messages to the IME backend |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 case IME_CANCELCOMPOSITION: | 910 case IME_CANCELCOMPOSITION: |
911 view()->OnImeSetComposition( | 911 view()->OnImeSetComposition( |
912 string16(), | 912 string16(), |
913 std::vector<WebKit::WebCompositionUnderline>(), | 913 std::vector<WebKit::WebCompositionUnderline>(), |
914 0, 0); | 914 0, 0); |
915 break; | 915 break; |
916 } | 916 } |
917 | 917 |
918 // Update the status of our IME back-end. | 918 // Update the status of our IME back-end. |
919 // TODO(hbono): we should verify messages to be sent from the back-end. | 919 // TODO(hbono): we should verify messages to be sent from the back-end. |
920 view()->UpdateTextInputState(); | 920 view()->UpdateTextInputState(RenderWidget::DO_NOT_SHOW_IME); |
921 ProcessPendingMessages(); | 921 ProcessPendingMessages(); |
922 render_thread_->sink().ClearMessages(); | 922 render_thread_->sink().ClearMessages(); |
923 | 923 |
924 if (ime_message->result) { | 924 if (ime_message->result) { |
925 // Retrieve the content of this page and compare it with the expected | 925 // Retrieve the content of this page and compare it with the expected |
926 // result. | 926 // result. |
927 const int kMaxOutputCharacters = 128; | 927 const int kMaxOutputCharacters = 128; |
928 std::wstring output = UTF16ToWideHack( | 928 std::wstring output = UTF16ToWideHack( |
929 GetMainFrame()->contentAsText(kMaxOutputCharacters)); | 929 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
930 EXPECT_EQ(output, ime_message->result); | 930 EXPECT_EQ(output, ime_message->result); |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1789 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); | 1789 EXPECT_EQ("abcdefgopqrstuvwxyz", info.value); |
1790 EXPECT_EQ(7, info.selectionStart); | 1790 EXPECT_EQ(7, info.selectionStart); |
1791 EXPECT_EQ(7, info.selectionEnd); | 1791 EXPECT_EQ(7, info.selectionEnd); |
1792 view()->OnSetEditableSelectionOffsets(4, 8); | 1792 view()->OnSetEditableSelectionOffsets(4, 8); |
1793 view()->OnExtendSelectionAndDelete(2, 5); | 1793 view()->OnExtendSelectionAndDelete(2, 5); |
1794 info = view()->webview()->textInputInfo(); | 1794 info = view()->webview()->textInputInfo(); |
1795 EXPECT_EQ("abuvwxyz", info.value); | 1795 EXPECT_EQ("abuvwxyz", info.value); |
1796 EXPECT_EQ(2, info.selectionStart); | 1796 EXPECT_EQ(2, info.selectionStart); |
1797 EXPECT_EQ(2, info.selectionEnd); | 1797 EXPECT_EQ(2, info.selectionEnd); |
1798 } | 1798 } |
OLD | NEW |