1 package com.android.systemui.animation 2 3 import android.testing.AndroidTestingRunner 4 import androidx.test.filters.SmallTest 5 import com.android.systemui.SysuiTestCase 6 import junit.framework.Assert 7 import org.junit.Test 8 import org.junit.runner.RunWith 9 10 private const val TAG_WGHT = "wght" 11 private const val TAG_WDTH = "wdth" 12 private const val TAG_OPSZ = "opsz" 13 private const val TAG_ROND = "ROND" 14 15 @RunWith(AndroidTestingRunner::class) 16 @SmallTest 17 class FontVariationUtilsTest : SysuiTestCase() { 18 @Test 19 fun testUpdateFontVariation_getCorrectFvarStr() { 20 val fontVariationUtils = FontVariationUtils() 21 val initFvar = 22 fontVariationUtils.updateFontVariation( 23 weight = 100, 24 width = 100, 25 opticalSize = -1, 26 roundness = 100 27 ) 28 Assert.assertEquals("'$TAG_WGHT' 100, '$TAG_WDTH' 100, '$TAG_ROND' 100", initFvar) 29 val updatedFvar = 30 fontVariationUtils.updateFontVariation( 31 weight = 200, 32 width = 100, 33 opticalSize = 0, 34 roundness = 100 35 ) 36 Assert.assertEquals( 37 "'$TAG_WGHT' 200, '$TAG_WDTH' 100, '$TAG_OPSZ' 0, '$TAG_ROND' 100", 38 updatedFvar 39 ) 40 } 41 42 @Test 43 fun testStyleValueUnchange_getBlankStr() { 44 val fontVariationUtils = FontVariationUtils() 45 fontVariationUtils.updateFontVariation( 46 weight = 100, 47 width = 100, 48 opticalSize = 0, 49 roundness = 100 50 ) 51 val updatedFvar1 = 52 fontVariationUtils.updateFontVariation( 53 weight = 100, 54 width = 100, 55 opticalSize = 0, 56 roundness = 100 57 ) 58 Assert.assertEquals("", updatedFvar1) 59 val updatedFvar2 = fontVariationUtils.updateFontVariation() 60 Assert.assertEquals("", updatedFvar2) 61 } 62 } 63