awtk/tests/fscript_widget_test.cc

29 lines
770 B
C++
Raw Normal View History

2022-04-17 11:47:08 +08:00
#include "tkc/fscript.h"
#include "tkc/object_default.h"
#include "gtest/gtest.h"
#include "widgets/button.h"
#include "widgets/progress_bar.h"
TEST(FScriptWidget, basic) {
value_t v;
tk_object_t* obj = object_default_create();
widget_t* w = progress_bar_create(NULL, 0, 0, 100, 20);
widget_set_value_int(w, 20);
2022-04-23 09:00:54 +08:00
tk_object_set_prop_pointer(obj, STR_PROP_SELF, w);
2022-04-17 11:47:08 +08:00
fscript_eval(obj, "widget_add_value('self', 20)", &v);
ASSERT_EQ(widget_get_value_int(w), 40);
value_reset(&v);
2022-04-23 09:00:54 +08:00
2022-04-17 11:47:08 +08:00
fscript_eval(obj, "widget_set('self', 'value', 20)", &v);
ASSERT_EQ(widget_get_value_int(w), 20);
value_reset(&v);
2022-04-23 09:00:54 +08:00
2022-04-17 11:47:08 +08:00
fscript_eval(obj, "widget_get('self', 'value')", &v);
ASSERT_EQ(value_int(&v), 20);
value_reset(&v);
widget_unref(w);
TK_OBJECT_UNREF(obj);
}