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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "ui/gfx/break_list.h" | 16 #include "ui/gfx/break_list.h" |
17 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
18 #include "ui/gfx/color_utils.h" | |
18 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font.h" |
19 #include "ui/gfx/render_text_harfbuzz.h" | 20 #include "ui/gfx/render_text_harfbuzz.h" |
20 | 21 |
21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
22 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
23 #include "ui/gfx/platform_font_win.h" | 24 #include "ui/gfx/platform_font_win.h" |
24 #include "ui/gfx/render_text_win.h" | 25 #include "ui/gfx/render_text_win.h" |
25 #endif | 26 #endif |
26 | 27 |
27 #if defined(OS_LINUX) && !defined(USE_OZONE) | 28 #if defined(OS_LINUX) && !defined(USE_OZONE) |
(...skipping 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2393 sk_canvas->clear(SK_ColorWHITE); | 2394 sk_canvas->clear(SK_ColorWHITE); |
2394 render_text->SetText(WideToUTF16(kTestStrings[i])); | 2395 render_text->SetText(WideToUTF16(kTestStrings[i])); |
2395 render_text->SetStyle(BOLD, true); | 2396 render_text->SetStyle(BOLD, true); |
2396 render_text->Draw(canvas.get()); | 2397 render_text->Draw(canvas.get()); |
2397 int width = render_text->GetStringSize().width(); | 2398 int width = render_text->GetStringSize().width(); |
2398 ASSERT_LT(width, 300); | 2399 ASSERT_LT(width, 300); |
2399 const uint32* buffer = static_cast<const uint32*>( | 2400 const uint32* buffer = static_cast<const uint32*>( |
2400 sk_canvas->peekPixels(NULL, NULL)); | 2401 sk_canvas->peekPixels(NULL, NULL)); |
2401 ASSERT_NE(nullptr, buffer); | 2402 ASSERT_NE(nullptr, buffer); |
2402 for (int y = 0; y < 50; ++y) { | 2403 for (int y = 0; y < 50; ++y) { |
2403 EXPECT_EQ(SK_ColorWHITE, buffer[width + y * 300]) | 2404 const SkColor color = buffer[width + y * 300]; |
2405 EXPECT_LT(230U, color_utils::GetLuminanceForColor(color)) | |
msw
2014/12/10 23:55:50
Add a comment explaining the lax condition here.
msw
2014/12/11 23:30:12
Should this perhaps just allow the first column pa
ckocagil
2014/12/12 09:52:11
Done.
| |
2404 << "String: " << kTestStrings[i]; | 2406 << "String: " << kTestStrings[i]; |
2405 } | 2407 } |
2406 } | 2408 } |
2407 } | 2409 } |
2408 | 2410 |
2409 } // namespace gfx | 2411 } // namespace gfx |
OLD | NEW |