| 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 |
| 11 #import "base/mac/foundation_util.h" | 11 #import "base/mac/foundation_util.h" |
| 12 #import "base/mac/mac_util.h" | 12 #import "base/mac/mac_util.h" |
| 13 #import "base/mac/sdk_forward_declarations.h" | 13 #import "base/mac/sdk_forward_declarations.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #import "testing/gtest_mac.h" | 19 #import "testing/gtest_mac.h" |
| 20 #import "ui/base/cocoa/window_size_constants.h" | 20 #import "ui/base/cocoa/window_size_constants.h" |
| 21 #include "ui/base/ime/input_method.h" | 21 #include "ui/base/ime/input_method.h" |
| 22 #import "ui/gfx/mac/coordinate_conversion.h" | 22 #import "ui/gfx/mac/coordinate_conversion.h" |
| 23 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 23 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
| 24 #import "ui/views/cocoa/bridged_content_view.h" | 24 #import "ui/views/cocoa/bridged_content_view.h" |
| 25 #import "ui/views/cocoa/native_widget_mac_nswindow.h" | 25 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
| 26 #import "ui/views/cocoa/views_nswindow_delegate.h" | 26 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| 27 #include "ui/views/controls/textfield/textfield.h" | 27 #include "ui/views/controls/textfield/textfield.h" |
| 28 #include "ui/views/test/test_views_delegate.h" |
| 28 #include "ui/views/view.h" | 29 #include "ui/views/view.h" |
| 29 #include "ui/views/widget/native_widget_mac.h" | 30 #include "ui/views/widget/native_widget_mac.h" |
| 30 #include "ui/views/widget/root_view.h" | 31 #include "ui/views/widget/root_view.h" |
| 31 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 32 #include "ui/views/widget/widget_observer.h" | 33 #include "ui/views/widget/widget_observer.h" |
| 33 | 34 |
| 34 using base::ASCIIToUTF16; | 35 using base::ASCIIToUTF16; |
| 35 using base::SysNSStringToUTF8; | 36 using base::SysNSStringToUTF8; |
| 36 using base::SysNSStringToUTF16; | 37 using base::SysNSStringToUTF16; |
| 37 using base::SysUTF8ToNSString; | 38 using base::SysUTF8ToNSString; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 @"moveToRightEndOfLineAndModifySelection:" | 107 @"moveToRightEndOfLineAndModifySelection:" |
| 107 ]; | 108 ]; |
| 108 | 109 |
| 109 NSArray* const kDeleteActions = @[ | 110 NSArray* const kDeleteActions = @[ |
| 110 @"deleteForward:", @"deleteBackward:", @"deleteWordForward:", | 111 @"deleteForward:", @"deleteBackward:", @"deleteWordForward:", |
| 111 @"deleteWordBackward:", @"deleteToBeginningOfLine:", @"deleteToEndOfLine:", | 112 @"deleteWordBackward:", @"deleteToBeginningOfLine:", @"deleteToEndOfLine:", |
| 112 @"deleteToBeginningOfParagraph:", @"deleteToEndOfParagraph:" | 113 @"deleteToBeginningOfParagraph:", @"deleteToEndOfParagraph:" |
| 113 ]; | 114 ]; |
| 114 | 115 |
| 115 NSArray* const kMiscActions = | 116 NSArray* const kMiscActions = |
| 116 @[ @"insertText:", @"cancelOperation:", @"transpose:" ]; | 117 @[ @"insertText:", @"cancelOperation:", @"transpose:", @"yank:" ]; |
| 117 | 118 |
| 118 // Empty range shortcut for readibility. | 119 // Empty range shortcut for readibility. |
| 119 NSRange EmptyRange() { | 120 NSRange EmptyRange() { |
| 120 return NSMakeRange(NSNotFound, 0); | 121 return NSMakeRange(NSNotFound, 0); |
| 121 } | 122 } |
| 122 | 123 |
| 123 // Sets |composition_text| as the composition text with caret placed at | 124 // Sets |composition_text| as the composition text with caret placed at |
| 124 // |caret_pos| and updates |caret_range|. | 125 // |caret_pos| and updates |caret_range|. |
| 125 void SetCompositionText(ui::TextInputClient* client, | 126 void SetCompositionText(ui::TextInputClient* client, |
| 126 const base::string16& composition_text, | 127 const base::string16& composition_text, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 init_params_.opacity = Widget::InitParams::OPAQUE_WINDOW; | 253 init_params_.opacity = Widget::InitParams::OPAQUE_WINDOW; |
| 253 | 254 |
| 254 init_params_.bounds = gfx::Rect(100, 100, 100, 100); | 255 init_params_.bounds = gfx::Rect(100, 100, 100, 100); |
| 255 | 256 |
| 256 native_widget_mac_->GetWidget()->Init(init_params_); | 257 native_widget_mac_->GetWidget()->Init(init_params_); |
| 257 } | 258 } |
| 258 | 259 |
| 259 protected: | 260 protected: |
| 260 std::unique_ptr<Widget> widget_; | 261 std::unique_ptr<Widget> widget_; |
| 261 MockNativeWidgetMac* native_widget_mac_; // Weak. Owned by |widget_|. | 262 MockNativeWidgetMac* native_widget_mac_; // Weak. Owned by |widget_|. |
| 263 TestViewsDelegate test_views_delegate_; |
| 262 | 264 |
| 263 // Make the InitParams available to tests to cover initialization codepaths. | 265 // Make the InitParams available to tests to cover initialization codepaths. |
| 264 Widget::InitParams init_params_; | 266 Widget::InitParams init_params_; |
| 265 }; | 267 }; |
| 266 | 268 |
| 267 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase { | 269 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase { |
| 268 public: | 270 public: |
| 269 BridgedNativeWidgetTest(); | 271 BridgedNativeWidgetTest(); |
| 270 ~BridgedNativeWidgetTest() override; | 272 ~BridgedNativeWidgetTest() override; |
| 271 | 273 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 478 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 477 GetActualSelectionRange()); | 479 GetActualSelectionRange()); |
| 478 | 480 |
| 479 // Make a selection as- " bar |baz|". | 481 // Make a selection as- " bar |baz|". |
| 480 SetSelectionRange(NSMakeRange(5, 3)); | 482 SetSelectionRange(NSMakeRange(5, 3)); |
| 481 PerformCommand(sel); | 483 PerformCommand(sel); |
| 482 // Verify only the selection is deleted so that the state is " bar |". | 484 // Verify only the selection is deleted so that the state is " bar |". |
| 483 EXPECT_NSEQ_3(@" bar ", GetExpectedText(), GetActualText()); | 485 EXPECT_NSEQ_3(@" bar ", GetExpectedText(), GetActualText()); |
| 484 EXPECT_EQ_RANGE_3(NSMakeRange(5, 0), GetExpectedSelectionRange(), | 486 EXPECT_EQ_RANGE_3(NSMakeRange(5, 0), GetExpectedSelectionRange(), |
| 485 GetActualSelectionRange()); | 487 GetActualSelectionRange()); |
| 488 |
| 489 // Verify yanking inserts the deleted text. |
| 490 PerformCommand(@selector(yank:)); |
| 491 EXPECT_NSEQ_3(@" bar baz", GetExpectedText(), GetActualText()); |
| 492 EXPECT_EQ_RANGE_3(NSMakeRange(8, 0), GetExpectedSelectionRange(), |
| 493 GetActualSelectionRange()); |
| 486 } | 494 } |
| 487 | 495 |
| 488 void BridgedNativeWidgetTest::TestDeleteEnd(SEL sel) { | 496 void BridgedNativeWidgetTest::TestDeleteEnd(SEL sel) { |
| 489 InstallTextField("foo bar baz"); | 497 InstallTextField("foo bar baz"); |
| 490 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), | 498 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), |
| 491 GetActualSelectionRange()); | 499 GetActualSelectionRange()); |
| 492 | 500 |
| 493 // Caret is at the end of the line. Verify no deletion takes place. | 501 // Caret is at the end of the line. Verify no deletion takes place. |
| 494 PerformCommand(sel); | 502 PerformCommand(sel); |
| 495 EXPECT_NSEQ_3(@"foo bar baz", GetExpectedText(), GetActualText()); | 503 EXPECT_NSEQ_3(@"foo bar baz", GetExpectedText(), GetActualText()); |
| 496 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), | 504 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), |
| 497 GetActualSelectionRange()); | 505 GetActualSelectionRange()); |
| 498 | 506 |
| 499 // Move the caret as- "foo bar| baz". | 507 // Move the caret as- "foo bar| baz". |
| 500 SetSelectionRange(NSMakeRange(7, 0)); | 508 SetSelectionRange(NSMakeRange(7, 0)); |
| 501 PerformCommand(sel); | 509 PerformCommand(sel); |
| 502 // Verify state is "foo bar|". | 510 // Verify state is "foo bar|". |
| 503 EXPECT_NSEQ_3(@"foo bar", GetExpectedText(), GetActualText()); | 511 EXPECT_NSEQ_3(@"foo bar", GetExpectedText(), GetActualText()); |
| 504 EXPECT_EQ_RANGE_3(NSMakeRange(7, 0), GetExpectedSelectionRange(), | 512 EXPECT_EQ_RANGE_3(NSMakeRange(7, 0), GetExpectedSelectionRange(), |
| 505 GetActualSelectionRange()); | 513 GetActualSelectionRange()); |
| 506 | 514 |
| 507 // Make a selection as- "|foo |bar". | 515 // Make a selection as- "|foo |bar". |
| 508 SetSelectionRange(NSMakeRange(0, 4)); | 516 SetSelectionRange(NSMakeRange(0, 4)); |
| 509 PerformCommand(sel); | 517 PerformCommand(sel); |
| 510 // Verify only the selection is deleted so that the state is "|bar". | 518 // Verify only the selection is deleted so that the state is "|bar". |
| 511 EXPECT_NSEQ_3(@"bar", GetExpectedText(), GetActualText()); | 519 EXPECT_NSEQ_3(@"bar", GetExpectedText(), GetActualText()); |
| 512 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 520 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 513 GetActualSelectionRange()); | 521 GetActualSelectionRange()); |
| 522 |
| 523 // Verify yanking inserts the deleted text. |
| 524 PerformCommand(@selector(yank:)); |
| 525 EXPECT_NSEQ_3(@"foo bar", GetExpectedText(), GetActualText()); |
| 526 EXPECT_EQ_RANGE_3(NSMakeRange(4, 0), GetExpectedSelectionRange(), |
| 527 GetActualSelectionRange()); |
| 514 } | 528 } |
| 515 | 529 |
| 516 void BridgedNativeWidgetTest::TestEditingCommands(NSArray* selectors) { | 530 void BridgedNativeWidgetTest::TestEditingCommands(NSArray* selectors) { |
| 517 const base::string16 test_strings[] = { | 531 const base::string16 test_strings[] = { |
| 518 base::WideToUTF16(L"ab c"), | 532 base::WideToUTF16(L"ab c"), |
| 519 base::WideToUTF16(L"\x0634\x0632 \x064A") // RTL string. | 533 base::WideToUTF16(L"\x0634\x0632 \x064A") // RTL string. |
| 520 }; | 534 }; |
| 521 | 535 |
| 522 for (const base::string16& test_string : test_strings) { | 536 for (const base::string16& test_string : test_strings) { |
| 523 for (NSString* selector_string in selectors) { | 537 for (NSString* selector_string in selectors) { |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 InstallTextField("a"); | 904 InstallTextField("a"); |
| 891 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), | 905 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), |
| 892 GetActualSelectionRange()); | 906 GetActualSelectionRange()); |
| 893 | 907 |
| 894 // Delete one character. | 908 // Delete one character. |
| 895 PerformCommand(@selector(deleteBackward:)); | 909 PerformCommand(@selector(deleteBackward:)); |
| 896 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); | 910 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); |
| 897 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 911 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 898 GetActualSelectionRange()); | 912 GetActualSelectionRange()); |
| 899 | 913 |
| 914 // Verify that deletion did not modify the kill buffer. |
| 915 PerformCommand(@selector(yank:)); |
| 916 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); |
| 917 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 918 GetActualSelectionRange()); |
| 919 |
| 900 // Try to delete again on an empty string. | 920 // Try to delete again on an empty string. |
| 901 PerformCommand(@selector(deleteBackward:)); | 921 PerformCommand(@selector(deleteBackward:)); |
| 902 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); | 922 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); |
| 903 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 923 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 904 GetActualSelectionRange()); | 924 GetActualSelectionRange()); |
| 905 } | 925 } |
| 906 | 926 |
| 907 // Test forward delete using text input protocol. | 927 // Test forward delete using text input protocol. |
| 908 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteForward) { | 928 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteForward) { |
| 909 InstallTextField("a"); | 929 InstallTextField("a"); |
| 910 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), | 930 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), |
| 911 GetActualSelectionRange()); | 931 GetActualSelectionRange()); |
| 912 | 932 |
| 913 // At the end of the string, can't delete forward. | 933 // At the end of the string, can't delete forward. |
| 914 PerformCommand(@selector(deleteForward:)); | 934 PerformCommand(@selector(deleteForward:)); |
| 915 EXPECT_NSEQ_3(@"a", GetExpectedText(), GetActualText()); | 935 EXPECT_NSEQ_3(@"a", GetExpectedText(), GetActualText()); |
| 916 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), | 936 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), |
| 917 GetActualSelectionRange()); | 937 GetActualSelectionRange()); |
| 918 | 938 |
| 919 // Should succeed after moving left first. | 939 // Should succeed after moving left first. |
| 920 PerformCommand(@selector(moveLeft:)); | 940 PerformCommand(@selector(moveLeft:)); |
| 921 PerformCommand(@selector(deleteForward:)); | 941 PerformCommand(@selector(deleteForward:)); |
| 922 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); | 942 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); |
| 923 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 943 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 924 GetActualSelectionRange()); | 944 GetActualSelectionRange()); |
| 945 |
| 946 // Verify that deletion did not modify the kill buffer. |
| 947 PerformCommand(@selector(yank:)); |
| 948 EXPECT_NSEQ_3(nil, GetExpectedText(), GetActualText()); |
| 949 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 950 GetActualSelectionRange()); |
| 925 } | 951 } |
| 926 | 952 |
| 927 // Test forward word deletion using text input protocol. | 953 // Test forward word deletion using text input protocol. |
| 928 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteWordForward) { | 954 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteWordForward) { |
| 929 InstallTextField("foo bar baz"); | 955 InstallTextField("foo bar baz"); |
| 930 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), | 956 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), |
| 931 GetActualSelectionRange()); | 957 GetActualSelectionRange()); |
| 932 | 958 |
| 933 // Caret is at the end of the line. Verify no deletion takes place. | 959 // Caret is at the end of the line. Verify no deletion takes place. |
| 934 PerformCommand(@selector(deleteWordForward:)); | 960 PerformCommand(@selector(deleteWordForward:)); |
| 935 EXPECT_NSEQ_3(@"foo bar baz", GetExpectedText(), GetActualText()); | 961 EXPECT_NSEQ_3(@"foo bar baz", GetExpectedText(), GetActualText()); |
| 936 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), | 962 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), |
| 937 GetActualSelectionRange()); | 963 GetActualSelectionRange()); |
| 938 | 964 |
| 939 // Move the caret as- "foo b|ar baz". | 965 // Move the caret as- "foo b|ar baz". |
| 940 SetSelectionRange(NSMakeRange(5, 0)); | 966 SetSelectionRange(NSMakeRange(5, 0)); |
| 941 PerformCommand(@selector(deleteWordForward:)); | 967 PerformCommand(@selector(deleteWordForward:)); |
| 942 // Verify state is "foo b| baz" | 968 // Verify state is "foo b| baz" |
| 943 EXPECT_NSEQ_3(@"foo b baz", GetExpectedText(), GetActualText()); | 969 EXPECT_NSEQ_3(@"foo b baz", GetExpectedText(), GetActualText()); |
| 944 EXPECT_EQ_RANGE_3(NSMakeRange(5, 0), GetExpectedSelectionRange(), | 970 EXPECT_EQ_RANGE_3(NSMakeRange(5, 0), GetExpectedSelectionRange(), |
| 945 GetActualSelectionRange()); | 971 GetActualSelectionRange()); |
| 946 | 972 |
| 947 // Make a selection as- "|fo|o b baz". | 973 // Make a selection as- "|fo|o b baz". |
| 948 SetSelectionRange(NSMakeRange(0, 2)); | 974 SetSelectionRange(NSMakeRange(0, 2)); |
| 949 PerformCommand(@selector(deleteWordForward:)); | 975 PerformCommand(@selector(deleteWordForward:)); |
| 950 // Verify only the selection is deleted and state is "|o b baz". | 976 // Verify only the selection is deleted and state is "|o b baz". |
| 951 EXPECT_NSEQ_3(@"o b baz", GetExpectedText(), GetActualText()); | 977 EXPECT_NSEQ_3(@"o b baz", GetExpectedText(), GetActualText()); |
| 952 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 978 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 953 GetActualSelectionRange()); | 979 GetActualSelectionRange()); |
| 980 |
| 981 // Verify that deletion did not modify the kill buffer. |
| 982 PerformCommand(@selector(yank:)); |
| 983 EXPECT_NSEQ_3(@"o b baz", GetExpectedText(), GetActualText()); |
| 984 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 985 GetActualSelectionRange()); |
| 954 } | 986 } |
| 955 | 987 |
| 956 // Test backward word deletion using text input protocol. | 988 // Test backward word deletion using text input protocol. |
| 957 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteWordBackward) { | 989 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteWordBackward) { |
| 958 InstallTextField("foo bar baz"); | 990 InstallTextField("foo bar baz"); |
| 959 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), | 991 EXPECT_EQ_RANGE_3(NSMakeRange(11, 0), GetExpectedSelectionRange(), |
| 960 GetActualSelectionRange()); | 992 GetActualSelectionRange()); |
| 961 | 993 |
| 962 // Move the caret to the beginning of the line. | 994 // Move the caret to the beginning of the line. |
| 963 SetSelectionRange(NSMakeRange(0, 0)); | 995 SetSelectionRange(NSMakeRange(0, 0)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 975 EXPECT_EQ_RANGE_3(NSMakeRange(4, 0), GetExpectedSelectionRange(), | 1007 EXPECT_EQ_RANGE_3(NSMakeRange(4, 0), GetExpectedSelectionRange(), |
| 976 GetActualSelectionRange()); | 1008 GetActualSelectionRange()); |
| 977 | 1009 |
| 978 // Make a selection as- "f|oo r b|az". | 1010 // Make a selection as- "f|oo r b|az". |
| 979 SetSelectionRange(NSMakeRange(1, 6)); | 1011 SetSelectionRange(NSMakeRange(1, 6)); |
| 980 PerformCommand(@selector(deleteWordBackward:)); | 1012 PerformCommand(@selector(deleteWordBackward:)); |
| 981 // Verify only the selection is deleted and state is "f|az" | 1013 // Verify only the selection is deleted and state is "f|az" |
| 982 EXPECT_NSEQ_3(@"faz", GetExpectedText(), GetActualText()); | 1014 EXPECT_NSEQ_3(@"faz", GetExpectedText(), GetActualText()); |
| 983 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), | 1015 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), |
| 984 GetActualSelectionRange()); | 1016 GetActualSelectionRange()); |
| 1017 |
| 1018 // Verify that deletion did not modify the kill buffer. |
| 1019 PerformCommand(@selector(yank:)); |
| 1020 EXPECT_NSEQ_3(@"faz", GetExpectedText(), GetActualText()); |
| 1021 EXPECT_EQ_RANGE_3(NSMakeRange(1, 0), GetExpectedSelectionRange(), |
| 1022 GetActualSelectionRange()); |
| 985 } | 1023 } |
| 986 | 1024 |
| 987 // Test deleting to beginning/end of line/paragraph using text input protocol. | 1025 // Test deleting to beginning/end of line/paragraph using text input protocol. |
| 988 | 1026 |
| 989 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfLine) { | 1027 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfLine) { |
| 990 TestDeleteBeginning(@selector(deleteToBeginningOfLine:)); | 1028 TestDeleteBeginning(@selector(deleteToBeginningOfLine:)); |
| 991 } | 1029 } |
| 992 | 1030 |
| 993 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfLine) { | 1031 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfLine) { |
| 994 TestDeleteEnd(@selector(deleteToEndOfLine:)); | 1032 TestDeleteEnd(@selector(deleteToEndOfLine:)); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 [center postNotificationName:NSWindowDidExitFullScreenNotification | 1234 [center postNotificationName:NSWindowDidExitFullScreenNotification |
| 1197 object:window]; | 1235 object:window]; |
| 1198 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. | 1236 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. |
| 1199 EXPECT_FALSE(bridge()->target_fullscreen_state()); | 1237 EXPECT_FALSE(bridge()->target_fullscreen_state()); |
| 1200 | 1238 |
| 1201 widget_->CloseNow(); | 1239 widget_->CloseNow(); |
| 1202 } | 1240 } |
| 1203 | 1241 |
| 1204 } // namespace test | 1242 } // namespace test |
| 1205 } // namespace views | 1243 } // namespace views |
| OLD | NEW |