add digit clock

This commit is contained in:
xianjimli 2018-11-03 12:10:25 +08:00
parent ee4cf3ba1f
commit fa00bc59ae
10 changed files with 626 additions and 18 deletions

57
src/base/date_time.c Normal file
View File

@ -0,0 +1,57 @@
/**
* File: date_time.c
* Author: AWTK Develop Team
* Brief: date time
*
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-11-03 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "base/mem.h"
#include "base/date_time.h"
static date_time_get_now_t s_date_time_get_now;
ret_t date_time_set_impl(date_time_get_now_t date_time_get_now) {
s_date_time_get_now = date_time_get_now;
return RET_OK;
}
date_time_t* date_time_create(void) {
date_time_t* dt = TKMEM_ZALLOC(date_time_t);
return date_time_init(dt);
}
date_time_t* date_time_init(date_time_t* dt) {
return_value_if_fail(dt != NULL, NULL);
memset(dt, 0x00, sizeof(date_time_t));
if (s_date_time_get_now != NULL) {
s_date_time_get_now(dt);
} else {
assert(!"please call date_time_set_impl before call date_time_get_now");
}
return dt;
}
ret_t date_time_destroy(date_time_t* dt) {
return_value_if_fail(dt != NULL, RET_BAD_PARAMS);
TKMEM_FREE(dt);
return RET_OK;
}

115
src/base/date_time.h Normal file
View File

@ -0,0 +1,115 @@
/**
* File: date_time.h
* Author: AWTK Develop Team
* Brief: date time
*
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-11-03 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_DATE_TIME_H
#define TK_DATE_TIME_H
#include "base/types_def.h"
BEGIN_C_DECLS
/**
* @class date_time_t
* @annotation ["scriptable"]
*
*/
typedef struct _date_time_t {
/**
* @property {int32_t} second
* @annotation ["readable"]
* (0 - 59)
*/
int32_t second;
/**
* @property {int32_t} minute
* @annotation ["readable"]
* (0 - 59)
*/
int32_t minute;
/**
* @property {int32_t} hour
* @annotation ["readable"]
* (0 - 23)
*/
int32_t hour; /* hours (0 - 23) */
/**
* @property {int32_t} day
* @annotation ["readable"]
* (1-31)
*/
int32_t day;
/**
* @property {int32_t} month
* @annotation ["readable"]
* (1-12)
*/
int32_t month;
/**
* @property {int32_t} year
* @annotation ["readable"]
*
*/
int32_t year;
} date_time_t;
/**
* @method date_time_create
* date_time对象(使)
* @annotation ["constructor", "scriptable"]
*
* @return {date_time_t*} date_time对象
*/
date_time_t* date_time_create(void);
/**
* @method date_time_init
*
* @param {date_time_t*} dt date_time对象
*
* @return {date_time_t*} date_time对象
*/
date_time_t* date_time_init(date_time_t* dt);
/**
* @method date_time_destroy
* date_time对象(使)
* @annotation ["deconstructor", "scriptable"]
* @param {date_time_t*} dt date_time对象
*
* @return {ret_t} RET_OK表示成功
*/
ret_t date_time_destroy(date_time_t* dt);
typedef ret_t (*date_time_get_now_t)(date_time_t* dt);
/**
* @method date_time_date_time_set_impl
*
* @param {date_time_get_now_t} date_time_get_now
*
* @return {ret_t} RET_OK表示成功
*/
ret_t date_time_set_impl(date_time_get_now_t date_time_get_now);
END_C_DECLS
#endif /*TK_DATE_TIME_H*/

View File

@ -61,9 +61,8 @@ bool_t value_bool(const value_t* v) {
return v->value.f64 ? TRUE : FALSE;
}
case VALUE_TYPE_STRING: {
return (v->value.str == NULL || v->value.str[0] == '\0' || strcmp(v->value.str, "false") == 0)
? FALSE
: TRUE;
const char* str = v->value.str;
return (str == NULL || *str == '0' || *str == 'f' || *str == 'F') ? FALSE : TRUE;
}
default:
break;

View File

@ -27,6 +27,7 @@
#include "rich_text/rich_text.h"
#include "keyboard/candidates.h"
#include "time_clock/time_clock.h"
#include "time_clock/digit_clock.h"
#include "scroll_view/list_item.h"
#include "scroll_view/list_view.h"
#include "slide_view/slide_view.h"
@ -55,6 +56,7 @@ ret_t tk_ext_widgets_init() {
widget_factory_register(widget_factory(), WIDGET_TYPE_KEYBOARD, keyboard_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_CANDIDATES, candidates_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_TIME_CLOCK, time_clock_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_DIGIT_CLOCK, digit_clock_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_GUAGE, guage_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_TEXT_SELECTOR, text_selector_create);
widget_factory_register(widget_factory(), WIDGET_TYPE_SWITCH, switch_create);

View File

@ -0,0 +1,167 @@
/**
* File: digit_clock.h
* Author: AWTK Develop Team
* Brief: digit_clock
*
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-08-29 Li XianJing <xianjimli@hotmail.com> created
*
*/
#include "base/mem.h"
#include "base/timer.h"
#include "base/utils.h"
#include "base/date_time.h"
#include "base/widget_vtable.h"
#include "time_clock/digit_clock.h"
static ret_t digit_clock_update_time(widget_t* widget) {
char str[128];
date_time_t dt;
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
const char* format = digit_clock->format;
date_time_init(&dt);
memset(str, 0x00, sizeof(str));
if (digit_clock->show_date && digit_clock->show_time) {
format = format != NULL ? format : "%d-%02d-%02d %02d:%02d:%02d";
tk_snprintf(str, sizeof(str) - 1, format, dt.year, dt.month, dt.day, dt.hour, dt.minute,
dt.second);
} else if (digit_clock->show_date) {
format = format != NULL ? format : "%d-%02d-%02d";
tk_snprintf(str, sizeof(str) - 1, format, dt.year, dt.month, dt.day);
} else {
format = format != NULL ? format : "%02d:%02d:%02d";
tk_snprintf(str, sizeof(str) - 1, format, dt.hour, dt.minute, dt.second);
}
widget_set_text_utf8(widget, str);
return RET_OK;
}
ret_t digit_clock_set_show_date(widget_t* widget, bool_t show_date) {
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
digit_clock->show_date = show_date;
digit_clock_update_time(widget);
return RET_OK;
}
ret_t digit_clock_set_show_time(widget_t* widget, bool_t show_time) {
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
digit_clock->show_time = show_time;
digit_clock_update_time(widget);
return RET_OK;
}
ret_t digit_clock_set_format(widget_t* widget, const char* format) {
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
digit_clock->format = tk_str_copy(digit_clock->format, format);
digit_clock_update_time(widget);
return RET_OK;
}
static ret_t digit_clock_get_prop(widget_t* widget, const char* name, value_t* v) {
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, DIGIT_CLOCK_PROP_SHOW_DATE)) {
value_set_bool(v, digit_clock->show_date);
return RET_OK;
} else if (tk_str_eq(name, DIGIT_CLOCK_PROP_SHOW_TIME)) {
value_set_bool(v, digit_clock->show_time);
return RET_OK;
} else if (tk_str_eq(name, DIGIT_CLOCK_PROP_FORMAT)) {
value_set_str(v, digit_clock->format);
return RET_OK;
}
return RET_NOT_FOUND;
}
static ret_t digit_clock_set_prop(widget_t* widget, const char* name, const value_t* v) {
return_value_if_fail(widget != NULL && name != NULL && v != NULL, RET_BAD_PARAMS);
if (tk_str_eq(name, DIGIT_CLOCK_PROP_SHOW_DATE)) {
return digit_clock_set_show_date(widget, value_bool(v));
} else if (tk_str_eq(name, DIGIT_CLOCK_PROP_SHOW_TIME)) {
return digit_clock_set_show_time(widget, value_bool(v));
} else if (tk_str_eq(name, DIGIT_CLOCK_PROP_FORMAT)) {
return digit_clock_set_format(widget, value_str(v));
}
return RET_NOT_FOUND;
}
static ret_t digit_clock_on_timer(const timer_info_t* info) {
widget_t* widget = WIDGET(info->ctx);
digit_clock_update_time(widget);
widget_invalidate(widget, NULL);
return RET_REPEAT;
}
static ret_t digit_clock_destroy(widget_t* widget) {
digit_clock_t* digit_clock = DIGIT_CLOCK(widget);
TKMEM_FREE(digit_clock->format);
return RET_OK;
}
static const char* s_digit_clock_properties[] = {
DIGIT_CLOCK_PROP_SHOW_DATE, DIGIT_CLOCK_PROP_SHOW_TIME, DIGIT_CLOCK_PROP_FORMAT, NULL};
static const widget_vtable_t s_digit_clock_vtable = {
.size = sizeof(digit_clock_t),
.type = WIDGET_TYPE_DIGIT_CLOCK,
.clone_properties = s_digit_clock_properties,
.persistent_properties = s_digit_clock_properties,
.create = digit_clock_create,
.on_paint_self = widget_on_paint_self_default,
.set_prop = digit_clock_set_prop,
.get_prop = digit_clock_get_prop,
.destroy = digit_clock_destroy};
widget_t* digit_clock_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
digit_clock_t* digit_clock = TKMEM_ZALLOC(digit_clock_t);
widget_t* widget = WIDGET(digit_clock);
return_value_if_fail(digit_clock != NULL, NULL);
return_value_if_fail(widget_init(widget, parent, &s_digit_clock_vtable, x, y, w, h) != NULL,
widget);
digit_clock->show_date = TRUE;
digit_clock->show_time = TRUE;
digit_clock_update_time(widget);
widget_add_timer(widget, digit_clock_on_timer, 1000);
return widget;
}
widget_t* digit_clock_cast(widget_t* widget) {
return_value_if_fail(widget != NULL && widget->vt == &s_digit_clock_vtable, NULL);
return widget;
}

View File

@ -0,0 +1,127 @@
/**
* File: digit_clock.h
* Author: AWTK Develop Team
* Brief: digit_clock
*
* Copyright (c) 2018 - 2018 Guangzhou ZHIYUAN Electronics Co.,Ltd.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* License file for more details.
*
*/
/**
* History:
* ================================================================
* 2018-11-03 Li XianJing <xianjimli@hotmail.com> created
*
*/
#ifndef TK_DIGIT_CLOCK_H
#define TK_DIGIT_CLOCK_H
#include "base/widget.h"
BEGIN_C_DECLS
/**
* @class digit_clock_t
* @parent widget_t
* @annotation ["scriptable"]
*
*/
typedef struct _digit_clock_t {
widget_t widget;
/**
* @property {bool_t} show_date
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
bool_t show_date;
/**
* @property {bool_t} show_time
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
*
*/
bool_t show_time;
/**
* @property {char*} format
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* "%d-%02d-%02d"2018-12-12
*/
char* format;
} digit_clock_t;
/**
* @method digit_clock_create
* digit_clock对象
* @annotation ["constructor", "scriptable"]
* @param {widget_t*} parent
* @param {xy_t} x x坐标
* @param {xy_t} y y坐标
* @param {wh_t} w
* @param {wh_t} h
*
* @return {widget_t*}
*/
widget_t* digit_clock_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h);
/**
* @method digit_clock_cast
* digit_clock对象(使)
* @annotation ["cast", "scriptable"]
* @param {widget_t*} widget digit_clock对象
*
* @return {widget_t*} digit_clock对象
*/
widget_t* digit_clock_cast(widget_t* widget);
/**
* @method digit_clock_set_show_date
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} show_date
*
* @return {ret_t} RET_OK表示成功
*/
ret_t digit_clock_set_show_date(widget_t* widget, bool_t show_date);
/**
* @method digit_clock_set_show_time
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {bool_t} show_time
*
* @return {ret_t} RET_OK表示成功
*/
ret_t digit_clock_set_show_time(widget_t* widget, bool_t show_time);
/**
* @method digit_clock_set_format
*
* @annotation ["scriptable"]
* @param {widget_t*} widget
* @param {const char*} format
*
* @return {ret_t} RET_OK表示成功
*/
ret_t digit_clock_set_bg_format(widget_t* widget, const char* format);
#define DIGIT_CLOCK_PROP_FORMAT "format"
#define DIGIT_CLOCK_PROP_SHOW_DATE "show_date"
#define DIGIT_CLOCK_PROP_SHOW_TIME "show_time"
#define WIDGET_TYPE_DIGIT_CLOCK "digit_clock"
#define DIGIT_CLOCK(widget) ((digit_clock_t*)(widget))
END_C_DECLS
#endif /*TK_DIGIT_CLOCK_H*/

View File

@ -23,6 +23,7 @@
#include "base/timer.h"
#include "base/utils.h"
#include "base/matrix.h"
#include "base/date_time.h"
#include "base/image_manager.h"
#include "time_clock/time_clock.h"
@ -57,8 +58,7 @@ ret_t time_clock_set_hour_image(widget_t* widget, const char* hour_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
TKMEM_FREE(time_clock->hour_image);
time_clock->hour_image = tk_strdup(hour_image);
time_clock->hour_image = tk_str_copy(time_clock->hour_image, hour_image);
return RET_OK;
}
@ -67,8 +67,7 @@ ret_t time_clock_set_minute_image(widget_t* widget, const char* minute_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
TKMEM_FREE(time_clock->minute_image);
time_clock->minute_image = tk_strdup(minute_image);
time_clock->minute_image = tk_str_copy(time_clock->minute_image, minute_image);
return RET_OK;
}
@ -77,8 +76,7 @@ ret_t time_clock_set_second_image(widget_t* widget, const char* second_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
TKMEM_FREE(time_clock->second_image);
time_clock->second_image = tk_strdup(second_image);
time_clock->second_image = tk_str_copy(time_clock->second_image, second_image);
return RET_OK;
}
@ -87,8 +85,7 @@ ret_t time_clock_set_bg_image(widget_t* widget, const char* bg_image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
TKMEM_FREE(time_clock->bg_image);
time_clock->bg_image = tk_strdup(bg_image);
time_clock->bg_image = tk_str_copy(time_clock->bg_image, bg_image);
return RET_OK;
}
@ -97,8 +94,7 @@ ret_t time_clock_set_image(widget_t* widget, const char* image) {
time_clock_t* time_clock = TIME_CLOCK(widget);
return_value_if_fail(widget != NULL, RET_BAD_PARAMS);
TKMEM_FREE(time_clock->image);
time_clock->image = tk_strdup(image);
time_clock->image = tk_str_copy(time_clock->image, image);
return RET_OK;
}
@ -111,7 +107,7 @@ static ret_t time_clock_get_prop(widget_t* widget, const char* name, value_t* v)
value_set_int(v, time_clock->hour);
return RET_OK;
} else if (tk_str_eq(name, TIME_CLOCK_PROP_MINUTE)) {
value_set_int(v, time_clock->hour);
value_set_int(v, time_clock->minute);
return RET_OK;
} else if (tk_str_eq(name, TIME_CLOCK_PROP_SECOND)) {
value_set_int(v, time_clock->second);
@ -292,6 +288,7 @@ static const widget_vtable_t s_time_clock_vtable = {
.destroy = time_clock_destroy};
widget_t* time_clock_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
date_time_t dt;
time_clock_t* time_clock = TKMEM_ZALLOC(time_clock_t);
widget_t* widget = WIDGET(time_clock);
return_value_if_fail(time_clock != NULL, NULL);
@ -299,6 +296,11 @@ widget_t* time_clock_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
return_value_if_fail(widget_init(widget, parent, &s_time_clock_vtable, x, y, w, h) != NULL,
widget);
widget_add_timer(widget, time_clock_on_timer, 1000);
date_time_init(&dt);
time_clock->hour = dt.hour;
time_clock->minute = dt.minute;
time_clock->second = dt.second;
return widget;
}

View File

@ -19,12 +19,13 @@
*
*/
#include "base/timer.h"
#include "base/platform.h"
#ifdef WIN32
#include <time.h>
#include <stdio.h>
#include "base/timer.h"
#include "base/platform.h"
#include "base/date_time.h"
#ifdef WIN32
#include <windows.h>
#pragma comment(lib, "Ws2_32.lib")
@ -45,9 +46,37 @@ int gettimeofday(struct timeval* tp, void* tzp) {
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
static ret_t date_time_get_now_impl(date_time_t* dt) {
SYSTEMTIME wtm;
GetLocalTime(&wtm);
dt->second = wtm.wSecond;
dt->minute = wtm.wMinute;
dt->hour = wtm.wHour;
dt->day = wtm.wDay;
dt->month = wtm.wMonth;
dt->year = wtm.wYear;
return RET_OK;
}
#else
#include <sys/time.h>
#include <unistd.h>
static ret_t date_time_get_now_impl(date_time_t* dt) {
time_t now = time(0);
struct tm* t = localtime(&now);
dt->second = t->tm_sec;
dt->minute = t->tm_min;
dt->hour = t->tm_hour;
dt->day = t->tm_mday;
dt->month = t->tm_mon + 1;
dt->year = t->tm_year + 1900;
return RET_OK;
}
#endif
uint32_t get_time_ms() {
@ -73,6 +102,7 @@ ret_t platform_prepare(void) {
#ifndef HAS_STD_MALLOC
tk_mem_init(s_heap_mem, sizeof(s_heap_mem));
#endif /*HAS_STD_MALLOC*/
date_time_set_impl(date_time_get_now_impl);
return RET_OK;
}

45
tests/digit_clock_test.cc Normal file
View File

@ -0,0 +1,45 @@
#include "time_clock/digit_clock.h"
#include "gtest/gtest.h"
#include <stdlib.h>
#include <string>
using std::string;
TEST(DigitClock, basic) {
value_t v1;
value_t v2;
widget_t* w = digit_clock_create(NULL, 10, 20, 30, 40);
digit_clock_t* t = DIGIT_CLOCK(w);
value_set_bool(&v1, TRUE);
ASSERT_EQ(widget_set_prop(w, DIGIT_CLOCK_PROP_SHOW_DATE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, DIGIT_CLOCK_PROP_SHOW_DATE, &v2), RET_OK);
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
ASSERT_EQ(value_bool(&v1), t->show_date);
value_set_bool(&v1, FALSE);
ASSERT_EQ(widget_set_prop(w, DIGIT_CLOCK_PROP_SHOW_DATE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, DIGIT_CLOCK_PROP_SHOW_DATE, &v2), RET_OK);
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
ASSERT_EQ(value_bool(&v1), t->show_date);
value_set_bool(&v1, TRUE);
ASSERT_EQ(widget_set_prop(w, DIGIT_CLOCK_PROP_SHOW_TIME, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, DIGIT_CLOCK_PROP_SHOW_TIME, &v2), RET_OK);
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
ASSERT_EQ(value_bool(&v1), t->show_time);
value_set_bool(&v1, FALSE);
ASSERT_EQ(widget_set_prop(w, DIGIT_CLOCK_PROP_SHOW_TIME, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, DIGIT_CLOCK_PROP_SHOW_TIME, &v2), RET_OK);
ASSERT_EQ(value_bool(&v1), value_bool(&v2));
ASSERT_EQ(value_bool(&v1), t->show_time);
value_set_str(&v1, "%d/%d");
ASSERT_EQ(widget_set_prop(w, DIGIT_CLOCK_PROP_FORMAT, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, DIGIT_CLOCK_PROP_FORMAT, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->format));
widget_destroy(w);
}

64
tests/time_clock_test.cc Normal file
View File

@ -0,0 +1,64 @@
#include "time_clock/time_clock.h"
#include "gtest/gtest.h"
#include <stdlib.h>
#include <string>
using std::string;
TEST(TimeClock, basic) {
value_t v1;
value_t v2;
widget_t* w = time_clock_create(NULL, 10, 20, 30, 40);
time_clock_t* t = TIME_CLOCK(w);
value_set_int(&v1, 10);
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_HOUR, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_HOUR, &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
ASSERT_EQ(value_int(&v1), t->hour);
value_set_int(&v1, 12);
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_MINUTE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_MINUTE, &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
ASSERT_EQ(value_int(&v1), t->minute);
value_set_int(&v1, 14);
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_SECOND, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_SECOND, &v2), RET_OK);
ASSERT_EQ(value_int(&v1), value_int(&v2));
ASSERT_EQ(value_int(&v1), t->second);
value_set_str(&v1, "hour");
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_HOUR_IMAGE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_HOUR_IMAGE, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->hour_image));
value_set_str(&v1, "minute");
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_MINUTE_IMAGE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_MINUTE_IMAGE, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->minute_image));
value_set_str(&v1, "second");
;
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_SECOND_IMAGE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_SECOND_IMAGE, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->second_image));
value_set_str(&v1, "bg");
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_BG_IMAGE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_BG_IMAGE, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->bg_image));
value_set_str(&v1, "image");
ASSERT_EQ(widget_set_prop(w, TIME_CLOCK_PROP_IMAGE, &v1), RET_OK);
ASSERT_EQ(widget_get_prop(w, TIME_CLOCK_PROP_IMAGE, &v2), RET_OK);
ASSERT_EQ(string(value_str(&v1)), string(value_str(&v2)));
ASSERT_EQ(string(value_str(&v1)), string(t->image));
widget_destroy(w);
}