This repository has been archived by the owner on May 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 783
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] [Tradfri] Support for new RGB bulbs #4251
Signed-off-by: Holger Reichert <mail@h0lger.de>
- Loading branch information
Showing
9 changed files
with
473 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...i.test/src/test/java/org/eclipse/smarthome/binding/tradfri/internal/TradfriColorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright (c) 2014-2017 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.binding.tradfri.internal; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import org.eclipse.smarthome.core.library.types.HSBType; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Tests for {@link TradfriColor}. | ||
* | ||
* @author Holger Reichert - Initial contribution | ||
*/ | ||
public class TradfriColorTest { | ||
|
||
@Test | ||
public void testFromCieKnownGood1() { | ||
TradfriColor color = TradfriColor.fromCie(29577, 12294, 254); | ||
assertNotNull(color); | ||
assertEquals(255, color.rgbR); | ||
assertEquals(21, color.rgbG); | ||
assertEquals(207, color.rgbB); | ||
assertEquals(29577, color.xyX); | ||
assertEquals(12294, color.xyY); | ||
assertEquals(254, color.brightness); | ||
} | ||
|
||
@Test | ||
public void testFromCieKnownGood2() { | ||
TradfriColor color = TradfriColor.fromCie(19983, 37417, 84); | ||
assertNotNull(color); | ||
assertEquals(110, color.rgbR); | ||
assertEquals(174, color.rgbG); | ||
assertEquals(58, color.rgbB); | ||
assertEquals(19983, color.xyX); | ||
assertEquals(37417, color.xyY); | ||
assertEquals(84, color.brightness); | ||
} | ||
|
||
@Test | ||
public void testFromHSBTypeKnownGood1() { | ||
TradfriColor color = TradfriColor.fromHSBType(HSBType.RED); | ||
assertNotNull(color); | ||
assertEquals(254, color.rgbR); | ||
assertEquals(0, color.rgbG); | ||
assertEquals(0, color.rgbB); | ||
assertEquals(45914, color.xyX); | ||
assertEquals(19615, color.xyY); | ||
assertEquals(254, color.brightness); | ||
} | ||
|
||
@Test | ||
public void testConversionReverse() { | ||
// convert from HSBType | ||
TradfriColor color = TradfriColor.fromHSBType(HSBType.GREEN); | ||
assertNotNull(color); | ||
assertEquals(0, color.rgbR); | ||
assertEquals(254, color.rgbG); // 254 instead of 255 - only approximated calculation | ||
assertEquals(0, color.rgbB); | ||
assertEquals(11299, color.xyX); | ||
assertEquals(48941, color.xyY); | ||
assertEquals(254, color.brightness); | ||
// convert the result again based on the XY values | ||
TradfriColor reverse = TradfriColor.fromCie(color.xyX, color.xyY, color.brightness); | ||
assertNotNull(reverse); | ||
assertEquals(0, reverse.rgbR); | ||
assertEquals(255, reverse.rgbG); // 255 instead of 254 - only approximated calculation | ||
assertEquals(0, reverse.rgbB); | ||
assertEquals(11299, reverse.xyX); | ||
assertEquals(48941, reverse.xyY); | ||
assertEquals(254, reverse.brightness); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.