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

Unified Diff: ui/views/cocoa/bridged_native_widget_unittest.mm

Issue 2177853002: MacViews: Fix setMarkedText in BridgedContentView to take replacementRange into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ime_regression
Patch Set: Add test. Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget_unittest.mm
diff --git a/ui/views/cocoa/bridged_native_widget_unittest.mm b/ui/views/cocoa/bridged_native_widget_unittest.mm
index 4554eee36a5155c614f9e5d7cec497da7f4d048a..6977ee80215d93ae4939a9767f33e1623d5f3703 100644
--- a/ui/views/cocoa/bridged_native_widget_unittest.mm
+++ b/ui/views/cocoa/bridged_native_widget_unittest.mm
@@ -863,6 +863,36 @@ void PerformInit() {
GetExpectedSelectionRange(), GetActualSelectionRange());
}
+// Test IME composition for accented characters.
+TEST_F(BridgedNativeWidgetTest, TextInput_AccentedCharacter) {
+ InstallTextField("abc");
+
+ // Simulate action messages generated when the key 'a' is pressed repeatedly
+ // and leads to the showing of an IME candidate window.
+
+ // First an insertText: message with key 'a' is generated.
+ [ns_view_ insertText:@"a" replacementRange:EmptyRange()];
+ [dummy_text_view_ insertText:@"a" replacementRange:EmptyRange()];
+ EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
+ EXPECT_NSEQ_3(@"abca", GetExpectedText(), GetActualText());
+
+ // Next the IME popup appears. On selecting the accented character using arrow
+ // keys, setMarkedText action message is generated which replaces the earlier
+ // inserted 'a'.
+ [ns_view_ setMarkedText:@"à"
+ selectedRange:NSMakeRange(0, 1)
+ replacementRange:NSMakeRange(3, 1)];
+ [dummy_text_view_ setMarkedText:@"à"
+ selectedRange:NSMakeRange(0, 1)
+ replacementRange:NSMakeRange(3, 1)];
+ EXPECT_EQ_3(YES, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
+ EXPECT_EQ_RANGE_3(NSMakeRange(3, 1), [dummy_text_view_ markedRange],
+ [ns_view_ markedRange]);
+ EXPECT_EQ_RANGE_3(NSMakeRange(3, 1), GetExpectedSelectionRange(),
+ GetActualSelectionRange());
+ EXPECT_NSEQ_3(@"abcà", GetExpectedText(), GetActualText());
+}
+
// Test moving the caret left and right using text input protocol.
TEST_F(BridgedNativeWidgetTest, TextInput_MoveLeftRight) {
InstallTextField("foo");
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698