Unit test for widget_set_timer()

This commit is contained in:
Pim van Pelt
2017-11-26 16:51:59 +01:00
parent 63f1088e7a
commit 6c4c1b3d95
3 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,8 @@
#include "test.h"
#include "widget.h"
extern int _mgos_timers;
static int test_widget_create_from_file(void) {
struct widget_t *w;
@ -13,6 +15,14 @@ static int test_widget_create_from_file(void) {
ASSERT(w->w == 48, "'x' field is invalid");
ASSERT(w->h == 48, "'x' field is invalid");
LOG(LL_INFO, ("widget_set_timer()"));
widget_set_timer(w, 1000);
ASSERT(_mgos_timers==1, "timer not found");
LOG(LL_INFO, ("widget_delete_timer()"));
widget_delete_timer(w);
ASSERT(_mgos_timers==0, "timers found");
fn = "data/TestWidget-invalid.json";
LOG(LL_INFO, ("widget_create_from_file(%s)", fn));
w = widget_create_from_file(fn);
@ -22,5 +32,9 @@ static int test_widget_create_from_file(void) {
int test_widget() {
test_widget_create_from_file();
LOG(LL_INFO, ("ensure we have no timers"));
ASSERT(_mgos_timers==0, "timers found");
return 0;
}