efl

Форк
0
/
efl_ui_test_vg_animation.c 
122 строки · 4.3 Кб
1
#ifdef HAVE_CONFIG_H
2
# include "elementary_config.h"
3
#endif
4

5
#include <Efl_Ui.h>
6
#include "efl_ui_suite.h"
7

8
#ifdef BUILD_VG_LOADER_JSON
9

10
EFL_START_TEST(vg_anim_playing_control)
11
{
12
   Evas_Object *win, *vg_anim;
13
   win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
14
                 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
15
                 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
16
   vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,
17
                     efl_content_set(win, efl_added));
18

19
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);
20

21
   // File load
22
   efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);
23
   ck_assert(efl_file_loaded_get(vg_anim));
24
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
25

26
   // Play start
27
   efl_player_playing_set(vg_anim, EINA_TRUE);
28
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);
29

30
   // Play pause
31
   efl_player_paused_set(vg_anim, EINA_TRUE);
32
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PAUSED);
33

34
   // Play resume
35
   efl_player_paused_set(vg_anim, EINA_FALSE);
36
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING);
37

38
   // Playback speed
39
   efl_player_playback_speed_set(vg_anim, 2.0);
40
   ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), 2.0));
41

42
   efl_player_playback_speed_set(vg_anim, -2.0);
43
   ck_assert(EINA_DBL_EQ(efl_player_playback_speed_get(vg_anim), -2.0));
44

45
   // playing backwards
46
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_PLAYING_BACKWARDS);
47

48
   // Play stop
49
   efl_player_playing_set(vg_anim, EINA_FALSE);
50
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
51

52
   // Auto repeat
53
   efl_player_playback_loop_set(vg_anim, EINA_TRUE);
54
   ck_assert_int_eq(efl_player_playback_loop_get(vg_anim), EINA_TRUE);
55

56
   // Auto play
57
   efl_player_autoplay_set(vg_anim, EINA_TRUE);
58
   ck_assert_int_eq(efl_player_autoplay_get(vg_anim), EINA_TRUE);
59
}
60
EFL_END_TEST
61

62
EFL_START_TEST(vg_anim_frame_control)
63
{
64
   Evas_Object *win, *vg_anim;
65
   int frame_count = 0;
66

67
   win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
68
                 efl_text_set(efl_added, "Efl_Ui_Vg_Animation demo"),
69
                 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
70
   vg_anim = efl_add(EFL_UI_VG_ANIMATION_CLASS, win,
71
                     efl_content_set(win, efl_added));
72

73
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_NOT_READY);
74

75
   // File load
76
   // emoji_wink.json is 60 frames sample.
77
   efl_file_simple_load(vg_anim, TESTS_SRC_DIR"/emoji_wink.json", NULL);
78
   ck_assert(efl_file_loaded_get(vg_anim));
79
   ck_assert_int_eq(efl_ui_vg_animation_state_get(vg_anim), EFL_UI_VG_ANIMATION_STATE_STOPPED);
80

81
   // Total frame
82
   frame_count = efl_ui_vg_animation_frame_count_get(vg_anim);
83
   ck_assert_int_eq(frame_count, 60);
84

85
   // Frame set, get
86
   efl_ui_vg_animation_frame_set(vg_anim, 30);
87
   ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 30);
88

89
   // Frame set, get
90
   efl_player_playback_progress_set(vg_anim, 0.3);
91
   ck_assert(EINA_DBL_EQ(efl_player_playback_progress_get(vg_anim), 0.3));
92

93
   // Min/Max frame set,get
94
   efl_ui_vg_animation_min_frame_set(vg_anim, 5);
95
   ck_assert_int_eq(efl_ui_vg_animation_min_frame_get(vg_anim), 5);
96
   efl_ui_vg_animation_frame_set(vg_anim, 1);
97
   ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 5);
98

99
   efl_ui_vg_animation_max_frame_set(vg_anim, 55);
100
   ck_assert_int_eq(efl_ui_vg_animation_max_frame_get(vg_anim), 55);
101
   efl_ui_vg_animation_frame_set(vg_anim, 60);
102
   ck_assert_int_eq(efl_ui_vg_animation_frame_get(vg_anim), 55);
103

104
   // Min/Max progress set,get
105
   efl_ui_vg_animation_min_progress_set(vg_anim, 0.2);
106
   ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_min_progress_get(vg_anim), 0.2));
107

108
   efl_ui_vg_animation_max_progress_set(vg_anim, 0.8);
109
   ck_assert(EINA_DBL_EQ(efl_ui_vg_animation_max_progress_get(vg_anim), 0.8));
110
}
111
EFL_END_TEST
112

113
#endif
114

115
void efl_ui_test_vg_animation(TCase *tc)
116
{
117
   tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
118
#ifdef BUILD_VG_LOADER_JSON
119
   tcase_add_test(tc, vg_anim_playing_control);
120
   tcase_add_test(tc, vg_anim_frame_control);
121
#endif
122
}
123

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.