mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 11:08:34 +08:00
add test
This commit is contained in:
parent
36420ee41a
commit
83e5f9384b
@ -9,30 +9,30 @@
|
||||
TEST(Label, basic) {
|
||||
value_t v1;
|
||||
value_t v2;
|
||||
widget_t* l = label_create(NULL, 10, 20, 30, 40);
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
ASSERT_EQ(widget_set_text(l, L"OK"), RET_OK);
|
||||
ASSERT_EQ(wcscmp(l->text.str, L"OK"), 0);
|
||||
ASSERT_EQ(widget_set_text(l, L"Cancel"), RET_OK);
|
||||
ASSERT_EQ(wcscmp(l->text.str, L"Cancel"), 0);
|
||||
ASSERT_EQ(widget_set_text(label, L"OK"), RET_OK);
|
||||
ASSERT_EQ(wcscmp(label->text.str, L"OK"), 0);
|
||||
ASSERT_EQ(widget_set_text(label, L"Cancel"), RET_OK);
|
||||
ASSERT_EQ(wcscmp(label->text.str, L"Cancel"), 0);
|
||||
|
||||
value_set_wstr(&v1, L"label");
|
||||
ASSERT_EQ(widget_set_prop(l, WIDGET_PROP_TEXT, &v1), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop(l, WIDGET_PROP_TEXT, &v2), RET_OK);
|
||||
ASSERT_EQ(widget_set_prop(label, WIDGET_PROP_TEXT, &v1), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop(label, WIDGET_PROP_TEXT, &v2), RET_OK);
|
||||
ASSERT_EQ(wcscmp(v1.value.wstr, v2.value.wstr), 0);
|
||||
|
||||
widget_destroy(l);
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
||||
TEST(Label, value) {
|
||||
widget_t* l = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(widget_set_value(l, 100), RET_OK);
|
||||
ASSERT_EQ(widget_get_value(l), 100);
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(widget_set_value(label, 100), RET_OK);
|
||||
ASSERT_EQ(widget_get_value(label), 100);
|
||||
|
||||
ASSERT_EQ(widget_add_value(l, 100), RET_OK);
|
||||
ASSERT_EQ(widget_get_value(l), 200);
|
||||
ASSERT_EQ(widget_add_value(label, 100), RET_OK);
|
||||
ASSERT_EQ(widget_get_value(label), 200);
|
||||
|
||||
widget_destroy(l);
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
||||
TEST(Label, clone) {
|
||||
@ -52,31 +52,42 @@ TEST(Label, clone) {
|
||||
}
|
||||
|
||||
TEST(Label, line_wrap) {
|
||||
widget_t* l = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(l)->line_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_bool(l, WIDGET_PROP_LINE_WRAP, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_bool(l, WIDGET_PROP_LINE_WRAP, FALSE), TRUE);
|
||||
ASSERT_EQ(LABEL(l)->line_wrap, TRUE);
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(label)->line_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_bool(label, WIDGET_PROP_LINE_WRAP, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_bool(label, WIDGET_PROP_LINE_WRAP, FALSE), TRUE);
|
||||
ASSERT_EQ(LABEL(label)->line_wrap, TRUE);
|
||||
|
||||
widget_destroy(l);
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
||||
TEST(Label, word_wrap) {
|
||||
widget_t* l = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(l)->word_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_bool(l, WIDGET_PROP_WORD_WRAP, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_bool(l, WIDGET_PROP_WORD_WRAP, FALSE), TRUE);
|
||||
ASSERT_EQ(LABEL(l)->word_wrap, TRUE);
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(label)->word_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_bool(label, WIDGET_PROP_WORD_WRAP, TRUE), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_bool(label, WIDGET_PROP_WORD_WRAP, FALSE), TRUE);
|
||||
ASSERT_EQ(LABEL(label)->word_wrap, TRUE);
|
||||
|
||||
widget_destroy(l);
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
||||
TEST(Label, max_w) {
|
||||
widget_t* l = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(l)->word_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_int(l, WIDGET_PROP_MAX_W, 123), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(l, WIDGET_PROP_MAX_W, 0), 123);
|
||||
ASSERT_EQ(LABEL(l)->max_w, 123);
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
ASSERT_EQ(LABEL(label)->word_wrap, FALSE);
|
||||
ASSERT_EQ(widget_set_prop_int(label, WIDGET_PROP_MAX_W, 123), RET_OK);
|
||||
ASSERT_EQ(widget_get_prop_int(label, WIDGET_PROP_MAX_W, 0), 123);
|
||||
ASSERT_EQ(LABEL(label)->max_w, 123);
|
||||
|
||||
widget_destroy(l);
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
||||
TEST(Label, add_value) {
|
||||
widget_t* label = label_create(NULL, 10, 20, 30, 40);
|
||||
|
||||
widget_set_text_utf8(label, "10");
|
||||
ASSERT_EQ((int)widget_get_value(label), 10);
|
||||
ASSERT_EQ(widget_add_value(label, -1), RET_OK);
|
||||
ASSERT_EQ((int)widget_get_value(label), 9);
|
||||
|
||||
widget_destroy(label);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user