OLD | NEW |
| (Empty) |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "core/css/CSSFontFace.h" | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace blink { | |
10 | |
11 static const UChar hiraganaA[2] = { 0x3042, 0 }; | |
12 | |
13 TEST(CSSFontFace, UnicodeRangeSetEmpty) | |
14 { | |
15 Vector<CSSFontFace::UnicodeRange> ranges; | |
16 CSSFontFace::UnicodeRangeSet set(ranges); | |
17 EXPECT_TRUE(set.isEntireRange()); | |
18 EXPECT_EQ(0u, set.size()); | |
19 EXPECT_FALSE(set.intersectsWith(String())); | |
20 EXPECT_TRUE(set.intersectsWith(String("a"))); | |
21 EXPECT_TRUE(set.intersectsWith(String(hiraganaA))); | |
22 } | |
23 | |
24 TEST(CSSFontFace, UnicodeRangeSetSingleCharacter) | |
25 { | |
26 Vector<CSSFontFace::UnicodeRange> ranges; | |
27 ranges.append(CSSFontFace::UnicodeRange('b', 'b')); | |
28 CSSFontFace::UnicodeRangeSet set(ranges); | |
29 EXPECT_FALSE(set.isEntireRange()); | |
30 EXPECT_FALSE(set.intersectsWith(String())); | |
31 EXPECT_FALSE(set.intersectsWith(String("a"))); | |
32 EXPECT_TRUE(set.intersectsWith(String("b"))); | |
33 EXPECT_FALSE(set.intersectsWith(String("c"))); | |
34 EXPECT_TRUE(set.intersectsWith(String("abc"))); | |
35 EXPECT_FALSE(set.intersectsWith(String(hiraganaA))); | |
36 ASSERT_EQ(1u, set.size()); | |
37 EXPECT_EQ('b', set.rangeAt(0).from()); | |
38 EXPECT_EQ('b', set.rangeAt(0).to()); | |
39 } | |
40 | |
41 TEST(CSSFontFace, UnicodeRangeSetTwoRanges) | |
42 { | |
43 Vector<CSSFontFace::UnicodeRange> ranges; | |
44 ranges.append(CSSFontFace::UnicodeRange('6', '7')); | |
45 ranges.append(CSSFontFace::UnicodeRange('2', '4')); | |
46 CSSFontFace::UnicodeRangeSet set(ranges); | |
47 EXPECT_FALSE(set.isEntireRange()); | |
48 EXPECT_FALSE(set.intersectsWith(String())); | |
49 EXPECT_FALSE(set.intersectsWith(String("1"))); | |
50 EXPECT_TRUE(set.intersectsWith(String("2"))); | |
51 EXPECT_TRUE(set.intersectsWith(String("3"))); | |
52 EXPECT_TRUE(set.intersectsWith(String("4"))); | |
53 EXPECT_FALSE(set.intersectsWith(String("5"))); | |
54 EXPECT_TRUE(set.intersectsWith(String("6"))); | |
55 EXPECT_TRUE(set.intersectsWith(String("7"))); | |
56 EXPECT_FALSE(set.intersectsWith(String("8"))); | |
57 ASSERT_EQ(2u, set.size()); | |
58 EXPECT_EQ('2', set.rangeAt(0).from()); | |
59 EXPECT_EQ('4', set.rangeAt(0).to()); | |
60 EXPECT_EQ('6', set.rangeAt(1).from()); | |
61 EXPECT_EQ('7', set.rangeAt(1).to()); | |
62 } | |
63 | |
64 TEST(CSSFontFace, UnicodeRangeSetOverlap) | |
65 { | |
66 Vector<CSSFontFace::UnicodeRange> ranges; | |
67 ranges.append(CSSFontFace::UnicodeRange('0', '2')); | |
68 ranges.append(CSSFontFace::UnicodeRange('1', '1')); | |
69 ranges.append(CSSFontFace::UnicodeRange('3', '5')); | |
70 ranges.append(CSSFontFace::UnicodeRange('4', '6')); | |
71 CSSFontFace::UnicodeRangeSet set(ranges); | |
72 ASSERT_EQ(1u, set.size()); | |
73 EXPECT_EQ('0', set.rangeAt(0).from()); | |
74 EXPECT_EQ('6', set.rangeAt(0).to()); | |
75 } | |
76 | |
77 TEST(CSSFontFace, UnicodeRangeSetNon8Bit) | |
78 { | |
79 Vector<CSSFontFace::UnicodeRange> ranges; | |
80 ranges.append(CSSFontFace::UnicodeRange(0x3042, 0x3042)); | |
81 CSSFontFace::UnicodeRangeSet set(ranges); | |
82 ASSERT_EQ(1u, set.size()); | |
83 EXPECT_EQ(0x3042, set.rangeAt(0).from()); | |
84 EXPECT_EQ(0x3042, set.rangeAt(0).to()); | |
85 EXPECT_FALSE(set.intersectsWith(String("a"))); | |
86 EXPECT_TRUE(set.intersectsWith(String(hiraganaA))); | |
87 } | |
88 | |
89 } // namespace blink | |
OLD | NEW |