PaintCompatHasGlyphTest.java revision 1b54dfb2b705a342186357111a95fd634b080751
1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.support.v4.graphics;
18
19import static org.junit.Assert.assertEquals;
20
21import android.graphics.Paint;
22import android.support.test.filters.SmallTest;
23
24import org.junit.Test;
25import org.junit.runner.RunWith;
26import org.junit.runners.Parameterized;
27
28import java.util.Arrays;
29import java.util.Collection;
30
31@RunWith(Parameterized.class)
32@SmallTest
33public class PaintCompatHasGlyphTest {
34
35    @Parameterized.Parameters
36    public static Collection<Object[]> data() {
37        return Arrays.asList(new Object[][]{
38                {"B", true},
39                {"\uDB3F\uDFFD", false},
40                {"☺", true},
41                {"Hello", false},
42                {"\u0020", true},  // white space
43                {"\t\t\t", false},  // more white space
44        });
45    }
46
47    private final String mTestString;
48    private final boolean mExpectedResult;
49
50    public PaintCompatHasGlyphTest(String testString, boolean expectedResult) {
51        mTestString = testString;
52        mExpectedResult = expectedResult;
53    }
54
55    @Test
56    public void testHasGlyph() {
57        assertEquals(mExpectedResult, PaintCompat.hasGlyph(new Paint(), mTestString));
58    }
59}
60