| 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 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 NSMutableArray* selectors = [NSMutableArray array]; | 1031 NSMutableArray* selectors = [NSMutableArray array]; |
| 1031 [selectors addObjectsFromArray:kMoveActions]; | 1032 [selectors addObjectsFromArray:kMoveActions]; |
| 1032 [selectors addObjectsFromArray:kSelectActions]; | 1033 [selectors addObjectsFromArray:kSelectActions]; |
| 1033 [selectors addObjectsFromArray:kDeleteActions]; | 1034 [selectors addObjectsFromArray:kDeleteActions]; |
| 1034 [selectors addObjectsFromArray:kMiscActions]; | 1035 [selectors addObjectsFromArray:kMiscActions]; |
| 1035 | 1036 |
| 1036 for (NSString* selector in selectors) | 1037 for (NSString* selector in selectors) |
| 1037 [ns_view_ doCommandBySelector:NSSelectorFromString(selector)]; | 1038 [ns_view_ doCommandBySelector:NSSelectorFromString(selector)]; |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1041 // Test transpose command against expectations set by |dummy_text_view_|. |
| 1042 TEST_F(BridgedNativeWidgetTest, TextInput_Transpose) { |
| 1043 TestEditingCommands(@[ @"transpose:" ]); |
| 1044 } |
| 1045 |
| 1040 // Test firstRectForCharacterRange:actualRange for cases where query range is | 1046 // Test firstRectForCharacterRange:actualRange for cases where query range is |
| 1041 // empty or outside composition range. | 1047 // empty or outside composition range. |
| 1042 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { | 1048 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { |
| 1043 InstallTextField(""); | 1049 InstallTextField(""); |
| 1044 ui::TextInputClient* client = [ns_view_ textInputClient]; | 1050 ui::TextInputClient* client = [ns_view_ textInputClient]; |
| 1045 | 1051 |
| 1046 // No composition. Ensure bounds and range corresponding to the current caret | 1052 // No composition. Ensure bounds and range corresponding to the current caret |
| 1047 // position are returned. | 1053 // position are returned. |
| 1048 // Initially selection range will be [0, 0]. | 1054 // Initially selection range will be [0, 0]. |
| 1049 NSRange caret_range = NSMakeRange(0, 0); | 1055 NSRange caret_range = NSMakeRange(0, 0); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 [center postNotificationName:NSWindowDidExitFullScreenNotification | 1200 [center postNotificationName:NSWindowDidExitFullScreenNotification |
| 1195 object:window]; | 1201 object:window]; |
| 1196 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. | 1202 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. |
| 1197 EXPECT_FALSE(bridge()->target_fullscreen_state()); | 1203 EXPECT_FALSE(bridge()->target_fullscreen_state()); |
| 1198 | 1204 |
| 1199 widget_->CloseNow(); | 1205 widget_->CloseNow(); |
| 1200 } | 1206 } |
| 1201 | 1207 |
| 1202 } // namespace test | 1208 } // namespace test |
| 1203 } // namespace views | 1209 } // namespace views |
| OLD | NEW |