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

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

Issue 2054273002: Font fallback for UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clang build error due to signed-unsigned comparison 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 // Unit tests for eliding and formatting utility functions. 5 // Unit tests for eliding and formatting utility functions.
6 6
7 #include "ui/gfx/text_elider.h" 7 #include "ui/gfx/text_elider.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/i18n/rtl.h" 15 #include "base/i18n/rtl.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/run_loop.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "build/build_config.h" 20 #include "build/build_config.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/gfx/font.h" 22 #include "ui/gfx/font.h"
22 #include "ui/gfx/font_list.h" 23 #include "ui/gfx/font_list.h"
23 #include "ui/gfx/font_render_params.h" 24 #include "ui/gfx/font_render_params.h"
24 #include "ui/gfx/text_utils.h" 25 #include "ui/gfx/text_utils.h"
25 26
26 using base::ASCIIToUTF16; 27 using base::ASCIIToUTF16;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 324
324 // Test that both both UTF-16 surrogate pairs and combining character sequences 325 // Test that both both UTF-16 surrogate pairs and combining character sequences
325 // do not get split by ElideText. 326 // do not get split by ElideText.
326 // TODO(crbug.com/338784): Enable this on android. 327 // TODO(crbug.com/338784): Enable this on android.
327 #if defined(OS_ANDROID) 328 #if defined(OS_ANDROID)
328 #define MAYBE_ElideTextAtomicSequences DISABLED_ElideTextAtomicSequences 329 #define MAYBE_ElideTextAtomicSequences DISABLED_ElideTextAtomicSequences
329 #else 330 #else
330 #define MAYBE_ElideTextAtomicSequences ElideTextAtomicSequences 331 #define MAYBE_ElideTextAtomicSequences ElideTextAtomicSequences
331 #endif 332 #endif
332 TEST(TextEliderTest, MAYBE_ElideTextAtomicSequences) { 333 TEST(TextEliderTest, MAYBE_ElideTextAtomicSequences) {
334 #if defined(OS_WIN)
335 // Needed to bypass DCHECK in GetFallbackFont.
336 base::MessageLoopForUI message_loop;
337 #endif
333 const FontList font_list; 338 const FontList font_list;
334 // The below is 'MUSICAL SYMBOL G CLEF' (U+1D11E), which is represented in 339 // The below is 'MUSICAL SYMBOL G CLEF' (U+1D11E), which is represented in
335 // UTF-16 as two code units forming a surrogate pair: 0xD834 0xDD1E. 340 // UTF-16 as two code units forming a surrogate pair: 0xD834 0xDD1E.
336 const base::char16 kSurrogate[] = {0xD834, 0xDD1E, 0}; 341 const base::char16 kSurrogate[] = {0xD834, 0xDD1E, 0};
337 // The below is a Devanagari two-character combining sequence U+0921 U+093F. 342 // The below is a Devanagari two-character combining sequence U+0921 U+093F.
338 // The sequence forms a single display character and should not be separated. 343 // The sequence forms a single display character and should not be separated.
339 const base::char16 kCombiningSequence[] = {0x921, 0x93F, 0}; 344 const base::char16 kCombiningSequence[] = {0x921, 0x93F, 0};
340 std::vector<base::string16> pairs; 345 std::vector<base::string16> pairs;
341 pairs.push_back(kSurrogate); 346 pairs.push_back(kSurrogate);
342 pairs.push_back(kCombiningSequence); 347 pairs.push_back(kCombiningSequence);
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 1142
1138 // Test breaking in the middle of the first word, with leading whitespace. 1143 // Test breaking in the middle of the first word, with leading whitespace.
1139 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(str2, 4, WORD_BREAK))); 1144 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(str2, 4, WORD_BREAK)));
1140 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(str2, 4, CHARACTER_BREAK))); 1145 EXPECT_EQ(L"\x2026", UTF16ToWide(TruncateString(str2, 4, CHARACTER_BREAK)));
1141 EXPECT_EQ(L" f\x2026", UTF16ToWide(TruncateString(str2, 5, WORD_BREAK))); 1146 EXPECT_EQ(L" f\x2026", UTF16ToWide(TruncateString(str2, 5, WORD_BREAK)));
1142 EXPECT_EQ(L" f\x2026", 1147 EXPECT_EQ(L" f\x2026",
1143 UTF16ToWide(TruncateString(str2, 5, CHARACTER_BREAK))); 1148 UTF16ToWide(TruncateString(str2, 5, CHARACTER_BREAK)));
1144 } 1149 }
1145 1150
1146 } // namespace gfx 1151 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698