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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 2817403002: [Omnibox] Elide omnibox text (Closed)
Patch Set: Add comment Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index d262f5f5d790806a4c9ef9fd07d905702f08f243..0e1e3b49791bdfb46ec7501c652b3affeecb1588 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -534,6 +534,10 @@ class RenderTextHarfBuzzTest : public RenderTextTest {
return GetRenderText()->GetLineOffset(line_num).y() + 1;
}
+ // Do not use this function to ensure layout. This is only used to run a
+ // subset of the EnsureLayout functionality and check intermediate state.
+ void EnsureLayoutRunList() { GetRenderTextHarfBuzz()->EnsureLayoutRunList(); }
+
private:
DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzzTest);
};
@@ -3963,6 +3967,17 @@ TEST_P(RenderTextMacTest, Mac_ElidedText) {
EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
EXPECT_NE(0, glyph_count);
}
+
+TEST_P(RenderTextMacTest, LinesInvalidationOnElideBehaviorChange) {
+ RenderTextMac* render_text = GetRenderTextMac();
+ render_text->SetText(ASCIIToUTF16("This is an example"));
+ test_api()->EnsureLayout();
+ EXPECT_TRUE(GetCoreTextLine());
+
+ // Lines are cleared when elide behavior changes.
+ render_text->SetElideBehavior(gfx::ELIDE_TAIL);
+ EXPECT_FALSE(GetCoreTextLine());
+}
#endif // defined(OS_MACOSX)
// Ensure color changes are picked up by the RenderText implementation.
@@ -4409,6 +4424,18 @@ TEST_P(RenderTextTest, InvalidFont) {
DrawVisualText();
}
+TEST_P(RenderTextHarfBuzzTest, LinesInvalidationOnElideBehaviorChange) {
+ RenderTextHarfBuzz* render_text = GetRenderTextHarfBuzz();
+ render_text->SetText(ASCIIToUTF16("This is an example"));
+ test_api()->EnsureLayout();
+ EXPECT_FALSE(test_api()->lines().empty());
+
+ // Lines are cleared when elide behavior changes.
+ render_text->SetElideBehavior(gfx::ELIDE_TAIL);
+ EnsureLayoutRunList();
+ EXPECT_TRUE(test_api()->lines().empty());
+}
+
// Ensures that text is centered vertically and consistently when either the
// display rectangle height changes, or when the minimum line height changes.
// The difference between the two is the selection rectangle, which should match
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698