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 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 view_->AddChildView(textfield); | 354 view_->AddChildView(textfield); |
355 textfield->SetBoundsRect(init_params_.bounds); | 355 textfield->SetBoundsRect(init_params_.bounds); |
356 | 356 |
357 // Request focus so the InputMethod can dispatch events to the RootView, and | 357 // Request focus so the InputMethod can dispatch events to the RootView, and |
358 // have them delivered to the textfield. Note that focusing a textfield | 358 // have them delivered to the textfield. Note that focusing a textfield |
359 // schedules a task to flash the cursor, so this requires |message_loop_|. | 359 // schedules a task to flash the cursor, so this requires |message_loop_|. |
360 textfield->RequestFocus(); | 360 textfield->RequestFocus(); |
361 | 361 |
362 [ns_view_ setTextInputClient:textfield]; | 362 [ns_view_ setTextInputClient:textfield]; |
363 | 363 |
364 // Initialize the dummy text view. | 364 // Initialize the dummy text view. Initializing this with NSZeroRect causes |
365 dummy_text_view_.reset([[NSTextView alloc] initWithFrame:NSZeroRect]); | 365 // weird NSTextView behavior on OSX 10.9. |
| 366 dummy_text_view_.reset( |
| 367 [[NSTextView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); |
366 [dummy_text_view_ setString:SysUTF16ToNSString(text)]; | 368 [dummy_text_view_ setString:SysUTF16ToNSString(text)]; |
367 } | 369 } |
368 | 370 |
369 void BridgedNativeWidgetTest::InstallTextField(const base::string16& text) { | 371 void BridgedNativeWidgetTest::InstallTextField(const base::string16& text) { |
370 InstallTextField(text, ui::TEXT_INPUT_TYPE_TEXT); | 372 InstallTextField(text, ui::TEXT_INPUT_TYPE_TEXT); |
371 } | 373 } |
372 | 374 |
373 void BridgedNativeWidgetTest::InstallTextField(const std::string& text) { | 375 void BridgedNativeWidgetTest::InstallTextField(const std::string& text) { |
374 InstallTextField(base::ASCIIToUTF16(text), ui::TEXT_INPUT_TYPE_TEXT); | 376 InstallTextField(base::ASCIIToUTF16(text), ui::TEXT_INPUT_TYPE_TEXT); |
375 } | 377 } |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfParagraph) { | 996 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfParagraph) { |
995 TestDeleteBeginning(@selector(deleteToBeginningOfParagraph:)); | 997 TestDeleteBeginning(@selector(deleteToBeginningOfParagraph:)); |
996 } | 998 } |
997 | 999 |
998 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfParagraph) { | 1000 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfParagraph) { |
999 TestDeleteEnd(@selector(deleteToEndOfParagraph:)); | 1001 TestDeleteEnd(@selector(deleteToEndOfParagraph:)); |
1000 } | 1002 } |
1001 | 1003 |
1002 // Test move commands against expectations set by |dummy_text_view_|. | 1004 // Test move commands against expectations set by |dummy_text_view_|. |
1003 TEST_F(BridgedNativeWidgetTest, TextInput_MoveEditingCommands) { | 1005 TEST_F(BridgedNativeWidgetTest, TextInput_MoveEditingCommands) { |
1004 // Broken on 10.9. http://crbug.com/621734. | |
1005 if (base::mac::IsOSMavericks()) | |
1006 return; | |
1007 TestEditingCommands(kMoveActions); | 1006 TestEditingCommands(kMoveActions); |
1008 } | 1007 } |
1009 | 1008 |
1010 // Todo(karandeepb): Enable this test once the behavior of all move and select | 1009 // Todo(karandeepb): Enable this test once the behavior of all move and select |
1011 // commands are fixed. | 1010 // commands are fixed. |
1012 // Test move and select commands against expectations set by |dummy_text_view_|. | 1011 // Test move and select commands against expectations set by |dummy_text_view_|. |
1013 TEST_F(BridgedNativeWidgetTest, | 1012 TEST_F(BridgedNativeWidgetTest, |
1014 TextInput_MoveAndSelectEditingCommands_DISABLED) { | 1013 TextInput_MoveAndSelectEditingCommands_DISABLED) { |
1015 TestEditingCommands(kSelectActions); | 1014 TestEditingCommands(kSelectActions); |
1016 } | 1015 } |
1017 | 1016 |
1018 // Test delete commands against expectations set by |dummy_text_view_|. | 1017 // Test delete commands against expectations set by |dummy_text_view_|. |
1019 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteCommands) { | 1018 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteCommands) { |
1020 // Broken on 10.9. http://crbug.com/621734. | |
1021 if (base::mac::IsOSMavericks()) | |
1022 return; | |
1023 TestEditingCommands(kDeleteActions); | 1019 TestEditingCommands(kDeleteActions); |
1024 } | 1020 } |
1025 | 1021 |
1026 // Test that we don't crash during an action message even if the TextInputClient | 1022 // Test that we don't crash during an action message even if the TextInputClient |
1027 // is nil. Regression test for crbug.com/615745. | 1023 // is nil. Regression test for crbug.com/615745. |
1028 TEST_F(BridgedNativeWidgetTest, NilTextInputClient) { | 1024 TEST_F(BridgedNativeWidgetTest, NilTextInputClient) { |
1029 [ns_view_ setTextInputClient:nil]; | 1025 [ns_view_ setTextInputClient:nil]; |
1030 NSMutableArray* selectors = [NSMutableArray array]; | 1026 NSMutableArray* selectors = [NSMutableArray array]; |
1031 [selectors addObjectsFromArray:kMoveActions]; | 1027 [selectors addObjectsFromArray:kMoveActions]; |
1032 [selectors addObjectsFromArray:kSelectActions]; | 1028 [selectors addObjectsFromArray:kSelectActions]; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 [center postNotificationName:NSWindowDidExitFullScreenNotification | 1190 [center postNotificationName:NSWindowDidExitFullScreenNotification |
1195 object:window]; | 1191 object:window]; |
1196 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. | 1192 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. |
1197 EXPECT_FALSE(bridge()->target_fullscreen_state()); | 1193 EXPECT_FALSE(bridge()->target_fullscreen_state()); |
1198 | 1194 |
1199 widget_->CloseNow(); | 1195 widget_->CloseNow(); |
1200 } | 1196 } |
1201 | 1197 |
1202 } // namespace test | 1198 } // namespace test |
1203 } // namespace views | 1199 } // namespace views |
OLD | NEW |