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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 738363002: Enable subpixel positioning for UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« ui/gfx/font_render_params_win.cc ('K') | « ui/gfx/font_render_params_win.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 859689b5febce093495cea438fc1b3a3dd0d523d..42976a5c0e00433754831bd0537910b7b6de751f 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -2373,4 +2373,35 @@ TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) {
}
#endif // defined(OS_WIN)
+// Ensure that the width reported by RenderText is sufficient for drawing. Draws
+// to a canvas and checks whether any pixel beyond the width is colored.
+TEST_F(RenderTextTest, TextDoesntClip) {
+ const wchar_t* kTestStrings[] = { L"Save", L"Remove", L"TEST", L"W", L"WWW" };
+
+ skia::RefPtr<SkCanvas> sk_canvas =
+ skia::AdoptRef(SkCanvas::NewRasterN32(300, 50));
+ scoped_ptr<Canvas> canvas(
+ Canvas::CreateCanvasWithoutScaling(sk_canvas.get(), 1.0f));
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ render_text->SetDisplayRect(Rect(300, 50));
+ render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ render_text->SetColor(SK_ColorBLACK);
+
+ for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
+ sk_canvas->clear(SK_ColorWHITE);
+ render_text->SetText(WideToUTF16(kTestStrings[i]));
+ render_text->SetStyle(BOLD, true);
+ render_text->Draw(canvas.get());
+ int width = render_text->GetStringSize().width();
+ ASSERT_LT(width, 300);
+ const uint32* buffer = static_cast<const uint32*>(
+ sk_canvas->peekPixels(NULL, NULL));
+ ASSERT_NE(nullptr, buffer);
+ for (int y = 0; y < 50; ++y) {
+ EXPECT_EQ(SK_ColorWHITE, buffer[width + y * 300])
+ << "String: " << kTestStrings[i];
+ }
+ }
+}
+
} // namespace gfx
« ui/gfx/font_render_params_win.cc ('K') | « ui/gfx/font_render_params_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698