summaryrefslogtreecommitdiff
path: root/xfa/fde/cfde_texteditengine_unittest.cpp
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-04-19 21:33:53 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-19 21:33:53 +0000
commit8549ab48a5f8b613ea35dfd64f925fd0438efd0d (patch)
treed3cfe056c721f956c9635ef69421e66e06ebc04a /xfa/fde/cfde_texteditengine_unittest.cpp
parentee96772e0878fa385b9a4a736a2fc109e19fd01e (diff)
downloadpdfium-8549ab48a5f8b613ea35dfd64f925fd0438efd0d.tar.xz
Fix caret moving to start of edit on click after the text.
It now moves to the end of the edit text instead. In a multiline edit, clicking after the end of a line in the middle of the text moves the caret to the beginning of the next line. This is a known issue to be addressed later. Bug: chromium:832293 Change-Id: I55ca1f7eebf935fbb7d9526f115489bdfbd8ba1c Reviewed-on: https://pdfium-review.googlesource.com/31012 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fde/cfde_texteditengine_unittest.cpp')
-rw-r--r--xfa/fde/cfde_texteditengine_unittest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp
index 522e61a011..e279f8eb34 100644
--- a/xfa/fde/cfde_texteditengine_unittest.cpp
+++ b/xfa/fde/cfde_texteditengine_unittest.cpp
@@ -415,6 +415,18 @@ TEST_F(CFDE_TextEditEngineTest, GetIndexForPoint) {
engine()->Insert(0, L"Hello World");
EXPECT_EQ(0U, engine()->GetIndexForPoint({0.0f, 0.0f}));
EXPECT_EQ(11U, engine()->GetIndexForPoint({999999.0f, 9999999.0f}));
+ EXPECT_EQ(11U, engine()->GetIndexForPoint({999999.0f, 0.0f}));
+ EXPECT_EQ(1U, engine()->GetIndexForPoint({10.0f, 5.0f}));
+}
+
+TEST_F(CFDE_TextEditEngineTest, GetIndexForPointMultiline) {
+ engine()->SetFontSize(10.0f);
+ engine()->Insert(0,
+ L"A text long enough to span multiple lines and test "
+ L"getting indexes on multi-line edits.");
+ EXPECT_EQ(0U, engine()->GetIndexForPoint({0.0f, 0.0f}));
+ EXPECT_EQ(87U, engine()->GetIndexForPoint({999999.0f, 9999999.0f}));
+ EXPECT_EQ(12U, engine()->GetIndexForPoint({999999.0f, 0.0f}));
EXPECT_EQ(1U, engine()->GetIndexForPoint({10.0f, 5.0f}));
}