efl
122 строки · 4.3 Кб
1#ifdef HAVE_CONFIG_H2# include "elementary_config.h"3#endif4
5#include <Efl_Ui.h>6#include "efl_ui_suite.h"7
8#ifdef BUILD_VG_LOADER_JSON9
10EFL_START_TEST(vg_anim_playing_control)11{
12Evas_Object *win, *vg_anim;13win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),14efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),15efl_ui_win_autodel_set(efl_added, EINA_TRUE));16vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,17efl_content_set(win, efl_added));18
19ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);20
21// File load22efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);23ck_assert(efl_file_loaded_get(vg_anim));24ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);25
26// Play start27efl_player_playing_set(vg_anim, EINA_TRUE);28ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);29
30// Play pause31efl_player_paused_set(vg_anim, EINA_TRUE);32ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PAUSED);33
34// Play resume35efl_player_paused_set(vg_anim, EINA_FALSE);36ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);37
38// Playback speed39efl_player_playback_speed_set(vg_anim, 2.0);40ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), 2.0));41
42efl_player_playback_speed_set(vg_anim, -2.0);43ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), -2.0));44
45// playing backwards46ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS);47
48// Play stop49efl_player_playing_set(vg_anim, EINA_FALSE);50ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);51
52// Auto repeat53efl_player_playback_loop_set(vg_anim, EINA_TRUE);54ck_assert_int_eq(efl_player_playback_loop_get(vg_anim), EINA_TRUE);55
56// Auto play57efl_player_autoplay_set(vg_anim, EINA_TRUE);58ck_assert_int_eq(efl_player_autoplay_get(vg_anim), EINA_TRUE);59}
60EFL_END_TEST
61
62EFL_START_TEST(vg_anim_frame_control)63{
64Evas_Object *win, *vg_anim;65int frame_count = 0;66
67win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),68efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),69efl_ui_win_autodel_set(efl_added, EINA_TRUE));70vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,71efl_content_set(win, efl_added));72
73ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);74
75// File load76// emoji_wink.json is 60 frames sample.77efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);78ck_assert(efl_file_loaded_get(vg_anim));79ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);80
81// Total frame82frame_count = efl_ui_vg_animation_frame_count_get(vg_anim);83ck_assert_int_eq(frame_count, 60);84
85// Frame set, get86efl_ui_vg_animation_frame_set(vg_anim, 30);87ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 30);88
89// Frame set, get90efl_player_playback_progress_set(vg_anim, 0.3);91ck_assert(EINA_DBL_EQ(efl_player_playback_progress_get(vg_anim), 0.3));92
93// Min/Max frame set,get94efl_ui_vg_animation_min_frame_set(vg_anim, 5);95ck_assert_int_eq(efl_ui_vg_animation_min_frame_get(vg_anim), 5);96efl_ui_vg_animation_frame_set(vg_anim, 1);97ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 5);98
99efl_ui_vg_animation_max_frame_set(vg_anim, 55);100ck_assert_int_eq(efl_ui_vg_animation_max_frame_get(vg_anim), 55);101efl_ui_vg_animation_frame_set(vg_anim, 60);102ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 55);103
104// Min/Max progress set,get105efl_ui_vg_animation_min_progress_set(vg_anim, 0.2);106ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_min_progress_get(vg_anim), 0.2));107
108efl_ui_vg_animation_max_progress_set(vg_anim, 0.8);109ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_max_progress_get(vg_anim), 0.8));110}
111EFL_END_TEST
112
113#endif114
115void efl_ui_test_vg_animation(TCase *tc)116{
117tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);118#ifdef BUILD_VG_LOADER_JSON119tcase_add_test(tc, vg_anim_playing_control);120tcase_add_test(tc, vg_anim_frame_control);121#endif122}
123