| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 const int kRepeatCount = 10; | 1085 const int kRepeatCount = 10; |
| 1086 for (int i = 0; i < kRepeatCount; i++) { | 1086 for (int i = 0; i < kRepeatCount; i++) { |
| 1087 // Move the input focus to the first <input> element, where we should | 1087 // Move the input focus to the first <input> element, where we should |
| 1088 // activate IMEs. | 1088 // activate IMEs. |
| 1089 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 1089 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
| 1090 ProcessPendingMessages(); | 1090 ProcessPendingMessages(); |
| 1091 render_thread_->sink().ClearMessages(); | 1091 render_thread_->sink().ClearMessages(); |
| 1092 | 1092 |
| 1093 // Update the IME status and verify if our IME backend sends an IPC message | 1093 // Update the IME status and verify if our IME backend sends an IPC message |
| 1094 // to activate IMEs. | 1094 // to activate IMEs. |
| 1095 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 1095 view()->UpdateTextInputState(); |
| 1096 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 1096 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
| 1097 EXPECT_TRUE(msg != NULL); | 1097 EXPECT_TRUE(msg != NULL); |
| 1098 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 1098 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
| 1099 ViewHostMsg_TextInputStateChanged::Param params; | 1099 ViewHostMsg_TextInputStateChanged::Param params; |
| 1100 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 1100 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
| 1101 TextInputState p = std::get<0>(params); | 1101 TextInputState p = std::get<0>(params); |
| 1102 ui::TextInputType type = p.type; | 1102 ui::TextInputType type = p.type; |
| 1103 ui::TextInputMode input_mode = p.mode; | 1103 ui::TextInputMode input_mode = p.mode; |
| 1104 bool can_compose_inline = p.can_compose_inline; | 1104 bool can_compose_inline = p.can_compose_inline; |
| 1105 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); | 1105 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); |
| 1106 EXPECT_EQ(true, can_compose_inline); | 1106 EXPECT_EQ(true, can_compose_inline); |
| 1107 | 1107 |
| 1108 // Move the input focus to the second <input> element, where we should | 1108 // Move the input focus to the second <input> element, where we should |
| 1109 // de-activate IMEs. | 1109 // de-activate IMEs. |
| 1110 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); | 1110 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); |
| 1111 ProcessPendingMessages(); | 1111 ProcessPendingMessages(); |
| 1112 render_thread_->sink().ClearMessages(); | 1112 render_thread_->sink().ClearMessages(); |
| 1113 | 1113 |
| 1114 // Update the IME status and verify if our IME backend sends an IPC message | 1114 // Update the IME status and verify if our IME backend sends an IPC message |
| 1115 // to de-activate IMEs. | 1115 // to de-activate IMEs. |
| 1116 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 1116 view()->UpdateTextInputState(); |
| 1117 msg = render_thread_->sink().GetMessageAt(0); | 1117 msg = render_thread_->sink().GetMessageAt(0); |
| 1118 EXPECT_TRUE(msg != NULL); | 1118 EXPECT_TRUE(msg != NULL); |
| 1119 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 1119 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
| 1120 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 1120 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
| 1121 p = std::get<0>(params); | 1121 p = std::get<0>(params); |
| 1122 type = p.type; | 1122 type = p.type; |
| 1123 input_mode = p.mode; | 1123 input_mode = p.mode; |
| 1124 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); | 1124 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); |
| 1125 | 1125 |
| 1126 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { | 1126 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { |
| 1127 const InputModeTestCase* test_case = &kInputModeTestCases[i]; | 1127 const InputModeTestCase* test_case = &kInputModeTestCases[i]; |
| 1128 std::string javascript = | 1128 std::string javascript = |
| 1129 base::StringPrintf("document.getElementById('%s').focus();", | 1129 base::StringPrintf("document.getElementById('%s').focus();", |
| 1130 test_case->input_id); | 1130 test_case->input_id); |
| 1131 // Move the input focus to the target <input> element, where we should | 1131 // Move the input focus to the target <input> element, where we should |
| 1132 // activate IMEs. | 1132 // activate IMEs. |
| 1133 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); | 1133 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); |
| 1134 ProcessPendingMessages(); | 1134 ProcessPendingMessages(); |
| 1135 render_thread_->sink().ClearMessages(); | 1135 render_thread_->sink().ClearMessages(); |
| 1136 | 1136 |
| 1137 // Update the IME status and verify if our IME backend sends an IPC | 1137 // Update the IME status and verify if our IME backend sends an IPC |
| 1138 // message to activate IMEs. | 1138 // message to activate IMEs. |
| 1139 view()->UpdateTextInputState(ShowIme::HIDE_IME, | 1139 view()->UpdateTextInputState(); |
| 1140 ChangeSource::FROM_NON_IME); | |
| 1141 ProcessPendingMessages(); | 1140 ProcessPendingMessages(); |
| 1142 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 1141 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
| 1143 EXPECT_TRUE(msg != NULL); | 1142 EXPECT_TRUE(msg != NULL); |
| 1144 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 1143 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
| 1145 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 1144 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
| 1146 p = std::get<0>(params); | 1145 p = std::get<0>(params); |
| 1147 type = p.type; | 1146 type = p.type; |
| 1148 input_mode = p.mode; | 1147 input_mode = p.mode; |
| 1149 EXPECT_EQ(test_case->expected_mode, input_mode); | 1148 EXPECT_EQ(test_case->expected_mode, input_mode); |
| 1150 } | 1149 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 view()->OnImeSetComposition( | 1269 view()->OnImeSetComposition( |
| 1271 base::string16(), | 1270 base::string16(), |
| 1272 std::vector<blink::WebCompositionUnderline>(), | 1271 std::vector<blink::WebCompositionUnderline>(), |
| 1273 gfx::Range::InvalidRange(), | 1272 gfx::Range::InvalidRange(), |
| 1274 0, 0); | 1273 0, 0); |
| 1275 break; | 1274 break; |
| 1276 } | 1275 } |
| 1277 | 1276 |
| 1278 // Update the status of our IME back-end. | 1277 // Update the status of our IME back-end. |
| 1279 // TODO(hbono): we should verify messages to be sent from the back-end. | 1278 // TODO(hbono): we should verify messages to be sent from the back-end. |
| 1280 view()->UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); | 1279 view()->UpdateTextInputState(); |
| 1281 ProcessPendingMessages(); | 1280 ProcessPendingMessages(); |
| 1282 render_thread_->sink().ClearMessages(); | 1281 render_thread_->sink().ClearMessages(); |
| 1283 | 1282 |
| 1284 if (ime_message->result) { | 1283 if (ime_message->result) { |
| 1285 // Retrieve the content of this page and compare it with the expected | 1284 // Retrieve the content of this page and compare it with the expected |
| 1286 // result. | 1285 // result. |
| 1287 const int kMaxOutputCharacters = 128; | 1286 const int kMaxOutputCharacters = 128; |
| 1288 base::string16 output = WebFrameContentDumper::dumpWebViewAsText( | 1287 base::string16 output = WebFrameContentDumper::dumpWebViewAsText( |
| 1289 view()->GetWebView(), kMaxOutputCharacters); | 1288 view()->GetWebView(), kMaxOutputCharacters); |
| 1290 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); | 1289 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2566 ExpectPauseAndResume(3); | 2565 ExpectPauseAndResume(3); |
| 2567 blink::WebScriptSource source2( | 2566 blink::WebScriptSource source2( |
| 2568 WebString::fromUTF8("function func2() { func1(); }; func2();")); | 2567 WebString::fromUTF8("function func2() { func1(); }; func2();")); |
| 2569 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); | 2568 frame()->GetWebFrame()->executeScriptInIsolatedWorld(17, &source2, 1); |
| 2570 | 2569 |
| 2571 EXPECT_FALSE(IsPaused()); | 2570 EXPECT_FALSE(IsPaused()); |
| 2572 Detach(); | 2571 Detach(); |
| 2573 } | 2572 } |
| 2574 | 2573 |
| 2575 } // namespace content | 2574 } // namespace content |
| OLD | NEW |