| Index: ui/views/controls/textfield/textfield_unittest.cc
|
| diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc
|
| index 97595c57cb4e5b61a1c8569801d43f7724a0607d..d06aabde111557200a0ce61d739181c97e2a3186 100644
|
| --- a/ui/views/controls/textfield/textfield_unittest.cc
|
| +++ b/ui/views/controls/textfield/textfield_unittest.cc
|
| @@ -39,6 +39,7 @@
|
| #include "ui/views/controls/textfield/textfield_model.h"
|
| #include "ui/views/controls/textfield/textfield_test_api.h"
|
| #include "ui/views/focus/focus_manager.h"
|
| +#include "ui/views/style/platform_style.h"
|
| #include "ui/views/test/test_views_delegate.h"
|
| #include "ui/views/test/views_test_base.h"
|
| #include "ui/views/test/widget_test.h"
|
| @@ -1195,6 +1196,53 @@ TEST_F(TextfieldTest, DragToSelect) {
|
| EXPECT_EQ(textfield_->text(), textfield_->GetSelectedText());
|
| }
|
|
|
| +// This test checks that dragging above the textfield selects to the beginning
|
| +// and dragging below the textfield selects to the end, but only on platforms
|
| +// where that is the expected behavior.
|
| +TEST_F(TextfieldTest, DragUpOrDownSelectsToEnd) {
|
| + InitTextfield();
|
| + textfield_->SetText(ASCIIToUTF16("hello world"));
|
| + const base::string16 expected_up =
|
| + base::ASCIIToUTF16(PlatformStyle::kTextfieldDragVerticallyDragsToEnd ?
|
| + "hello" : "lo");
|
| + const base::string16 expected_down =
|
| + base::ASCIIToUTF16(PlatformStyle::kTextfieldDragVerticallyDragsToEnd ?
|
| + " world" : " w");
|
| + const int kStartX = GetCursorPositionX(5);
|
| + const int kDownX = GetCursorPositionX(7);
|
| + const int kUpX = GetCursorPositionX(3);
|
| + gfx::Point start_point(kStartX, 0);
|
| + gfx::Point down_point(kDownX, 500);
|
| + gfx::Point up_point(kUpX, -500);
|
| +
|
| + ui::MouseEvent click_start(ui::ET_MOUSE_PRESSED, start_point, start_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent click_down(ui::ET_MOUSE_PRESSED, down_point, down_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent drag_up(ui::ET_MOUSE_DRAGGED, up_point, up_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
|
| + ui::MouseEvent drag_down(ui::ET_MOUSE_DRAGGED, down_point, down_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, 0);
|
| + ui::MouseEvent release_up(ui::ET_MOUSE_RELEASED, up_point, up_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| + ui::MouseEvent release_down(ui::ET_MOUSE_RELEASED, down_point, down_point,
|
| + ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
|
| + ui::EF_LEFT_MOUSE_BUTTON);
|
| +
|
| + textfield_->OnMousePressed(click_start);
|
| + textfield_->OnMouseDragged(drag_up);
|
| + textfield_->OnMouseReleased(release_up);
|
| + EXPECT_EQ(textfield_->GetSelectedText(), expected_up);
|
| +
|
| + textfield_->OnMousePressed(click_start);
|
| + textfield_->OnMouseDragged(drag_down);
|
| + textfield_->OnMouseReleased(release_down);
|
| + EXPECT_EQ(textfield_->GetSelectedText(), expected_down);
|
| +}
|
| +
|
| #if defined(OS_WIN)
|
| TEST_F(TextfieldTest, DragAndDrop_AcceptDrop) {
|
| InitTextfield();
|
|
|