Chromium Code Reviews| 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/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #import "testing/gtest_mac.h" | 19 #import "testing/gtest_mac.h" |
| 19 #import "ui/base/cocoa/window_size_constants.h" | 20 #import "ui/base/cocoa/window_size_constants.h" |
| 20 #include "ui/base/ime/input_method.h" | 21 #include "ui/base/ime/input_method.h" |
| 21 #import "ui/gfx/mac/coordinate_conversion.h" | 22 #import "ui/gfx/mac/coordinate_conversion.h" |
| 22 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 23 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
| 23 #import "ui/views/cocoa/bridged_content_view.h" | 24 #import "ui/views/cocoa/bridged_content_view.h" |
| 24 #import "ui/views/cocoa/native_widget_mac_nswindow.h" | 25 #import "ui/views/cocoa/native_widget_mac_nswindow.h" |
| 25 #import "ui/views/cocoa/views_nswindow_delegate.h" | 26 #import "ui/views/cocoa/views_nswindow_delegate.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 Widget::InitParams init_params_; | 206 Widget::InitParams init_params_; |
| 206 }; | 207 }; |
| 207 | 208 |
| 208 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase { | 209 class BridgedNativeWidgetTest : public BridgedNativeWidgetTestBase { |
| 209 public: | 210 public: |
| 210 BridgedNativeWidgetTest(); | 211 BridgedNativeWidgetTest(); |
| 211 ~BridgedNativeWidgetTest() override; | 212 ~BridgedNativeWidgetTest() override; |
| 212 | 213 |
| 213 // Install a textfield with input type |text_input_type| in the view hierarchy | 214 // Install a textfield with input type |text_input_type| in the view hierarchy |
| 214 // and make it the text input client. Also initializes |dummy_text_view_|. | 215 // and make it the text input client. Also initializes |dummy_text_view_|. |
| 215 void InstallTextField(const std::string& text, | 216 void InstallTextField(const base::string16& text, |
| 216 ui::TextInputType text_input_type); | 217 ui::TextInputType text_input_type); |
| 217 | 218 |
| 218 // Install a textfield with input type ui::TEXT_INPUT_TYPE_TEXT in the view | 219 // Install a textfield with input type ui::TEXT_INPUT_TYPE_TEXT in the view |
| 219 // hierarchy and make it the text input client. Also initializes | 220 // hierarchy and make it the text input client. Also initializes |
| 220 // |dummy_text_view_|. | 221 // |dummy_text_view_|. |
| 222 void InstallTextField(const base::string16& text); | |
| 223 | |
| 221 void InstallTextField(const std::string& text); | 224 void InstallTextField(const std::string& text); |
| 222 | 225 |
| 223 // Returns the actual current text for |ns_view_|. | 226 // Returns the actual current text for |ns_view_|. |
| 224 NSString* GetActualText(); | 227 NSString* GetActualText(); |
| 225 | 228 |
| 226 // Returns the expected current text from |dummy_text_view_|. | 229 // Returns the expected current text from |dummy_text_view_|. |
| 227 NSString* GetExpectedText(); | 230 NSString* GetExpectedText(); |
| 228 | 231 |
| 229 // Returns the actual selection range for |ns_view_|. | 232 // Returns the actual selection range for |ns_view_|. |
| 230 NSRange GetActualSelectionRange(); | 233 NSRange GetActualSelectionRange(); |
| 231 | 234 |
| 232 // Returns the expected selection range from |dummy_text_view_|. | 235 // Returns the expected selection range from |dummy_text_view_|. |
| 233 NSRange GetExpectedSelectionRange(); | 236 NSRange GetExpectedSelectionRange(); |
| 234 | 237 |
| 235 // Set the selection range for the installed textfield and |dummy_text_view_|. | 238 // Set the selection range for the installed textfield and |dummy_text_view_|. |
| 236 void SetSelectionRange(NSRange range); | 239 void SetSelectionRange(NSRange range); |
| 237 | 240 |
| 238 // Perform command |sel| on |ns_view_| and |dummy_text_view_|. | 241 // Perform command |sel| on |ns_view_| and |dummy_text_view_|. |
| 239 void PerformCommand(SEL sel); | 242 void PerformCommand(SEL sel); |
| 240 | 243 |
| 244 // Make selection from |start| to |end| on installed textfield and | |
|
tapted
2016/05/16 05:34:41
textfield -> views::Textfield
karandeepb
2016/05/16 11:18:06
Done.
| |
| 245 // |dummy_text_view_|. If |start| > |end|, extend selection to left from | |
| 246 // |start|. | |
| 247 void MakeSelection(int start, int end); | |
| 248 | |
| 241 // testing::Test: | 249 // testing::Test: |
| 242 void SetUp() override; | 250 void SetUp() override; |
| 243 void TearDown() override; | 251 void TearDown() override; |
| 244 | 252 |
| 245 protected: | 253 protected: |
| 246 // Test delete to beginning of line or paragraph based on |sel|. |sel| can be | 254 // Test delete to beginning of line or paragraph based on |sel|. |sel| can be |
| 247 // either deleteToBeginningOfLine: or deleteToBeginningOfParagraph:. | 255 // either deleteToBeginningOfLine: or deleteToBeginningOfParagraph:. |
| 248 void TestDeleteBeginning(SEL sel); | 256 void TestDeleteBeginning(SEL sel); |
| 249 | 257 |
| 250 // Test delete to end of line or paragraph based on |sel|. |sel| can be | 258 // Test delete to end of line or paragraph based on |sel|. |sel| can be |
| 251 // either deleteToEndOfLine: or deleteToEndOfParagraph:. | 259 // either deleteToEndOfLine: or deleteToEndOfParagraph:. |
| 252 void TestDeleteEnd(SEL sel); | 260 void TestDeleteEnd(SEL sel); |
| 253 | 261 |
| 262 // Test editing commands in array |selectors| against the expectations set by | |
|
tapted
2016/05/16 05:34:40
needs to say |selectors| is an NSArray of NSString
karandeepb
2016/05/16 11:18:06
Done.
| |
| 263 // |dummy_text_view_|. | |
| 264 void TestEditingCommands(NSArray* selectors); | |
| 265 | |
| 254 std::unique_ptr<views::View> view_; | 266 std::unique_ptr<views::View> view_; |
| 255 | 267 |
| 256 // Weak. Owned by bridge(). | 268 // Weak. Owned by bridge(). |
| 257 BridgedContentView* ns_view_; | 269 BridgedContentView* ns_view_; |
| 258 | 270 |
| 259 // An NSTextView which helps set the expectations for our tests. | 271 // An NSTextView which helps set the expectations for our tests. |
| 260 base::scoped_nsobject<NSTextView> dummy_text_view_; | 272 base::scoped_nsobject<NSTextView> dummy_text_view_; |
| 261 | 273 |
| 262 base::MessageLoopForUI message_loop_; | 274 base::MessageLoopForUI message_loop_; |
| 263 | 275 |
| 264 private: | 276 private: |
| 265 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidgetTest); | 277 DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidgetTest); |
| 266 }; | 278 }; |
| 267 | 279 |
| 268 BridgedNativeWidgetTest::BridgedNativeWidgetTest() { | 280 BridgedNativeWidgetTest::BridgedNativeWidgetTest() { |
| 269 } | 281 } |
| 270 | 282 |
| 271 BridgedNativeWidgetTest::~BridgedNativeWidgetTest() { | 283 BridgedNativeWidgetTest::~BridgedNativeWidgetTest() { |
| 272 } | 284 } |
| 273 | 285 |
| 274 void BridgedNativeWidgetTest::InstallTextField( | 286 void BridgedNativeWidgetTest::InstallTextField( |
| 275 const std::string& text, | 287 const base::string16& text, |
| 276 ui::TextInputType text_input_type) { | 288 ui::TextInputType text_input_type) { |
| 277 Textfield* textfield = new Textfield(); | 289 Textfield* textfield = new Textfield(); |
| 278 textfield->SetText(ASCIIToUTF16(text)); | 290 textfield->SetText(text); |
| 279 textfield->SetTextInputType(text_input_type); | 291 textfield->SetTextInputType(text_input_type); |
| 280 view_->RemoveAllChildViews(true); | 292 view_->RemoveAllChildViews(true); |
| 281 view_->AddChildView(textfield); | 293 view_->AddChildView(textfield); |
| 282 textfield->SetBoundsRect(init_params_.bounds); | 294 textfield->SetBoundsRect(init_params_.bounds); |
| 283 | 295 |
| 284 // Request focus so the InputMethod can dispatch events to the RootView, and | 296 // Request focus so the InputMethod can dispatch events to the RootView, and |
| 285 // have them delivered to the textfield. Note that focusing a textfield | 297 // have them delivered to the textfield. Note that focusing a textfield |
| 286 // schedules a task to flash the cursor, so this requires |message_loop_|. | 298 // schedules a task to flash the cursor, so this requires |message_loop_|. |
| 287 textfield->RequestFocus(); | 299 textfield->RequestFocus(); |
| 288 | 300 |
| 289 [ns_view_ setTextInputClient:textfield]; | 301 [ns_view_ setTextInputClient:textfield]; |
| 290 | 302 |
| 291 // Initialize the dummy text view. | 303 // Initialize the dummy text view. |
| 292 dummy_text_view_.reset([[NSTextView alloc] initWithFrame:NSZeroRect]); | 304 dummy_text_view_.reset([[NSTextView alloc] initWithFrame:NSZeroRect]); |
| 293 [dummy_text_view_ setString:SysUTF8ToNSString(text)]; | 305 [dummy_text_view_ setString:SysUTF16ToNSString(text)]; |
| 306 } | |
| 307 | |
| 308 void BridgedNativeWidgetTest::InstallTextField(const base::string16& text) { | |
| 309 InstallTextField(text, ui::TEXT_INPUT_TYPE_TEXT); | |
| 294 } | 310 } |
| 295 | 311 |
| 296 void BridgedNativeWidgetTest::InstallTextField(const std::string& text) { | 312 void BridgedNativeWidgetTest::InstallTextField(const std::string& text) { |
| 297 InstallTextField(text, ui::TEXT_INPUT_TYPE_TEXT); | 313 InstallTextField(base::ASCIIToUTF16(text), ui::TEXT_INPUT_TYPE_TEXT); |
| 298 } | 314 } |
| 299 | 315 |
| 300 NSString* BridgedNativeWidgetTest::GetActualText() { | 316 NSString* BridgedNativeWidgetTest::GetActualText() { |
| 301 NSRange range = NSMakeRange(0, NSUIntegerMax); | 317 NSRange range = NSMakeRange(0, NSUIntegerMax); |
| 302 return [[ns_view_ attributedSubstringForProposedRange:range | 318 return [[ns_view_ attributedSubstringForProposedRange:range |
| 303 actualRange:nullptr] string]; | 319 actualRange:nullptr] string]; |
| 304 } | 320 } |
| 305 | 321 |
| 306 NSString* BridgedNativeWidgetTest::GetExpectedText() { | 322 NSString* BridgedNativeWidgetTest::GetExpectedText() { |
| 307 NSRange range = NSMakeRange(0, NSUIntegerMax); | 323 NSRange range = NSMakeRange(0, NSUIntegerMax); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 323 client->SetSelectionRange(gfx::Range(range)); | 339 client->SetSelectionRange(gfx::Range(range)); |
| 324 | 340 |
| 325 [dummy_text_view_ setSelectedRange:range]; | 341 [dummy_text_view_ setSelectedRange:range]; |
| 326 } | 342 } |
| 327 | 343 |
| 328 void BridgedNativeWidgetTest::PerformCommand(SEL sel) { | 344 void BridgedNativeWidgetTest::PerformCommand(SEL sel) { |
| 329 [ns_view_ doCommandBySelector:sel]; | 345 [ns_view_ doCommandBySelector:sel]; |
| 330 [dummy_text_view_ doCommandBySelector:sel]; | 346 [dummy_text_view_ doCommandBySelector:sel]; |
| 331 } | 347 } |
| 332 | 348 |
| 349 void BridgedNativeWidgetTest::MakeSelection(int start, int end) { | |
| 350 ui::TextInputClient* client = [ns_view_ textInputClient]; | |
| 351 client->SetSelectionRange(gfx::Range(start, end)); | |
| 352 | |
| 353 // NSTextView does not support specifying the selection "direction" i.e. the | |
|
tapted
2016/05/16 05:34:41
It does :)
Perhaps try [dummy_text_view_ setSelec
karandeepb
2016/05/16 11:18:06
Can't get it to work. For example consider this te
tapted
2016/05/17 04:02:57
Ah, can you update the comment then? i.e. we shoul
karandeepb
2016/05/18 01:33:18
Done.
| |
| 354 // leading edge of selection. Hence we extend the selection from |start| to | |
| 355 // |end|. | |
| 356 [dummy_text_view_ setSelectedRange:NSMakeRange(start, 0)]; | |
| 357 SEL sel = start > end ? @selector(moveBackwardAndModifySelection:) | |
| 358 : @selector(moveForwardAndModifySelection:); | |
| 359 size_t delta = std::abs(end - start); | |
| 360 | |
| 361 for (size_t i = 0; i < delta; i++) | |
| 362 [dummy_text_view_ doCommandBySelector:sel]; | |
| 363 } | |
| 364 | |
| 333 void BridgedNativeWidgetTest::SetUp() { | 365 void BridgedNativeWidgetTest::SetUp() { |
| 334 BridgedNativeWidgetTestBase::SetUp(); | 366 BridgedNativeWidgetTestBase::SetUp(); |
| 335 | 367 |
| 336 view_.reset(new views::internal::RootView(widget_.get())); | 368 view_.reset(new views::internal::RootView(widget_.get())); |
| 337 base::scoped_nsobject<NSWindow> window([test_window() retain]); | 369 base::scoped_nsobject<NSWindow> window([test_window() retain]); |
| 338 | 370 |
| 339 // BridgedNativeWidget expects to be initialized with a hidden (deferred) | 371 // BridgedNativeWidget expects to be initialized with a hidden (deferred) |
| 340 // window. | 372 // window. |
| 341 [window orderOut:nil]; | 373 [window orderOut:nil]; |
| 342 EXPECT_FALSE([window delegate]); | 374 EXPECT_FALSE([window delegate]); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 | 442 |
| 411 // Make a selection as- "|foo |bar". | 443 // Make a selection as- "|foo |bar". |
| 412 SetSelectionRange(NSMakeRange(0, 4)); | 444 SetSelectionRange(NSMakeRange(0, 4)); |
| 413 PerformCommand(sel); | 445 PerformCommand(sel); |
| 414 // Verify only the selection is deleted so that the state is "|bar". | 446 // Verify only the selection is deleted so that the state is "|bar". |
| 415 EXPECT_NSEQ_3(@"bar", GetExpectedText(), GetActualText()); | 447 EXPECT_NSEQ_3(@"bar", GetExpectedText(), GetActualText()); |
| 416 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), | 448 EXPECT_EQ_RANGE_3(NSMakeRange(0, 0), GetExpectedSelectionRange(), |
| 417 GetActualSelectionRange()); | 449 GetActualSelectionRange()); |
| 418 } | 450 } |
| 419 | 451 |
| 452 void BridgedNativeWidgetTest::TestEditingCommands(NSArray* selectors) { | |
|
tapted
2016/05/16 05:34:40
nit: comment
karandeepb
2016/05/16 11:18:07
Doesn't the comment in the class declaration suffi
tapted
2016/05/17 04:02:57
Ah, I thought this was in an anon namespace for so
karandeepb
2016/05/18 01:33:18
Done.
| |
| 453 struct { | |
| 454 const std::wstring test_string; | |
|
tapted
2016/05/16 05:34:41
string16? wstring doesn't get used much. You'll pr
karandeepb
2016/05/16 11:18:06
Done. Also a question. From what I saw, we use wst
tapted
2016/05/17 04:02:56
yeah - wchar_t has different meanings on different
| |
| 455 bool is_rtl; | |
| 456 } cases[] = {{L"abc def", false}, | |
|
tapted
2016/05/16 05:34:41
Can we get equivalent coverage by making these sho
karandeepb
2016/05/16 11:18:06
Done.
| |
| 457 {L"\x0634\x0632\x0630 \x064A\x062B\x0628", true}}; | |
| 458 | |
| 459 for (auto test_case : cases) { | |
|
tapted
2016/05/16 05:34:40
nit: const auto&
karandeepb
2016/05/16 11:18:06
Done.
| |
| 460 for (NSString* selector_string in selectors) { | |
| 461 SEL sel = NSSelectorFromString(selector_string); | |
| 462 const int len = test_case.test_string.length(); | |
| 463 for (int i = 0; i <= len; i++) { | |
| 464 for (int j = 0; j <= len; j++) { | |
| 465 SCOPED_TRACE(base::StringPrintf( | |
| 466 "Testing range [%d-%d] for case %s and selector %s\n", i, j, | |
| 467 base::WideToUTF8(test_case.test_string).c_str(), | |
| 468 base::SysNSStringToUTF8(selector_string).c_str())); | |
| 469 | |
| 470 InstallTextField(base::WideToUTF16(test_case.test_string)); | |
| 471 MakeSelection(i, j); | |
| 472 EXPECT_EQ_RANGE_3(NSMakeRange(std::min(i, j), std::abs(i - j)), | |
| 473 GetExpectedSelectionRange(), | |
| 474 GetActualSelectionRange()); | |
| 475 | |
| 476 PerformCommand(sel); | |
| 477 EXPECT_NSEQ(GetExpectedText(), GetActualText()); | |
| 478 EXPECT_EQ_RANGE(GetExpectedSelectionRange(), | |
| 479 GetActualSelectionRange()); | |
| 480 } | |
| 481 } | |
| 482 } | |
| 483 } | |
| 484 } | |
| 485 | |
| 420 // The TEST_VIEW macro expects the view it's testing to have a superview. In | 486 // The TEST_VIEW macro expects the view it's testing to have a superview. In |
| 421 // these tests, the NSView bridge is a contentView, at the root. These mimic | 487 // these tests, the NSView bridge is a contentView, at the root. These mimic |
| 422 // what TEST_VIEW usually does. | 488 // what TEST_VIEW usually does. |
| 423 TEST_F(BridgedNativeWidgetTest, BridgedNativeWidgetTest_TestViewAddRemove) { | 489 TEST_F(BridgedNativeWidgetTest, BridgedNativeWidgetTest_TestViewAddRemove) { |
| 424 base::scoped_nsobject<BridgedContentView> view([bridge()->ns_view() retain]); | 490 base::scoped_nsobject<BridgedContentView> view([bridge()->ns_view() retain]); |
| 425 EXPECT_NSEQ([test_window() contentView], view); | 491 EXPECT_NSEQ([test_window() contentView], view); |
| 426 EXPECT_NSEQ(test_window(), [view window]); | 492 EXPECT_NSEQ(test_window(), [view window]); |
| 427 | 493 |
| 428 // The superview of a contentView is an NSNextStepFrame. | 494 // The superview of a contentView is an NSNextStepFrame. |
| 429 EXPECT_TRUE([view superview]); | 495 EXPECT_TRUE([view superview]); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 PerformInit(); | 609 PerformInit(); |
| 544 EXPECT_TRUE([window_ hasShadow]); // Preserves shadow. | 610 EXPECT_TRUE([window_ hasShadow]); // Preserves shadow. |
| 545 | 611 |
| 546 window_.reset(); | 612 window_.reset(); |
| 547 widget_.reset(); | 613 widget_.reset(); |
| 548 } | 614 } |
| 549 | 615 |
| 550 // Ensure a nil NSTextInputContext is returned when the ui::TextInputClient is | 616 // Ensure a nil NSTextInputContext is returned when the ui::TextInputClient is |
| 551 // not editable, a password field, or unset. | 617 // not editable, a password field, or unset. |
| 552 TEST_F(BridgedNativeWidgetTest, InputContext) { | 618 TEST_F(BridgedNativeWidgetTest, InputContext) { |
| 553 const std::string test_string = "test_str"; | 619 const base::string16 test_string = base::ASCIIToUTF16("test_str"); |
| 554 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_PASSWORD); | 620 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_PASSWORD); |
| 555 EXPECT_FALSE([ns_view_ inputContext]); | 621 EXPECT_FALSE([ns_view_ inputContext]); |
| 556 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_TEXT); | 622 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_TEXT); |
| 557 EXPECT_TRUE([ns_view_ inputContext]); | 623 EXPECT_TRUE([ns_view_ inputContext]); |
| 558 [ns_view_ setTextInputClient:nil]; | 624 [ns_view_ setTextInputClient:nil]; |
| 559 EXPECT_FALSE([ns_view_ inputContext]); | 625 EXPECT_FALSE([ns_view_ inputContext]); |
| 560 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_NONE); | 626 InstallTextField(test_string, ui::TEXT_INPUT_TYPE_NONE); |
| 561 EXPECT_FALSE([ns_view_ inputContext]); | 627 EXPECT_FALSE([ns_view_ inputContext]); |
| 562 } | 628 } |
| 563 | 629 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 866 } | 932 } |
| 867 | 933 |
| 868 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfParagraph) { | 934 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToBeginningOfParagraph) { |
| 869 TestDeleteBeginning(@selector(deleteToBeginningOfParagraph:)); | 935 TestDeleteBeginning(@selector(deleteToBeginningOfParagraph:)); |
| 870 } | 936 } |
| 871 | 937 |
| 872 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfParagraph) { | 938 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteToEndOfParagraph) { |
| 873 TestDeleteEnd(@selector(deleteToEndOfParagraph:)); | 939 TestDeleteEnd(@selector(deleteToEndOfParagraph:)); |
| 874 } | 940 } |
| 875 | 941 |
| 942 // Test move commands against expectations set by |dummy_text_view_|. | |
| 943 TEST_F(BridgedNativeWidgetTest, TextInput_MoveEditingCommands) { | |
| 944 NSArray* selectors = @[ | |
| 945 @"moveForward:", | |
| 946 @"moveRight:", | |
| 947 @"moveBackward:", | |
| 948 @"moveLeft:", | |
| 949 @"moveUp:", | |
| 950 @"moveDown:", | |
| 951 @"moveWordForward:", | |
| 952 @"moveWordBackward:", | |
| 953 @"moveToBeginningOfLine:", | |
| 954 @"moveToEndOfLine:", | |
| 955 @"moveToBeginningOfParagraph:", | |
| 956 @"moveToEndOfParagraph:", | |
| 957 @"moveToEndOfDocument:", | |
| 958 @"moveToBeginningOfDocument:", | |
| 959 @"pageDown:", | |
| 960 @"pageUp:", | |
| 961 @"moveWordRight:", | |
| 962 @"moveWordLeft:", | |
| 963 @"moveToLeftEndOfLine:", | |
| 964 @"moveToRightEndOfLine:" | |
| 965 ]; | |
| 966 TestEditingCommands(selectors); | |
| 967 } | |
| 968 | |
| 969 // Todo(karandeepb): Enable this test once the behavior of all move and select | |
| 970 // commands are fixed. | |
| 971 // Test move and select commands against expectations set by |dummy_text_view_|. | |
| 972 TEST_F(BridgedNativeWidgetTest, | |
| 973 TextInput_MoveAndSelectEditingCommands_DISABLED) { | |
| 974 NSArray* selectors = @[ | |
| 975 @"moveBackwardAndModifySelection:", | |
| 976 @"moveForwardAndModifySelection:", | |
| 977 @"moveWordForwardAndModifySelection:", | |
| 978 @"moveWordBackwardAndModifySelection:", | |
| 979 @"moveUpAndModifySelection:", | |
| 980 @"moveDownAndModifySelection:", | |
| 981 @"moveToBeginningOfLineAndModifySelection:", | |
| 982 @"moveToEndOfLineAndModifySelection:", | |
| 983 @"moveToBeginningOfParagraphAndModifySelection:", | |
| 984 @"moveToEndOfParagraphAndModifySelection:", | |
| 985 @"moveToEndOfDocumentAndModifySelection:", | |
| 986 @"moveToBeginningOfDocumentAndModifySelection:", | |
| 987 @"pageDownAndModifySelection:", | |
| 988 @"pageUpAndModifySelection:", | |
| 989 @"moveParagraphForwardAndModifySelection:", | |
| 990 @"moveParagraphBackwardAndModifySelection:", | |
| 991 @"moveRightAndModifySelection:", | |
| 992 @"moveLeftAndModifySelection:", | |
| 993 @"moveWordRightAndModifySelection:", | |
| 994 @"moveWordLeftAndModifySelection:", | |
| 995 @"moveToLeftEndOfLineAndModifySelection:", | |
| 996 @"moveToRightEndOfLineAndModifySelection:" | |
| 997 ]; | |
| 998 TestEditingCommands(selectors); | |
| 999 } | |
| 1000 | |
| 1001 // Test delete commands against expectations set by |dummy_text_view_|. | |
| 1002 TEST_F(BridgedNativeWidgetTest, TextInput_DeleteCommands) { | |
| 1003 NSArray* selectors = @[ | |
| 1004 @"deleteForward:", @"deleteBackward:", @"deleteWordForward:", | |
| 1005 @"deleteWordBackward:", @"deleteToBeginningOfLine:", @"deleteToEndOfLine:", | |
| 1006 @"deleteToBeginningOfParagraph:", @"deleteToEndOfParagraph:" | |
| 1007 ]; | |
| 1008 TestEditingCommands(selectors); | |
| 1009 } | |
| 1010 | |
| 876 // Test firstRectForCharacterRange:actualRange for cases where query range is | 1011 // Test firstRectForCharacterRange:actualRange for cases where query range is |
| 877 // empty or outside composition range. | 1012 // empty or outside composition range. |
| 878 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { | 1013 TEST_F(BridgedNativeWidgetTest, TextInput_FirstRectForCharacterRange_Caret) { |
| 879 InstallTextField(""); | 1014 InstallTextField(""); |
| 880 ui::TextInputClient* client = [ns_view_ textInputClient]; | 1015 ui::TextInputClient* client = [ns_view_ textInputClient]; |
| 881 | 1016 |
| 882 // No composition. Ensure bounds and range corresponding to the current caret | 1017 // No composition. Ensure bounds and range corresponding to the current caret |
| 883 // position are returned. | 1018 // position are returned. |
| 884 // Initially selection range will be [0, 0]. | 1019 // Initially selection range will be [0, 0]. |
| 885 NSRange caret_range = NSMakeRange(0, 0); | 1020 NSRange caret_range = NSMakeRange(0, 0); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1030 [center postNotificationName:NSWindowDidExitFullScreenNotification | 1165 [center postNotificationName:NSWindowDidExitFullScreenNotification |
| 1031 object:window]; | 1166 object:window]; |
| 1032 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. | 1167 EXPECT_EQ(1, [window ignoredToggleFullScreenCount]); // No change. |
| 1033 EXPECT_FALSE(bridge()->target_fullscreen_state()); | 1168 EXPECT_FALSE(bridge()->target_fullscreen_state()); |
| 1034 | 1169 |
| 1035 widget_->CloseNow(); | 1170 widget_->CloseNow(); |
| 1036 } | 1171 } |
| 1037 | 1172 |
| 1038 } // namespace test | 1173 } // namespace test |
| 1039 } // namespace views | 1174 } // namespace views |
| OLD | NEW |