awtk/tests/animator_rotation_test.cc

25 lines
745 B
C++
Raw Normal View History

2018-06-27 13:46:42 +08:00
#include <string>
2018-05-31 11:01:46 +08:00
#include "base/timer.h"
#include "gtest/gtest.h"
#include "widgets/image.h"
2018-05-31 11:01:46 +08:00
#include "widget_animators/widget_animator_rotation.h"
TEST(AnimatorRotation, once) {
2018-07-18 10:36:54 +08:00
image_t* image = IMAGE(image_create(NULL, 0, 0, 100, 30));
2018-11-22 14:58:21 +08:00
image_base_t* image_base = IMAGE_BASE(image);
2018-07-18 10:36:54 +08:00
widget_animator_t* wa = widget_animator_rotation_create(WIDGET(image), 1000, 0, EASING_LINEAR);
2018-05-31 11:01:46 +08:00
widget_animator_rotation_set_params(wa, 0, 100);
widget_animator_start(wa);
2018-11-05 17:32:23 +08:00
widget_animator_time_elapse(wa, 0);
2018-11-22 14:58:21 +08:00
ASSERT_EQ(image_base->rotation, 0);
2018-05-31 11:01:46 +08:00
2018-11-05 17:32:23 +08:00
widget_animator_time_elapse(wa, 500);
2018-11-22 14:58:21 +08:00
ASSERT_EQ(image_base->rotation, 50);
2018-05-31 11:01:46 +08:00
2018-11-05 17:32:23 +08:00
widget_animator_time_elapse(wa, 500);
2018-11-22 14:58:21 +08:00
ASSERT_EQ(image_base->rotation, 100);
2018-05-31 11:01:46 +08:00
2018-07-18 10:36:54 +08:00
widget_destroy(WIDGET(image));
2018-05-31 11:01:46 +08:00
}