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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 2054273002: Font fallback for UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests Created 4 years, 5 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 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 <limits.h> 7 #include <limits.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <memory> 12 #include <memory>
13 13
14 #include "base/format_macros.h" 14 #include "base/format_macros.h"
15 #include "base/i18n/break_iterator.h" 15 #include "base/i18n/break_iterator.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/run_loop.h"
17 #include "base/strings/string_split.h" 18 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 #include "third_party/skia/include/core/SkRefCnt.h" 24 #include "third_party/skia/include/core/SkRefCnt.h"
24 #include "third_party/skia/include/core/SkSurface.h" 25 #include "third_party/skia/include/core/SkSurface.h"
25 #include "third_party/skia/include/core/SkTypeface.h" 26 #include "third_party/skia/include/core/SkTypeface.h"
26 #include "ui/gfx/break_list.h" 27 #include "ui/gfx/break_list.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 RenderTextHarfBuzz render_text_harfbuzz_; 297 RenderTextHarfBuzz render_text_harfbuzz_;
297 #if defined(OS_MACOSX) 298 #if defined(OS_MACOSX)
298 RenderTextMac render_text_mac_; 299 RenderTextMac render_text_mac_;
299 #endif 300 #endif
300 301
301 DISALLOW_COPY_AND_ASSIGN(RenderTextAllBackends); 302 DISALLOW_COPY_AND_ASSIGN(RenderTextAllBackends);
302 }; 303 };
303 304
304 } // namespace 305 } // namespace
305 306
306 using RenderTextTest = testing::Test; 307 class RenderTextTest : public testing::Test {
308 private:
309 #if defined(OS_WIN)
310 // Needed to bypass DCHECK in GetFallbackFont
msw 2016/06/23 20:59:38 nit: trailing period.
Ilya Kulshin 2016/06/24 20:48:25 Done.
311 base::MessageLoopForUI message_loop_;
msw 2016/06/23 20:59:38 q: can you move this to just the needed fixtures?
Ilya Kulshin 2016/06/24 20:48:25 There's about two dozen tests that need this. I'll
312 #endif
313 };
307 314
308 TEST_F(RenderTextTest, DefaultStyles) { 315 TEST_F(RenderTextTest, DefaultStyles) {
309 // Check the default styles applied to new instances and adjusted text. 316 // Check the default styles applied to new instances and adjusted text.
310 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance()); 317 std::unique_ptr<RenderText> render_text(RenderText::CreateInstance());
311 EXPECT_TRUE(render_text->text().empty()); 318 EXPECT_TRUE(render_text->text().empty());
312 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" }; 319 const wchar_t* const cases[] = { kWeak, kLtr, L"Hello", kRtl, L"", L"" };
313 for (size_t i = 0; i < arraysize(cases); ++i) { 320 for (size_t i = 0; i < arraysize(cases); ++i) {
314 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLACK)); 321 EXPECT_TRUE(render_text->colors().EqualsValueForTesting(SK_ColorBLACK));
315 EXPECT_TRUE( 322 EXPECT_TRUE(
316 render_text->baselines().EqualsValueForTesting(NORMAL_BASELINE)); 323 render_text->baselines().EqualsValueForTesting(NORMAL_BASELINE));
(...skipping 3095 matching lines...) Expand 10 before | Expand all | Expand 10 after
3412 EXPECT_FALSE(backend.paint().isLCDRenderText()); 3419 EXPECT_FALSE(backend.paint().isLCDRenderText());
3413 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering = 3420 backend.GetHarfbuzzRunList()->runs()[0]->render_params.subpixel_rendering =
3414 FontRenderParams::SUBPIXEL_RENDERING_RGB; 3421 FontRenderParams::SUBPIXEL_RENDERING_RGB;
3415 backend.DrawVisualText(); 3422 backend.DrawVisualText();
3416 #endif 3423 #endif
3417 EXPECT_FALSE(backend.paint().isLCDRenderText()); 3424 EXPECT_FALSE(backend.paint().isLCDRenderText());
3418 } 3425 }
3419 } 3426 }
3420 3427
3421 } // namespace gfx 3428 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698