diff options
11 files changed, 137 insertions, 98 deletions
diff --git a/core/tests/coretests/res/color/color_with_lstar.xml b/core/tests/coretests/res/color/color_with_lstar.xml index dcc3d6db1b0a..7762fc069ed5 100644 --- a/core/tests/coretests/res/color/color_with_lstar.xml +++ b/core/tests/coretests/res/color/color_with_lstar.xml @@ -16,5 +16,5 @@ --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> - <item android:color="#ff0000" android:lStar="50" /> + <item android:color="@color/testcolor2" android:lStar="50" /> </selector> diff --git a/core/tests/coretests/res/values/colors.xml b/core/tests/coretests/res/values/colors.xml index 029aa0dd8eb6..f01af8421515 100644 --- a/core/tests/coretests/res/values/colors.xml +++ b/core/tests/coretests/res/values/colors.xml @@ -25,6 +25,5 @@ <drawable name="yellow">#ffffff00</drawable> <color name="testcolor1">#ff00ff00</color> <color name="testcolor2">#ffff0000</color> - <color name="testcolor3">#fff00000</color> <color name="failColor">#ff0000ff</color> </resources> diff --git a/core/tests/coretests/src/android/graphics/BitmapFactoryTest.java b/core/tests/coretests/src/android/graphics/BitmapFactoryTest.java index 564460e18294..84bdbe03df13 100644 --- a/core/tests/coretests/src/android/graphics/BitmapFactoryTest.java +++ b/core/tests/coretests/src/android/graphics/BitmapFactoryTest.java @@ -16,19 +16,27 @@ package android.graphics; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import android.os.ParcelFileDescriptor; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import junit.framework.TestCase; +import org.junit.Test; +import org.junit.runner.RunWith; import java.io.ByteArrayOutputStream; import java.io.FileDescriptor; -public class BitmapFactoryTest extends TestCase { +@RunWith(AndroidJUnit4.class) +public class BitmapFactoryTest { // tests that we can decode bitmaps from MemoryFiles @SmallTest + @Test public void testBitmapParcelFileDescriptor() throws Exception { Bitmap bitmap1 = Bitmap.createBitmap( new int[] { Color.BLUE }, 1, 1, Bitmap.Config.RGB_565); diff --git a/core/tests/coretests/src/android/graphics/BitmapTest.java b/core/tests/coretests/src/android/graphics/BitmapTest.java index 2280cf1cccfa..0126d367eb20 100644 --- a/core/tests/coretests/src/android/graphics/BitmapTest.java +++ b/core/tests/coretests/src/android/graphics/BitmapTest.java @@ -16,19 +16,28 @@ package android.graphics; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import android.hardware.HardwareBuffer; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import junit.framework.TestCase; +import org.junit.Test; +import org.junit.runner.RunWith; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; -public class BitmapTest extends TestCase { +@SmallTest +@RunWith(AndroidJUnit4.class) +public class BitmapTest { - @SmallTest + @Test public void testBasic() throws Exception { Bitmap bm1 = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888); Bitmap bm2 = Bitmap.createBitmap(100, 200, Bitmap.Config.RGB_565); @@ -63,7 +72,7 @@ public class BitmapTest extends TestCase { assertTrue("getConfig", bm3.getConfig() == Bitmap.Config.ARGB_8888); } - @SmallTest + @Test public void testMutability() throws Exception { Bitmap bm1 = Bitmap.createBitmap(100, 200, Bitmap.Config.ARGB_8888); Bitmap bm2 = Bitmap.createBitmap(new int[100 * 200], 100, 200, @@ -82,7 +91,7 @@ public class BitmapTest extends TestCase { } } - @SmallTest + @Test public void testGetPixelsWithAlpha() throws Exception { int[] colors = new int[100]; for (int i = 0; i < 100; i++) { @@ -108,7 +117,7 @@ public class BitmapTest extends TestCase { } - @SmallTest + @Test public void testGetPixelsWithoutAlpha() throws Exception { int[] colors = new int[100]; for (int i = 0; i < 100; i++) { @@ -125,7 +134,7 @@ public class BitmapTest extends TestCase { } } - @SmallTest + @Test public void testSetPixelsWithAlpha() throws Exception { int[] colors = new int[100]; for (int i = 0; i < 100; i++) { @@ -151,7 +160,7 @@ public class BitmapTest extends TestCase { } } - @SmallTest + @Test public void testSetPixelsWithoutAlpha() throws Exception { int[] colors = new int[100]; for (int i = 0; i < 100; i++) { @@ -181,7 +190,7 @@ public class BitmapTest extends TestCase { return unpre; } - @SmallTest + @Test public void testSetPixelsWithNonOpaqueAlpha() throws Exception { int[] colors = new int[256]; for (int i = 0; i < 256; i++) { @@ -238,10 +247,13 @@ public class BitmapTest extends TestCase { } } - @SmallTest + private static final int GRAPHICS_USAGE = + GraphicBuffer.USAGE_HW_TEXTURE | GraphicBuffer.USAGE_SW_READ_OFTEN + | GraphicBuffer.USAGE_SW_WRITE_OFTEN; + + @Test public void testWrapHardwareBufferWithSrgbColorSpace() { - GraphicBuffer buffer = GraphicBuffer.create(10, 10, PixelFormat.RGBA_8888, - GraphicBuffer.USAGE_HW_TEXTURE | GraphicBuffer.USAGE_SOFTWARE_MASK); + GraphicBuffer buffer = GraphicBuffer.create(10, 10, PixelFormat.RGBA_8888, GRAPHICS_USAGE); Canvas canvas = buffer.lockCanvas(); canvas.drawColor(Color.YELLOW); buffer.unlockCanvasAndPost(canvas); @@ -252,10 +264,9 @@ public class BitmapTest extends TestCase { assertEquals(ColorSpace.get(ColorSpace.Named.SRGB), hardwareBitmap.getColorSpace()); } - @SmallTest + @Test public void testWrapHardwareBufferWithDisplayP3ColorSpace() { - GraphicBuffer buffer = GraphicBuffer.create(10, 10, PixelFormat.RGBA_8888, - GraphicBuffer.USAGE_HW_TEXTURE | GraphicBuffer.USAGE_SOFTWARE_MASK); + GraphicBuffer buffer = GraphicBuffer.create(10, 10, PixelFormat.RGBA_8888, GRAPHICS_USAGE); Canvas canvas = buffer.lockCanvas(); canvas.drawColor(Color.YELLOW); buffer.unlockCanvasAndPost(canvas); @@ -267,7 +278,7 @@ public class BitmapTest extends TestCase { assertEquals(ColorSpace.get(ColorSpace.Named.DISPLAY_P3), hardwareBitmap.getColorSpace()); } - @SmallTest + @Test public void testCopyWithDirectByteBuffer() { // Initialize Bitmap final int width = 2; @@ -305,7 +316,7 @@ public class BitmapTest extends TestCase { assertTrue(bm2.sameAs(bm1)); } - @SmallTest + @Test public void testCopyWithDirectShortBuffer() { // Initialize Bitmap final int width = 2; @@ -344,7 +355,7 @@ public class BitmapTest extends TestCase { assertTrue(bm2.sameAs(bm1)); } - @SmallTest + @Test public void testCopyWithDirectIntBuffer() { // Initialize Bitmap final int width = 2; @@ -383,7 +394,7 @@ public class BitmapTest extends TestCase { assertTrue(bm2.sameAs(bm1)); } - @SmallTest + @Test public void testCopyWithHeapByteBuffer() { // Initialize Bitmap final int width = 2; @@ -420,7 +431,7 @@ public class BitmapTest extends TestCase { assertTrue(bm2.sameAs(bm1)); } - @SmallTest + @Test public void testCopyWithHeapShortBuffer() { // Initialize Bitmap final int width = 2; @@ -457,7 +468,7 @@ public class BitmapTest extends TestCase { assertTrue(bm2.sameAs(bm1)); } - @SmallTest + @Test public void testCopyWithHeapIntBuffer() { // Initialize Bitmap final int width = 2; diff --git a/core/tests/coretests/src/android/graphics/ColorStateListTest.java b/core/tests/coretests/src/android/graphics/ColorStateListTest.java index ab41bd07ac6d..5cc915e45a6f 100644 --- a/core/tests/coretests/src/android/graphics/ColorStateListTest.java +++ b/core/tests/coretests/src/android/graphics/ColorStateListTest.java @@ -16,33 +16,41 @@ package android.graphics; +import static org.junit.Assert.assertEquals; + import android.content.res.ColorStateList; import android.content.res.Resources; -import android.test.AndroidTestCase; import android.util.proto.ProtoInputStream; import android.util.proto.ProtoOutputStream; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; +import androidx.test.platform.app.InstrumentationRegistry; import com.android.frameworks.coretests.R; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + /** - * Tests of {@link android.graphics.ColorStateList} + * Tests of {@link ColorStateList} */ -public class ColorStateListTest extends AndroidTestCase { +@SmallTest +@RunWith(AndroidJUnit4.class) +public class ColorStateListTest { private Resources mResources; private int mFailureColor; - @Override - protected void setUp() throws Exception { - super.setUp(); - mResources = mContext.getResources(); + @Before + public void setUp() throws Exception { + mResources = InstrumentationRegistry.getInstrumentation().getContext().getResources(); mFailureColor = mResources.getColor(R.color.failColor); } - @SmallTest + @Test public void testStateIsInList() throws Exception { ColorStateList colorStateList = mResources.getColorStateList(R.color.color1); int[] focusedState = {android.R.attr.state_focused}; @@ -50,7 +58,7 @@ public class ColorStateListTest extends AndroidTestCase { assertEquals(mResources.getColor(R.color.testcolor1), focusColor); } - @SmallTest + @Test public void testStateIsInList_proto() throws Exception { ColorStateList colorStateList = recreateFromProto( mResources.getColorStateList(R.color.color1)); @@ -59,7 +67,7 @@ public class ColorStateListTest extends AndroidTestCase { assertEquals(mResources.getColor(R.color.testcolor1), focusColor); } - @SmallTest + @Test public void testEmptyState() throws Exception { ColorStateList colorStateList = mResources.getColorStateList(R.color.color1); int[] emptyState = {}; @@ -67,7 +75,7 @@ public class ColorStateListTest extends AndroidTestCase { assertEquals(mResources.getColor(R.color.testcolor2), defaultColor); } - @SmallTest + @Test public void testEmptyState_proto() throws Exception { ColorStateList colorStateList = recreateFromProto( mResources.getColorStateList(R.color.color1)); @@ -76,22 +84,23 @@ public class ColorStateListTest extends AndroidTestCase { assertEquals(mResources.getColor(R.color.testcolor2), defaultColor); } - @SmallTest + @Test public void testGetColor() throws Exception { int defaultColor = mResources.getColor(R.color.color1); assertEquals(mResources.getColor(R.color.testcolor2), defaultColor); } - @SmallTest + @Test public void testGetColorWhenListHasNoDefault() throws Exception { int defaultColor = mResources.getColor(R.color.color_no_default); assertEquals(mResources.getColor(R.color.testcolor1), defaultColor); } - @SmallTest + @Test public void testLstar() throws Exception { + var cl = ColorStateList.valueOf(mResources.getColor(R.color.testcolor2)).withLStar(50.0f); int defaultColor = mResources.getColor(R.color.color_with_lstar); - assertEquals(mResources.getColor(R.color.testcolor3), defaultColor); + assertEquals(cl.getDefaultColor(), defaultColor); } private ColorStateList recreateFromProto(ColorStateList colorStateList) throws Exception { diff --git a/core/tests/coretests/src/android/graphics/FontFileUtilTest.java b/core/tests/coretests/src/android/graphics/FontFileUtilTest.java index 52cc4cac4816..063bdf52fbd2 100644 --- a/core/tests/coretests/src/android/graphics/FontFileUtilTest.java +++ b/core/tests/coretests/src/android/graphics/FontFileUtilTest.java @@ -30,9 +30,11 @@ import android.util.Log; import android.util.Pair; import androidx.test.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import org.junit.Test; +import org.junit.runner.RunWith; import java.io.File; import java.io.FileInputStream; @@ -43,6 +45,7 @@ import java.nio.ByteBuffer; import java.nio.channels.FileChannel; @SmallTest +@RunWith(AndroidJUnit4.class) public class FontFileUtilTest { private static final String TAG = "FontFileUtilTest"; private static final String CACHE_FILE_PREFIX = ".font"; diff --git a/core/tests/coretests/src/android/graphics/GraphicsTests.java b/core/tests/coretests/src/android/graphics/GraphicsTests.java deleted file mode 100644 index 70f5976843bc..000000000000 --- a/core/tests/coretests/src/android/graphics/GraphicsTests.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.graphics; - -import junit.framework.TestSuite; - -public class GraphicsTests { - public static TestSuite suite() { - TestSuite suite = new TestSuite(GraphicsTests.class.getName()); - - suite.addTestSuite(BitmapTest.class); - return suite; - } -} diff --git a/core/tests/coretests/src/android/graphics/PaintFontVariationTest.java b/core/tests/coretests/src/android/graphics/PaintFontVariationTest.java index 8a54e5b998e7..816bde603d36 100644 --- a/core/tests/coretests/src/android/graphics/PaintFontVariationTest.java +++ b/core/tests/coretests/src/android/graphics/PaintFontVariationTest.java @@ -21,10 +21,9 @@ import static com.google.common.truth.Truth.assertThat; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; -import android.test.InstrumentationTestCase; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; -import androidx.test.runner.AndroidJUnit4; import com.android.text.flags.Flags; @@ -37,7 +36,7 @@ import org.junit.runner.RunWith; */ @SmallTest @RunWith(AndroidJUnit4.class) -public class PaintFontVariationTest extends InstrumentationTestCase { +public class PaintFontVariationTest { @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); diff --git a/core/tests/coretests/src/android/graphics/PaintTest.java b/core/tests/coretests/src/android/graphics/PaintTest.java index 878ba703c8fe..56760d77e28b 100644 --- a/core/tests/coretests/src/android/graphics/PaintTest.java +++ b/core/tests/coretests/src/android/graphics/PaintTest.java @@ -18,19 +18,26 @@ package android.graphics; import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import android.platform.test.annotations.RequiresFlagsEnabled; import android.platform.test.flag.junit.CheckFlagsRule; import android.platform.test.flag.junit.DeviceFlagsValueProvider; -import android.test.InstrumentationTestCase; import android.text.TextUtils; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; +import androidx.test.platform.app.InstrumentationRegistry; import com.android.text.flags.Flags; import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; import java.util.Arrays; import java.util.HashSet; @@ -38,13 +45,14 @@ import java.util.HashSet; /** * PaintTest tests {@link Paint}. */ -public class PaintTest extends InstrumentationTestCase { +@RunWith(AndroidJUnit4.class) +public class PaintTest { @Rule public final CheckFlagsRule mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule(); private static final String FONT_PATH = "fonts/HintedAdvanceWidthTest-Regular.ttf"; - static void assertEquals(String message, float[] expected, float[] actual) { + static void assertFloatArrayEquals(String message, float[] expected, float[] actual) { if (expected.length != actual.length) { fail(message + " expected array length:<" + expected.length + "> but was:<" + actual.length + ">"); @@ -88,9 +96,10 @@ public class PaintTest extends InstrumentationTestCase { }; @SmallTest + @Test public void testHintingWidth() { final Typeface fontTypeface = Typeface.createFromAsset( - getInstrumentation().getContext().getAssets(), FONT_PATH); + InstrumentationRegistry.getInstrumentation().getContext().getAssets(), FONT_PATH); Paint paint = new Paint(); paint.setTypeface(fontTypeface); @@ -103,12 +112,14 @@ public class PaintTest extends InstrumentationTestCase { paint.setHinting(Paint.HINTING_OFF); paint.getTextWidths(String.valueOf(testCase.mText), widths); - assertEquals("Text width of '" + testCase.mText + "' without hinting is not expected.", + assertFloatArrayEquals( + "Text width of '" + testCase.mText + "' without hinting is not expected.", testCase.mWidthWithoutHinting, widths); paint.setHinting(Paint.HINTING_ON); paint.getTextWidths(String.valueOf(testCase.mText), widths); - assertEquals("Text width of '" + testCase.mText + "' with hinting is not expected.", + assertFloatArrayEquals( + "Text width of '" + testCase.mText + "' with hinting is not expected.", testCase.mWidthWithHinting, widths); } } @@ -131,9 +142,11 @@ public class PaintTest extends InstrumentationTestCase { return sb.toString(); } + @Test public void testHasGlyph_variationSelectors() { final Typeface fontTypeface = Typeface.createFromAsset( - getInstrumentation().getContext().getAssets(), "fonts/hasGlyphTestFont.ttf"); + InstrumentationRegistry.getInstrumentation().getContext().getAssets(), + "fonts/hasGlyphTestFont.ttf"); Paint p = new Paint(); p.setTypeface(fontTypeface); @@ -175,6 +188,7 @@ public class PaintTest extends InstrumentationTestCase { } } + @Test public void testGetTextRunAdvances() { { // LTR @@ -231,6 +245,7 @@ public class PaintTest extends InstrumentationTestCase { } } + @Test public void testGetTextRunAdvances_invalid() { Paint p = new Paint(); char[] text = "test".toCharArray(); @@ -284,6 +299,7 @@ public class PaintTest extends InstrumentationTestCase { } } + @Test public void testMeasureTextBidi() { Paint p = new Paint(); { @@ -340,18 +356,21 @@ public class PaintTest extends InstrumentationTestCase { } } + @Test public void testSetGetWordSpacing() { Paint p = new Paint(); - assertEquals(0.0f, p.getWordSpacing()); // The default value should be 0. + assertEquals(0.0f, p.getWordSpacing(), 0.0f); // The default value should be 0. p.setWordSpacing(1.0f); - assertEquals(1.0f, p.getWordSpacing()); + assertEquals(1.0f, p.getWordSpacing(), 0.0f); p.setWordSpacing(-2.0f); - assertEquals(-2.0f, p.getWordSpacing()); + assertEquals(-2.0f, p.getWordSpacing(), 0.0f); } + @Test public void testGetUnderlinePositionAndThickness() { final Typeface fontTypeface = Typeface.createFromAsset( - getInstrumentation().getContext().getAssets(), "fonts/underlineTestFont.ttf"); + InstrumentationRegistry.getInstrumentation().getContext().getAssets(), + "fonts/underlineTestFont.ttf"); final Paint p = new Paint(); final int textSize = 100; p.setTextSize(textSize); @@ -391,6 +410,7 @@ public class PaintTest extends InstrumentationTestCase { return ccByChars; } + @Test public void testCluster() { final Paint p = new Paint(); p.setTextSize(100); @@ -417,6 +437,7 @@ public class PaintTest extends InstrumentationTestCase { } @RequiresFlagsEnabled(Flags.FLAG_TYPEFACE_CACHE_FOR_VAR_SETTINGS) + @Test public void testDerivedFromSameTypeface() { final Paint p = new Paint(); @@ -432,6 +453,7 @@ public class PaintTest extends InstrumentationTestCase { } @RequiresFlagsEnabled(Flags.FLAG_TYPEFACE_CACHE_FOR_VAR_SETTINGS) + @Test public void testDerivedFromChained() { final Paint p = new Paint(); diff --git a/core/tests/coretests/src/android/graphics/ThreadBitmapTest.java b/core/tests/coretests/src/android/graphics/ThreadBitmapTest.java index e1ca7dfb7cc2..fbaf502596f7 100644 --- a/core/tests/coretests/src/android/graphics/ThreadBitmapTest.java +++ b/core/tests/coretests/src/android/graphics/ThreadBitmapTest.java @@ -16,17 +16,17 @@ package android.graphics; +import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import junit.framework.TestCase; +import org.junit.Test; +import org.junit.runner.RunWith; -public class ThreadBitmapTest extends TestCase { - - @Override - protected void setUp() throws Exception { - } +@RunWith(AndroidJUnit4.class) +public class ThreadBitmapTest { @LargeTest + @Test public void testCreation() { for (int i = 0; i < 200; i++) { @@ -44,4 +44,3 @@ public class ThreadBitmapTest extends TestCase { public void run() {} } } - diff --git a/core/tests/coretests/src/android/graphics/TypefaceSystemFallbackTest.java b/core/tests/coretests/src/android/graphics/TypefaceSystemFallbackTest.java index 14292725506e..2b6eda8f0988 100644 --- a/core/tests/coretests/src/android/graphics/TypefaceSystemFallbackTest.java +++ b/core/tests/coretests/src/android/graphics/TypefaceSystemFallbackTest.java @@ -39,6 +39,8 @@ import androidx.test.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; +import com.android.text.flags.Flags; + import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -514,9 +516,14 @@ public class TypefaceSystemFallbackTest { assertEquals(GLYPH_1EM_WIDTH, paint.measureText("c"), 0.0f); paint.setElegantTextHeight(false); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); - assertEquals(GLYPH_3EM_WIDTH, paint.measureText("b"), 0.0f); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("c"), 0.0f); + if (Flags.deprecateElegantTextHeightApi()) { + // Calling setElegantTextHeight is no-op. + assertTrue(paint.isElegantTextHeight()); + } else { + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); + assertEquals(GLYPH_3EM_WIDTH, paint.measureText("b"), 0.0f); + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("c"), 0.0f); + } } @Test @@ -553,9 +560,14 @@ public class TypefaceSystemFallbackTest { assertEquals(GLYPH_1EM_WIDTH, paint.measureText("c"), 0.0f); paint.setElegantTextHeight(false); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("b"), 0.0f); - assertEquals(GLYPH_3EM_WIDTH, paint.measureText("c"), 0.0f); + if (Flags.deprecateElegantTextHeightApi()) { + // Calling setElegantTextHeight is no-op. + assertTrue(paint.isElegantTextHeight()); + } else { + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("b"), 0.0f); + assertEquals(GLYPH_3EM_WIDTH, paint.measureText("c"), 0.0f); + } testTypeface = fontMap.get("sans-serif"); assertNotNull(testTypeface); @@ -566,9 +578,14 @@ public class TypefaceSystemFallbackTest { assertEquals(GLYPH_1EM_WIDTH, paint.measureText("c"), 0.0f); paint.setElegantTextHeight(false); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); - assertEquals(GLYPH_1EM_WIDTH, paint.measureText("b"), 0.0f); - assertEquals(GLYPH_3EM_WIDTH, paint.measureText("c"), 0.0f); + if (Flags.deprecateElegantTextHeightApi()) { + // Calling setElegantTextHeight is no-op. + assertTrue(paint.isElegantTextHeight()); + } else { + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("a"), 0.0f); + assertEquals(GLYPH_1EM_WIDTH, paint.measureText("b"), 0.0f); + assertEquals(GLYPH_3EM_WIDTH, paint.measureText("c"), 0.0f); + } } @Test |