| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "views/events/event.h" | 27 #include "views/events/event.h" |
| 28 #include "views/focus/focus_manager.h" | 28 #include "views/focus/focus_manager.h" |
| 29 #include "views/ime/mock_input_method.h" | 29 #include "views/ime/mock_input_method.h" |
| 30 #include "views/ime/text_input_client.h" | 30 #include "views/ime/text_input_client.h" |
| 31 #include "views/test/test_views_delegate.h" | 31 #include "views/test/test_views_delegate.h" |
| 32 #include "views/test/views_test_base.h" | 32 #include "views/test/views_test_base.h" |
| 33 #include "views/views_delegate.h" | 33 #include "views/views_delegate.h" |
| 34 #include "views/widget/native_widget_private.h" | 34 #include "views/widget/native_widget_private.h" |
| 35 #include "views/widget/widget.h" | 35 #include "views/widget/widget.h" |
| 36 | 36 |
| 37 // Bug http://crbug.com/99128 | |
| 38 #if defined(USE_AURA) && defined(OS_LINUX) | |
| 39 #define MAYBE_KeyTest FAILS_KeyTest | |
| 40 #define MAYBE_ControlAndSelectTest FAILS_ControlAndSelectTest | |
| 41 #define MAYBE_InsertionDeletionTest FAILS_InsertionDeletionTest | |
| 42 #define MAYBE_OnKeyPressReturnValueTest FAILS_OnKeyPressReturnValueTest | |
| 43 #define MAYBE_CursorMovement FAILS_CursorMovement | |
| 44 | |
| 45 // Drag and drop for aura in linux hasn't been implemented yet. | 37 // Drag and drop for aura in linux hasn't been implemented yet. |
| 46 // Bug http://crbug.com/97845 | 38 // Bug http://crbug.com/97845 |
| 39 #if defined(USE_AURA) && defined(OS_LINUX) |
| 47 #define MAYBE_DragAndDrop_InitiateDrag DISABLED_DragAndDrop_InitiateDrag | 40 #define MAYBE_DragAndDrop_InitiateDrag DISABLED_DragAndDrop_InitiateDrag |
| 48 #define MAYBE_DragAndDrop_ToTheLeft DISABLED_DragAndDrop_ToTheLeft | 41 #define MAYBE_DragAndDrop_ToTheLeft DISABLED_DragAndDrop_ToTheLeft |
| 49 #define MAYBE_DragAndDrop_ToTheRight DISABLED_DragAndDrop_ToTheRight | 42 #define MAYBE_DragAndDrop_ToTheRight DISABLED_DragAndDrop_ToTheRight |
| 50 #define MAYBE_DragAndDrop_Canceled DISABLED_DragAndDrop_Canceled | 43 #define MAYBE_DragAndDrop_Canceled DISABLED_DragAndDrop_Canceled |
| 51 | |
| 52 #define MAYBE_ReadOnlyTest FAILS_ReadOnlyTest | |
| 53 #define MAYBE_TextInputClientTest FAILS_TextInputClientTest | |
| 54 #define MAYBE_UndoRedoTest FAILS_UndoRedoTest | |
| 55 #define MAYBE_TextCursorDisplayTest FAILS_TextCursorDisplayTest | |
| 56 #define MAYBE_TextCursorDisplayInRTLTest FAILS_TextCursorDisplayInRTLTest | |
| 57 #define MAYBE_HitOutsideTextAreaTest FAILS_HitOutsideTextAreaTest | |
| 58 #define MAYBE_HitOutsideTextAreaInRTLTest FAILS_HitOutsideTextAreaInRTLTest | |
| 59 #define MAYBE_OverflowTest FAILS_OverflowTest | |
| 60 #define MAYBE_OverflowInRTLTest FAILS_OverflowInRTLTest | |
| 61 #else | 44 #else |
| 62 #define MAYBE_KeyTest KeyTest | |
| 63 #define MAYBE_ControlAndSelectTest ControlAndSelectTest | |
| 64 #define MAYBE_InsertionDeletionTest InsertionDeletionTest | |
| 65 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest | |
| 66 #define MAYBE_CursorMovement CursorMovement | |
| 67 #define MAYBE_DragAndDrop_InitiateDrag DragAndDrop_InitiateDrag | 45 #define MAYBE_DragAndDrop_InitiateDrag DragAndDrop_InitiateDrag |
| 68 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft | 46 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft |
| 69 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight | 47 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight |
| 70 #define MAYBE_DragAndDrop_Canceled DragAndDrop_Canceled | 48 #define MAYBE_DragAndDrop_Canceled DragAndDrop_Canceled |
| 71 #define MAYBE_ReadOnlyTest ReadOnlyTest | |
| 72 #define MAYBE_TextInputClientTest TextInputClientTest | |
| 73 #define MAYBE_UndoRedoTest UndoRedoTest | |
| 74 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest | |
| 75 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest | |
| 76 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest | |
| 77 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest | |
| 78 #define MAYBE_OverflowTest OverflowTest | |
| 79 #define MAYBE_OverflowInRTLTest OverflowInRTLTest | |
| 80 #endif // OS_LINUX && USE_AURA | 49 #endif // OS_LINUX && USE_AURA |
| 81 | 50 |
| 82 namespace { | 51 namespace { |
| 83 | 52 |
| 84 // A wrapper of Textfield to intercept the result of OnKeyPressed() and | 53 // A wrapper of Textfield to intercept the result of OnKeyPressed() and |
| 85 // OnKeyReleased() methods. | 54 // OnKeyReleased() methods. |
| 86 class TestTextfield : public views::Textfield { | 55 class TestTextfield : public views::Textfield { |
| 87 public: | 56 public: |
| 88 TestTextfield() | 57 TestTextfield() |
| 89 : key_handled_(false), | 58 : key_handled_(false), |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 EXPECT_STR_EQ("this is a test", model_->GetText()); | 341 EXPECT_STR_EQ("this is a test", model_->GetText()); |
| 373 EXPECT_STR_EQ("this is a test", textfield_->text()); | 342 EXPECT_STR_EQ("this is a test", textfield_->text()); |
| 374 EXPECT_TRUE(last_contents_.empty()); | 343 EXPECT_TRUE(last_contents_.empty()); |
| 375 | 344 |
| 376 EXPECT_EQ(string16(), textfield_->GetSelectedText()); | 345 EXPECT_EQ(string16(), textfield_->GetSelectedText()); |
| 377 textfield_->SelectAll(); | 346 textfield_->SelectAll(); |
| 378 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); | 347 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); |
| 379 EXPECT_TRUE(last_contents_.empty()); | 348 EXPECT_TRUE(last_contents_.empty()); |
| 380 } | 349 } |
| 381 | 350 |
| 382 TEST_F(NativeTextfieldViewsTest, MAYBE_KeyTest) { | 351 TEST_F(NativeTextfieldViewsTest, KeyTest) { |
| 383 InitTextfield(Textfield::STYLE_DEFAULT); | 352 InitTextfield(Textfield::STYLE_DEFAULT); |
| 384 SendKeyEvent(ui::VKEY_C, true, false); | 353 SendKeyEvent(ui::VKEY_C, true, false); |
| 385 EXPECT_STR_EQ("C", textfield_->text()); | 354 EXPECT_STR_EQ("C", textfield_->text()); |
| 386 EXPECT_STR_EQ("C", last_contents_); | 355 EXPECT_STR_EQ("C", last_contents_); |
| 387 last_contents_.clear(); | 356 last_contents_.clear(); |
| 388 | 357 |
| 389 SendKeyEvent(ui::VKEY_R, false, false); | 358 SendKeyEvent(ui::VKEY_R, false, false); |
| 390 EXPECT_STR_EQ("Cr", textfield_->text()); | 359 EXPECT_STR_EQ("Cr", textfield_->text()); |
| 391 EXPECT_STR_EQ("Cr", last_contents_); | 360 EXPECT_STR_EQ("Cr", last_contents_); |
| 392 | 361 |
| 393 textfield_->SetText(ASCIIToUTF16("")); | 362 textfield_->SetText(ASCIIToUTF16("")); |
| 394 SendKeyEvent(ui::VKEY_C, true, false, true); | 363 SendKeyEvent(ui::VKEY_C, true, false, true); |
| 395 SendKeyEvent(ui::VKEY_C, false, false, true); | 364 SendKeyEvent(ui::VKEY_C, false, false, true); |
| 396 SendKeyEvent(ui::VKEY_1, false, false, true); | 365 SendKeyEvent(ui::VKEY_1, false, false, true); |
| 397 SendKeyEvent(ui::VKEY_1, true, false, true); | 366 SendKeyEvent(ui::VKEY_1, true, false, true); |
| 398 SendKeyEvent(ui::VKEY_1, true, false, false); | 367 SendKeyEvent(ui::VKEY_1, true, false, false); |
| 399 EXPECT_STR_EQ("cC1!!", textfield_->text()); | 368 EXPECT_STR_EQ("cC1!!", textfield_->text()); |
| 400 EXPECT_STR_EQ("cC1!!", last_contents_); | 369 EXPECT_STR_EQ("cC1!!", last_contents_); |
| 401 } | 370 } |
| 402 | 371 |
| 403 TEST_F(NativeTextfieldViewsTest, MAYBE_ControlAndSelectTest) { | 372 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) { |
| 404 // Insert a test string in a textfield. | 373 // Insert a test string in a textfield. |
| 405 InitTextfield(Textfield::STYLE_DEFAULT); | 374 InitTextfield(Textfield::STYLE_DEFAULT); |
| 406 textfield_->SetText(ASCIIToUTF16("one two three")); | 375 textfield_->SetText(ASCIIToUTF16("one two three")); |
| 407 SendKeyEvent(ui::VKEY_RIGHT, | 376 SendKeyEvent(ui::VKEY_RIGHT, |
| 408 true /* shift */, false /* control */); | 377 true /* shift */, false /* control */); |
| 409 SendKeyEvent(ui::VKEY_RIGHT, true, false); | 378 SendKeyEvent(ui::VKEY_RIGHT, true, false); |
| 410 SendKeyEvent(ui::VKEY_RIGHT, true, false); | 379 SendKeyEvent(ui::VKEY_RIGHT, true, false); |
| 411 | 380 |
| 412 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); | 381 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); |
| 413 | 382 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 428 SendKeyEvent(ui::VKEY_O, true, false); | 397 SendKeyEvent(ui::VKEY_O, true, false); |
| 429 SendKeyEvent(ui::VKEY_SPACE, false, false); | 398 SendKeyEvent(ui::VKEY_SPACE, false, false); |
| 430 EXPECT_STR_EQ("ZERO two three", textfield_->text()); | 399 EXPECT_STR_EQ("ZERO two three", textfield_->text()); |
| 431 | 400 |
| 432 SendKeyEvent(ui::VKEY_END, true, false); | 401 SendKeyEvent(ui::VKEY_END, true, false); |
| 433 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); | 402 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); |
| 434 SendKeyEvent(ui::VKEY_HOME, true, false); | 403 SendKeyEvent(ui::VKEY_HOME, true, false); |
| 435 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); | 404 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); |
| 436 } | 405 } |
| 437 | 406 |
| 438 TEST_F(NativeTextfieldViewsTest, MAYBE_InsertionDeletionTest) { | 407 TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) { |
| 439 // Insert a test string in a textfield. | 408 // Insert a test string in a textfield. |
| 440 InitTextfield(Textfield::STYLE_DEFAULT); | 409 InitTextfield(Textfield::STYLE_DEFAULT); |
| 441 char test_str[] = "this is a test"; | 410 char test_str[] = "this is a test"; |
| 442 for (size_t i = 0; i < sizeof(test_str); i++) { | 411 for (size_t i = 0; i < sizeof(test_str); i++) { |
| 443 // This is ugly and should be replaced by a utility standard function. | 412 // This is ugly and should be replaced by a utility standard function. |
| 444 // See comment in NativeTextfieldViews::GetPrintableChar. | 413 // See comment in NativeTextfieldViews::GetPrintableChar. |
| 445 char c = test_str[i]; | 414 char c = test_str[i]; |
| 446 ui::KeyboardCode code = | 415 ui::KeyboardCode code = |
| 447 c == ' ' ? ui::VKEY_SPACE : | 416 c == ' ' ? ui::VKEY_SPACE : |
| 448 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); | 417 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); | 526 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); |
| 558 | 527 |
| 559 textfield_->SetReadOnly(false); | 528 textfield_->SetReadOnly(false); |
| 560 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, GetTextInputType()); | 529 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, GetTextInputType()); |
| 561 | 530 |
| 562 // As do disabled textfields | 531 // As do disabled textfields |
| 563 textfield_->SetEnabled(false); | 532 textfield_->SetEnabled(false); |
| 564 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); | 533 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); |
| 565 } | 534 } |
| 566 | 535 |
| 567 TEST_F(NativeTextfieldViewsTest, MAYBE_OnKeyPressReturnValueTest) { | 536 TEST_F(NativeTextfieldViewsTest, OnKeyPressReturnValueTest) { |
| 568 InitTextfield(Textfield::STYLE_DEFAULT); | 537 InitTextfield(Textfield::STYLE_DEFAULT); |
| 569 | 538 |
| 570 // Character keys will be handled by input method. | 539 // Character keys will be handled by input method. |
| 571 SendKeyEvent(ui::VKEY_A); | 540 SendKeyEvent(ui::VKEY_A); |
| 572 EXPECT_TRUE(textfield_->key_received()); | 541 EXPECT_TRUE(textfield_->key_received()); |
| 573 EXPECT_FALSE(textfield_->key_handled()); | 542 EXPECT_FALSE(textfield_->key_handled()); |
| 574 textfield_->clear(); | 543 textfield_->clear(); |
| 575 | 544 |
| 576 // Home will be handled. | 545 // Home will be handled. |
| 577 SendKeyEvent(ui::VKEY_HOME); | 546 SendKeyEvent(ui::VKEY_HOME); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 588 SendKeyEvent(ui::VKEY_UP); | 557 SendKeyEvent(ui::VKEY_UP); |
| 589 EXPECT_TRUE(textfield_->key_received()); | 558 EXPECT_TRUE(textfield_->key_received()); |
| 590 EXPECT_FALSE(textfield_->key_handled()); | 559 EXPECT_FALSE(textfield_->key_handled()); |
| 591 textfield_->clear(); | 560 textfield_->clear(); |
| 592 | 561 |
| 593 SendKeyEvent(ui::VKEY_DOWN); | 562 SendKeyEvent(ui::VKEY_DOWN); |
| 594 EXPECT_TRUE(textfield_->key_received()); | 563 EXPECT_TRUE(textfield_->key_received()); |
| 595 EXPECT_FALSE(textfield_->key_handled()); | 564 EXPECT_FALSE(textfield_->key_handled()); |
| 596 } | 565 } |
| 597 | 566 |
| 598 TEST_F(NativeTextfieldViewsTest, MAYBE_CursorMovement) { | 567 TEST_F(NativeTextfieldViewsTest, CursorMovement) { |
| 599 InitTextfield(Textfield::STYLE_DEFAULT); | 568 InitTextfield(Textfield::STYLE_DEFAULT); |
| 600 | 569 |
| 601 // Test with trailing whitespace. | 570 // Test with trailing whitespace. |
| 602 textfield_->SetText(ASCIIToUTF16("one two hre ")); | 571 textfield_->SetText(ASCIIToUTF16("one two hre ")); |
| 603 | 572 |
| 604 // Send the cursor at the end. | 573 // Send the cursor at the end. |
| 605 SendKeyEvent(ui::VKEY_END); | 574 SendKeyEvent(ui::VKEY_END); |
| 606 | 575 |
| 607 // Ctrl+Left should move the cursor just before the last word. | 576 // Ctrl+Left should move the cursor just before the last word. |
| 608 SendKeyEvent(ui::VKEY_LEFT, false, true); | 577 SendKeyEvent(ui::VKEY_LEFT, false, true); |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 ui::EF_LEFT_BUTTON_DOWN); | 952 ui::EF_LEFT_BUTTON_DOWN); |
| 984 MouseEvent release(ui::ET_MOUSE_RELEASED, GetCursorPositionX(9), 0, | 953 MouseEvent release(ui::ET_MOUSE_RELEASED, GetCursorPositionX(9), 0, |
| 985 ui::EF_LEFT_BUTTON_DOWN); | 954 ui::EF_LEFT_BUTTON_DOWN); |
| 986 textfield_view_->OnMouseDragged(drag); | 955 textfield_view_->OnMouseDragged(drag); |
| 987 textfield_view_->OnMouseReleased(release); | 956 textfield_view_->OnMouseReleased(release); |
| 988 textfield_view_->OnDragDone(); | 957 textfield_view_->OnDragDone(); |
| 989 EXPECT_EQ(ASCIIToUTF16("hello world"), textfield_->text()); | 958 EXPECT_EQ(ASCIIToUTF16("hello world"), textfield_->text()); |
| 990 } | 959 } |
| 991 #endif | 960 #endif |
| 992 | 961 |
| 993 TEST_F(NativeTextfieldViewsTest, MAYBE_ReadOnlyTest) { | 962 TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) { |
| 994 InitTextfield(Textfield::STYLE_DEFAULT); | 963 InitTextfield(Textfield::STYLE_DEFAULT); |
| 995 textfield_->SetText(ASCIIToUTF16(" one two three ")); | 964 textfield_->SetText(ASCIIToUTF16(" one two three ")); |
| 996 textfield_->SetReadOnly(true); | 965 textfield_->SetReadOnly(true); |
| 997 SendKeyEvent(ui::VKEY_HOME); | 966 SendKeyEvent(ui::VKEY_HOME); |
| 998 EXPECT_EQ(0U, textfield_->GetCursorPosition()); | 967 EXPECT_EQ(0U, textfield_->GetCursorPosition()); |
| 999 | 968 |
| 1000 SendKeyEvent(ui::VKEY_END); | 969 SendKeyEvent(ui::VKEY_END); |
| 1001 EXPECT_EQ(15U, textfield_->GetCursorPosition()); | 970 EXPECT_EQ(15U, textfield_->GetCursorPosition()); |
| 1002 | 971 |
| 1003 SendKeyEvent(ui::VKEY_LEFT, false, false); | 972 SendKeyEvent(ui::VKEY_LEFT, false, false); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 | 1009 |
| 1041 // Text field is unmodifiable and selection shouldn't change. | 1010 // Text field is unmodifiable and selection shouldn't change. |
| 1042 SendKeyEvent(ui::VKEY_DELETE); | 1011 SendKeyEvent(ui::VKEY_DELETE); |
| 1043 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 1012 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
| 1044 SendKeyEvent(ui::VKEY_BACK); | 1013 SendKeyEvent(ui::VKEY_BACK); |
| 1045 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 1014 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
| 1046 SendKeyEvent(ui::VKEY_T); | 1015 SendKeyEvent(ui::VKEY_T); |
| 1047 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 1016 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
| 1048 } | 1017 } |
| 1049 | 1018 |
| 1050 TEST_F(NativeTextfieldViewsTest, MAYBE_TextInputClientTest) { | 1019 TEST_F(NativeTextfieldViewsTest, TextInputClientTest) { |
| 1051 InitTextfield(Textfield::STYLE_DEFAULT); | 1020 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1052 TextInputClient* client = textfield_->GetTextInputClient(); | 1021 TextInputClient* client = textfield_->GetTextInputClient(); |
| 1053 EXPECT_TRUE(client); | 1022 EXPECT_TRUE(client); |
| 1054 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); | 1023 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); |
| 1055 | 1024 |
| 1056 textfield_->SetText(ASCIIToUTF16("0123456789")); | 1025 textfield_->SetText(ASCIIToUTF16("0123456789")); |
| 1057 ui::Range range; | 1026 ui::Range range; |
| 1058 EXPECT_TRUE(client->GetTextRange(&range)); | 1027 EXPECT_TRUE(client->GetTextRange(&range)); |
| 1059 EXPECT_EQ(0U, range.start()); | 1028 EXPECT_EQ(0U, range.start()); |
| 1060 EXPECT_EQ(10U, range.end()); | 1029 EXPECT_EQ(10U, range.end()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1099 EXPECT_TRUE(input_method_->text_input_type_changed()); |
| 1131 EXPECT_FALSE(textfield_->GetTextInputClient()); | 1100 EXPECT_FALSE(textfield_->GetTextInputClient()); |
| 1132 | 1101 |
| 1133 textfield_->SetReadOnly(false); | 1102 textfield_->SetReadOnly(false); |
| 1134 input_method_->Clear(); | 1103 input_method_->Clear(); |
| 1135 textfield_->SetPassword(true); | 1104 textfield_->SetPassword(true); |
| 1136 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1105 EXPECT_TRUE(input_method_->text_input_type_changed()); |
| 1137 EXPECT_TRUE(textfield_->GetTextInputClient()); | 1106 EXPECT_TRUE(textfield_->GetTextInputClient()); |
| 1138 } | 1107 } |
| 1139 | 1108 |
| 1140 TEST_F(NativeTextfieldViewsTest, MAYBE_UndoRedoTest) { | 1109 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) { |
| 1141 InitTextfield(Textfield::STYLE_DEFAULT); | 1110 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1142 SendKeyEvent(ui::VKEY_A); | 1111 SendKeyEvent(ui::VKEY_A); |
| 1143 EXPECT_STR_EQ("a", textfield_->text()); | 1112 EXPECT_STR_EQ("a", textfield_->text()); |
| 1144 SendKeyEvent(ui::VKEY_Z, false, true); | 1113 SendKeyEvent(ui::VKEY_Z, false, true); |
| 1145 EXPECT_STR_EQ("", textfield_->text()); | 1114 EXPECT_STR_EQ("", textfield_->text()); |
| 1146 SendKeyEvent(ui::VKEY_Z, false, true); | 1115 SendKeyEvent(ui::VKEY_Z, false, true); |
| 1147 EXPECT_STR_EQ("", textfield_->text()); | 1116 EXPECT_STR_EQ("", textfield_->text()); |
| 1148 SendKeyEvent(ui::VKEY_Y, false, true); | 1117 SendKeyEvent(ui::VKEY_Y, false, true); |
| 1149 EXPECT_STR_EQ("a", textfield_->text()); | 1118 EXPECT_STR_EQ("a", textfield_->text()); |
| 1150 SendKeyEvent(ui::VKEY_Y, false, true); | 1119 SendKeyEvent(ui::VKEY_Y, false, true); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 SendKeyEvent(ui::VKEY_A); | 1207 SendKeyEvent(ui::VKEY_A); |
| 1239 EXPECT_STR_EQ("a23", textfield_->text()); | 1208 EXPECT_STR_EQ("a23", textfield_->text()); |
| 1240 SendKeyEvent(ui::VKEY_B); | 1209 SendKeyEvent(ui::VKEY_B); |
| 1241 EXPECT_STR_EQ("ab3", textfield_->text()); | 1210 EXPECT_STR_EQ("ab3", textfield_->text()); |
| 1242 SendKeyEvent(ui::VKEY_Z, false, true); | 1211 SendKeyEvent(ui::VKEY_Z, false, true); |
| 1243 EXPECT_STR_EQ("123", textfield_->text()); | 1212 EXPECT_STR_EQ("123", textfield_->text()); |
| 1244 SendKeyEvent(ui::VKEY_Y, false, true); | 1213 SendKeyEvent(ui::VKEY_Y, false, true); |
| 1245 EXPECT_STR_EQ("ab3", textfield_->text()); | 1214 EXPECT_STR_EQ("ab3", textfield_->text()); |
| 1246 } | 1215 } |
| 1247 | 1216 |
| 1248 TEST_F(NativeTextfieldViewsTest, MAYBE_TextCursorDisplayTest) { | 1217 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) { |
| 1249 InitTextfield(Textfield::STYLE_DEFAULT); | 1218 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1250 // LTR-RTL string in LTR context. | 1219 // LTR-RTL string in LTR context. |
| 1251 SendKeyEvent('a'); | 1220 SendKeyEvent('a'); |
| 1252 EXPECT_STR_EQ("a", textfield_->text()); | 1221 EXPECT_STR_EQ("a", textfield_->text()); |
| 1253 int x = GetCursorBounds().x(); | 1222 int x = GetCursorBounds().x(); |
| 1254 int prev_x = x; | 1223 int prev_x = x; |
| 1255 | 1224 |
| 1256 SendKeyEvent('b'); | 1225 SendKeyEvent('b'); |
| 1257 EXPECT_STR_EQ("ab", textfield_->text()); | 1226 EXPECT_STR_EQ("ab", textfield_->text()); |
| 1258 x = GetCursorBounds().x(); | 1227 x = GetCursorBounds().x(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 x = GetCursorBounds().x(); | 1259 x = GetCursorBounds().x(); |
| 1291 EXPECT_LT(prev_x, x); | 1260 EXPECT_LT(prev_x, x); |
| 1292 prev_x = x; | 1261 prev_x = x; |
| 1293 | 1262 |
| 1294 SendKeyEvent('b'); | 1263 SendKeyEvent('b'); |
| 1295 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); | 1264 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); |
| 1296 x = GetCursorBounds().x(); | 1265 x = GetCursorBounds().x(); |
| 1297 EXPECT_LT(prev_x, x); | 1266 EXPECT_LT(prev_x, x); |
| 1298 } | 1267 } |
| 1299 | 1268 |
| 1300 TEST_F(NativeTextfieldViewsTest, MAYBE_TextCursorDisplayInRTLTest) { | 1269 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayInRTLTest) { |
| 1301 std::string locale = l10n_util::GetApplicationLocale(""); | 1270 std::string locale = l10n_util::GetApplicationLocale(""); |
| 1302 base::i18n::SetICUDefaultLocale("he"); | 1271 base::i18n::SetICUDefaultLocale("he"); |
| 1303 | 1272 |
| 1304 InitTextfield(Textfield::STYLE_DEFAULT); | 1273 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1305 // LTR-RTL string in RTL context. | 1274 // LTR-RTL string in RTL context. |
| 1306 SendKeyEvent('a'); | 1275 SendKeyEvent('a'); |
| 1307 EXPECT_STR_EQ("a", textfield_->text()); | 1276 EXPECT_STR_EQ("a", textfield_->text()); |
| 1308 int x = GetCursorBounds().x(); | 1277 int x = GetCursorBounds().x(); |
| 1309 EXPECT_EQ(GetDisplayRect().right() - 1, x); | 1278 EXPECT_EQ(GetDisplayRect().right() - 1, x); |
| 1310 int prev_x = x; | 1279 int prev_x = x; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1408 // for the test to run if using sleep(). | 1377 // for the test to run if using sleep(). |
| 1409 NonClientMouseClick(); | 1378 NonClientMouseClick(); |
| 1410 | 1379 |
| 1411 MouseClick(cursor_bounds[i + 1], - (half_width / 2)); | 1380 MouseClick(cursor_bounds[i + 1], - (half_width / 2)); |
| 1412 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); | 1381 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); |
| 1413 | 1382 |
| 1414 NonClientMouseClick(); | 1383 NonClientMouseClick(); |
| 1415 } | 1384 } |
| 1416 } | 1385 } |
| 1417 | 1386 |
| 1418 TEST_F(NativeTextfieldViewsTest, MAYBE_HitOutsideTextAreaTest) { | 1387 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaTest) { |
| 1419 InitTextfield(Textfield::STYLE_DEFAULT); | 1388 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1420 | 1389 |
| 1421 // LTR-RTL string in LTR context. | 1390 // LTR-RTL string in LTR context. |
| 1422 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); | 1391 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); |
| 1423 | 1392 |
| 1424 SendKeyEvent(ui::VKEY_HOME); | 1393 SendKeyEvent(ui::VKEY_HOME); |
| 1425 gfx::Rect bound = GetCursorBounds(); | 1394 gfx::Rect bound = GetCursorBounds(); |
| 1426 MouseClick(bound, -10); | 1395 MouseClick(bound, -10); |
| 1427 EXPECT_EQ(bound, GetCursorBounds()); | 1396 EXPECT_EQ(bound, GetCursorBounds()); |
| 1428 | 1397 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1448 SendKeyEvent(ui::VKEY_END); | 1417 SendKeyEvent(ui::VKEY_END); |
| 1449 bound = GetCursorBounds(); | 1418 bound = GetCursorBounds(); |
| 1450 #if defined(OS_WIN) | 1419 #if defined(OS_WIN) |
| 1451 MouseClick(bound, 10); | 1420 MouseClick(bound, 10); |
| 1452 #else | 1421 #else |
| 1453 MouseClick(bound, -10); | 1422 MouseClick(bound, -10); |
| 1454 #endif | 1423 #endif |
| 1455 EXPECT_EQ(bound, GetCursorBounds()); | 1424 EXPECT_EQ(bound, GetCursorBounds()); |
| 1456 } | 1425 } |
| 1457 | 1426 |
| 1458 TEST_F(NativeTextfieldViewsTest, MAYBE_HitOutsideTextAreaInRTLTest) { | 1427 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaInRTLTest) { |
| 1459 std::string locale = l10n_util::GetApplicationLocale(""); | 1428 std::string locale = l10n_util::GetApplicationLocale(""); |
| 1460 base::i18n::SetICUDefaultLocale("he"); | 1429 base::i18n::SetICUDefaultLocale("he"); |
| 1461 | 1430 |
| 1462 InitTextfield(Textfield::STYLE_DEFAULT); | 1431 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1463 | 1432 |
| 1464 // RTL-LTR string in RTL context. | 1433 // RTL-LTR string in RTL context. |
| 1465 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); | 1434 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); |
| 1466 SendKeyEvent(ui::VKEY_HOME); | 1435 SendKeyEvent(ui::VKEY_HOME); |
| 1467 gfx::Rect bound = GetCursorBounds(); | 1436 gfx::Rect bound = GetCursorBounds(); |
| 1468 MouseClick(bound, 10); | 1437 MouseClick(bound, 10); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1502 // This verifies that |bound| is contained by |display|. |bound|'s right edge | 1471 // This verifies that |bound| is contained by |display|. |bound|'s right edge |
| 1503 // must be less than |diaplay|'s right edge. | 1472 // must be less than |diaplay|'s right edge. |
| 1504 void OverflowCursorBoundTestVerifier(const gfx::Rect& display, | 1473 void OverflowCursorBoundTestVerifier(const gfx::Rect& display, |
| 1505 const gfx::Rect& bound) { | 1474 const gfx::Rect& bound) { |
| 1506 EXPECT_LE(display.x(), bound.x()); | 1475 EXPECT_LE(display.x(), bound.x()); |
| 1507 EXPECT_GT(display.right(), bound.right()); | 1476 EXPECT_GT(display.right(), bound.right()); |
| 1508 EXPECT_LE(display.y(), bound.y()); | 1477 EXPECT_LE(display.y(), bound.y()); |
| 1509 EXPECT_GE(display.bottom(), bound.bottom()); | 1478 EXPECT_GE(display.bottom(), bound.bottom()); |
| 1510 } | 1479 } |
| 1511 | 1480 |
| 1512 TEST_F(NativeTextfieldViewsTest, MAYBE_OverflowTest) { | 1481 TEST_F(NativeTextfieldViewsTest, OverflowTest) { |
| 1513 InitTextfield(Textfield::STYLE_DEFAULT); | 1482 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1514 | 1483 |
| 1515 string16 str; | 1484 string16 str; |
| 1516 for (int i = 0; i < 500; ++i) | 1485 for (int i = 0; i < 500; ++i) |
| 1517 SendKeyEvent('a'); | 1486 SendKeyEvent('a'); |
| 1518 SendKeyEvent(kHebrewLetterSamekh); | 1487 SendKeyEvent(kHebrewLetterSamekh); |
| 1519 gfx::Rect bound = GetCursorBounds(); | 1488 gfx::Rect bound = GetCursorBounds(); |
| 1520 gfx::Rect display = GetDisplayRect(); | 1489 gfx::Rect display = GetDisplayRect(); |
| 1521 OverflowCursorBoundTestVerifier(display, bound); | 1490 OverflowCursorBoundTestVerifier(display, bound); |
| 1522 | 1491 |
| 1523 // Test mouse pointing. | 1492 // Test mouse pointing. |
| 1524 MouseClick(bound, -1); | 1493 MouseClick(bound, -1); |
| 1525 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1494 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
| 1526 | 1495 |
| 1527 // Clear text. | 1496 // Clear text. |
| 1528 SendKeyEvent(ui::VKEY_A, false, true); | 1497 SendKeyEvent(ui::VKEY_A, false, true); |
| 1529 SendKeyEvent('\n'); | 1498 SendKeyEvent('\n'); |
| 1530 | 1499 |
| 1531 for (int i = 0; i < 500; ++i) | 1500 for (int i = 0; i < 500; ++i) |
| 1532 SendKeyEvent(kHebrewLetterSamekh); | 1501 SendKeyEvent(kHebrewLetterSamekh); |
| 1533 SendKeyEvent('a'); | 1502 SendKeyEvent('a'); |
| 1534 bound = GetCursorBounds(); | 1503 bound = GetCursorBounds(); |
| 1535 display = GetDisplayRect(); | 1504 display = GetDisplayRect(); |
| 1536 OverflowCursorBoundTestVerifier(display, bound); | 1505 OverflowCursorBoundTestVerifier(display, bound); |
| 1537 | 1506 |
| 1538 MouseClick(bound, -1); | 1507 MouseClick(bound, -1); |
| 1539 EXPECT_EQ(501U, textfield_->GetCursorPosition()); | 1508 EXPECT_EQ(501U, textfield_->GetCursorPosition()); |
| 1540 } | 1509 } |
| 1541 | 1510 |
| 1542 TEST_F(NativeTextfieldViewsTest, MAYBE_OverflowInRTLTest) { | 1511 TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) { |
| 1543 std::string locale = l10n_util::GetApplicationLocale(""); | 1512 std::string locale = l10n_util::GetApplicationLocale(""); |
| 1544 base::i18n::SetICUDefaultLocale("he"); | 1513 base::i18n::SetICUDefaultLocale("he"); |
| 1545 | 1514 |
| 1546 InitTextfield(Textfield::STYLE_DEFAULT); | 1515 InitTextfield(Textfield::STYLE_DEFAULT); |
| 1547 | 1516 |
| 1548 string16 str; | 1517 string16 str; |
| 1549 for (int i = 0; i < 500; ++i) | 1518 for (int i = 0; i < 500; ++i) |
| 1550 SendKeyEvent('a'); | 1519 SendKeyEvent('a'); |
| 1551 SendKeyEvent(kHebrewLetterSamekh); | 1520 SendKeyEvent(kHebrewLetterSamekh); |
| 1552 gfx::Rect bound = GetCursorBounds(); | 1521 gfx::Rect bound = GetCursorBounds(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1575 EXPECT_EQ(0U, textfield_->GetCursorPosition()); | 1544 EXPECT_EQ(0U, textfield_->GetCursorPosition()); |
| 1576 #else | 1545 #else |
| 1577 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1546 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
| 1578 #endif | 1547 #endif |
| 1579 | 1548 |
| 1580 // Reset locale. | 1549 // Reset locale. |
| 1581 base::i18n::SetICUDefaultLocale(locale); | 1550 base::i18n::SetICUDefaultLocale(locale); |
| 1582 } | 1551 } |
| 1583 | 1552 |
| 1584 } // namespace views | 1553 } // namespace views |
| OLD | NEW |