Chromium Code Reviews| Index: views/touchui/touch_selection_controller_impl_unittest.cc |
| =================================================================== |
| --- views/touchui/touch_selection_controller_impl_unittest.cc (revision 103192) |
| +++ views/touchui/touch_selection_controller_impl_unittest.cc (working copy) |
| @@ -49,10 +49,9 @@ |
| } |
| protected: |
| - gfx::Point GetCursorPosition(int cursor_pos) { |
| + gfx::Point GetCursorPosition(const gfx::SelectionModel& sel) { |
| gfx::RenderText* render_text = textfield_view_->GetRenderText(); |
| - gfx::Rect cursor_bounds = render_text->GetCursorBounds( |
| - gfx::SelectionModel(cursor_pos), false); |
| + gfx::Rect cursor_bounds = render_text->GetCursorBounds(sel, true); |
| return gfx::Point(cursor_bounds.x(), cursor_bounds.bottom() - 1); |
| } |
| @@ -85,8 +84,10 @@ |
| EXPECT_TRUE(GetSelectionController()->IsSelectionHandle2Visible()); |
| gfx::SelectionModel sel; |
| textfield_view_->GetSelectionModel(&sel); |
| - gfx::Point selection_start = GetCursorPosition(sel.selection_start()); |
| - gfx::Point selection_end = GetCursorPosition(sel.selection_end()); |
| + gfx::SelectionModel sel_start = textfield_view_->GetRenderText()-> |
| + GetSelectionModelForSelectionStart(); |
| + gfx::Point selection_start = GetCursorPosition(sel_start); |
| + gfx::Point selection_end = GetCursorPosition(sel); |
| gfx::Point sh1 = GetSelectionController()->GetSelectionHandle1Position(); |
| gfx::Point sh2 = GetSelectionController()->GetSelectionHandle2Position(); |
| sh1.Offset(10, 0); // offset by kSelectionHandleRadius. |
| @@ -141,6 +142,21 @@ |
| VerifySelectionHandlePositions(false); |
| } |
| +// Tests that the selection handles are placed appropriately in bidi text. |
| +TEST_F(TouchSelectionControllerImplTest, SelectionInBidiTextfieldTest) { |
| + CreateTextfield(); |
| + textfield_->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2")); |
| + |
| + // Test cursor at run boundary and with empty selection. |
| + textfield_->SelectSelectionModel( |
| + gfx::SelectionModel(3, 2, gfx::SelectionModel::TRAILING)); |
| + VerifySelectionHandlePositions(false); |
| + |
| + // Test selection range (3, 2). |
|
msw
2011/09/29 02:20:21
Please also test some other pertinent BiDi ranges.
xji
2011/10/03 23:18:57
Done.
|
| + textfield_->SelectSelectionModel(gfx::SelectionModel(3, 2)); |
| + VerifySelectionHandlePositions(false); |
| +} |
| + |
| // Tests if the SelectRect callback is called appropriately when selection |
| // handles are moved. |
| TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { |