First start of MQTT buttons

This commit is contained in:
Pim van Pelt
2017-12-02 16:51:09 +01:00
parent c315de560f
commit b8e5637c8b
9 changed files with 97 additions and 13 deletions

View File

@ -0,0 +1,10 @@
{
"name": "heli_led_on",
"x": 240,
"y": 36,
"w": 64,
"h": 56,
"label": "On",
"type": 1,
"mqtt": [ "/topic1 Hello", "/topic2 World" ]
}

View File

@ -5,6 +5,6 @@
"w": 48,
"h": 48,
"label": "One",
"type": 0
"type": 0,
"img": "/some/file.ext"
}

View File

@ -5,6 +5,7 @@ int assert_count=0;
int main() {
test_widget();
test_widget_mqtt();
test_screen();
if (test_failures) {

View File

@ -21,6 +21,7 @@ extern int assert_count;
int test_widget(void);
int test_widget_mqtt(void);
int test_screen(void);
#endif // __TEST_H

View File

@ -71,3 +71,15 @@ int test_widget() {
return 0;
}
int test_widget_mqtt() {
struct widget_t *w;
char *fn = "data/TestWidget-MQTT.json";
LOG(LL_INFO, ("widget_create_from_file(%s)", fn));
w = widget_create_from_file(fn);
ASSERT(w, "widget_create_from_file()");
ASSERT(w->x == 240, "'x' field is invalid");
ASSERT(w->type == WIDGET_TYPE_MQTT_BUTTON, "'type' field is not WIDGET_TYPE_MQTT_BUTTON");
return 0;
}