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/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 // Move the input focus to the first <input> element, where we should | 974 // Move the input focus to the first <input> element, where we should |
975 // activate IMEs. | 975 // activate IMEs. |
976 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); | 976 ExecuteJavaScriptForTests("document.getElementById('test1').focus();"); |
977 ProcessPendingMessages(); | 977 ProcessPendingMessages(); |
978 render_thread_->sink().ClearMessages(); | 978 render_thread_->sink().ClearMessages(); |
979 | 979 |
980 // Update the IME status and verify if our IME backend sends an IPC message | 980 // Update the IME status and verify if our IME backend sends an IPC message |
981 // to activate IMEs. | 981 // to activate IMEs. |
982 view()->UpdateTextInputState( | 982 view()->UpdateTextInputState( |
983 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); | 983 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
| 984 ProcessPendingMessages(); |
984 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 985 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
985 EXPECT_TRUE(msg != NULL); | 986 EXPECT_TRUE(msg != NULL); |
986 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 987 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
987 ViewHostMsg_TextInputStateChanged::Param params; | 988 ViewHostMsg_TextInputStateChanged::Param params; |
988 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 989 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
989 ViewHostMsg_TextInputState_Params p = base::get<0>(params); | 990 ViewHostMsg_TextInputState_Params p = base::get<0>(params); |
990 ui::TextInputType type = p.type; | 991 ui::TextInputType type = p.type; |
991 ui::TextInputMode input_mode = p.mode; | 992 ui::TextInputMode input_mode = p.mode; |
992 bool can_compose_inline = p.can_compose_inline; | 993 bool can_compose_inline = p.can_compose_inline; |
993 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); | 994 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); |
994 EXPECT_EQ(true, can_compose_inline); | 995 EXPECT_EQ(true, can_compose_inline); |
995 | 996 |
996 // Move the input focus to the second <input> element, where we should | 997 // Move the input focus to the second <input> element, where we should |
997 // de-activate IMEs. | 998 // de-activate IMEs. |
998 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); | 999 ExecuteJavaScriptForTests("document.getElementById('test2').focus();"); |
999 ProcessPendingMessages(); | 1000 ProcessPendingMessages(); |
1000 render_thread_->sink().ClearMessages(); | 1001 render_thread_->sink().ClearMessages(); |
1001 | 1002 |
1002 // Update the IME status and verify if our IME backend sends an IPC message | 1003 // Update the IME status and verify if our IME backend sends an IPC message |
1003 // to de-activate IMEs. | 1004 // to de-activate IMEs. |
1004 view()->UpdateTextInputState( | 1005 view()->UpdateTextInputState( |
1005 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); | 1006 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
| 1007 ProcessPendingMessages(); |
1006 msg = render_thread_->sink().GetMessageAt(0); | 1008 msg = render_thread_->sink().GetMessageAt(0); |
1007 EXPECT_TRUE(msg != NULL); | 1009 EXPECT_TRUE(msg != NULL); |
1008 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 1010 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
1009 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 1011 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
1010 p = base::get<0>(params); | 1012 p = base::get<0>(params); |
1011 type = p.type; | 1013 type = p.type; |
1012 input_mode = p.mode; | 1014 input_mode = p.mode; |
1013 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); | 1015 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); |
1014 | 1016 |
1015 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { | 1017 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { |
1016 const InputModeTestCase* test_case = &kInputModeTestCases[i]; | 1018 const InputModeTestCase* test_case = &kInputModeTestCases[i]; |
1017 std::string javascript = | 1019 std::string javascript = |
1018 base::StringPrintf("document.getElementById('%s').focus();", | 1020 base::StringPrintf("document.getElementById('%s').focus();", |
1019 test_case->input_id); | 1021 test_case->input_id); |
1020 // Move the input focus to the target <input> element, where we should | 1022 // Move the input focus to the target <input> element, where we should |
1021 // activate IMEs. | 1023 // activate IMEs. |
1022 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); | 1024 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); |
1023 ProcessPendingMessages(); | 1025 ProcessPendingMessages(); |
1024 render_thread_->sink().ClearMessages(); | 1026 render_thread_->sink().ClearMessages(); |
1025 | 1027 |
1026 // Update the IME status and verify if our IME backend sends an IPC | 1028 // Update the IME status and verify if our IME backend sends an IPC |
1027 // message to activate IMEs. | 1029 // message to activate IMEs. |
1028 view()->UpdateTextInputState( | 1030 view()->UpdateTextInputState( |
1029 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); | 1031 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME); |
| 1032 ProcessPendingMessages(); |
1030 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); | 1033 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); |
1031 EXPECT_TRUE(msg != NULL); | 1034 EXPECT_TRUE(msg != NULL); |
1032 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); | 1035 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type()); |
1033 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); | 1036 ViewHostMsg_TextInputStateChanged::Read(msg, ¶ms); |
1034 p = base::get<0>(params); | 1037 p = base::get<0>(params); |
1035 type = p.type; | 1038 type = p.type; |
1036 input_mode = p.mode; | 1039 input_mode = p.mode; |
1037 EXPECT_EQ(test_case->expected_mode, input_mode); | 1040 EXPECT_EQ(test_case->expected_mode, input_mode); |
1038 } | 1041 } |
1039 } | 1042 } |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 ssl_status = view()->GetSSLStatusOfFrame(frame); | 1955 ssl_status = view()->GetSSLStatusOfFrame(frame); |
1953 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); | 1956 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); |
1954 } | 1957 } |
1955 | 1958 |
1956 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { | 1959 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { |
1957 view()->set_send_content_state_immediately(true); | 1960 view()->set_send_content_state_immediately(true); |
1958 LoadHTML("<textarea id=\"test\"></textarea>"); | 1961 LoadHTML("<textarea id=\"test\"></textarea>"); |
1959 | 1962 |
1960 view()->handling_input_event_ = true; | 1963 view()->handling_input_event_ = true; |
1961 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); | 1964 ExecuteJavaScriptForTests("document.getElementById('test').focus();"); |
| 1965 ProcessPendingMessages(); |
1962 | 1966 |
1963 bool is_input_type_called = false; | 1967 bool is_input_type_called = false; |
1964 bool is_selection_called = false; | 1968 bool is_selection_called = false; |
1965 size_t last_input_type = 0; | 1969 size_t last_input_type = 0; |
1966 size_t last_selection = 0; | 1970 size_t last_selection = 0; |
1967 | 1971 |
1968 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { | 1972 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { |
1969 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); | 1973 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); |
1970 if (type == ViewHostMsg_TextInputStateChanged::ID) { | 1974 if (type == ViewHostMsg_TextInputStateChanged::ID) { |
1971 is_input_type_called = true; | 1975 is_input_type_called = true; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 FROM_HERE, | 2387 FROM_HERE, |
2384 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); | 2388 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); |
2385 ExecuteJavaScriptForTests("debugger;"); | 2389 ExecuteJavaScriptForTests("debugger;"); |
2386 | 2390 |
2387 // CloseWhilePaused should resume execution and continue here. | 2391 // CloseWhilePaused should resume execution and continue here. |
2388 EXPECT_FALSE(IsPaused()); | 2392 EXPECT_FALSE(IsPaused()); |
2389 Detach(); | 2393 Detach(); |
2390 } | 2394 } |
2391 | 2395 |
2392 } // namespace content | 2396 } // namespace content |
OLD | NEW |