mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 10:14:36 +00:00
Continue test cases
This commit is contained in:
@@ -36,7 +36,7 @@ public class ColorDecode {
|
||||
rgb.add(rgbInt[1]);
|
||||
rgb.add(rgbInt[2]);
|
||||
|
||||
log.info("Color change with HSL: " + hsl + ". Resulting RGB Values: " + rgb.get(0) + " " + rgb.get(1) + " "
|
||||
log.debug("Color change with HSL: " + hsl + ". Resulting RGB Values: " + rgb.get(0) + " " + rgb.get(1) + " "
|
||||
+ rgb.get(2));
|
||||
return rgb;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,49 @@ public class ConvertCIEColorTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionXYtoRGB() {
|
||||
public void testColorConverterRGBtoHSL() {
|
||||
float[] rgb = ColorConverter.RGBtoHLS(255,0,0);
|
||||
List<Float> rgbDecode = new ArrayList<Float>();
|
||||
rgbDecode.add(0, rgb[0]);
|
||||
rgbDecode.add(1, rgb[1]);
|
||||
rgbDecode.add(2, rgb[2]);
|
||||
List<Float> assertDecode = new ArrayList<Float>();
|
||||
assertDecode.add(0, 0.0f);
|
||||
assertDecode.add(1, 1.0f);
|
||||
assertDecode.add(2, 0.50000f);
|
||||
Assert.assertEquals(rgbDecode, assertDecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConverterHSLtoRGB2() {
|
||||
int[] rgb = ColorConverter.normalizeRGB(ColorConverter.HSLtoRGB(0.57629f, 0.56299f, 0.50394f));
|
||||
List<Integer> rgbDecode = new ArrayList<Integer>();
|
||||
rgbDecode.add(0, rgb[0]);
|
||||
rgbDecode.add(1, rgb[1]);
|
||||
rgbDecode.add(2, rgb[2]);
|
||||
List<Integer> assertDecode = new ArrayList<Integer>();
|
||||
assertDecode.add(0, 58);
|
||||
assertDecode.add(1, 135);
|
||||
assertDecode.add(2, 200);
|
||||
Assert.assertEquals(rgbDecode, assertDecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConverterRGBtoHSL2() {
|
||||
float[] rgb = ColorConverter.RGBtoHLS(58,135,200);
|
||||
List<Float> rgbDecode = new ArrayList<Float>();
|
||||
rgbDecode.add(0, rgb[0]);
|
||||
rgbDecode.add(1, rgb[1]);
|
||||
rgbDecode.add(2, rgb[2]);
|
||||
List<Float> assertDecode = new ArrayList<Float>();
|
||||
assertDecode.add(0, 0.57629f);
|
||||
assertDecode.add(1, 0.56299f);
|
||||
assertDecode.add(2, 0.50394f);
|
||||
Assert.assertEquals(rgbDecode, assertDecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionXYtoRGB1() {
|
||||
ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(Double.parseDouble("0.671254"), Double.parseDouble("0.303273")));
|
||||
|
||||
List<Integer> colorDecode = ColorDecode.convertCIEtoRGB(xy, 50);
|
||||
@@ -69,7 +111,23 @@ public class ConvertCIEColorTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionHSLtoRGB() {
|
||||
public void testColorConversionXYtoRGB2() {
|
||||
ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(Double.parseDouble("0.32312"), Double.parseDouble("0.15539")));
|
||||
|
||||
List<Integer> colorDecode = ColorDecode.convertCIEtoRGB(xy, 59);
|
||||
List<Integer> assertDecode = new ArrayList<Integer>();
|
||||
assertDecode.add(0, 233);
|
||||
assertDecode.add(1, 0);
|
||||
assertDecode.add(2, 231);
|
||||
Assert.assertEquals(colorDecode, assertDecode);
|
||||
|
||||
ColorData colorData = new ColorData(ColorData.ColorMode.XY, xy);
|
||||
int rgbIntVal = ColorDecode.getIntRGB(colorData, 59);
|
||||
Assert.assertEquals(rgbIntVal, 15270119);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionHSLtoRGB1() {
|
||||
HueSatBri hsb = new HueSatBri();
|
||||
hsb.setHue(0);
|
||||
hsb.setSat(254);
|
||||
@@ -83,6 +141,21 @@ public class ConvertCIEColorTestCase {
|
||||
Assert.assertEquals(colorDecode, assertDecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionHSLtoRGB2() {
|
||||
HueSatBri hsb = new HueSatBri();
|
||||
hsb.setHue(37767);
|
||||
hsb.setSat(143);
|
||||
hsb.setBri(128);
|
||||
|
||||
List<Integer> colorDecode = ColorDecode.convertHSLtoRGB(hsb);
|
||||
List<Integer> assertDecode = new ArrayList<Integer>();
|
||||
assertDecode.add(0, 58);
|
||||
assertDecode.add(1, 135);
|
||||
assertDecode.add(2, 200);
|
||||
Assert.assertEquals(colorDecode, assertDecode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColorConversionCTtoRGB() {
|
||||
Integer ct = 500;
|
||||
@@ -90,8 +163,8 @@ public class ConvertCIEColorTestCase {
|
||||
List<Integer> colorDecode = ColorDecode.convertCTtoRGB(ct);
|
||||
List<Integer> assertDecode = new ArrayList<Integer>();
|
||||
assertDecode.add(0, 255);
|
||||
assertDecode.add(1, 214);
|
||||
assertDecode.add(2, 73);
|
||||
assertDecode.add(1, 137);
|
||||
assertDecode.add(2, 14);
|
||||
Assert.assertEquals(colorDecode, assertDecode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user