PaintCompatHasGlyphTest.java revision 5c4dd610eace399c47eb0418d617aa05701f9ab9
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 }); 44 } 45 46 private final String mTestString; 47 private final boolean mExpectedResult; 48 49 public PaintCompatHasGlyphTest(String testString, boolean expectedResult) { 50 mTestString = testString; 51 mExpectedResult = expectedResult; 52 } 53 54 @Test 55 public void testHasGlyph() { 56 assertEquals(mExpectedResult, PaintCompat.hasGlyph(new Paint(), mTestString)); 57 } 58} 59