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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
(...skipping 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 2366
2367 render_text.SetFontList(font_list); 2367 render_text.SetFontList(font_list);
2368 // Korean character "han". 2368 // Korean character "han".
2369 render_text.SetText(WideToUTF16(L"\xd55c")); 2369 render_text.SetText(WideToUTF16(L"\xd55c"));
2370 render_text.EnsureLayout(); 2370 render_text.EnsureLayout();
2371 ASSERT_EQ(1U, render_text.runs_.size()); 2371 ASSERT_EQ(1U, render_text.runs_.size());
2372 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs()); 2372 EXPECT_EQ(0U, render_text.runs_[0]->CountMissingGlyphs());
2373 } 2373 }
2374 #endif // defined(OS_WIN) 2374 #endif // defined(OS_WIN)
2375 2375
2376 // Ensure that the width reported by RenderText is sufficient for drawing. Draws
2377 // to a canvas and checks whether any pixel beyond the width is colored.
2378 TEST_F(RenderTextTest, TextDoesntClip) {
2379 const wchar_t* kTestStrings[] = { L"Save", L"Remove", L"TEST", L"W", L"WWW" };
2380
2381 skia::RefPtr<SkCanvas> sk_canvas =
2382 skia::AdoptRef(SkCanvas::NewRasterN32(300, 50));
2383 scoped_ptr<Canvas> canvas(
2384 Canvas::CreateCanvasWithoutScaling(sk_canvas.get(), 1.0f));
2385 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2386 render_text->SetDisplayRect(Rect(300, 50));
2387 render_text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
2388 render_text->SetColor(SK_ColorBLACK);
2389
2390 for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
2391 sk_canvas->clear(SK_ColorWHITE);
2392 render_text->SetText(WideToUTF16(kTestStrings[i]));
2393 render_text->SetStyle(BOLD, true);
2394 render_text->Draw(canvas.get());
2395 int width = render_text->GetStringSize().width();
2396 ASSERT_LT(width, 300);
2397 const uint32* buffer = static_cast<const uint32*>(
2398 sk_canvas->peekPixels(NULL, NULL));
2399 ASSERT_NE(nullptr, buffer);
2400 for (int y = 0; y < 50; ++y) {
2401 EXPECT_EQ(SK_ColorWHITE, buffer[width + y * 300])
2402 << "String: " << kTestStrings[i];
2403 }
2404 }
2405 }
2406
2376 } // namespace gfx 2407 } // namespace gfx
OLDNEW
« 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