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 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 const int kRepeatCount = 10; | 890 const int kRepeatCount = 10; |
891 for (int i = 0; i < kRepeatCount; i++) { | 891 for (int i = 0; i < kRepeatCount; i++) { |
892 // Move the input focus to the first <input> element, where we should | 892 // Move the input focus to the first <input> element, where we should |
893 // activate IMEs. | 893 // activate IMEs. |
894 ExecuteJavaScript("document.getElementById('test1').focus();"); | 894 ExecuteJavaScript("document.getElementById('test1').focus();"); |
895 ProcessPendingMessages(); | 895 ProcessPendingMessages(); |
896 render_thread_->sink().ClearMessages(); | 896 render_thread_->sink().ClearMessages(); |
897 | 897 |
898 // Update the IME status and verify if our IME backend sends an IPC message | 898 // Update the IME status and verify if our IME backend sends an IPC message |
899 // to activate IMEs. | 899 // to activate IMEs. |
900 view()->UpdateTextInputType(); | 900 view()->UpdateTextInputState( |
| 901 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
901 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 902 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
902 EXPECT_TRUE(msg != NULL); | 903 EXPECT_TRUE(msg != NULL); |
903 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 904 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
904 ViewHostMsg_TextInputTypeChanged::Param params; | 905 ViewHostMsg_TextInputStateChanged::Param params; |
905 ViewHostMsg_TextInputTypeChanged::Read(msg, ¶ms); | 906 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
906 ui::TextInputType type = params.a; | 907 ViewHostMsg_TextInputState_Params p = params.a; |
907 ui::TextInputMode input_mode = params.b; | 908 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, p.type); |
908 bool can_compose_inline = params.c; | 909 EXPECT_EQ(true, p.can_compose_inline); |
909 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); | |
910 EXPECT_EQ(true, can_compose_inline); | |
911 | 910 |
912 // Move the input focus to the second <input> element, where we should | 911 // Move the input focus to the second <input> element, where we should |
913 // de-activate IMEs. | 912 // de-activate IMEs. |
914 ExecuteJavaScript("document.getElementById('test2').focus();"); | 913 ExecuteJavaScript("document.getElementById('test2').focus();"); |
915 ProcessPendingMessages(); | 914 ProcessPendingMessages(); |
916 render_thread_->sink().ClearMessages(); | 915 render_thread_->sink().ClearMessages(); |
917 | 916 |
918 // Update the IME status and verify if our IME backend sends an IPC message | 917 // Update the IME status and verify if our IME backend sends an IPC message |
919 // to de-activate IMEs. | 918 // to de-activate IMEs. |
920 view()->UpdateTextInputType(); | 919 view()->UpdateTextInputState( |
| 920 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
921 msg = render_thread_->sink().GetMessageAt(0); | 921 msg = render_thread_->sink().GetMessageAt(0); |
922 EXPECT_TRUE(msg != NULL); | 922 EXPECT_TRUE(msg != NULL); |
923 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 923 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
924 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); | 924 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
925 type = params.a; | 925 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, params.a.type); |
926 input_mode = params.b; | |
927 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); | |
928 | 926 |
929 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInputModeTestCases); i++) { | 927 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(kInputModeTestCases); j++) { |
930 const InputModeTestCase* test_case = &kInputModeTestCases[i]; | 928 const InputModeTestCase* test_case = &kInputModeTestCases[j]; |
931 std::string javascript = | 929 std::string javascript = |
932 base::StringPrintf("document.getElementById('%s').focus();", | 930 base::StringPrintf("document.getElementById('%s').focus();", |
933 test_case->input_id); | 931 test_case->input_id); |
934 // Move the input focus to the target <input> element, where we should | 932 // Move the input focus to the target <input> element, where we should |
935 // activate IMEs. | 933 // activate IMEs. |
936 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); | 934 ExecuteJavaScript(javascript.c_str()); |
937 ProcessPendingMessages(); | 935 ProcessPendingMessages(); |
938 render_thread_->sink().ClearMessages(); | 936 render_thread_->sink().ClearMessages(); |
939 | 937 |
940 // Update the IME status and verify if our IME backend sends an IPC | 938 // Update the IME status and verify if our IME backend sends an IPC |
941 // message to activate IMEs. | 939 // message to activate IMEs. |
942 view()->UpdateTextInputType(); | 940 view()->UpdateTextInputState( |
943 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 941 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
| 942 msg = render_thread_->sink().GetMessageAt(0); |
944 EXPECT_TRUE(msg != NULL); | 943 EXPECT_TRUE(msg != NULL); |
945 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); | 944 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
946 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); | 945 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
947 type = params.a; | 946 EXPECT_EQ(test_case->expected_mode, params.a.mode); |
948 input_mode = params.b; | |
949 EXPECT_EQ(test_case->expected_mode, input_mode); | |
950 } | 947 } |
951 } | 948 } |
952 } | 949 } |
953 | 950 |
954 // Test that our IME backend can compose CJK words. | 951 // Test that our IME backend can compose CJK words. |
955 // Our IME front-end sends many platform-independent messages to the IME backend | 952 // Our IME front-end sends many platform-independent messages to the IME backend |
956 // while it composes CJK words. This test sends the minimal messages captured | 953 // while it composes CJK words. This test sends the minimal messages captured |
957 // on my local environment directly to the IME backend to verify if the backend | 954 // on my local environment directly to the IME backend to verify if the backend |
958 // can compose CJK words without any problems. | 955 // can compose CJK words without any problems. |
959 // This test uses an array of command sets because an IME composotion does not | 956 // This test uses an array of command sets because an IME composotion does not |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 case IME_CANCELCOMPOSITION: | 1065 case IME_CANCELCOMPOSITION: |
1069 view()->OnImeSetComposition( | 1066 view()->OnImeSetComposition( |
1070 base::string16(), | 1067 base::string16(), |
1071 std::vector<blink::WebCompositionUnderline>(), | 1068 std::vector<blink::WebCompositionUnderline>(), |
1072 0, 0); | 1069 0, 0); |
1073 break; | 1070 break; |
1074 } | 1071 } |
1075 | 1072 |
1076 // Update the status of our IME back-end. | 1073 // Update the status of our IME back-end. |
1077 // TODO(hbono): we should verify messages to be sent from the back-end. | 1074 // TODO(hbono): we should verify messages to be sent from the back-end. |
1078 view()->UpdateTextInputType(); | 1075 view()->UpdateTextInputState( |
| 1076 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
1079 ProcessPendingMessages(); | 1077 ProcessPendingMessages(); |
1080 render_thread_->sink().ClearMessages(); | 1078 render_thread_->sink().ClearMessages(); |
1081 | 1079 |
1082 if (ime_message->result) { | 1080 if (ime_message->result) { |
1083 // Retrieve the content of this page and compare it with the expected | 1081 // Retrieve the content of this page and compare it with the expected |
1084 // result. | 1082 // result. |
1085 const int kMaxOutputCharacters = 128; | 1083 const int kMaxOutputCharacters = 128; |
1086 base::string16 output = | 1084 base::string16 output = |
1087 GetMainFrame()->contentAsText(kMaxOutputCharacters); | 1085 GetMainFrame()->contentAsText(kMaxOutputCharacters); |
1088 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); | 1086 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); |
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 view()->handling_input_event_ = true; | 2059 view()->handling_input_event_ = true; |
2062 ExecuteJavaScript("document.getElementById('test').focus();"); | 2060 ExecuteJavaScript("document.getElementById('test').focus();"); |
2063 | 2061 |
2064 bool is_input_type_called = false; | 2062 bool is_input_type_called = false; |
2065 bool is_selection_called = false; | 2063 bool is_selection_called = false; |
2066 size_t last_input_type = 0; | 2064 size_t last_input_type = 0; |
2067 size_t last_selection = 0; | 2065 size_t last_selection = 0; |
2068 | 2066 |
2069 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { | 2067 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { |
2070 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); | 2068 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); |
2071 if (type == ViewHostMsg_TextInputTypeChanged::ID) { | 2069 if (type == ViewHostMsg_TextInputStateChanged::ID) { |
2072 is_input_type_called = true; | 2070 is_input_type_called = true; |
2073 last_input_type = i; | 2071 last_input_type = i; |
2074 } else if (type == ViewHostMsg_SelectionChanged::ID) { | 2072 } else if (type == ViewHostMsg_SelectionChanged::ID) { |
2075 is_selection_called = true; | 2073 is_selection_called = true; |
2076 last_selection = i; | 2074 last_selection = i; |
2077 } | 2075 } |
2078 } | 2076 } |
2079 | 2077 |
2080 EXPECT_TRUE(is_input_type_called); | 2078 EXPECT_TRUE(is_input_type_called); |
2081 EXPECT_TRUE(is_selection_called); | 2079 EXPECT_TRUE(is_selection_called); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 view()->renderer_accessibility()->GetType()); | 2331 view()->renderer_accessibility()->GetType()); |
2334 | 2332 |
2335 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); | 2333 view()->OnSetAccessibilityMode(AccessibilityModeEditableTextOnly); |
2336 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); | 2334 ASSERT_EQ(AccessibilityModeEditableTextOnly, view()->accessibility_mode()); |
2337 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); | 2335 ASSERT_NE((RendererAccessibility*) NULL, view()->renderer_accessibility()); |
2338 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, | 2336 ASSERT_EQ(RendererAccessibilityTypeFocusOnly, |
2339 view()->renderer_accessibility()->GetType()); | 2337 view()->renderer_accessibility()->GetType()); |
2340 } | 2338 } |
2341 | 2339 |
2342 } // namespace content | 2340 } // namespace content |
OLD | NEW |