| OLD | NEW |
| 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 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2416 render_text->Draw(canvas.get()); | 2416 render_text->Draw(canvas.get()); |
| 2417 int width = render_text->GetStringSize().width(); | 2417 int width = render_text->GetStringSize().width(); |
| 2418 ASSERT_LT(width + kTestWidth, kCanvasSize.width()); | 2418 ASSERT_LT(width + kTestWidth, kCanvasSize.width()); |
| 2419 const uint32* buffer = static_cast<const uint32*>( | 2419 const uint32* buffer = static_cast<const uint32*>( |
| 2420 surface->peekPixels(NULL, NULL)); | 2420 surface->peekPixels(NULL, NULL)); |
| 2421 ASSERT_NE(nullptr, buffer); | 2421 ASSERT_NE(nullptr, buffer); |
| 2422 | 2422 |
| 2423 for (int y = 0; y < kCanvasSize.height(); ++y) { | 2423 for (int y = 0; y < kCanvasSize.height(); ++y) { |
| 2424 // Allow one column of anti-aliased pixels past the expected width. | 2424 // Allow one column of anti-aliased pixels past the expected width. |
| 2425 SkColor color = buffer[width + y * kCanvasSize.width()]; | 2425 SkColor color = buffer[width + y * kCanvasSize.width()]; |
| 2426 EXPECT_LT(230U, color_utils::GetLuminanceForColor(color)) << string; | 2426 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; |
| 2427 for (int x = 1; x < kTestWidth; ++x) { | 2427 for (int x = 1; x < kTestWidth; ++x) { |
| 2428 color = buffer[width + x + y * kCanvasSize.width()]; | 2428 color = buffer[width + x + y * kCanvasSize.width()]; |
| 2429 EXPECT_EQ(SK_ColorWHITE, color) << string; | 2429 EXPECT_EQ(SK_ColorWHITE, color) << string; |
| 2430 } | 2430 } |
| 2431 } | 2431 } |
| 2432 } | 2432 } |
| 2433 } | 2433 } |
| 2434 | 2434 |
| 2435 // This test validates that the RenderText centering baseline is greater than | 2435 // This test validates that the RenderText centering baseline is greater than |
| 2436 // the font list baseline for a valid display rect. | 2436 // the font list baseline for a valid display rect. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2459 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); | 2459 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); |
| 2460 | 2460 |
| 2461 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2461 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 2462 render_text->SetDisplayRect(Rect(0, 0, 25, 25)); | 2462 render_text->SetDisplayRect(Rect(0, 0, 25, 25)); |
| 2463 render_text->SetFontList(font_list); | 2463 render_text->SetFontList(font_list); |
| 2464 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline()); | 2464 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline()); |
| 2465 } | 2465 } |
| 2466 #endif | 2466 #endif |
| 2467 | 2467 |
| 2468 } // namespace gfx | 2468 } // namespace gfx |
| OLD | NEW |