diff options
| author | 2021-06-14 21:02:28 +0000 | |
|---|---|---|
| committer | 2021-06-14 21:02:28 +0000 | |
| commit | 1ab7e96c3136b2ece6330194862602c2bbb3fdc2 (patch) | |
| tree | 629dd2c18d604b9e2dcf0a42f097023a977f8d20 /tests/UpdatableSystemFontTest/src | |
| parent | f6f5306420a41f501e90c6fa50c0f81a2f3e5de8 (diff) | |
| parent | 9f5b66cd5c20e3b191d6cf14ab34a64fcb835ec5 (diff) | |
Merge "Read font attributes from buffer." into sc-dev am: 7adad678e0 am: 9f5b66cd5c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14924347
Change-Id: I84fce8f1eff31fd70e9d22191e38ddeadd222f9e
Diffstat (limited to 'tests/UpdatableSystemFontTest/src')
| -rw-r--r-- | tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java b/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java index 108063ee866a..87fda0d220e5 100644 --- a/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java +++ b/tests/UpdatableSystemFontTest/src/com/android/updatablesystemfont/UpdatableSystemFontTest.java @@ -44,6 +44,9 @@ import android.util.Pair; import androidx.annotation.Nullable; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.UiDevice; +import androidx.test.uiautomator.Until; import com.android.compatibility.common.util.StreamUtil; import com.android.compatibility.common.util.SystemUtil; @@ -119,6 +122,9 @@ public class UpdatableSystemFontTest { private static final String TEST_NOTO_SERIF = "test-noto-serif"; private static final long ACTIVITY_TIMEOUT_MILLIS = SECONDS.toMillis(10); + private static final String GET_AVAILABLE_FONTS_TEST_ACTIVITY = + EMOJI_RENDERING_TEST_APP_ID + "/.GetAvailableFontsTestActivity"; + private static final Pattern PATTERN_FONT_FILES = Pattern.compile("\\.(ttf|otf|ttc|otc)$"); private static final Pattern PATTERN_TMP_FILES = Pattern.compile("^/data/local/tmp/"); private static final Pattern PATTERN_DATA_FONT_FILES = Pattern.compile("^/data/fonts/files/"); @@ -127,6 +133,7 @@ public class UpdatableSystemFontTest { private String mKeyId; private FontManager mFontManager; + private UiDevice mUiDevice; @Before public void setUp() throws Exception { @@ -138,6 +145,7 @@ public class UpdatableSystemFontTest { mKeyId = insertCert(CERT_PATH); mFontManager = context.getSystemService(FontManager.class); expectCommandToSucceed("cmd font clear"); + mUiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); } @After @@ -347,6 +355,19 @@ public class UpdatableSystemFontTest { assertThat(countMatch(openFiles, patternEmojiVPlus1)).isEqualTo(0); } + @Test + public void getAvailableFonts() throws Exception { + String fontPath = getFontPath(NOTO_COLOR_EMOJI_POSTSCRIPT_NAME); + startActivity(EMOJI_RENDERING_TEST_APP_ID, GET_AVAILABLE_FONTS_TEST_ACTIVITY); + // GET_AVAILABLE_FONTS_TEST_ACTIVITY shows the NotoColorEmoji path it got. + mUiDevice.wait( + Until.findObject(By.pkg(EMOJI_RENDERING_TEST_APP_ID).text(fontPath)), + ACTIVITY_TIMEOUT_MILLIS); + // The font file should not be opened just by querying the path using + // SystemFont.getAvailableFonts(). + assertThat(isFileOpenedBy(fontPath, EMOJI_RENDERING_TEST_APP_ID)).isFalse(); + } + private static String insertCert(String certPath) throws Exception { Pair<String, String> result; try (InputStream is = new FileInputStream(certPath)) { |