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

Side by Side 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, 4 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
« no previous file with comments | « ui/views/cocoa/bridged_content_view.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "ui/views/cocoa/bridged_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 856
857 EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]); 857 EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
858 EXPECT_FALSE( 858 EXPECT_FALSE(
859 NSEqualRanges([dummy_text_view_ markedRange], [ns_view_ markedRange])); 859 NSEqualRanges([dummy_text_view_ markedRange], [ns_view_ markedRange]));
860 EXPECT_EQ_RANGE(EmptyRange(), [ns_view_ markedRange]); 860 EXPECT_EQ_RANGE(EmptyRange(), [ns_view_ markedRange]);
861 EXPECT_NSEQ_3(@"foo bar", GetExpectedText(), GetActualText()); 861 EXPECT_NSEQ_3(@"foo bar", GetExpectedText(), GetActualText());
862 EXPECT_EQ_RANGE_3(NSMakeRange([GetActualText() length], 0), 862 EXPECT_EQ_RANGE_3(NSMakeRange([GetActualText() length], 0),
863 GetExpectedSelectionRange(), GetActualSelectionRange()); 863 GetExpectedSelectionRange(), GetActualSelectionRange());
864 } 864 }
865 865
866 // Test IME composition for accented characters.
867 TEST_F(BridgedNativeWidgetTest, TextInput_AccentedCharacter) {
868 InstallTextField("abc");
869
870 // Simulate action messages generated when the key 'a' is pressed repeatedly
871 // and leads to the showing of an IME candidate window.
872
873 // First an insertText: message with key 'a' is generated.
874 [ns_view_ insertText:@"a" replacementRange:EmptyRange()];
875 [dummy_text_view_ insertText:@"a" replacementRange:EmptyRange()];
876 EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
877 EXPECT_NSEQ_3(@"abca", GetExpectedText(), GetActualText());
878
879 // Next the IME popup appears. On selecting the accented character using arrow
880 // keys, setMarkedText action message is generated which replaces the earlier
881 // inserted 'a'.
882 [ns_view_ setMarkedText:@"à"
883 selectedRange:NSMakeRange(0, 1)
884 replacementRange:NSMakeRange(3, 1)];
885 [dummy_text_view_ setMarkedText:@"à"
886 selectedRange:NSMakeRange(0, 1)
887 replacementRange:NSMakeRange(3, 1)];
888 EXPECT_EQ_3(YES, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
889 EXPECT_EQ_RANGE_3(NSMakeRange(3, 1), [dummy_text_view_ markedRange],
890 [ns_view_ markedRange]);
891 EXPECT_EQ_RANGE_3(NSMakeRange(3, 1), GetExpectedSelectionRange(),
892 GetActualSelectionRange());
893 EXPECT_NSEQ_3(@"abcà", GetExpectedText(), GetActualText());
894 }
895
866 // Test moving the caret left and right using text input protocol. 896 // Test moving the caret left and right using text input protocol.
867 TEST_F(BridgedNativeWidgetTest, TextInput_MoveLeftRight) { 897 TEST_F(BridgedNativeWidgetTest, TextInput_MoveLeftRight) {
868 InstallTextField("foo"); 898 InstallTextField("foo");
869 EXPECT_EQ_RANGE_3(NSMakeRange(3, 0), GetExpectedSelectionRange(), 899 EXPECT_EQ_RANGE_3(NSMakeRange(3, 0), GetExpectedSelectionRange(),
870 GetActualSelectionRange()); 900 GetActualSelectionRange());
871 901
872 // Move right not allowed, out of range. 902 // Move right not allowed, out of range.
873 PerformCommand(@selector(moveRight:)); 903 PerformCommand(@selector(moveRight:));
874 EXPECT_EQ_RANGE_3(NSMakeRange(3, 0), GetExpectedSelectionRange(), 904 EXPECT_EQ_RANGE_3(NSMakeRange(3, 0), GetExpectedSelectionRange(),
875 GetActualSelectionRange()); 905 GetActualSelectionRange());
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 [center postNotificationName:NSWindowDidExitFullScreenNotification 1226 [center postNotificationName:NSWindowDidExitFullScreenNotification
1197 object:window]; 1227 object:window];
1198 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. 1228 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change.
1199 EXPECT_FALSE(bridge()->target_fullscreen_state()); 1229 EXPECT_FALSE(bridge()->target_fullscreen_state());
1200 1230
1201 widget_->CloseNow(); 1231 widget_->CloseNow();
1202 } 1232 }
1203 1233
1204 } // namespace test 1234 } // namespace test
1205 } // namespace views 1235 } // namespace views
OLDNEW
« 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