OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/singleton.h" | 6 #include "base/memory/singleton.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( | 946 RenderViewHostImpl* guest_rvh = static_cast<RenderViewHostImpl*>( |
947 test_guest()->web_contents()->GetRenderViewHost()); | 947 test_guest()->web_contents()->GetRenderViewHost()); |
948 | 948 |
949 std::vector<blink::WebCompositionUnderline> underlines; | 949 std::vector<blink::WebCompositionUnderline> underlines; |
950 | 950 |
951 // An input field in browser plugin guest gets focus and given some user | 951 // An input field in browser plugin guest gets focus and given some user |
952 // input via IME. | 952 // input via IME. |
953 { | 953 { |
954 ExecuteSyncJSFunction(guest_rvh, | 954 ExecuteSyncJSFunction(guest_rvh, |
955 "document.getElementById('input1').focus();"); | 955 "document.getElementById('input1').focus();"); |
956 string16 expected_title = UTF8ToUTF16("InputTest123"); | 956 base::string16 expected_title = UTF8ToUTF16("InputTest123"); |
957 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 957 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
958 expected_title); | 958 expected_title); |
959 embedder_rvh->Send( | 959 embedder_rvh->Send( |
960 new ViewMsg_ImeSetComposition( | 960 new ViewMsg_ImeSetComposition( |
961 test_embedder()->web_contents()->GetRoutingID(), | 961 test_embedder()->web_contents()->GetRoutingID(), |
962 expected_title, | 962 expected_title, |
963 underlines, | 963 underlines, |
964 12, 12)); | 964 12, 12)); |
965 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 965 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
966 EXPECT_EQ(expected_title, actual_title); | 966 EXPECT_EQ(expected_title, actual_title); |
967 } | 967 } |
968 // A composition is committed via IME. | 968 // A composition is committed via IME. |
969 { | 969 { |
970 string16 expected_title = UTF8ToUTF16("InputTest456"); | 970 base::string16 expected_title = UTF8ToUTF16("InputTest456"); |
971 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 971 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
972 expected_title); | 972 expected_title); |
973 embedder_rvh->Send( | 973 embedder_rvh->Send( |
974 new ViewMsg_ImeConfirmComposition( | 974 new ViewMsg_ImeConfirmComposition( |
975 test_embedder()->web_contents()->GetRoutingID(), | 975 test_embedder()->web_contents()->GetRoutingID(), |
976 expected_title, | 976 expected_title, |
977 gfx::Range(), | 977 gfx::Range(), |
978 true)); | 978 true)); |
979 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 979 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
980 EXPECT_EQ(expected_title, actual_title); | 980 EXPECT_EQ(expected_title, actual_title); |
981 } | 981 } |
982 // IME composition starts, but focus moves out, then the composition will | 982 // IME composition starts, but focus moves out, then the composition will |
983 // be committed and get cancel msg. | 983 // be committed and get cancel msg. |
984 { | 984 { |
985 ExecuteSyncJSFunction(guest_rvh, | 985 ExecuteSyncJSFunction(guest_rvh, |
986 "document.getElementById('input1').value = '';"); | 986 "document.getElementById('input1').value = '';"); |
987 string16 composition = UTF8ToUTF16("InputTest789"); | 987 base::string16 composition = UTF8ToUTF16("InputTest789"); |
988 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 988 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
989 composition); | 989 composition); |
990 embedder_rvh->Send( | 990 embedder_rvh->Send( |
991 new ViewMsg_ImeSetComposition( | 991 new ViewMsg_ImeSetComposition( |
992 test_embedder()->web_contents()->GetRoutingID(), | 992 test_embedder()->web_contents()->GetRoutingID(), |
993 composition, | 993 composition, |
994 underlines, | 994 underlines, |
995 12, 12)); | 995 12, 12)); |
996 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 996 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
997 EXPECT_EQ(composition, actual_title); | 997 EXPECT_EQ(composition, actual_title); |
(...skipping 11 matching lines...) Expand all Loading... |
1009 } | 1009 } |
1010 // Tests ExtendSelectionAndDelete message works in browser_plugin. | 1010 // Tests ExtendSelectionAndDelete message works in browser_plugin. |
1011 { | 1011 { |
1012 // Set 'InputTestABC' in input1 and put caret at 6 (after 'T'). | 1012 // Set 'InputTestABC' in input1 and put caret at 6 (after 'T'). |
1013 ExecuteSyncJSFunction(guest_rvh, | 1013 ExecuteSyncJSFunction(guest_rvh, |
1014 "var i = document.getElementById('input1');" | 1014 "var i = document.getElementById('input1');" |
1015 "i.focus();" | 1015 "i.focus();" |
1016 "i.value = 'InputTestABC';" | 1016 "i.value = 'InputTestABC';" |
1017 "i.selectionStart=6;" | 1017 "i.selectionStart=6;" |
1018 "i.selectionEnd=6;"); | 1018 "i.selectionEnd=6;"); |
1019 string16 expected_value = UTF8ToUTF16("InputABC"); | 1019 base::string16 expected_value = UTF8ToUTF16("InputABC"); |
1020 content::TitleWatcher title_watcher(test_guest()->web_contents(), | 1020 content::TitleWatcher title_watcher(test_guest()->web_contents(), |
1021 expected_value); | 1021 expected_value); |
1022 // Delete 'Test' in 'InputTestABC', as the caret is after 'T': | 1022 // Delete 'Test' in 'InputTestABC', as the caret is after 'T': |
1023 // delete before 1 character ('T') and after 3 characters ('est'). | 1023 // delete before 1 character ('T') and after 3 characters ('est'). |
1024 embedder_rvh->Send( | 1024 embedder_rvh->Send( |
1025 new ViewMsg_ExtendSelectionAndDelete( | 1025 new ViewMsg_ExtendSelectionAndDelete( |
1026 test_embedder()->web_contents()->GetRoutingID(), | 1026 test_embedder()->web_contents()->GetRoutingID(), |
1027 1, 3)); | 1027 1, 3)); |
1028 base::string16 actual_title = title_watcher.WaitAndGetTitle(); | 1028 base::string16 actual_title = title_watcher.WaitAndGetTitle(); |
1029 EXPECT_EQ(expected_value, actual_title); | 1029 EXPECT_EQ(expected_value, actual_title); |
1030 scoped_ptr<base::Value> value = | 1030 scoped_ptr<base::Value> value = |
1031 content::ExecuteScriptAndGetValue( | 1031 content::ExecuteScriptAndGetValue( |
1032 guest_rvh, "document.getElementById('input1').value"); | 1032 guest_rvh, "document.getElementById('input1').value"); |
1033 std::string actual_value; | 1033 std::string actual_value; |
1034 ASSERT_TRUE(value->GetAsString(&actual_value)); | 1034 ASSERT_TRUE(value->GetAsString(&actual_value)); |
1035 EXPECT_EQ(UTF16ToUTF8(expected_value), actual_value); | 1035 EXPECT_EQ(UTF16ToUTF8(expected_value), actual_value); |
1036 } | 1036 } |
1037 } | 1037 } |
1038 | 1038 |
1039 } // namespace content | 1039 } // namespace content |
OLD | NEW |