tests: Add test cases for Efl.Ui.Vg_Animation

Add test cases for Efl.Ui.Vg_Animation APIs
 - vg_anim_playing_control
 - vg_anim_frame_control

ref T8476

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11022
This commit is contained in:
junsu choi 2020-01-16 02:12:37 +00:00 committed by Marcel Hollerbach
parent 0b389a8338
commit 3a4c5cf6a5
5 changed files with 128 additions and 0 deletions

View File

@ -43,6 +43,9 @@ static const Efl_Test_Case etc[] = {
{ "efl_ui_view_model", efl_ui_test_view_model },
{ "efl_ui_group_item", efl_ui_test_group_item },
{ "efl_ui_text", efl_ui_test_text},
#ifdef BUILD_VG_LOADER_JSON
{ "efl_ui_vg_animation", efl_ui_test_vg_animation},
#endif
{ NULL, NULL }
};

View File

@ -54,6 +54,7 @@ void efl_ui_test_select_model(TCase *tc);
void efl_ui_test_view_model(TCase *tc);
void efl_ui_test_group_item(TCase *tc);
void efl_ui_test_text(TCase *tc);
void efl_ui_test_vg_animation(TCase *tc);
void loop_timer_interval_set(Eo *obj, double in);

View File

@ -0,0 +1,122 @@
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif
#include <Efl_Ui.h>
#include "efl_ui_suite.h"
#ifdef BUILD_VG_LOADER_JSON
EFL_START_TEST(vg_anim_playing_control)
{
Evas_Object *win, *vg_anim;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,
efl_content_set(win, efl_added));
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);
// File load
efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);
ck_assert(efl_file_loaded_get(vg_anim));
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
// Play start
efl_player_playing_set(vg_anim, EINA_TRUE);
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);
// Play pause
efl_player_paused_set(vg_anim, EINA_TRUE);
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PAUSED);
// Play resume
efl_player_paused_set(vg_anim, EINA_FALSE);
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);
// Playback speed
efl_player_playback_speed_set(vg_anim, 2.0);
ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), 2.0));
efl_player_playback_speed_set(vg_anim, -2.0);
ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), -2.0));
// playing backwards
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS);
// Play stop
efl_player_playing_set(vg_anim, EINA_FALSE);
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
// Auto repeat
efl_ui_vg_animation_autorepeat_set(vg_anim, EINA_TRUE);
ck_assert_int_eq(efl_ui_vg_animation_autorepeat_get(vg_anim), EINA_TRUE);
// Auto play
efl_ui_vg_animation_autoplay_set(vg_anim, EINA_TRUE);
ck_assert_int_eq(efl_ui_vg_animation_autoplay_get(vg_anim), EINA_TRUE);
}
EFL_END_TEST
EFL_START_TEST(vg_anim_frame_control)
{
Evas_Object *win, *vg_anim;
int frame_count = 0;
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
efl_ui_win_autodel_set(efl_added, EINA_TRUE));
vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,
efl_content_set(win, efl_added));
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);
// File load
// emoji_wink.json is 60 frames sample.
efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);
ck_assert(efl_file_loaded_get(vg_anim));
ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
// Total frame
frame_count = efl_ui_vg_animation_frame_count_get(vg_anim);
ck_assert_int_eq(frame_count, 60);
// Frame set, get
efl_ui_vg_animation_frame_set(vg_anim, 30);
ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 30);
// Frame set, get
efl_player_playback_progress_set(vg_anim, 0.3);
ck_assert(EINA_DBL_EQ(efl_player_playback_progress_get(vg_anim), 0.3));
// Min/Max frame set,get
efl_ui_vg_animation_min_frame_set(vg_anim, 5);
ck_assert_int_eq(efl_ui_vg_animation_min_frame_get(vg_anim), 5);
efl_ui_vg_animation_frame_set(vg_anim, 1);
ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 5);
efl_ui_vg_animation_max_frame_set(vg_anim, 55);
ck_assert_int_eq(efl_ui_vg_animation_max_frame_get(vg_anim), 55);
efl_ui_vg_animation_frame_set(vg_anim, 60);
ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 55);
// Min/Max progress set,get
efl_ui_vg_animation_min_progress_set(vg_anim, 0.2);
ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_min_progress_get(vg_anim), 0.2));
efl_ui_vg_animation_max_progress_set(vg_anim, 0.8);
ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_max_progress_get(vg_anim), 0.8));
}
EFL_END_TEST
#endif
void efl_ui_test_vg_animation(TCase *tc)
{
tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
#ifdef BUILD_VG_LOADER_JSON
tcase_add_test(tc, vg_anim_playing_control);
tcase_add_test(tc, vg_anim_frame_control);
#endif
}

File diff suppressed because one or more lines are too long

View File

@ -160,6 +160,7 @@ efl_ui_suite_src = [
'efl_ui_test_view_model.c',
'efl_ui_test_group_item.c',
'efl_ui_test_text.c',
'efl_ui_test_vg_animation.c',
]
efl_ui_suite = executable('efl_ui_suite',