Index: ui/gfx/render_text_unittest.cc |
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc |
index 9f884c73cc58ba6cc748c012f2d415dc068841a9..5bbc049f1a30b1ae3c5dfc1387d0b19166b8fbe3 100644 |
--- a/ui/gfx/render_text_unittest.cc |
+++ b/ui/gfx/render_text_unittest.cc |
@@ -3998,9 +3998,9 @@ TEST_P(RenderTextTest, SubpixelRenderingSuppressed) { |
EXPECT_FALSE(GetRendererPaint().isLCDRenderText()); |
} |
-// Verify GetDecoratedWordAtPoint returns the correct baseline point and |
-// decorated word for an LTR string. |
-TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_LTR) { |
+// Verify GetDecoratedWordAndBaselineAtPoint returns the correct baseline point |
msw
2017/01/26 20:59:16
Please add a basic test fixture for the new range-
spqchan
2017/02/01 00:32:38
Done.
|
+// and decorated word for an LTR string. |
+TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtPoint_LTR) { |
const base::string16 ltr = ASCIIToUTF16(" ab c "); |
const int kWordOneStartIndex = 2; |
const int kWordTwoStartIndex = 6; |
@@ -4046,14 +4046,14 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_LTR) { |
{ |
SCOPED_TRACE(base::StringPrintf("Query to the left of text bounds")); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(-5, cursor_y), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_1, decorated_word); |
EXPECT_TRUE(left_glyph_word_1.Contains(baseline_point)); |
} |
{ |
SCOPED_TRACE(base::StringPrintf("Query to the right of text bounds")); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(105, cursor_y), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_2, decorated_word); |
EXPECT_TRUE(left_glyph_word_2.Contains(baseline_point)); |
@@ -4066,8 +4066,8 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_LTR) { |
render_text->GetCursorBounds(SelectionModel(i, CURSOR_FORWARD), false) |
.origin(); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint(query, &decorated_word, |
- &baseline_point)); |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
+ query, &decorated_word, &baseline_point)); |
if (i < kWordTwoStartIndex) { |
VerifyDecoratedWordsAreEqual(expected_word_1, decorated_word); |
@@ -4079,9 +4079,10 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_LTR) { |
} |
} |
-// Verify GetDecoratedWordAtPoint returns the correct baseline point and |
+// Verify GetDecoratedWordAndBaselineAtPoint returns the correct baseline point |
+// and |
// decorated word for an RTL string. |
-TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_RTL) { |
+TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtPoint_RTL) { |
const base::string16 rtl = WideToUTF16( |
L" " |
L"\x0634\x0632" |
@@ -4130,14 +4131,14 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_RTL) { |
{ |
SCOPED_TRACE(base::StringPrintf("Query to the left of text bounds")); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(-5, cursor_y), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_2, decorated_word); |
EXPECT_TRUE(left_glyph_word_2.Contains(baseline_point)); |
} |
{ |
SCOPED_TRACE(base::StringPrintf("Query to the right of text bounds")); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(105, cursor_y), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_1, decorated_word); |
EXPECT_TRUE(left_glyph_word_1.Contains(baseline_point)); |
@@ -4152,8 +4153,8 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_RTL) { |
render_text->GetCursorBounds(SelectionModel(i, CURSOR_FORWARD), false) |
.top_right(); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint(query, &decorated_word, |
- &baseline_point)); |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
+ query, &decorated_word, &baseline_point)); |
if (i < kWordTwoStartIndex) { |
VerifyDecoratedWordsAreEqual(expected_word_1, decorated_word); |
EXPECT_TRUE(left_glyph_word_1.Contains(baseline_point)); |
@@ -4164,8 +4165,9 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_RTL) { |
} |
} |
-// Test that GetDecoratedWordAtPoint behaves correctly for multiline text. |
-TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_Multiline) { |
+// Test that GetDecoratedWordAndBaselineAtPoint behaves correctly for multiline |
+// text. |
+TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtPoint_Multiline) { |
const base::string16 text = ASCIIToUTF16("a b\n..\ncd."); |
const size_t kWordOneIndex = 0; // Index of character 'a'. |
const size_t kWordTwoIndex = 2; // Index of character 'b'. |
@@ -4215,36 +4217,36 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_Multiline) { |
Point baseline_point; |
{ |
// Query to the left of the first line. |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(-5, GetCursorYForTesting(0)), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_1, decorated_word); |
EXPECT_TRUE(left_glyph_word_1.Contains(baseline_point)); |
} |
{ |
// Query on the second line. |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(5, GetCursorYForTesting(1)), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_2, decorated_word); |
EXPECT_TRUE(left_glyph_word_2.Contains(baseline_point)); |
} |
{ |
// Query at the center point of the character 'c'. |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
left_glyph_word_3.CenterPoint(), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_3, decorated_word); |
EXPECT_TRUE(left_glyph_word_3.Contains(baseline_point)); |
} |
{ |
// Query to the right of the third line. |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint( |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
Point(505, GetCursorYForTesting(2)), &decorated_word, &baseline_point)); |
VerifyDecoratedWordsAreEqual(expected_word_3, decorated_word); |
EXPECT_TRUE(left_glyph_word_3.Contains(baseline_point)); |
} |
} |
-// Verify the boolean return value of GetDecoratedWordAtPoint. |
-TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_Return) { |
+// Verify the boolean return value of GetDecoratedWordAndBaselineAtPoint. |
+TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAndBaselineAtPoint_Return) { |
RenderText* render_text = GetRenderText(); |
render_text->SetText(ASCIIToUTF16("...")); |
@@ -4255,21 +4257,21 @@ TEST_P(RenderTextHarfBuzzTest, GetDecoratedWordAtPoint_Return) { |
Point query = |
render_text->GetCursorBounds(SelectionModel(0, CURSOR_FORWARD), false) |
.origin(); |
- EXPECT_FALSE(render_text->GetDecoratedWordAtPoint(query, &decorated_word, |
- &baseline_point)); |
+ EXPECT_FALSE(render_text->GetDecoratedWordAndBaselineAtPoint( |
+ query, &decorated_word, &baseline_point)); |
render_text->SetText(ASCIIToUTF16("abc")); |
query = render_text->GetCursorBounds(SelectionModel(0, CURSOR_FORWARD), false) |
.origin(); |
- EXPECT_TRUE(render_text->GetDecoratedWordAtPoint(query, &decorated_word, |
- &baseline_point)); |
+ EXPECT_TRUE(render_text->GetDecoratedWordAndBaselineAtPoint( |
+ query, &decorated_word, &baseline_point)); |
// False should be returned for obscured text. |
render_text->SetObscured(true); |
query = render_text->GetCursorBounds(SelectionModel(0, CURSOR_FORWARD), false) |
.origin(); |
- EXPECT_FALSE(render_text->GetDecoratedWordAtPoint(query, &decorated_word, |
- &baseline_point)); |
+ EXPECT_FALSE(render_text->GetDecoratedWordAndBaselineAtPoint( |
+ query, &decorated_word, &baseline_point)); |
} |
// Tests text selection made at end points of individual lines of multiline |