Chromium Code Reviews| 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. | 37 // Bug http://crbug.com/99128 |
| 38 #if defined(USE_AURA) | 38 #if defined(OS_WIN) |
|
sadrul
2011/10/05 22:54:02
I think the simplest would be to make this
#if de
sadrul
2011/10/05 22:57:18
Clearly the #else block should remain as it is.
| |
| 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 | 39 #define MAYBE_KeyTest KeyTest |
| 57 #define MAYBE_ControlAndSelectTest ControlAndSelectTest | 40 #define MAYBE_ControlAndSelectTest ControlAndSelectTest |
| 58 #define MAYBE_InsertionDeletionTest InsertionDeletionTest | 41 #define MAYBE_InsertionDeletionTest InsertionDeletionTest |
| 59 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest | 42 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest |
| 60 #define MAYBE_CursorMovement CursorMovement | 43 #define MAYBE_CursorMovement CursorMovement |
| 44 #define MAYBE_DragAndDrop_InitiateDrag DragAndDrop_InitiateDrag | |
| 45 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft | |
| 61 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight | 46 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight |
| 62 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft | 47 #define MAYBE_DragAndDrop_Canceled DragAndDrop_Canceled |
| 63 #define MAYBE_ReadOnlyTest ReadOnlyTest | 48 #define MAYBE_ReadOnlyTest ReadOnlyTest |
| 64 #define MAYBE_TextInputClientTest TextInputClientTest | 49 #define MAYBE_TextInputClientTest TextInputClientTest |
| 65 #define MAYBE_UndoRedoTest UndoRedoTest | 50 #define MAYBE_UndoRedoTest UndoRedoTest |
| 66 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest | 51 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest |
| 67 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest | 52 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest |
| 68 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest | 53 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest |
| 69 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest | 54 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest |
| 70 #define MAYBE_OverflowTest OverflowTest | 55 #define MAYBE_OverflowTest OverflowTest |
| 71 #define MAYBE_OverflowInRTLTest OverflowInRTLTest | 56 #define MAYBE_OverflowInRTLTest OverflowInRTLTest |
| 72 #endif | 57 #else // OS_WIN |
| 58 | |
| 59 #define MAYBE_KeyTest FAILS_KeyTest | |
| 60 #define MAYBE_ControlAndSelectTest FAILS_ControlAndSelectTest | |
| 61 #define MAYBE_InsertionDeletionTest FAILS_InsertionDeletionTest | |
| 62 #define MAYBE_OnKeyPressReturnValueTest FAILS_OnKeyPressReturnValueTest | |
| 63 #define MAYBE_CursorMovement FAILS_CursorMovement | |
| 64 #define MAYBE_ReadOnlyTest FAILS_ReadOnlyTest | |
| 65 #define MAYBE_TextInputClientTest FAILS_TextInputClientTest | |
| 66 #define MAYBE_UndoRedoTest FAILS_UndoRedoTest | |
| 67 #define MAYBE_TextCursorDisplayTest FAILS_TextCursorDisplayTest | |
| 68 #define MAYBE_TextCursorDisplayInRTLTest FAILS_TextCursorDisplayInRTLTest | |
| 69 #define MAYBE_HitOutsideTextAreaTest FAILS_HitOutsideTextAreaTest | |
| 70 #define MAYBE_HitOutsideTextAreaInRTLTest FAILS_HitOutsideTextAreaInRTLTest | |
| 71 #define MAYBE_OverflowTest FAILS_OverflowTest | |
| 72 #define MAYBE_OverflowInRTLTest FAILS_OverflowInRTLTest | |
| 73 | |
| 74 // Drag and drop for aura in linux hasn't been implemented yet. | |
| 75 // Bug http://crbug.com/97845 | |
| 76 #if defined(USE_AURA) | |
| 77 #define MAYBE_DragAndDrop_InitiateDrag DISABLED_DragAndDrop_InitiateDrag | |
| 78 #define MAYBE_DragAndDrop_ToTheLeft DISABLED_DragAndDrop_ToTheLeft | |
| 79 #define MAYBE_DragAndDrop_ToTheRight DISABLED_DragAndDrop_ToTheRight | |
| 80 #define MAYBE_DragAndDrop_Canceled DISABLED_DragAndDrop_Canceled | |
| 81 #else // USE_AURA | |
| 82 #define MAYBE_DragAndDrop_InitiateDrag FAILS_DragAndDrop_InitiateDrag | |
| 83 #define MAYBE_DragAndDrop_ToTheLeft FAILS_DragAndDrop_ToTheLeft | |
| 84 #define MAYBE_DragAndDrop_ToTheRight FAILS_DragAndDrop_ToTheRight | |
| 85 #define MAYBE_DragAndDrop_Canceled FAILS_DragAndDrop_Canceled | |
| 86 #endif // USE_AURA | |
| 87 | |
| 88 #endif // OS_WIN | |
| 73 | 89 |
| 74 namespace { | 90 namespace { |
| 75 | 91 |
| 76 // A wrapper of Textfield to intercept the result of OnKeyPressed() and | 92 // A wrapper of Textfield to intercept the result of OnKeyPressed() and |
| 77 // OnKeyReleased() methods. | 93 // OnKeyReleased() methods. |
| 78 class TestTextfield : public views::Textfield { | 94 class TestTextfield : public views::Textfield { |
| 79 public: | 95 public: |
| 80 TestTextfield() | 96 TestTextfield() |
| 81 : key_handled_(false), | 97 : key_handled_(false), |
| 82 key_received_(false) { | 98 key_received_(false) { |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 #else | 819 #else |
| 804 // Skip OSExchangeDataProviderWin::SetURL, which also sets CF_TEXT / STRING. | 820 // Skip OSExchangeDataProviderWin::SetURL, which also sets CF_TEXT / STRING. |
| 805 bad_data.SetURL(GURL("x.org"), string16(ASCIIToUTF16("x"))); | 821 bad_data.SetURL(GURL("x.org"), string16(ASCIIToUTF16("x"))); |
| 806 bad_data.SetPickledData(GDK_SELECTION_PRIMARY, Pickle()); | 822 bad_data.SetPickledData(GDK_SELECTION_PRIMARY, Pickle()); |
| 807 #endif | 823 #endif |
| 808 EXPECT_FALSE(textfield_view_->CanDrop(bad_data)); | 824 EXPECT_FALSE(textfield_view_->CanDrop(bad_data)); |
| 809 } | 825 } |
| 810 #endif | 826 #endif |
| 811 | 827 |
| 812 #if !defined(TOUCH_UI) | 828 #if !defined(TOUCH_UI) |
| 813 TEST_F(NativeTextfieldViewsTest, DragAndDrop_InitiateDrag) { | 829 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_InitiateDrag) { |
| 814 InitTextfield(Textfield::STYLE_DEFAULT); | 830 InitTextfield(Textfield::STYLE_DEFAULT); |
| 815 textfield_->SetText(ASCIIToUTF16("hello string world")); | 831 textfield_->SetText(ASCIIToUTF16("hello string world")); |
| 816 | 832 |
| 817 // Ensure the textfield will provide selected text for drag data. | 833 // Ensure the textfield will provide selected text for drag data. |
| 818 string16 string; | 834 string16 string; |
| 819 ui::OSExchangeData data; | 835 ui::OSExchangeData data; |
| 820 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 12)); | 836 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 12)); |
| 821 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); | 837 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); |
| 822 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data); | 838 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data); |
| 823 EXPECT_TRUE(data.GetString(&string)); | 839 EXPECT_TRUE(data.GetString(&string)); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 SendKeyEvent(ui::VKEY_Z, false, true); | 963 SendKeyEvent(ui::VKEY_Z, false, true); |
| 948 EXPECT_STR_EQ("", textfield_->text()); | 964 EXPECT_STR_EQ("", textfield_->text()); |
| 949 SendKeyEvent(ui::VKEY_Y, false, true); | 965 SendKeyEvent(ui::VKEY_Y, false, true); |
| 950 EXPECT_STR_EQ("hello world", textfield_->text()); | 966 EXPECT_STR_EQ("hello world", textfield_->text()); |
| 951 SendKeyEvent(ui::VKEY_Y, false, true); | 967 SendKeyEvent(ui::VKEY_Y, false, true); |
| 952 EXPECT_STR_EQ("h worlellod", textfield_->text()); | 968 EXPECT_STR_EQ("h worlellod", textfield_->text()); |
| 953 SendKeyEvent(ui::VKEY_Y, false, true); | 969 SendKeyEvent(ui::VKEY_Y, false, true); |
| 954 EXPECT_STR_EQ("h worlellod", textfield_->text()); | 970 EXPECT_STR_EQ("h worlellod", textfield_->text()); |
| 955 } | 971 } |
| 956 | 972 |
| 957 TEST_F(NativeTextfieldViewsTest, DragAndDrop_Canceled) { | 973 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_Canceled) { |
| 958 InitTextfield(Textfield::STYLE_DEFAULT); | 974 InitTextfield(Textfield::STYLE_DEFAULT); |
| 959 textfield_->SetText(ASCIIToUTF16("hello world")); | 975 textfield_->SetText(ASCIIToUTF16("hello world")); |
| 960 | 976 |
| 961 // Start dragging "worl". | 977 // Start dragging "worl". |
| 962 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 10)); | 978 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 10)); |
| 963 MouseEvent click(ui::ET_MOUSE_PRESSED, GetCursorPositionX(8), 0, | 979 MouseEvent click(ui::ET_MOUSE_PRESSED, GetCursorPositionX(8), 0, |
| 964 ui::EF_LEFT_BUTTON_DOWN); | 980 ui::EF_LEFT_BUTTON_DOWN); |
| 965 textfield_view_->OnMousePressed(click); | 981 textfield_view_->OnMousePressed(click); |
| 966 ui::OSExchangeData data; | 982 ui::OSExchangeData data; |
| 967 textfield_view_->WriteDragDataForView(NULL, click.location(), &data); | 983 textfield_view_->WriteDragDataForView(NULL, click.location(), &data); |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1567 EXPECT_EQ(0U, textfield_->GetCursorPosition()); | 1583 EXPECT_EQ(0U, textfield_->GetCursorPosition()); |
| 1568 #else | 1584 #else |
| 1569 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | 1585 EXPECT_EQ(500U, textfield_->GetCursorPosition()); |
| 1570 #endif | 1586 #endif |
| 1571 | 1587 |
| 1572 // Reset locale. | 1588 // Reset locale. |
| 1573 base::i18n::SetICUDefaultLocale(locale); | 1589 base::i18n::SetICUDefaultLocale(locale); |
| 1574 } | 1590 } |
| 1575 | 1591 |
| 1576 } // namespace views | 1592 } // namespace views |
| OLD | NEW |