OLD | NEW |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 @"moveToLeftEndOfLineAndModifySelection:", | 105 @"moveToLeftEndOfLineAndModifySelection:", |
106 @"moveToRightEndOfLineAndModifySelection:" | 106 @"moveToRightEndOfLineAndModifySelection:" |
107 ]; | 107 ]; |
108 | 108 |
109 NSArray* const kDeleteActions = @[ | 109 NSArray* const kDeleteActions = @[ |
110 @"deleteForward:", @"deleteBackward:", @"deleteWordForward:", | 110 @"deleteForward:", @"deleteBackward:", @"deleteWordForward:", |
111 @"deleteWordBackward:", @"deleteToBeginningOfLine:", @"deleteToEndOfLine:", | 111 @"deleteWordBackward:", @"deleteToBeginningOfLine:", @"deleteToEndOfLine:", |
112 @"deleteToBeginningOfParagraph:", @"deleteToEndOfParagraph:" | 112 @"deleteToBeginningOfParagraph:", @"deleteToEndOfParagraph:" |
113 ]; | 113 ]; |
114 | 114 |
115 NSArray* const kMiscActions = @[ @"insertText:", @"cancelOperation:" ]; | 115 NSArray* const kMiscActions = |
| 116 @[ @"insertText:", @"cancelOperation:", @"transpose:" ]; |
116 | 117 |
117 // Empty range shortcut for readibility. | 118 // Empty range shortcut for readibility. |
118 NSRange EmptyRange() { | 119 NSRange EmptyRange() { |
119 return NSMakeRange(NSNotFound, 0); | 120 return NSMakeRange(NSNotFound, 0); |
120 } | 121 } |
121 | 122 |
122 // Sets |composition_text| as the composition text with caret placed at | 123 // Sets |composition_text| as the composition text with caret placed at |
123 // |caret_pos| and updates |caret_range|. | 124 // |caret_pos| and updates |caret_range|. |
124 void SetCompositionText(ui::TextInputClient* client, | 125 void SetCompositionText(ui::TextInputClient* client, |
125 const base::string16& composition_text, | 126 const base::string16& composition_text, |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 NSMutableArray* selectors = [NSMutableArray array]; | 1027 NSMutableArray* selectors = [NSMutableArray array]; |
1027 [selectors addObjectsFromArray:kMoveActions]; | 1028 [selectors addObjectsFromArray:kMoveActions]; |
1028 [selectors addObjectsFromArray:kSelectActions]; | 1029 [selectors addObjectsFromArray:kSelectActions]; |
1029 [selectors addObjectsFromArray:kDeleteActions]; | 1030 [selectors addObjectsFromArray:kDeleteActions]; |
1030 [selectors addObjectsFromArray:kMiscActions]; | 1031 [selectors addObjectsFromArray:kMiscActions]; |
1031 | 1032 |
1032 for (NSString* selector in selectors) | 1033 for (NSString* selector in selectors) |
1033 [ns_view_ doCommandBySelector:NSSelectorFromString(selector)]; | 1034 [ns_view_ doCommandBySelector:NSSelectorFromString(selector)]; |
1034 } | 1035 } |
1035 | 1036 |
| 1037 // Test transpose command against expectations set by |dummy_text_view_|. |
| 1038 TEST_F(BridgedNativeWidgetTest, TextInput_Transpose) { |
| 1039 TestEditingCommands(@[ @"transpose:" ]); |
| 1040 } |
| 1041 |
1036 // Test firstRectForCharacterRange:actualRange for cases where query range is | 1042 // Test firstRectForCharacterRange:actualRange for cases where query range is |
1037 // empty or outside composition range. | 1043 // empty or outside composition range. |
1038 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { | 1044 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { |
1039 InstallTextField(""); | 1045 InstallTextField(""); |
1040 ui::TextInputClient* client = [ns_view_ textInputClient]; | 1046 ui::TextInputClient* client = [ns_view_ textInputClient]; |
1041 | 1047 |
1042 // No composition. Ensure bounds and range corresponding to the current caret | 1048 // No composition. Ensure bounds and range corresponding to the current caret |
1043 // position are returned. | 1049 // position are returned. |
1044 // Initially selection range will be [0, 0]. | 1050 // Initially selection range will be [0, 0]. |
1045 NSRange caret_range = NSMakeRange(0, 0); | 1051 NSRange caret_range = NSMakeRange(0, 0); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 [center postNotificationName:NSWindowDidExitFullScreenNotification | 1196 [center postNotificationName:NSWindowDidExitFullScreenNotification |
1191 object:window]; | 1197 object:window]; |
1192 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. | 1198 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. |
1193 EXPECT_FALSE(bridge()->target_fullscreen_state()); | 1199 EXPECT_FALSE(bridge()->target_fullscreen_state()); |
1194 | 1200 |
1195 widget_->CloseNow(); | 1201 widget_->CloseNow(); |
1196 } | 1202 } |
1197 | 1203 |
1198 } // namespace test | 1204 } // namespace test |
1199 } // namespace views | 1205 } // namespace views |
OLD | NEW |