Add CTS unit test for Paint.setTextLocale()
Change-Id: If94c6884c811dd21604074b05e50305800b1bb6a
diff --git a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
index ec95a5e..3166322 100644
--- a/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/PaintTest.java
@@ -33,6 +33,8 @@
import android.test.AndroidTestCase;
import android.text.SpannedString;
+import java.util.Locale;
+
public class PaintTest extends AndroidTestCase {
private static final Typeface[] TYPEFACES = new Typeface[] {
@@ -533,6 +535,41 @@
assertEquals(Align.RIGHT, p.getTextAlign());
}
+ public void testAccessTextLocale() {
+ Paint p = new Paint();
+
+ final Locale defaultLocale = Locale.getDefault();
+
+ // Check default
+ assertEquals(defaultLocale, p.getTextLocale());
+
+ // Check setter / getter
+ p.setTextLocale(Locale.US);
+ assertEquals(Locale.US, p.getTextLocale());
+
+ p.setTextLocale(Locale.CHINESE);
+ assertEquals(Locale.CHINESE, p.getTextLocale());
+
+ p.setTextLocale(Locale.JAPANESE);
+ assertEquals(Locale.JAPANESE, p.getTextLocale());
+
+ p.setTextLocale(Locale.KOREAN);
+ assertEquals(Locale.KOREAN, p.getTextLocale());
+
+ // Check reverting back to default
+ p.setTextLocale(defaultLocale);
+ assertEquals(defaultLocale, p.getTextLocale());
+
+ // Check that we cannot pass a null locale
+ try {
+ p.setTextLocale(null);
+ assertFalse(true);
+ }
+ catch (IllegalArgumentException iae) {
+ // OK !!
+ }
+ }
+
public void testGetFillPath() {
Paint p = new Paint();
Path path1 = new Path();