### Question:
WXResourceUtils { public static int getColor(String color) { return getColor(color, Integer.MIN_VALUE); }  static int getColor(String color); static int getColor(String color, int defaultColor); static Shader getShader(String image, float width, float height); static boolean isNamedColor(String name);  }### Answer:
@Test public void testColor1() throws Exception { int color = WXResourceUtils.getColor("#ffffff"); assertEquals(color, 0xffffffff); color = WXResourceUtils.getColor("#99ffffff"); assertEquals(color, 0x99ffffff); color = WXResourceUtils.getColor("#aa123123"); assertEquals(color, 0xaa123123); color = WXResourceUtils.getColor("#00000000"); assertEquals(color, 0x00000000); color = WXResourceUtils.getColor("#ssssss"); assertEquals(color, Integer.MIN_VALUE); }
@Test public void testColor2() throws Exception { int color = WXResourceUtils.getColor("#123"); assertEquals(color, 0xff112233); color = WXResourceUtils.getColor("#abc"); assertEquals(color, 0xffaabbcc); color = WXResourceUtils.getColor("#12332"); assertEquals(color, Integer.MIN_VALUE); color = WXResourceUtils.getColor("#sss"); assertEquals(color, Integer.MIN_VALUE); }
@Test public void testColor3() throws Exception { int color = WXResourceUtils.getColor("rgba(50%,50%,50%, 0.5)"); assertEquals(color, 0x7f7f7f7f); color = WXResourceUtils.getColor("rgba( 50%, 50% , 50% , 0.5 )"); assertEquals(color, 0x7f7f7f7f); color = WXResourceUtils.getColor("rgba(255, 255, 255, 1.0)"); assertEquals(color, 0xffffffff); color = WXResourceUtils.getColor("rgba(1%, 1% ,1%, 1)"); assertEquals(color, 0xff020202); color = WXResourceUtils.getColor("rgba(0%, 0, 1%, 0.1)"); assertEquals(color, 0x19000002); color = WXResourceUtils.getColor("rgba(100%, 100%, 100%, 0.1)"); assertEquals(color, 0x19ffffff); color = WXResourceUtils.getColor("rgba(1, 1, 1, 1.0)"); assertEquals(color, 0xff010101); color = WXResourceUtils.getColor("rgba(0.1, 0.1, 0.1, 1.0)"); assertEquals(color, Integer.MIN_VALUE); color = WXResourceUtils.getColor("rgba(10.0%, 101%, -0.1, 50%)"); assertEquals(color, Integer.MIN_VALUE); }
@Test public void testColor4() throws Exception { int color = WXResourceUtils.getColor("rgb(255, 255, 255)"); assertEquals(color, 0xffffffff); color = WXResourceUtils.getColor("rgb(000000, 255, 255)"); assertEquals(color, 0xff00ffff); color = WXResourceUtils.getColor("rgb(256, 256, 256)"); assertEquals(color, 0xffffffff); color = WXResourceUtils.getColor("rgb(-1, 255, 255)"); assertEquals(color, 0xff00ffff); }
@Test public void testColor5() throws Exception { int color = WXResourceUtils.getColor("aliceblue"); assertEquals(color, 0XFFF0F8FF); color = WXResourceUtils.getColor("pink"); assertEquals(color, 0XFFFFC0CB); color = WXResourceUtils.getColor("jahskdja"); assertEquals(color, Integer.MIN_VALUE); }