Add test case of font loading on restricted context.

Bug: 64115349
Bug: 35763094
Bug: 62813533
Test: bit CtsTextTestCases:android.text.style.cts.TextAppearanceSpanTest
Change-Id: I9d54652140c5761e0218aacb18ab523c007a1197
diff --git a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
index aa9a9d8..489edb2 100644
--- a/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
+++ b/tests/tests/text/src/android/text/style/cts/TextAppearanceSpanTest.java
@@ -22,6 +22,7 @@
 import static org.junit.Assert.assertSame;
 
 import android.content.Context;
+import android.content.pm.PackageManager;
 import android.content.res.ColorStateList;
 import android.graphics.Color;
 import android.os.Parcel;
@@ -247,4 +248,18 @@
         unparceledSpan.updateDrawState(tp);
         assertEquals(originalSpanTextWidth, tp.measureText("a"), 0.0f);
     }
+
+    @Test
+    public void testRestrictContext() throws PackageManager.NameNotFoundException {
+        final Context ctx = mContext.createPackageContext(mContext.getPackageName(),
+                Context.CONTEXT_RESTRICTED);
+        final TextAppearanceSpan span = new TextAppearanceSpan(ctx,
+                android.text.cts.R.style.customFont);
+        final TextPaint tp = new TextPaint();
+        final float originalTextWidth = tp.measureText("a");
+        span.updateDrawState(tp);
+        // Custom font must not be loaded with the restricted context.
+        assertEquals(originalTextWidth, tp.measureText("a"), 0.0f);
+
+    }
 }