2018-12-15 17:22:05 +08:00
|
|
|
|
#include "widgets/window.h"
|
2018-04-20 21:49:47 +08:00
|
|
|
|
#include "base/canvas.h"
|
|
|
|
|
#include "base/widget.h"
|
|
|
|
|
#include "font_dummy.h"
|
|
|
|
|
#include "lcd_log.h"
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
TEST(Window, basic) {
|
|
|
|
|
value_t v1;
|
|
|
|
|
value_t v2;
|
|
|
|
|
widget_t* b = window_create(NULL, 10, 20, 30, 40);
|
|
|
|
|
|
|
|
|
|
value_set_wstr(&v1, L"window");
|
|
|
|
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_TEXT, &v1), RET_OK);
|
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_TEXT, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(wcscmp(v1.value.wstr, v2.value.wstr), 0);
|
|
|
|
|
|
2018-04-21 07:43:02 +08:00
|
|
|
|
value_set_str(&v1, "bottom_to_top");
|
2018-04-20 21:49:47 +08:00
|
|
|
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_ANIM_HINT, &v1), RET_OK);
|
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_ANIM_HINT, &v2), RET_OK);
|
2018-10-22 17:21:06 +08:00
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
2018-10-23 09:42:07 +08:00
|
|
|
|
|
2018-10-22 17:21:06 +08:00
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
2018-10-23 09:42:07 +08:00
|
|
|
|
|
2018-10-22 17:21:06 +08:00
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
|
|
|
|
|
|
|
|
|
value_set_str(&v1, "center_scale");
|
|
|
|
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v1), RET_OK);
|
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_OPEN_ANIM_HINT, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
2018-10-23 09:42:07 +08:00
|
|
|
|
|
2018-10-22 17:21:06 +08:00
|
|
|
|
value_set_str(&v1, "center_scale");
|
|
|
|
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v1), RET_OK);
|
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_CLOSE_ANIM_HINT, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
2018-10-23 09:42:07 +08:00
|
|
|
|
|
2018-10-22 17:21:06 +08:00
|
|
|
|
value_set_str(&v1, "main");
|
|
|
|
|
ASSERT_EQ(widget_set_prop(b, WIDGET_PROP_THEME, &v1), RET_OK);
|
|
|
|
|
ASSERT_EQ(widget_get_prop(b, WIDGET_PROP_THEME, &v2), RET_OK);
|
|
|
|
|
ASSERT_EQ(strcmp(value_str(&v2), value_str(&v1)), 0);
|
2018-04-20 21:49:47 +08:00
|
|
|
|
|
|
|
|
|
widget_destroy(b);
|
|
|
|
|
}
|