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

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

Issue 1234193002: Simplify InputMethodWin initialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 PageState state = base::get<1>(param); 904 PageState state = base::get<1>(param);
905 EXPECT_EQ(page_id_C, page_id); 905 EXPECT_EQ(page_id_C, page_id);
906 EXPECT_NE(state_A, state); 906 EXPECT_NE(state_A, state);
907 EXPECT_NE(state_B, state); 907 EXPECT_NE(state_B, state);
908 EXPECT_EQ(state_C, state); 908 EXPECT_EQ(state_C, state);
909 } 909 }
910 910
911 // Test that our IME backend sends a notification message when the input focus 911 // Test that our IME backend sends a notification message when the input focus
912 // changes. 912 // changes.
913 TEST_F(RenderViewImplTest, OnImeTypeChanged) { 913 TEST_F(RenderViewImplTest, OnImeTypeChanged) {
914 // Enable our IME backend code.
915 view()->OnSetInputMethodActive(true);
916
917 // Load an HTML page consisting of two input fields. 914 // Load an HTML page consisting of two input fields.
918 view()->set_send_content_state_immediately(true); 915 view()->set_send_content_state_immediately(true);
919 LoadHTML("<html>" 916 LoadHTML("<html>"
920 "<head>" 917 "<head>"
921 "</head>" 918 "</head>"
922 "<body>" 919 "<body>"
923 "<input id=\"test1\" type=\"text\" value=\"some text\"></input>" 920 "<input id=\"test1\" type=\"text\" value=\"some text\"></input>"
924 "<input id=\"test2\" type=\"password\"></input>" 921 "<input id=\"test2\" type=\"password\"></input>"
925 "<input id=\"test3\" type=\"text\" inputmode=\"verbatim\"></input>" 922 "<input id=\"test3\" type=\"text\" inputmode=\"verbatim\"></input>"
926 "<input id=\"test4\" type=\"text\" inputmode=\"latin\"></input>" 923 "<input id=\"test4\" type=\"text\" inputmode=\"latin\"></input>"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 {IME_CONFIRMCOMPOSITION, false, -1, -1, L"", L"\xC548\xB155"}, 1093 {IME_CONFIRMCOMPOSITION, false, -1, -1, L"", L"\xC548\xB155"},
1097 }; 1094 };
1098 1095
1099 for (size_t i = 0; i < arraysize(kImeMessages); i++) { 1096 for (size_t i = 0; i < arraysize(kImeMessages); i++) {
1100 const ImeMessage* ime_message = &kImeMessages[i]; 1097 const ImeMessage* ime_message = &kImeMessages[i];
1101 switch (ime_message->command) { 1098 switch (ime_message->command) {
1102 case IME_INITIALIZE: 1099 case IME_INITIALIZE:
1103 // Load an HTML page consisting of a content-editable <div> element, 1100 // Load an HTML page consisting of a content-editable <div> element,
1104 // and move the input focus to the <div> element, where we can use 1101 // and move the input focus to the <div> element, where we can use
1105 // IMEs. 1102 // IMEs.
1106 view()->OnSetInputMethodActive(ime_message->enable);
1107 view()->set_send_content_state_immediately(true); 1103 view()->set_send_content_state_immediately(true);
1108 LoadHTML("<html>" 1104 LoadHTML("<html>"
1109 "<head>" 1105 "<head>"
1110 "</head>" 1106 "</head>"
1111 "<body>" 1107 "<body>"
1112 "<div id=\"test1\" contenteditable=\"true\"></div>" 1108 "<div id=\"test1\" contenteditable=\"true\"></div>"
1113 "</body>" 1109 "</body>"
1114 "</html>"); 1110 "</html>");
1115 ExecuteJavaScript("document.getElementById('test1').focus();"); 1111 ExecuteJavaScript("document.getElementById('test1').focus();");
1116 break; 1112 break;
1117 1113
1118 case IME_SETINPUTMODE: 1114 case IME_SETINPUTMODE:
1119 // Activate (or deactivate) our IME back-end.
1120 view()->OnSetInputMethodActive(ime_message->enable);
1121 break; 1115 break;
1122 1116
1123 case IME_SETFOCUS: 1117 case IME_SETFOCUS:
1124 // Update the window focus. 1118 // Update the window focus.
1125 view()->OnSetFocus(ime_message->enable); 1119 view()->OnSetFocus(ime_message->enable);
1126 break; 1120 break;
1127 1121
1128 case IME_SETCOMPOSITION: 1122 case IME_SETCOMPOSITION:
1129 view()->OnImeSetComposition( 1123 view()->OnImeSetComposition(
1130 base::WideToUTF16(ime_message->ime_string), 1124 base::WideToUTF16(ime_message->ime_string),
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 return; 1737 return;
1744 #endif 1738 #endif
1745 1739
1746 LoadHTML("<textarea id=\"test\"></textarea>"); 1740 LoadHTML("<textarea id=\"test\"></textarea>");
1747 ExecuteJavaScript("document.getElementById('test').focus();"); 1741 ExecuteJavaScript("document.getElementById('test').focus();");
1748 1742
1749 const base::string16 empty_string; 1743 const base::string16 empty_string;
1750 const std::vector<blink::WebCompositionUnderline> empty_underline; 1744 const std::vector<blink::WebCompositionUnderline> empty_underline;
1751 std::vector<gfx::Rect> bounds; 1745 std::vector<gfx::Rect> bounds;
1752 view()->OnSetFocus(true); 1746 view()->OnSetFocus(true);
1753 view()->OnSetInputMethodActive(true);
1754 1747
1755 // ASCII composition 1748 // ASCII composition
1756 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo"); 1749 const base::string16 ascii_composition = base::UTF8ToUTF16("aiueo");
1757 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0); 1750 view()->OnImeSetComposition(ascii_composition, empty_underline, 0, 0);
1758 view()->GetCompositionCharacterBounds(&bounds); 1751 view()->GetCompositionCharacterBounds(&bounds);
1759 ASSERT_EQ(ascii_composition.size(), bounds.size()); 1752 ASSERT_EQ(ascii_composition.size(), bounds.size());
1760 for (size_t i = 0; i < bounds.size(); ++i) 1753 for (size_t i = 0; i < bounds.size(); ++i)
1761 EXPECT_LT(0, bounds[i].width()); 1754 EXPECT_LT(0, bounds[i].width());
1762 view()->OnImeConfirmComposition( 1755 view()->OnImeConfirmComposition(
1763 empty_string, gfx::Range::InvalidRange(), false); 1756 empty_string, gfx::Range::InvalidRange(), false);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 1927
1935 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()). 1928 const_cast<blink::WebURLResponse&>(frame->dataSource()->response()).
1936 setSecurityInfo( 1929 setSecurityInfo(
1937 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0, 1930 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0,
1938 SignedCertificateTimestampIDStatusList())); 1931 SignedCertificateTimestampIDStatusList()));
1939 ssl_status = view()->GetSSLStatusOfFrame(frame); 1932 ssl_status = view()->GetSSLStatusOfFrame(frame);
1940 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); 1933 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status));
1941 } 1934 }
1942 1935
1943 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) { 1936 TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
1944 view()->OnSetInputMethodActive(true);
1945 view()->set_send_content_state_immediately(true); 1937 view()->set_send_content_state_immediately(true);
1946 LoadHTML("<textarea id=\"test\"></textarea>"); 1938 LoadHTML("<textarea id=\"test\"></textarea>");
1947 1939
1948 view()->handling_input_event_ = true; 1940 view()->handling_input_event_ = true;
1949 ExecuteJavaScript("document.getElementById('test').focus();"); 1941 ExecuteJavaScript("document.getElementById('test').focus();");
1950 1942
1951 bool is_input_type_called = false; 1943 bool is_input_type_called = false;
1952 bool is_selection_called = false; 1944 bool is_selection_called = false;
1953 size_t last_input_type = 0; 1945 size_t last_input_type = 0;
1954 size_t last_selection = 0; 1946 size_t last_selection = 0;
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 FROM_HERE, 2314 FROM_HERE,
2323 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2315 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2324 ExecuteJavaScript("debugger;"); 2316 ExecuteJavaScript("debugger;");
2325 2317
2326 // CloseWhilePaused should resume execution and continue here. 2318 // CloseWhilePaused should resume execution and continue here.
2327 EXPECT_FALSE(IsPaused()); 2319 EXPECT_FALSE(IsPaused());
2328 Detach(); 2320 Detach();
2329 } 2321 }
2330 2322
2331 } // namespace content 2323 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698