Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 1249013005: Merge ViewHostMsg_TextInputTypeChanged and ViewHostMsg_TextInputStateChanged into one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 const int kRepeatCount = 10; 962 const int kRepeatCount = 10;
963 for (int i = 0; i < kRepeatCount; i++) { 963 for (int i = 0; i < kRepeatCount; i++) {
964 // Move the input focus to the first <input> element, where we should 964 // Move the input focus to the first <input> element, where we should
965 // activate IMEs. 965 // activate IMEs.
966 ExecuteJavaScript("document.getElementById('test1').focus();"); 966 ExecuteJavaScript("document.getElementById('test1').focus();");
967 ProcessPendingMessages(); 967 ProcessPendingMessages();
968 render_thread_->sink().ClearMessages(); 968 render_thread_->sink().ClearMessages();
969 969
970 // Update the IME status and verify if our IME backend sends an IPC message 970 // Update the IME status and verify if our IME backend sends an IPC message
971 // to activate IMEs. 971 // to activate IMEs.
972 view()->UpdateTextInputType(); 972 view()->UpdateTextInputState(
973 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
973 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); 974 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
974 EXPECT_TRUE(msg != NULL); 975 EXPECT_TRUE(msg != NULL);
975 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); 976 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
976 ViewHostMsg_TextInputTypeChanged::Param params; 977 ViewHostMsg_TextInputStateChanged::Param params;
977 ViewHostMsg_TextInputTypeChanged::Read(msg, &params); 978 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
978 ui::TextInputType type = base::get<0>(params); 979 ViewHostMsg_TextInputState_Params p = base::get<0>(params);
979 ui::TextInputMode input_mode = base::get<1>(params); 980 ui::TextInputType type = p.type;
980 bool can_compose_inline = base::get<2>(params); 981 ui::TextInputMode input_mode = p.mode;
982 bool can_compose_inline = p.can_compose_inline;
981 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type); 983 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, type);
982 EXPECT_EQ(true, can_compose_inline); 984 EXPECT_EQ(true, can_compose_inline);
983 985
984 // Move the input focus to the second <input> element, where we should 986 // Move the input focus to the second <input> element, where we should
985 // de-activate IMEs. 987 // de-activate IMEs.
986 ExecuteJavaScript("document.getElementById('test2').focus();"); 988 ExecuteJavaScript("document.getElementById('test2').focus();");
987 ProcessPendingMessages(); 989 ProcessPendingMessages();
988 render_thread_->sink().ClearMessages(); 990 render_thread_->sink().ClearMessages();
989 991
990 // Update the IME status and verify if our IME backend sends an IPC message 992 // Update the IME status and verify if our IME backend sends an IPC message
991 // to de-activate IMEs. 993 // to de-activate IMEs.
992 view()->UpdateTextInputType(); 994 view()->UpdateTextInputState(
995 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
993 msg = render_thread_->sink().GetMessageAt(0); 996 msg = render_thread_->sink().GetMessageAt(0);
994 EXPECT_TRUE(msg != NULL); 997 EXPECT_TRUE(msg != NULL);
995 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); 998 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
996 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); 999 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
997 type = base::get<0>(params); 1000 p = base::get<0>(params);
998 input_mode = base::get<1>(params); 1001 type = p.type;
1002 input_mode = p.mode;
999 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type); 1003 EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD, type);
1000 1004
1001 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) { 1005 for (size_t i = 0; i < arraysize(kInputModeTestCases); i++) {
1002 const InputModeTestCase* test_case = &kInputModeTestCases[i]; 1006 const InputModeTestCase* test_case = &kInputModeTestCases[i];
1003 std::string javascript = 1007 std::string javascript =
1004 base::StringPrintf("document.getElementById('%s').focus();", 1008 base::StringPrintf("document.getElementById('%s').focus();",
1005 test_case->input_id); 1009 test_case->input_id);
1006 // Move the input focus to the target <input> element, where we should 1010 // Move the input focus to the target <input> element, where we should
1007 // activate IMEs. 1011 // activate IMEs.
1008 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL); 1012 ExecuteJavaScriptAndReturnIntValue(base::ASCIIToUTF16(javascript), NULL);
1009 ProcessPendingMessages(); 1013 ProcessPendingMessages();
1010 render_thread_->sink().ClearMessages(); 1014 render_thread_->sink().ClearMessages();
1011 1015
1012 // Update the IME status and verify if our IME backend sends an IPC 1016 // Update the IME status and verify if our IME backend sends an IPC
1013 // message to activate IMEs. 1017 // message to activate IMEs.
1014 view()->UpdateTextInputType(); 1018 view()->UpdateTextInputState(
1019 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
1015 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0); 1020 const IPC::Message* msg = render_thread_->sink().GetMessageAt(0);
1016 EXPECT_TRUE(msg != NULL); 1021 EXPECT_TRUE(msg != NULL);
1017 EXPECT_EQ(ViewHostMsg_TextInputTypeChanged::ID, msg->type()); 1022 EXPECT_EQ(ViewHostMsg_TextInputStateChanged::ID, msg->type());
1018 ViewHostMsg_TextInputTypeChanged::Read(msg, & params); 1023 ViewHostMsg_TextInputStateChanged::Read(msg, &params);
1019 type = base::get<0>(params); 1024 p = base::get<0>(params);
1020 input_mode = base::get<1>(params); 1025 type = p.type;
1026 input_mode = p.mode;
1021 EXPECT_EQ(test_case->expected_mode, input_mode); 1027 EXPECT_EQ(test_case->expected_mode, input_mode);
1022 } 1028 }
1023 } 1029 }
1024 } 1030 }
1025 1031
1026 // Test that our IME backend can compose CJK words. 1032 // Test that our IME backend can compose CJK words.
1027 // Our IME front-end sends many platform-independent messages to the IME backend 1033 // Our IME front-end sends many platform-independent messages to the IME backend
1028 // while it composes CJK words. This test sends the minimal messages captured 1034 // while it composes CJK words. This test sends the minimal messages captured
1029 // on my local environment directly to the IME backend to verify if the backend 1035 // on my local environment directly to the IME backend to verify if the backend
1030 // can compose CJK words without any problems. 1036 // can compose CJK words without any problems.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 case IME_CANCELCOMPOSITION: 1143 case IME_CANCELCOMPOSITION:
1138 view()->OnImeSetComposition( 1144 view()->OnImeSetComposition(
1139 base::string16(), 1145 base::string16(),
1140 std::vector<blink::WebCompositionUnderline>(), 1146 std::vector<blink::WebCompositionUnderline>(),
1141 0, 0); 1147 0, 0);
1142 break; 1148 break;
1143 } 1149 }
1144 1150
1145 // Update the status of our IME back-end. 1151 // Update the status of our IME back-end.
1146 // TODO(hbono): we should verify messages to be sent from the back-end. 1152 // TODO(hbono): we should verify messages to be sent from the back-end.
1147 view()->UpdateTextInputType(); 1153 view()->UpdateTextInputState(
1154 RenderWidget::NO_SHOW_IME, RenderWidget::FROM_NON_IME);
1148 ProcessPendingMessages(); 1155 ProcessPendingMessages();
1149 render_thread_->sink().ClearMessages(); 1156 render_thread_->sink().ClearMessages();
1150 1157
1151 if (ime_message->result) { 1158 if (ime_message->result) {
1152 // Retrieve the content of this page and compare it with the expected 1159 // Retrieve the content of this page and compare it with the expected
1153 // result. 1160 // result.
1154 const int kMaxOutputCharacters = 128; 1161 const int kMaxOutputCharacters = 128;
1155 base::string16 output = 1162 base::string16 output =
1156 GetMainFrame()->contentAsText(kMaxOutputCharacters); 1163 GetMainFrame()->contentAsText(kMaxOutputCharacters);
1157 EXPECT_EQ(base::WideToUTF16(ime_message->result), output); 1164 EXPECT_EQ(base::WideToUTF16(ime_message->result), output);
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 view()->handling_input_event_ = true; 1947 view()->handling_input_event_ = true;
1941 ExecuteJavaScript("document.getElementById('test').focus();"); 1948 ExecuteJavaScript("document.getElementById('test').focus();");
1942 1949
1943 bool is_input_type_called = false; 1950 bool is_input_type_called = false;
1944 bool is_selection_called = false; 1951 bool is_selection_called = false;
1945 size_t last_input_type = 0; 1952 size_t last_input_type = 0;
1946 size_t last_selection = 0; 1953 size_t last_selection = 0;
1947 1954
1948 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) { 1955 for (size_t i = 0; i < render_thread_->sink().message_count(); ++i) {
1949 const uint32 type = render_thread_->sink().GetMessageAt(i)->type(); 1956 const uint32 type = render_thread_->sink().GetMessageAt(i)->type();
1950 if (type == ViewHostMsg_TextInputTypeChanged::ID) { 1957 if (type == ViewHostMsg_TextInputStateChanged::ID) {
1951 is_input_type_called = true; 1958 is_input_type_called = true;
1952 last_input_type = i; 1959 last_input_type = i;
1953 } else if (type == ViewHostMsg_SelectionChanged::ID) { 1960 } else if (type == ViewHostMsg_SelectionChanged::ID) {
1954 is_selection_called = true; 1961 is_selection_called = true;
1955 last_selection = i; 1962 last_selection = i;
1956 } 1963 }
1957 } 1964 }
1958 1965
1959 EXPECT_TRUE(is_input_type_called); 1966 EXPECT_TRUE(is_input_type_called);
1960 EXPECT_TRUE(is_selection_called); 1967 EXPECT_TRUE(is_selection_called);
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 FROM_HERE, 2359 FROM_HERE,
2353 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2360 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2354 ExecuteJavaScript("debugger;"); 2361 ExecuteJavaScript("debugger;");
2355 2362
2356 // CloseWhilePaused should resume execution and continue here. 2363 // CloseWhilePaused should resume execution and continue here.
2357 EXPECT_FALSE(IsPaused()); 2364 EXPECT_FALSE(IsPaused());
2358 Detach(); 2365 Detach();
2359 } 2366 }
2360 2367
2361 } // namespace content 2368 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698