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

Side by Side Diff: third_party/WebKit/Source/core/editing/InputMethodControllerTest.cpp

Issue 2568093003: Support parsing BackgroundSpans and UnderlineSpans in Android IME's commitText() (Closed)
Patch Set: Don't try to add default underline for commitText(), attempt to fix Mac builds Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "core/editing/InputMethodController.h" 5 #include "core/editing/InputMethodController.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/dom/Range.h" 9 #include "core/dom/Range.h"
10 #include "core/editing/Editor.h" 10 #include "core/editing/Editor.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 frame().editor().insertLineBreak(); 846 frame().editor().insertLineBreak();
847 EXPECT_STREQ("\n\n", div->innerText().utf8().data()); 847 EXPECT_STREQ("\n\n", div->innerText().utf8().data());
848 EXPECT_EQ(1u, controller().getSelectionOffsets().start()); 848 EXPECT_EQ(1u, controller().getSelectionOffsets().start());
849 EXPECT_EQ(1u, controller().getSelectionOffsets().end()); 849 EXPECT_EQ(1u, controller().getSelectionOffsets().end());
850 } 850 }
851 851
852 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) { 852 TEST_F(InputMethodControllerTest, InsertLineBreakAfterConfirmingText) {
853 Element* div = 853 Element* div =
854 insertHTMLElement("<div id='sample' contenteditable></div>", "sample"); 854 insertHTMLElement("<div id='sample' contenteditable></div>", "sample");
855 855
856 controller().commitText("hello", 0); 856 Vector<CompositionUnderline> underlines;
857 underlines.append(CompositionUnderline(0, 2, Color(255, 0, 0), false, 0));
858 controller().commitText("hello", underlines, 0);
857 EXPECT_STREQ("hello", div->innerText().utf8().data()); 859 EXPECT_STREQ("hello", div->innerText().utf8().data());
858 860
859 controller().setEditableSelectionOffsets(PlainTextRange(2, 2)); 861 controller().setEditableSelectionOffsets(PlainTextRange(2, 2));
860 EXPECT_EQ(2u, controller().getSelectionOffsets().start()); 862 EXPECT_EQ(2u, controller().getSelectionOffsets().start());
861 EXPECT_EQ(2u, controller().getSelectionOffsets().end()); 863 EXPECT_EQ(2u, controller().getSelectionOffsets().end());
862 864
863 frame().editor().insertLineBreak(); 865 frame().editor().insertLineBreak();
864 EXPECT_STREQ("he\nllo", div->innerText().utf8().data()); 866 EXPECT_STREQ("he\nllo", div->innerText().utf8().data());
865 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); 867 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
866 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); 868 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) { 962 TEST_F(InputMethodControllerTest, CompositionInputEventForInsert) {
961 createHTMLWithCompositionInputEventListeners(); 963 createHTMLWithCompositionInputEventListeners();
962 964
963 // Simulate composition in the |contentEditable|. 965 // Simulate composition in the |contentEditable|.
964 Vector<CompositionUnderline> underlines; 966 Vector<CompositionUnderline> underlines;
965 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 967 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
966 968
967 // Insert new text without previous composition. 969 // Insert new text without previous composition.
968 document().setTitle(emptyString()); 970 document().setTitle(emptyString());
969 document().updateStyleAndLayout(); 971 document().updateStyleAndLayout();
970 controller().commitText("hello", 0); 972 controller().commitText("hello", underlines, 0);
971 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;", 973 EXPECT_STREQ("beforeinput.data:hello;input.data:hello;",
972 document().title().utf8().data()); 974 document().title().utf8().data());
973 975
974 document().setTitle(emptyString()); 976 document().setTitle(emptyString());
975 controller().setComposition("n", underlines, 1, 1); 977 controller().setComposition("n", underlines, 1, 1);
976 EXPECT_STREQ("beforeinput.data:n;input.data:n;", 978 EXPECT_STREQ("beforeinput.data:n;input.data:n;",
977 document().title().utf8().data()); 979 document().title().utf8().data());
978 980
979 // Insert new text with previous composition. 981 // Insert new text with previous composition.
980 document().setTitle(emptyString()); 982 document().setTitle(emptyString());
981 document().updateStyleAndLayout(); 983 document().updateStyleAndLayout();
982 controller().commitText("hello", 1); 984 controller().commitText("hello", underlines, 1);
983 EXPECT_STREQ( 985 EXPECT_STREQ(
984 "beforeinput.data:hello;input.data:hello;compositionend.data:hello;", 986 "beforeinput.data:hello;input.data:hello;compositionend.data:hello;",
985 document().title().utf8().data()); 987 document().title().utf8().data());
986 } 988 }
987 989
988 TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) { 990 TEST_F(InputMethodControllerTest, CompositionEndEventForConfirm) {
989 createHTMLWithCompositionEndEventListener(CaretSelection); 991 createHTMLWithCompositionEndEventListener(CaretSelection);
990 992
991 // Simulate composition in the |contentEditable|. 993 // Simulate composition in the |contentEditable|.
992 Vector<CompositionUnderline> underlines; 994 Vector<CompositionUnderline> underlines;
(...skipping 17 matching lines...) Expand all
1010 1012
1011 // Simulate composition in the |contentEditable|. 1013 // Simulate composition in the |contentEditable|.
1012 Vector<CompositionUnderline> underlines; 1014 Vector<CompositionUnderline> underlines;
1013 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0)); 1015 underlines.append(CompositionUnderline(0, 5, Color(255, 0, 0), false, 0));
1014 1016
1015 controller().setComposition("n", underlines, 1, 1); 1017 controller().setComposition("n", underlines, 1, 1);
1016 1018
1017 // Insert new text with previous composition. Note that it moves the caret to 1019 // Insert new text with previous composition. Note that it moves the caret to
1018 // [4,4] before firing 'compositonend' event. 1020 // [4,4] before firing 'compositonend' event.
1019 document().updateStyleAndLayout(); 1021 document().updateStyleAndLayout();
1020 controller().commitText("hello", -1); 1022 controller().commitText("hello", underlines, -1);
1021 document().updateStyleAndLayout(); 1023 document().updateStyleAndLayout();
1022 EXPECT_EQ(3u, controller().getSelectionOffsets().start()); 1024 EXPECT_EQ(3u, controller().getSelectionOffsets().start());
1023 EXPECT_EQ(3u, controller().getSelectionOffsets().end()); 1025 EXPECT_EQ(3u, controller().getSelectionOffsets().end());
1024 } 1026 }
1025 1027
1026 TEST_F(InputMethodControllerTest, CompositionEndEventWithRangeSelection) { 1028 TEST_F(InputMethodControllerTest, CompositionEndEventWithRangeSelection) {
1027 createHTMLWithCompositionEndEventListener(RangeSelection); 1029 createHTMLWithCompositionEndEventListener(RangeSelection);
1028 1030
1029 // Simulate composition in the |contentEditable|. 1031 // Simulate composition in the |contentEditable|.
1030 Vector<CompositionUnderline> underlines; 1032 Vector<CompositionUnderline> underlines;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType()); 1079 EXPECT_EQ(WebTextInputTypeNone, controller().textInputType());
1078 1080
1079 document().getElementById("b")->focus(); 1081 document().getElementById("b")->focus();
1080 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); 1082 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType());
1081 1083
1082 controller().finishComposingText(InputMethodController::KeepSelection); 1084 controller().finishComposingText(InputMethodController::KeepSelection);
1083 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType()); 1085 EXPECT_EQ(WebTextInputTypeTelephone, controller().textInputType());
1084 } 1086 }
1085 1087
1086 } // namespace blink 1088 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698