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 99128. | |
oshima
2011/10/05 21:02:19
Can you keep the comment and say still a lot of te
sadrul
2011/10/05 21:44:56
FYI http://codereview.chromium.org/8143021/
Some
msw
2011/10/05 22:52:20
I merged with your changes from http://codereview.
| |
38 #if defined(USE_AURA) | |
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 #define MAYBE_DragAndDrop_ToTheRight FAILS_DragAndDrop_ToTheRight | |
45 #define MAYBE_DragAndDrop_ToTheLeft FAILS_DragAndDrop_ToTheLeft | |
46 #define MAYBE_ReadOnlyTest FAILS_ReadOnlyTest | |
47 #define MAYBE_TextInputClientTest FAILS_TextInputClientTest | |
48 #define MAYBE_UndoRedoTest FAILS_UndoRedoTest | |
49 #define MAYBE_TextCursorDisplayTest FAILS_TextCursorDisplayTest | |
50 #define MAYBE_TextCursorDisplayInRTLTest FAILS_TextCursorDisplayInRTLTest | |
51 #define MAYBE_HitOutsideTextAreaTest FAILS_HitOutsideTextAreaTest | |
52 #define MAYBE_HitOutsideTextAreaInRTLTest FAILS_HitOutsideTextAreaInRTLTest | |
53 #define MAYBE_OverflowTest FAILS_OverflowTest | |
54 #define MAYBE_OverflowInRTLTest FAILS_OverflowInRTLTest | |
55 #else | |
56 #define MAYBE_KeyTest KeyTest | |
57 #define MAYBE_ControlAndSelectTest ControlAndSelectTest | |
58 #define MAYBE_InsertionDeletionTest InsertionDeletionTest | |
59 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest | |
60 #define MAYBE_CursorMovement CursorMovement | |
61 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight | |
62 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft | |
63 #define MAYBE_ReadOnlyTest ReadOnlyTest | |
64 #define MAYBE_TextInputClientTest TextInputClientTest | |
65 #define MAYBE_UndoRedoTest UndoRedoTest | |
66 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest | |
67 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest | |
68 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest | |
69 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest | |
70 #define MAYBE_OverflowTest OverflowTest | |
71 #define MAYBE_OverflowInRTLTest OverflowInRTLTest | |
72 #endif | |
73 | |
74 namespace { | 37 namespace { |
75 | 38 |
76 // A wrapper of Textfield to intercept the result of OnKeyPressed() and | 39 // A wrapper of Textfield to intercept the result of OnKeyPressed() and |
77 // OnKeyReleased() methods. | 40 // OnKeyReleased() methods. |
78 class TestTextfield : public views::Textfield { | 41 class TestTextfield : public views::Textfield { |
79 public: | 42 public: |
80 TestTextfield() | 43 TestTextfield() |
81 : key_handled_(false), | 44 : key_handled_(false), |
82 key_received_(false) { | 45 key_received_(false) { |
83 } | 46 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 EXPECT_STR_EQ("this is a test", model_->GetText()); | 327 EXPECT_STR_EQ("this is a test", model_->GetText()); |
365 EXPECT_STR_EQ("this is a test", textfield_->text()); | 328 EXPECT_STR_EQ("this is a test", textfield_->text()); |
366 EXPECT_TRUE(last_contents_.empty()); | 329 EXPECT_TRUE(last_contents_.empty()); |
367 | 330 |
368 EXPECT_EQ(string16(), textfield_->GetSelectedText()); | 331 EXPECT_EQ(string16(), textfield_->GetSelectedText()); |
369 textfield_->SelectAll(); | 332 textfield_->SelectAll(); |
370 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); | 333 EXPECT_STR_EQ("this is a test", textfield_->GetSelectedText()); |
371 EXPECT_TRUE(last_contents_.empty()); | 334 EXPECT_TRUE(last_contents_.empty()); |
372 } | 335 } |
373 | 336 |
374 TEST_F(NativeTextfieldViewsTest, MAYBE_KeyTest) { | 337 TEST_F(NativeTextfieldViewsTest, KeyTest) { |
375 InitTextfield(Textfield::STYLE_DEFAULT); | 338 InitTextfield(Textfield::STYLE_DEFAULT); |
376 SendKeyEvent(ui::VKEY_C, true, false); | 339 SendKeyEvent(ui::VKEY_C, true, false); |
377 EXPECT_STR_EQ("C", textfield_->text()); | 340 EXPECT_STR_EQ("C", textfield_->text()); |
378 EXPECT_STR_EQ("C", last_contents_); | 341 EXPECT_STR_EQ("C", last_contents_); |
379 last_contents_.clear(); | 342 last_contents_.clear(); |
380 | 343 |
381 SendKeyEvent(ui::VKEY_R, false, false); | 344 SendKeyEvent(ui::VKEY_R, false, false); |
382 EXPECT_STR_EQ("Cr", textfield_->text()); | 345 EXPECT_STR_EQ("Cr", textfield_->text()); |
383 EXPECT_STR_EQ("Cr", last_contents_); | 346 EXPECT_STR_EQ("Cr", last_contents_); |
384 | 347 |
385 textfield_->SetText(ASCIIToUTF16("")); | 348 textfield_->SetText(ASCIIToUTF16("")); |
386 SendKeyEvent(ui::VKEY_C, true, false, true); | 349 SendKeyEvent(ui::VKEY_C, true, false, true); |
387 SendKeyEvent(ui::VKEY_C, false, false, true); | 350 SendKeyEvent(ui::VKEY_C, false, false, true); |
388 SendKeyEvent(ui::VKEY_1, false, false, true); | 351 SendKeyEvent(ui::VKEY_1, false, false, true); |
389 SendKeyEvent(ui::VKEY_1, true, false, true); | 352 SendKeyEvent(ui::VKEY_1, true, false, true); |
390 SendKeyEvent(ui::VKEY_1, true, false, false); | 353 SendKeyEvent(ui::VKEY_1, true, false, false); |
391 EXPECT_STR_EQ("cC1!!", textfield_->text()); | 354 EXPECT_STR_EQ("cC1!!", textfield_->text()); |
392 EXPECT_STR_EQ("cC1!!", last_contents_); | 355 EXPECT_STR_EQ("cC1!!", last_contents_); |
393 } | 356 } |
394 | 357 |
395 TEST_F(NativeTextfieldViewsTest, MAYBE_ControlAndSelectTest) { | 358 TEST_F(NativeTextfieldViewsTest, ControlAndSelectTest) { |
396 // Insert a test string in a textfield. | 359 // Insert a test string in a textfield. |
397 InitTextfield(Textfield::STYLE_DEFAULT); | 360 InitTextfield(Textfield::STYLE_DEFAULT); |
398 textfield_->SetText(ASCIIToUTF16("one two three")); | 361 textfield_->SetText(ASCIIToUTF16("one two three")); |
399 SendKeyEvent(ui::VKEY_RIGHT, | 362 SendKeyEvent(ui::VKEY_RIGHT, |
400 true /* shift */, false /* control */); | 363 true /* shift */, false /* control */); |
401 SendKeyEvent(ui::VKEY_RIGHT, true, false); | 364 SendKeyEvent(ui::VKEY_RIGHT, true, false); |
402 SendKeyEvent(ui::VKEY_RIGHT, true, false); | 365 SendKeyEvent(ui::VKEY_RIGHT, true, false); |
403 | 366 |
404 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); | 367 EXPECT_STR_EQ("one", textfield_->GetSelectedText()); |
405 | 368 |
(...skipping 14 matching lines...) Expand all Loading... | |
420 SendKeyEvent(ui::VKEY_O, true, false); | 383 SendKeyEvent(ui::VKEY_O, true, false); |
421 SendKeyEvent(ui::VKEY_SPACE, false, false); | 384 SendKeyEvent(ui::VKEY_SPACE, false, false); |
422 EXPECT_STR_EQ("ZERO two three", textfield_->text()); | 385 EXPECT_STR_EQ("ZERO two three", textfield_->text()); |
423 | 386 |
424 SendKeyEvent(ui::VKEY_END, true, false); | 387 SendKeyEvent(ui::VKEY_END, true, false); |
425 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); | 388 EXPECT_STR_EQ("two three", textfield_->GetSelectedText()); |
426 SendKeyEvent(ui::VKEY_HOME, true, false); | 389 SendKeyEvent(ui::VKEY_HOME, true, false); |
427 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); | 390 EXPECT_STR_EQ("ZERO ", textfield_->GetSelectedText()); |
428 } | 391 } |
429 | 392 |
430 TEST_F(NativeTextfieldViewsTest, MAYBE_InsertionDeletionTest) { | 393 TEST_F(NativeTextfieldViewsTest, InsertionDeletionTest) { |
431 // Insert a test string in a textfield. | 394 // Insert a test string in a textfield. |
432 InitTextfield(Textfield::STYLE_DEFAULT); | 395 InitTextfield(Textfield::STYLE_DEFAULT); |
433 char test_str[] = "this is a test"; | 396 char test_str[] = "this is a test"; |
434 for (size_t i = 0; i < sizeof(test_str); i++) { | 397 for (size_t i = 0; i < sizeof(test_str); i++) { |
435 // This is ugly and should be replaced by a utility standard function. | 398 // This is ugly and should be replaced by a utility standard function. |
436 // See comment in NativeTextfieldViews::GetPrintableChar. | 399 // See comment in NativeTextfieldViews::GetPrintableChar. |
437 char c = test_str[i]; | 400 char c = test_str[i]; |
438 ui::KeyboardCode code = | 401 ui::KeyboardCode code = |
439 c == ' ' ? ui::VKEY_SPACE : | 402 c == ' ' ? ui::VKEY_SPACE : |
440 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); | 403 static_cast<ui::KeyboardCode>(ui::VKEY_A + c - 'a'); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); | 512 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); |
550 | 513 |
551 textfield_->SetReadOnly(false); | 514 textfield_->SetReadOnly(false); |
552 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, GetTextInputType()); | 515 EXPECT_EQ(ui::TEXT_INPUT_TYPE_URL, GetTextInputType()); |
553 | 516 |
554 // As do disabled textfields | 517 // As do disabled textfields |
555 textfield_->SetEnabled(false); | 518 textfield_->SetEnabled(false); |
556 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); | 519 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, GetTextInputType()); |
557 } | 520 } |
558 | 521 |
559 TEST_F(NativeTextfieldViewsTest, MAYBE_OnKeyPressReturnValueTest) { | 522 TEST_F(NativeTextfieldViewsTest, OnKeyPressReturnValueTest) { |
560 InitTextfield(Textfield::STYLE_DEFAULT); | 523 InitTextfield(Textfield::STYLE_DEFAULT); |
561 | 524 |
562 // Character keys will be handled by input method. | 525 // Character keys will be handled by input method. |
563 SendKeyEvent(ui::VKEY_A); | 526 SendKeyEvent(ui::VKEY_A); |
564 EXPECT_TRUE(textfield_->key_received()); | 527 EXPECT_TRUE(textfield_->key_received()); |
565 EXPECT_FALSE(textfield_->key_handled()); | 528 EXPECT_FALSE(textfield_->key_handled()); |
566 textfield_->clear(); | 529 textfield_->clear(); |
567 | 530 |
568 // Home will be handled. | 531 // Home will be handled. |
569 SendKeyEvent(ui::VKEY_HOME); | 532 SendKeyEvent(ui::VKEY_HOME); |
(...skipping 10 matching lines...) Expand all Loading... | |
580 SendKeyEvent(ui::VKEY_UP); | 543 SendKeyEvent(ui::VKEY_UP); |
581 EXPECT_TRUE(textfield_->key_received()); | 544 EXPECT_TRUE(textfield_->key_received()); |
582 EXPECT_FALSE(textfield_->key_handled()); | 545 EXPECT_FALSE(textfield_->key_handled()); |
583 textfield_->clear(); | 546 textfield_->clear(); |
584 | 547 |
585 SendKeyEvent(ui::VKEY_DOWN); | 548 SendKeyEvent(ui::VKEY_DOWN); |
586 EXPECT_TRUE(textfield_->key_received()); | 549 EXPECT_TRUE(textfield_->key_received()); |
587 EXPECT_FALSE(textfield_->key_handled()); | 550 EXPECT_FALSE(textfield_->key_handled()); |
588 } | 551 } |
589 | 552 |
590 TEST_F(NativeTextfieldViewsTest, MAYBE_CursorMovement) { | 553 TEST_F(NativeTextfieldViewsTest, CursorMovement) { |
591 InitTextfield(Textfield::STYLE_DEFAULT); | 554 InitTextfield(Textfield::STYLE_DEFAULT); |
592 | 555 |
593 // Test with trailing whitespace. | 556 // Test with trailing whitespace. |
594 textfield_->SetText(ASCIIToUTF16("one two hre ")); | 557 textfield_->SetText(ASCIIToUTF16("one two hre ")); |
595 | 558 |
596 // Send the cursor at the end. | 559 // Send the cursor at the end. |
597 SendKeyEvent(ui::VKEY_END); | 560 SendKeyEvent(ui::VKEY_END); |
598 | 561 |
599 // Ctrl+Left should move the cursor just before the last word. | 562 // Ctrl+Left should move the cursor just before the last word. |
600 SendKeyEvent(ui::VKEY_LEFT, false, true); | 563 SendKeyEvent(ui::VKEY_LEFT, false, true); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 gfx::Point())); | 803 gfx::Point())); |
841 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, | 804 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, |
842 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | 805 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); |
843 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, | 806 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, |
844 gfx::Point())); | 807 gfx::Point())); |
845 // Ensure that textfields support local moves. | 808 // Ensure that textfields support local moves. |
846 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, | 809 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, |
847 textfield_view_->GetDragOperationsForView(textfield_view_, kStringPoint)); | 810 textfield_view_->GetDragOperationsForView(textfield_view_, kStringPoint)); |
848 } | 811 } |
849 | 812 |
850 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_ToTheRight) { | 813 TEST_F(NativeTextfieldViewsTest, DragAndDrop_ToTheRight) { |
851 InitTextfield(Textfield::STYLE_DEFAULT); | 814 InitTextfield(Textfield::STYLE_DEFAULT); |
852 textfield_->SetText(ASCIIToUTF16("hello world")); | 815 textfield_->SetText(ASCIIToUTF16("hello world")); |
853 | 816 |
854 string16 string; | 817 string16 string; |
855 ui::OSExchangeData data; | 818 ui::OSExchangeData data; |
856 int formats = 0; | 819 int formats = 0; |
857 int operations = 0; | 820 int operations = 0; |
858 std::set<OSExchangeData::CustomFormat> custom_formats; | 821 std::set<OSExchangeData::CustomFormat> custom_formats; |
859 | 822 |
860 // Start dragging "ello". | 823 // Start dragging "ello". |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
894 SendKeyEvent(ui::VKEY_Z, false, true); | 857 SendKeyEvent(ui::VKEY_Z, false, true); |
895 EXPECT_STR_EQ("", textfield_->text()); | 858 EXPECT_STR_EQ("", textfield_->text()); |
896 SendKeyEvent(ui::VKEY_Y, false, true); | 859 SendKeyEvent(ui::VKEY_Y, false, true); |
897 EXPECT_STR_EQ("hello world", textfield_->text()); | 860 EXPECT_STR_EQ("hello world", textfield_->text()); |
898 SendKeyEvent(ui::VKEY_Y, false, true); | 861 SendKeyEvent(ui::VKEY_Y, false, true); |
899 EXPECT_STR_EQ("h welloorld", textfield_->text()); | 862 EXPECT_STR_EQ("h welloorld", textfield_->text()); |
900 SendKeyEvent(ui::VKEY_Y, false, true); | 863 SendKeyEvent(ui::VKEY_Y, false, true); |
901 EXPECT_STR_EQ("h welloorld", textfield_->text()); | 864 EXPECT_STR_EQ("h welloorld", textfield_->text()); |
902 } | 865 } |
903 | 866 |
904 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_ToTheLeft) { | 867 TEST_F(NativeTextfieldViewsTest, DragAndDrop_ToTheLeft) { |
905 InitTextfield(Textfield::STYLE_DEFAULT); | 868 InitTextfield(Textfield::STYLE_DEFAULT); |
906 textfield_->SetText(ASCIIToUTF16("hello world")); | 869 textfield_->SetText(ASCIIToUTF16("hello world")); |
907 | 870 |
908 string16 string; | 871 string16 string; |
909 ui::OSExchangeData data; | 872 ui::OSExchangeData data; |
910 int formats = 0; | 873 int formats = 0; |
911 int operations = 0; | 874 int operations = 0; |
912 std::set<OSExchangeData::CustomFormat> custom_formats; | 875 std::set<OSExchangeData::CustomFormat> custom_formats; |
913 | 876 |
914 // Start dragging " worl". | 877 // Start dragging " worl". |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
975 ui::EF_LEFT_BUTTON_DOWN); | 938 ui::EF_LEFT_BUTTON_DOWN); |
976 MouseEvent release(ui::ET_MOUSE_RELEASED, GetCursorPositionX(9), 0, | 939 MouseEvent release(ui::ET_MOUSE_RELEASED, GetCursorPositionX(9), 0, |
977 ui::EF_LEFT_BUTTON_DOWN); | 940 ui::EF_LEFT_BUTTON_DOWN); |
978 textfield_view_->OnMouseDragged(drag); | 941 textfield_view_->OnMouseDragged(drag); |
979 textfield_view_->OnMouseReleased(release); | 942 textfield_view_->OnMouseReleased(release); |
980 textfield_view_->OnDragDone(); | 943 textfield_view_->OnDragDone(); |
981 EXPECT_EQ(ASCIIToUTF16("hello world"), textfield_->text()); | 944 EXPECT_EQ(ASCIIToUTF16("hello world"), textfield_->text()); |
982 } | 945 } |
983 #endif | 946 #endif |
984 | 947 |
985 TEST_F(NativeTextfieldViewsTest, MAYBE_ReadOnlyTest) { | 948 TEST_F(NativeTextfieldViewsTest, ReadOnlyTest) { |
986 InitTextfield(Textfield::STYLE_DEFAULT); | 949 InitTextfield(Textfield::STYLE_DEFAULT); |
987 textfield_->SetText(ASCIIToUTF16(" one two three ")); | 950 textfield_->SetText(ASCIIToUTF16(" one two three ")); |
988 textfield_->SetReadOnly(true); | 951 textfield_->SetReadOnly(true); |
989 SendKeyEvent(ui::VKEY_HOME); | 952 SendKeyEvent(ui::VKEY_HOME); |
990 EXPECT_EQ(0U, textfield_->GetCursorPosition()); | 953 EXPECT_EQ(0U, textfield_->GetCursorPosition()); |
991 | 954 |
992 SendKeyEvent(ui::VKEY_END); | 955 SendKeyEvent(ui::VKEY_END); |
993 EXPECT_EQ(15U, textfield_->GetCursorPosition()); | 956 EXPECT_EQ(15U, textfield_->GetCursorPosition()); |
994 | 957 |
995 SendKeyEvent(ui::VKEY_LEFT, false, false); | 958 SendKeyEvent(ui::VKEY_LEFT, false, false); |
(...skipping 13 matching lines...) Expand all Loading... | |
1009 SendKeyEvent(ui::VKEY_X, false, true); | 972 SendKeyEvent(ui::VKEY_X, false, true); |
1010 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText()); | 973 EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText()); |
1011 string16 str; | 974 string16 str; |
1012 views::ViewsDelegate::views_delegate->GetClipboard()-> | 975 views::ViewsDelegate::views_delegate->GetClipboard()-> |
1013 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); | 976 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); |
1014 EXPECT_STR_NE(" one two three ", str); | 977 EXPECT_STR_NE(" one two three ", str); |
1015 | 978 |
1016 SendKeyEvent(ui::VKEY_C, false, true); | 979 SendKeyEvent(ui::VKEY_C, false, true); |
1017 views::ViewsDelegate::views_delegate->GetClipboard()-> | 980 views::ViewsDelegate::views_delegate->GetClipboard()-> |
1018 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); | 981 ReadText(ui::Clipboard::BUFFER_STANDARD, &str); |
1019 EXPECT_STR_EQ(" one two three ", str); | 982 EXPECT_STR_EQ(" one two three ", str); |
oshima
2011/10/05 20:15:09
Did this work? It failed on linux because clipboar
msw
2011/10/05 20:45:34
Yes, it does work, via clipboard_win's ui::Clipboa
oshima
2011/10/05 21:02:19
I see. I think we added aura because linux impl us
| |
1020 | 983 |
1021 // SetText should work even in read only mode. | 984 // SetText should work even in read only mode. |
1022 textfield_->SetText(ASCIIToUTF16(" four five six ")); | 985 textfield_->SetText(ASCIIToUTF16(" four five six ")); |
1023 EXPECT_STR_EQ(" four five six ", textfield_->text()); | 986 EXPECT_STR_EQ(" four five six ", textfield_->text()); |
1024 | 987 |
1025 // Paste shouldn't work. | 988 // Paste shouldn't work. |
1026 SendKeyEvent(ui::VKEY_V, false, true); | 989 SendKeyEvent(ui::VKEY_V, false, true); |
1027 EXPECT_STR_EQ(" four five six ", textfield_->text()); | 990 EXPECT_STR_EQ(" four five six ", textfield_->text()); |
1028 EXPECT_TRUE(textfield_->GetSelectedText().empty()); | 991 EXPECT_TRUE(textfield_->GetSelectedText().empty()); |
1029 | 992 |
1030 textfield_->SelectAll(); | 993 textfield_->SelectAll(); |
1031 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 994 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
1032 | 995 |
1033 // Text field is unmodifiable and selection shouldn't change. | 996 // Text field is unmodifiable and selection shouldn't change. |
1034 SendKeyEvent(ui::VKEY_DELETE); | 997 SendKeyEvent(ui::VKEY_DELETE); |
1035 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 998 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
1036 SendKeyEvent(ui::VKEY_BACK); | 999 SendKeyEvent(ui::VKEY_BACK); |
1037 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 1000 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
1038 SendKeyEvent(ui::VKEY_T); | 1001 SendKeyEvent(ui::VKEY_T); |
1039 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); | 1002 EXPECT_STR_EQ(" four five six ", textfield_->GetSelectedText()); |
1040 } | 1003 } |
1041 | 1004 |
1042 TEST_F(NativeTextfieldViewsTest, MAYBE_TextInputClientTest) { | 1005 TEST_F(NativeTextfieldViewsTest, TextInputClientTest) { |
1043 InitTextfield(Textfield::STYLE_DEFAULT); | 1006 InitTextfield(Textfield::STYLE_DEFAULT); |
1044 TextInputClient* client = textfield_->GetTextInputClient(); | 1007 TextInputClient* client = textfield_->GetTextInputClient(); |
1045 EXPECT_TRUE(client); | 1008 EXPECT_TRUE(client); |
1046 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); | 1009 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, client->GetTextInputType()); |
1047 | 1010 |
1048 textfield_->SetText(ASCIIToUTF16("0123456789")); | 1011 textfield_->SetText(ASCIIToUTF16("0123456789")); |
1049 ui::Range range; | 1012 ui::Range range; |
1050 EXPECT_TRUE(client->GetTextRange(&range)); | 1013 EXPECT_TRUE(client->GetTextRange(&range)); |
1051 EXPECT_EQ(0U, range.start()); | 1014 EXPECT_EQ(0U, range.start()); |
1052 EXPECT_EQ(10U, range.end()); | 1015 EXPECT_EQ(10U, range.end()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1122 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1085 EXPECT_TRUE(input_method_->text_input_type_changed()); |
1123 EXPECT_FALSE(textfield_->GetTextInputClient()); | 1086 EXPECT_FALSE(textfield_->GetTextInputClient()); |
1124 | 1087 |
1125 textfield_->SetReadOnly(false); | 1088 textfield_->SetReadOnly(false); |
1126 input_method_->Clear(); | 1089 input_method_->Clear(); |
1127 textfield_->SetPassword(true); | 1090 textfield_->SetPassword(true); |
1128 EXPECT_TRUE(input_method_->text_input_type_changed()); | 1091 EXPECT_TRUE(input_method_->text_input_type_changed()); |
1129 EXPECT_TRUE(textfield_->GetTextInputClient()); | 1092 EXPECT_TRUE(textfield_->GetTextInputClient()); |
1130 } | 1093 } |
1131 | 1094 |
1132 TEST_F(NativeTextfieldViewsTest, MAYBE_UndoRedoTest) { | 1095 TEST_F(NativeTextfieldViewsTest, UndoRedoTest) { |
1133 InitTextfield(Textfield::STYLE_DEFAULT); | 1096 InitTextfield(Textfield::STYLE_DEFAULT); |
1134 SendKeyEvent(ui::VKEY_A); | 1097 SendKeyEvent(ui::VKEY_A); |
1135 EXPECT_STR_EQ("a", textfield_->text()); | 1098 EXPECT_STR_EQ("a", textfield_->text()); |
1136 SendKeyEvent(ui::VKEY_Z, false, true); | 1099 SendKeyEvent(ui::VKEY_Z, false, true); |
1137 EXPECT_STR_EQ("", textfield_->text()); | 1100 EXPECT_STR_EQ("", textfield_->text()); |
1138 SendKeyEvent(ui::VKEY_Z, false, true); | 1101 SendKeyEvent(ui::VKEY_Z, false, true); |
1139 EXPECT_STR_EQ("", textfield_->text()); | 1102 EXPECT_STR_EQ("", textfield_->text()); |
1140 SendKeyEvent(ui::VKEY_Y, false, true); | 1103 SendKeyEvent(ui::VKEY_Y, false, true); |
1141 EXPECT_STR_EQ("a", textfield_->text()); | 1104 EXPECT_STR_EQ("a", textfield_->text()); |
1142 SendKeyEvent(ui::VKEY_Y, false, true); | 1105 SendKeyEvent(ui::VKEY_Y, false, true); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1230 SendKeyEvent(ui::VKEY_A); | 1193 SendKeyEvent(ui::VKEY_A); |
1231 EXPECT_STR_EQ("a23", textfield_->text()); | 1194 EXPECT_STR_EQ("a23", textfield_->text()); |
1232 SendKeyEvent(ui::VKEY_B); | 1195 SendKeyEvent(ui::VKEY_B); |
1233 EXPECT_STR_EQ("ab3", textfield_->text()); | 1196 EXPECT_STR_EQ("ab3", textfield_->text()); |
1234 SendKeyEvent(ui::VKEY_Z, false, true); | 1197 SendKeyEvent(ui::VKEY_Z, false, true); |
1235 EXPECT_STR_EQ("123", textfield_->text()); | 1198 EXPECT_STR_EQ("123", textfield_->text()); |
1236 SendKeyEvent(ui::VKEY_Y, false, true); | 1199 SendKeyEvent(ui::VKEY_Y, false, true); |
1237 EXPECT_STR_EQ("ab3", textfield_->text()); | 1200 EXPECT_STR_EQ("ab3", textfield_->text()); |
1238 } | 1201 } |
1239 | 1202 |
1240 TEST_F(NativeTextfieldViewsTest, MAYBE_TextCursorDisplayTest) { | 1203 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) { |
1241 InitTextfield(Textfield::STYLE_DEFAULT); | 1204 InitTextfield(Textfield::STYLE_DEFAULT); |
1242 // LTR-RTL string in LTR context. | 1205 // LTR-RTL string in LTR context. |
1243 SendKeyEvent('a'); | 1206 SendKeyEvent('a'); |
1244 EXPECT_STR_EQ("a", textfield_->text()); | 1207 EXPECT_STR_EQ("a", textfield_->text()); |
1245 int x = GetCursorBounds().x(); | 1208 int x = GetCursorBounds().x(); |
1246 int prev_x = x; | 1209 int prev_x = x; |
1247 | 1210 |
1248 SendKeyEvent('b'); | 1211 SendKeyEvent('b'); |
1249 EXPECT_STR_EQ("ab", textfield_->text()); | 1212 EXPECT_STR_EQ("ab", textfield_->text()); |
1250 x = GetCursorBounds().x(); | 1213 x = GetCursorBounds().x(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1282 x = GetCursorBounds().x(); | 1245 x = GetCursorBounds().x(); |
1283 EXPECT_LT(prev_x, x); | 1246 EXPECT_LT(prev_x, x); |
1284 prev_x = x; | 1247 prev_x = x; |
1285 | 1248 |
1286 SendKeyEvent('b'); | 1249 SendKeyEvent('b'); |
1287 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); | 1250 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); |
1288 x = GetCursorBounds().x(); | 1251 x = GetCursorBounds().x(); |
1289 EXPECT_LT(prev_x, x); | 1252 EXPECT_LT(prev_x, x); |
1290 } | 1253 } |
1291 | 1254 |
1292 TEST_F(NativeTextfieldViewsTest, MAYBE_TextCursorDisplayInRTLTest) { | 1255 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayInRTLTest) { |
1293 std::string locale = l10n_util::GetApplicationLocale(""); | 1256 std::string locale = l10n_util::GetApplicationLocale(""); |
1294 base::i18n::SetICUDefaultLocale("he"); | 1257 base::i18n::SetICUDefaultLocale("he"); |
1295 | 1258 |
1296 InitTextfield(Textfield::STYLE_DEFAULT); | 1259 InitTextfield(Textfield::STYLE_DEFAULT); |
1297 // LTR-RTL string in RTL context. | 1260 // LTR-RTL string in RTL context. |
1298 SendKeyEvent('a'); | 1261 SendKeyEvent('a'); |
1299 EXPECT_STR_EQ("a", textfield_->text()); | 1262 EXPECT_STR_EQ("a", textfield_->text()); |
1300 int x = GetCursorBounds().x(); | 1263 int x = GetCursorBounds().x(); |
1301 EXPECT_EQ(GetDisplayRect().right() - 1, x); | 1264 EXPECT_EQ(GetDisplayRect().right() - 1, x); |
1302 int prev_x = x; | 1265 int prev_x = x; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1400 // for the test to run if using sleep(). | 1363 // for the test to run if using sleep(). |
1401 NonClientMouseClick(); | 1364 NonClientMouseClick(); |
1402 | 1365 |
1403 MouseClick(cursor_bounds[i + 1], - (half_width / 2)); | 1366 MouseClick(cursor_bounds[i + 1], - (half_width / 2)); |
1404 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); | 1367 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); |
1405 | 1368 |
1406 NonClientMouseClick(); | 1369 NonClientMouseClick(); |
1407 } | 1370 } |
1408 } | 1371 } |
1409 | 1372 |
1410 TEST_F(NativeTextfieldViewsTest, MAYBE_HitOutsideTextAreaTest) { | 1373 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaTest) { |
1411 InitTextfield(Textfield::STYLE_DEFAULT); | 1374 InitTextfield(Textfield::STYLE_DEFAULT); |
1412 | 1375 |
1413 // LTR-RTL string in LTR context. | 1376 // LTR-RTL string in LTR context. |
1414 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); | 1377 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); |
1415 | 1378 |
1416 SendKeyEvent(ui::VKEY_HOME); | 1379 SendKeyEvent(ui::VKEY_HOME); |
1417 gfx::Rect bound = GetCursorBounds(); | 1380 gfx::Rect bound = GetCursorBounds(); |
1418 MouseClick(bound, -10); | 1381 MouseClick(bound, -10); |
1419 EXPECT_EQ(bound, GetCursorBounds()); | 1382 EXPECT_EQ(bound, GetCursorBounds()); |
1420 | 1383 |
(...skipping 19 matching lines...) Expand all Loading... | |
1440 SendKeyEvent(ui::VKEY_END); | 1403 SendKeyEvent(ui::VKEY_END); |
1441 bound = GetCursorBounds(); | 1404 bound = GetCursorBounds(); |
1442 #if defined(OS_WIN) | 1405 #if defined(OS_WIN) |
1443 MouseClick(bound, 10); | 1406 MouseClick(bound, 10); |
1444 #else | 1407 #else |
1445 MouseClick(bound, -10); | 1408 MouseClick(bound, -10); |
1446 #endif | 1409 #endif |
1447 EXPECT_EQ(bound, GetCursorBounds()); | 1410 EXPECT_EQ(bound, GetCursorBounds()); |
1448 } | 1411 } |
1449 | 1412 |
1450 TEST_F(NativeTextfieldViewsTest, MAYBE_HitOutsideTextAreaInRTLTest) { | 1413 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaInRTLTest) { |
1451 std::string locale = l10n_util::GetApplicationLocale(""); | 1414 std::string locale = l10n_util::GetApplicationLocale(""); |
1452 base::i18n::SetICUDefaultLocale("he"); | 1415 base::i18n::SetICUDefaultLocale("he"); |
1453 | 1416 |
1454 InitTextfield(Textfield::STYLE_DEFAULT); | 1417 InitTextfield(Textfield::STYLE_DEFAULT); |
1455 | 1418 |
1456 // RTL-LTR string in RTL context. | 1419 // RTL-LTR string in RTL context. |
1457 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); | 1420 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); |
1458 SendKeyEvent(ui::VKEY_HOME); | 1421 SendKeyEvent(ui::VKEY_HOME); |
1459 gfx::Rect bound = GetCursorBounds(); | 1422 gfx::Rect bound = GetCursorBounds(); |
1460 MouseClick(bound, 10); | 1423 MouseClick(bound, 10); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1494 // This verifies that |bound| is contained by |display|. |bound|'s right edge | 1457 // This verifies that |bound| is contained by |display|. |bound|'s right edge |
1495 // must be less than |diaplay|'s right edge. | 1458 // must be less than |diaplay|'s right edge. |
1496 void OverflowCursorBoundTestVerifier(const gfx::Rect& display, | 1459 void OverflowCursorBoundTestVerifier(const gfx::Rect& display, |
1497 const gfx::Rect& bound) { | 1460 const gfx::Rect& bound) { |
1498 EXPECT_LE(display.x(), bound.x()); | 1461 EXPECT_LE(display.x(), bound.x()); |
1499 EXPECT_GT(display.right(), bound.right()); | 1462 EXPECT_GT(display.right(), bound.right()); |
1500 EXPECT_LE(display.y(), bound.y()); | 1463 EXPECT_LE(display.y(), bound.y()); |
1501 EXPECT_GE(display.bottom(), bound.bottom()); | 1464 EXPECT_GE(display.bottom(), bound.bottom()); |
1502 } | 1465 } |
1503 | 1466 |
1504 TEST_F(NativeTextfieldViewsTest, MAYBE_OverflowTest) { | 1467 TEST_F(NativeTextfieldViewsTest, OverflowTest) { |
1505 InitTextfield(Textfield::STYLE_DEFAULT); | 1468 InitTextfield(Textfield::STYLE_DEFAULT); |
1506 | 1469 |
1507 string16 str; | 1470 string16 str; |
1508 for (int i = 0; i < 500; ++i) | 1471 for (int i = 0; i < 500; ++i) |
1509 SendKeyEvent('a'); | 1472 SendKeyEvent('a'); |
1510 SendKeyEvent(kHebrewLetterSamekh); | 1473 SendKeyEvent(kHebrewLetterSamekh); |
1511 gfx::Rect bound = GetCursorBounds(); | 1474 gfx::Rect bound = GetCursorBounds(); |
1512 gfx::Rect display = GetDisplayRect(); | 1475 gfx::Rect display = GetDisplayRect(); |
1513 OverflowCursorBoundTestVerifier(display, bound); | 1476 OverflowCursorBoundTestVerifier(display, bound); |
1514 | 1477 |
1515 // Test mouse pointing. | 1478 // Test mouse pointing. |
1516 MouseClick(bound, -1); | 1479 MouseClick(bound, -1); |
1517 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1480 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
1518 | 1481 |
1519 // Clear text. | 1482 // Clear text. |
1520 SendKeyEvent(ui::VKEY_A, false, true); | 1483 SendKeyEvent(ui::VKEY_A, false, true); |
1521 SendKeyEvent('\n'); | 1484 SendKeyEvent('\n'); |
1522 | 1485 |
1523 for (int i = 0; i < 500; ++i) | 1486 for (int i = 0; i < 500; ++i) |
1524 SendKeyEvent(kHebrewLetterSamekh); | 1487 SendKeyEvent(kHebrewLetterSamekh); |
1525 SendKeyEvent('a'); | 1488 SendKeyEvent('a'); |
1526 bound = GetCursorBounds(); | 1489 bound = GetCursorBounds(); |
1527 display = GetDisplayRect(); | 1490 display = GetDisplayRect(); |
1528 OverflowCursorBoundTestVerifier(display, bound); | 1491 OverflowCursorBoundTestVerifier(display, bound); |
1529 | 1492 |
1530 MouseClick(bound, -1); | 1493 MouseClick(bound, -1); |
1531 EXPECT_EQ(501U, textfield_->GetCursorPosition()); | 1494 EXPECT_EQ(501U, textfield_->GetCursorPosition()); |
1532 } | 1495 } |
1533 | 1496 |
1534 TEST_F(NativeTextfieldViewsTest, MAYBE_OverflowInRTLTest) { | 1497 TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) { |
1535 std::string locale = l10n_util::GetApplicationLocale(""); | 1498 std::string locale = l10n_util::GetApplicationLocale(""); |
1536 base::i18n::SetICUDefaultLocale("he"); | 1499 base::i18n::SetICUDefaultLocale("he"); |
1537 | 1500 |
1538 InitTextfield(Textfield::STYLE_DEFAULT); | 1501 InitTextfield(Textfield::STYLE_DEFAULT); |
1539 | 1502 |
1540 string16 str; | 1503 string16 str; |
1541 for (int i = 0; i < 500; ++i) | 1504 for (int i = 0; i < 500; ++i) |
1542 SendKeyEvent('a'); | 1505 SendKeyEvent('a'); |
1543 SendKeyEvent(kHebrewLetterSamekh); | 1506 SendKeyEvent(kHebrewLetterSamekh); |
1544 gfx::Rect bound = GetCursorBounds(); | 1507 gfx::Rect bound = GetCursorBounds(); |
(...skipping 22 matching lines...) Expand all Loading... | |
1567 EXPECT_EQ(0U, textfield_->GetCursorPosition()); | 1530 EXPECT_EQ(0U, textfield_->GetCursorPosition()); |
1568 #else | 1531 #else |
1569 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1532 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
1570 #endif | 1533 #endif |
1571 | 1534 |
1572 // Reset locale. | 1535 // Reset locale. |
1573 base::i18n::SetICUDefaultLocale(locale); | 1536 base::i18n::SetICUDefaultLocale(locale); |
1574 } | 1537 } |
1575 | 1538 |
1576 } // namespace views | 1539 } // namespace views |
OLD | NEW |