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