Merge "Add security test annotation for SkiaICORecursiveDecodingTest" into nougat-cts-dev
diff --git a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
index 760e3f9..b4514ec 100644
--- a/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/ColorTest.java
@@ -15,12 +15,58 @@
*/
package android.graphics.cts;
+import android.content.res.Resources;
import android.graphics.Color;
import android.test.AndroidTestCase;
+import android.util.TypedValue;
+
+import java.util.Arrays;
+import java.util.List;
public class ColorTest extends AndroidTestCase {
- public void testAlpha(){
+ public void testResourceColor() {
+ int colors [][] = {
+ { 0xff000000, android.R.color.black },
+ { 0xffaaaaaa, android.R.color.darker_gray },
+ { 0xff00ddff, android.R.color.holo_blue_bright },
+ { 0xff0099cc, android.R.color.holo_blue_dark },
+ { 0xff33b5e5, android.R.color.holo_blue_light },
+ { 0xff669900, android.R.color.holo_green_dark },
+ { 0xff99cc00, android.R.color.holo_green_light },
+ { 0xffff8800, android.R.color.holo_orange_dark },
+ { 0xffffbb33, android.R.color.holo_orange_light },
+ { 0xffaa66cc, android.R.color.holo_purple },
+ { 0xffcc0000, android.R.color.holo_red_dark },
+ { 0xffff4444, android.R.color.holo_red_light },
+ { 0x00000000, android.R.color.transparent },
+ { 0xffffffff, android.R.color.white },
+ };
+
+ Resources resources = mContext.getResources();
+ for (int[] pair : colors) {
+ final int resourceId = pair[1];
+ final int expectedColor = pair[0];
+
+ // validate color from getColor
+ int observedColor = resources.getColor(resourceId);
+ assertEquals("Color = " + Integer.toHexString(observedColor) + ", "
+ + Integer.toHexString(expectedColor) + " expected",
+ expectedColor,
+ observedColor);
+
+ // validate color from getValue
+ TypedValue value = new TypedValue();
+ resources.getValue(resourceId, value, true);
+ assertEquals("Color should be expected value", expectedColor, value.data);
+
+ // colors should be raw ints
+ assertTrue("Type should be int", value.type >= TypedValue.TYPE_FIRST_INT
+ && value.type <= TypedValue.TYPE_LAST_INT);
+ }
+ }
+
+ public void testAlpha() {
assertEquals(0xff, Color.alpha(Color.RED));
assertEquals(0xff, Color.alpha(Color.YELLOW));
new Color();