Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Side by Side Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 8150001: Quick fix for NativeTextfieldViewsTest on win aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revise test expectation logic. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | views/events/event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(USE_AURA) && defined(OS_LINUX)
39 #define MAYBE_KeyTest FAILS_KeyTest 39 #define MAYBE_KeyTest FAILS_KeyTest
40 #define MAYBE_ControlAndSelectTest FAILS_ControlAndSelectTest 40 #define MAYBE_ControlAndSelectTest FAILS_ControlAndSelectTest
41 #define MAYBE_InsertionDeletionTest FAILS_InsertionDeletionTest 41 #define MAYBE_InsertionDeletionTest FAILS_InsertionDeletionTest
42 #define MAYBE_OnKeyPressReturnValueTest FAILS_OnKeyPressReturnValueTest 42 #define MAYBE_OnKeyPressReturnValueTest FAILS_OnKeyPressReturnValueTest
43 #define MAYBE_CursorMovement FAILS_CursorMovement 43 #define MAYBE_CursorMovement FAILS_CursorMovement
44 #define MAYBE_DragAndDrop_ToTheRight FAILS_DragAndDrop_ToTheRight 44
45 #define MAYBE_DragAndDrop_ToTheLeft FAILS_DragAndDrop_ToTheLeft 45 // Drag and drop for aura in linux hasn't been implemented yet.
46 // Bug http://crbug.com/97845
47 #define MAYBE_DragAndDrop_InitiateDrag DISABLED_DragAndDrop_InitiateDrag
48 #define MAYBE_DragAndDrop_ToTheLeft DISABLED_DragAndDrop_ToTheLeft
49 #define MAYBE_DragAndDrop_ToTheRight DISABLED_DragAndDrop_ToTheRight
50 #define MAYBE_DragAndDrop_Canceled DISABLED_DragAndDrop_Canceled
51
46 #define MAYBE_ReadOnlyTest FAILS_ReadOnlyTest 52 #define MAYBE_ReadOnlyTest FAILS_ReadOnlyTest
47 #define MAYBE_TextInputClientTest FAILS_TextInputClientTest 53 #define MAYBE_TextInputClientTest FAILS_TextInputClientTest
48 #define MAYBE_UndoRedoTest FAILS_UndoRedoTest 54 #define MAYBE_UndoRedoTest FAILS_UndoRedoTest
49 #define MAYBE_TextCursorDisplayTest FAILS_TextCursorDisplayTest 55 #define MAYBE_TextCursorDisplayTest FAILS_TextCursorDisplayTest
50 #define MAYBE_TextCursorDisplayInRTLTest FAILS_TextCursorDisplayInRTLTest 56 #define MAYBE_TextCursorDisplayInRTLTest FAILS_TextCursorDisplayInRTLTest
51 #define MAYBE_HitOutsideTextAreaTest FAILS_HitOutsideTextAreaTest 57 #define MAYBE_HitOutsideTextAreaTest FAILS_HitOutsideTextAreaTest
52 #define MAYBE_HitOutsideTextAreaInRTLTest FAILS_HitOutsideTextAreaInRTLTest 58 #define MAYBE_HitOutsideTextAreaInRTLTest FAILS_HitOutsideTextAreaInRTLTest
53 #define MAYBE_OverflowTest FAILS_OverflowTest 59 #define MAYBE_OverflowTest FAILS_OverflowTest
54 #define MAYBE_OverflowInRTLTest FAILS_OverflowInRTLTest 60 #define MAYBE_OverflowInRTLTest FAILS_OverflowInRTLTest
55 #else 61 #else
56 #define MAYBE_KeyTest KeyTest 62 #define MAYBE_KeyTest KeyTest
57 #define MAYBE_ControlAndSelectTest ControlAndSelectTest 63 #define MAYBE_ControlAndSelectTest ControlAndSelectTest
58 #define MAYBE_InsertionDeletionTest InsertionDeletionTest 64 #define MAYBE_InsertionDeletionTest InsertionDeletionTest
59 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest 65 #define MAYBE_OnKeyPressReturnValueTest OnKeyPressReturnValueTest
60 #define MAYBE_CursorMovement CursorMovement 66 #define MAYBE_CursorMovement CursorMovement
67 #define MAYBE_DragAndDrop_InitiateDrag DragAndDrop_InitiateDrag
68 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft
61 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight 69 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight
62 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft 70 #define MAYBE_DragAndDrop_Canceled DragAndDrop_Canceled
63 #define MAYBE_ReadOnlyTest ReadOnlyTest 71 #define MAYBE_ReadOnlyTest ReadOnlyTest
64 #define MAYBE_TextInputClientTest TextInputClientTest 72 #define MAYBE_TextInputClientTest TextInputClientTest
65 #define MAYBE_UndoRedoTest UndoRedoTest 73 #define MAYBE_UndoRedoTest UndoRedoTest
66 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest 74 #define MAYBE_TextCursorDisplayTest TextCursorDisplayTest
67 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest 75 #define MAYBE_TextCursorDisplayInRTLTest TextCursorDisplayInRTLTest
68 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest 76 #define MAYBE_HitOutsideTextAreaTest HitOutsideTextAreaTest
69 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest 77 #define MAYBE_HitOutsideTextAreaInRTLTest HitOutsideTextAreaInRTLTest
70 #define MAYBE_OverflowTest OverflowTest 78 #define MAYBE_OverflowTest OverflowTest
71 #define MAYBE_OverflowInRTLTest OverflowInRTLTest 79 #define MAYBE_OverflowInRTLTest OverflowInRTLTest
72 #endif 80 #endif // OS_LINUX && USE_AURA
73 81
74 namespace { 82 namespace {
75 83
76 // A wrapper of Textfield to intercept the result of OnKeyPressed() and 84 // A wrapper of Textfield to intercept the result of OnKeyPressed() and
77 // OnKeyReleased() methods. 85 // OnKeyReleased() methods.
78 class TestTextfield : public views::Textfield { 86 class TestTextfield : public views::Textfield {
79 public: 87 public:
80 TestTextfield() 88 TestTextfield()
81 : key_handled_(false), 89 : key_handled_(false),
82 key_received_(false) { 90 key_received_(false) {
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 #else 811 #else
804 // Skip OSExchangeDataProviderWin::SetURL, which also sets CF_TEXT / STRING. 812 // Skip OSExchangeDataProviderWin::SetURL, which also sets CF_TEXT / STRING.
805 bad_data.SetURL(GURL("x.org"), string16(ASCIIToUTF16("x"))); 813 bad_data.SetURL(GURL("x.org"), string16(ASCIIToUTF16("x")));
806 bad_data.SetPickledData(GDK_SELECTION_PRIMARY, Pickle()); 814 bad_data.SetPickledData(GDK_SELECTION_PRIMARY, Pickle());
807 #endif 815 #endif
808 EXPECT_FALSE(textfield_view_->CanDrop(bad_data)); 816 EXPECT_FALSE(textfield_view_->CanDrop(bad_data));
809 } 817 }
810 #endif 818 #endif
811 819
812 #if !defined(TOUCH_UI) 820 #if !defined(TOUCH_UI)
813 TEST_F(NativeTextfieldViewsTest, DragAndDrop_InitiateDrag) { 821 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_InitiateDrag) {
814 InitTextfield(Textfield::STYLE_DEFAULT); 822 InitTextfield(Textfield::STYLE_DEFAULT);
815 textfield_->SetText(ASCIIToUTF16("hello string world")); 823 textfield_->SetText(ASCIIToUTF16("hello string world"));
816 824
817 // Ensure the textfield will provide selected text for drag data. 825 // Ensure the textfield will provide selected text for drag data.
818 string16 string; 826 string16 string;
819 ui::OSExchangeData data; 827 ui::OSExchangeData data;
820 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 12)); 828 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 12));
821 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); 829 const gfx::Point kStringPoint(GetCursorPositionX(9), 0);
822 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data); 830 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data);
823 EXPECT_TRUE(data.GetString(&string)); 831 EXPECT_TRUE(data.GetString(&string));
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 SendKeyEvent(ui::VKEY_Z, false, true); 955 SendKeyEvent(ui::VKEY_Z, false, true);
948 EXPECT_STR_EQ("", textfield_->text()); 956 EXPECT_STR_EQ("", textfield_->text());
949 SendKeyEvent(ui::VKEY_Y, false, true); 957 SendKeyEvent(ui::VKEY_Y, false, true);
950 EXPECT_STR_EQ("hello world", textfield_->text()); 958 EXPECT_STR_EQ("hello world", textfield_->text());
951 SendKeyEvent(ui::VKEY_Y, false, true); 959 SendKeyEvent(ui::VKEY_Y, false, true);
952 EXPECT_STR_EQ("h worlellod", textfield_->text()); 960 EXPECT_STR_EQ("h worlellod", textfield_->text());
953 SendKeyEvent(ui::VKEY_Y, false, true); 961 SendKeyEvent(ui::VKEY_Y, false, true);
954 EXPECT_STR_EQ("h worlellod", textfield_->text()); 962 EXPECT_STR_EQ("h worlellod", textfield_->text());
955 } 963 }
956 964
957 TEST_F(NativeTextfieldViewsTest, DragAndDrop_Canceled) { 965 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_Canceled) {
958 InitTextfield(Textfield::STYLE_DEFAULT); 966 InitTextfield(Textfield::STYLE_DEFAULT);
959 textfield_->SetText(ASCIIToUTF16("hello world")); 967 textfield_->SetText(ASCIIToUTF16("hello world"));
960 968
961 // Start dragging "worl". 969 // Start dragging "worl".
962 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 10)); 970 textfield_->SelectSelectionModel(gfx::SelectionModel(6, 10));
963 MouseEvent click(ui::ET_MOUSE_PRESSED, GetCursorPositionX(8), 0, 971 MouseEvent click(ui::ET_MOUSE_PRESSED, GetCursorPositionX(8), 0,
964 ui::EF_LEFT_BUTTON_DOWN); 972 ui::EF_LEFT_BUTTON_DOWN);
965 textfield_view_->OnMousePressed(click); 973 textfield_view_->OnMousePressed(click);
966 ui::OSExchangeData data; 974 ui::OSExchangeData data;
967 textfield_view_->WriteDragDataForView(NULL, click.location(), &data); 975 textfield_view_->WriteDragDataForView(NULL, click.location(), &data);
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 EXPECT_EQ(0U, textfield_->GetCursorPosition()); 1575 EXPECT_EQ(0U, textfield_->GetCursorPosition());
1568 #else 1576 #else
1569 EXPECT_EQ(500U, textfield_->GetCursorPosition()); 1577 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1570 #endif 1578 #endif
1571 1579
1572 // Reset locale. 1580 // Reset locale.
1573 base::i18n::SetICUDefaultLocale(locale); 1581 base::i18n::SetICUDefaultLocale(locale);
1574 } 1582 }
1575 1583
1576 } // namespace views 1584 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | views/events/event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698