Search in sources :

Example 1 with ColorMapper

use of org.openhab.habdroid.ui.OpenHABWidgetAdapter.ColorMapper in project openhab-android by openhab.

the class WidgetAdapterTest method testColorMappingDarkTheme.

@Test
public void testColorMappingDarkTheme() {
    ColorMapper colorMapper = new ColorMapper(new ContextThemeWrapper(context, R.style.HABDroid_Basic_ui_dark));
    assertEquals("Map #ffffff", Integer.valueOf(0xffffffff), colorMapper.mapColor("#ffffff"));
    assertEquals("Must return \"null\" for invalid colors", null, colorMapper.mapColor("#fffzzz"));
    assertEquals("Map white => #ffffff in dark themes", Integer.valueOf(0xffffffff), colorMapper.mapColor("white"));
    assertEquals("Map red => #ff0000 in dark themes", Integer.valueOf(0xffff0000), colorMapper.mapColor("red"));
    assertEquals("Map yellow => #ffff00 in dark themes", Integer.valueOf(0xffffff00), colorMapper.mapColor("yellow"));
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) ColorMapper(org.openhab.habdroid.ui.OpenHABWidgetAdapter.ColorMapper) Test(org.junit.Test)

Example 2 with ColorMapper

use of org.openhab.habdroid.ui.OpenHABWidgetAdapter.ColorMapper in project openhab-android by openhab.

the class WidgetAdapterTest method testColorMappingBrightTheme.

@Test
public void testColorMappingBrightTheme() {
    ColorMapper colorMapper = new ColorMapper(new ContextThemeWrapper(context, R.style.HABDroid_Basic_ui));
    assertEquals("Map #ffffff", Integer.valueOf(0xffffffff), colorMapper.mapColor("#ffffff"));
    assertEquals("Must return \"null\" for invalid colors", null, colorMapper.mapColor("#fffzzz"));
    assertEquals("Map white => #000000 in bright themes", Integer.valueOf(0xff000000), colorMapper.mapColor("white"));
    assertEquals("Map red => #ff0000 in bright themes", Integer.valueOf(0xffff0000), colorMapper.mapColor("red"));
    assertEquals("Map yellow => #fdd835 in bright themes", Integer.valueOf(0xfffdd835), colorMapper.mapColor("yellow"));
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) ColorMapper(org.openhab.habdroid.ui.OpenHABWidgetAdapter.ColorMapper) Test(org.junit.Test)

Aggregations

ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)2 Test (org.junit.Test)2 ColorMapper (org.openhab.habdroid.ui.OpenHABWidgetAdapter.ColorMapper)2