| Index: ui/views/cocoa/bridged_native_widget_unittest.mm
|
| diff --git a/ui/views/cocoa/bridged_native_widget_unittest.mm b/ui/views/cocoa/bridged_native_widget_unittest.mm
|
| index 6977ee80215d93ae4939a9767f33e1623d5f3703..d7c9fb97e9c18753448c70ccbfe6fe1ae3755fff 100644
|
| --- a/ui/views/cocoa/bridged_native_widget_unittest.mm
|
| +++ b/ui/views/cocoa/bridged_native_widget_unittest.mm
|
| @@ -19,6 +19,7 @@
|
| #import "testing/gtest_mac.h"
|
| #import "ui/base/cocoa/window_size_constants.h"
|
| #include "ui/base/ime/input_method.h"
|
| +#include "ui/events/test/cocoa_test_event_utils.h"
|
| #import "ui/gfx/mac/coordinate_conversion.h"
|
| #import "ui/gfx/test/ui_cocoa_test_helper.h"
|
| #import "ui/views/cocoa/bridged_content_view.h"
|
| @@ -304,6 +305,9 @@ void InstallTextField(const base::string16& text,
|
| // |start|.
|
| void MakeSelection(int start, int end);
|
|
|
| + // Helper method to set the private |keyDownEvent_| field on |ns_view_|.
|
| + void SetKeyDownEvent(NSEvent* event);
|
| +
|
| // testing::Test:
|
| void SetUp() override;
|
| void TearDown() override;
|
| @@ -426,6 +430,10 @@ void InstallTextField(const base::string16& text,
|
| [dummy_text_view_ doCommandBySelector:sel];
|
| }
|
|
|
| +void BridgedNativeWidgetTest::SetKeyDownEvent(NSEvent* event) {
|
| + [ns_view_ setValue:event forKey:@"keyDownEvent_"];
|
| +}
|
| +
|
| void BridgedNativeWidgetTest::SetUp() {
|
| BridgedNativeWidgetTestBase::SetUp();
|
|
|
| @@ -868,9 +876,12 @@ void PerformInit() {
|
| InstallTextField("abc");
|
|
|
| // Simulate action messages generated when the key 'a' is pressed repeatedly
|
| - // and leads to the showing of an IME candidate window.
|
| + // and leads to the showing of an IME candidate window. To simulate an event,
|
| + // set the private keyDownEvent field on the BridgedContentView.
|
|
|
| // First an insertText: message with key 'a' is generated.
|
| + SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
| + widget_->GetNativeWindow(), true, ui::VKEY_A, 0));
|
| [ns_view_ insertText:@"a" replacementRange:EmptyRange()];
|
| [dummy_text_view_ insertText:@"a" replacementRange:EmptyRange()];
|
| EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
|
| @@ -879,6 +890,8 @@ void PerformInit() {
|
| // Next the IME popup appears. On selecting the accented character using arrow
|
| // keys, setMarkedText action message is generated which replaces the earlier
|
| // inserted 'a'.
|
| + SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
| + widget_->GetNativeWindow(), true, ui::VKEY_RIGHT, 0));
|
| [ns_view_ setMarkedText:@"à"
|
| selectedRange:NSMakeRange(0, 1)
|
| replacementRange:NSMakeRange(3, 1)];
|
| @@ -891,6 +904,16 @@ void PerformInit() {
|
| EXPECT_EQ_RANGE_3(NSMakeRange(3, 1), GetExpectedSelectionRange(),
|
| GetActualSelectionRange());
|
| EXPECT_NSEQ_3(@"abcà", GetExpectedText(), GetActualText());
|
| +
|
| + // On pressing enter, the marked text is confirmed.
|
| + SetKeyDownEvent(cocoa_test_event_utils::SynthesizeKeyEvent(
|
| + widget_->GetNativeWindow(), true, ui::VKEY_RETURN, 0));
|
| + [ns_view_ insertText:@"à" replacementRange:EmptyRange()];
|
| + [dummy_text_view_ insertText:@"à" replacementRange:EmptyRange()];
|
| + EXPECT_EQ_3(NO, [dummy_text_view_ hasMarkedText], [ns_view_ hasMarkedText]);
|
| + EXPECT_EQ_RANGE_3(NSMakeRange(4, 0), GetExpectedSelectionRange(),
|
| + GetActualSelectionRange());
|
| + EXPECT_NSEQ_3(@"abcà", GetExpectedText(), GetActualText());
|
| }
|
|
|
| // Test moving the caret left and right using text input protocol.
|
|
|