diff --git a/docs/changes.md b/docs/changes.md index 70a40bd91..61b6efc27 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,5 +1,8 @@ # 最新动态 +2023/03/14 + * easing 完善注释与单元测试(感谢泽武提供补丁) + 2023/03/13 * 完善编译脚本(感谢高源提供补丁) diff --git a/src/tkc/easing.h b/src/tkc/easing.h index 85216f935..a7fe5d5d7 100644 --- a/src/tkc/easing.h +++ b/src/tkc/easing.h @@ -22,11 +22,18 @@ #ifndef TK_EASING_H #define TK_EASING_H -#include "tkc/types_def.h" #include "tkc/darray.h" +#include "tkc/types_def.h" BEGIN_C_DECLS +typedef float_t (*easing_func_t)(float_t k); + +typedef struct _easing_name_func_t { + key_type_value_t* type_name_value; + easing_func_t easing_func; +} easing_name_func_t; + /** * @enum easing_type_t * @prefix EASING_ @@ -157,17 +164,16 @@ typedef enum _easing_type_t { EASING_FUNC_NR } easing_type_t; -typedef float_t (*easing_func_t)(float_t k); - -typedef struct _easing_name_func_t { - key_type_value_t* type_name_value; - easing_func_t easing_func; -} easing_name_func_t; +/** + * @class easing_t + * @annotation ["fake"] + * 动画趋势类。 + * + */ /** * @method easing_get * 获取对应类型的操作函数。 - * @annotation ["global"] * @param {easing_type_t} type 类型。 * * @return {easing_func_t} 返回对应的操作函数地址。 @@ -177,7 +183,6 @@ easing_func_t easing_get(easing_type_t type); /** * @method easing_register * 注册指定名称的动画趋势。 - * @annotation ["global"] * @param {const char*} type_name 类型名称。 * @param {easing_func_t} easing_func 动画趋势函数。 * diff --git a/tests/easing_test.cc b/tests/easing_test.cc index 1ff187fd6..798b88846 100644 --- a/tests/easing_test.cc +++ b/tests/easing_test.cc @@ -1,15 +1,23 @@ #include "tkc/easing.h" #include "gtest/gtest.h" +#include "widgets/button.h" +#include "widget_animators/widget_animator_prop.h" static float_t easing_linear(float_t k) { return k; } -TEST(easing, easingreg) { +TEST(easing, basic) { ASSERT_EQ(easing_register("test1", easing_linear), EASING_FUNC_NR + 1); ASSERT_EQ(easing_register("test2", easing_linear), EASING_FUNC_NR + 2); - ASSERT_EQ(easing_register("test3", easing_linear), EASING_FUNC_NR + 3); - ASSERT_EQ(easing_register("test4", easing_linear), EASING_FUNC_NR + 4); - ASSERT_EQ(easing_register("test5", easing_linear), EASING_FUNC_NR + 5); + + uint32_t easing_type = easing_register("test3", easing_linear); + widget_t* button = button_create(NULL, 0, 0, 100, 30); + widget_animator_t* wa = widget_animator_prop_create(button, 1000, 0, (easing_type_t)easing_type, "x"); + + ASSERT_EQ(widget_animator_prop_set_params(wa, 0, 300), RET_OK); + + widget_animator_destroy(wa); + widget_destroy(button); }