summaryrefslogtreecommitdiff
path: root/src/tests/elementary/efl_ui_test_vg_animation.c
blob: 2da7d0fbde5c033e7e66990802eb7d666ea65703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
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_looping_set(vg_anim, EINA_TRUE);
   ck_assert_int_eq(efl_ui_vg_animation_looping_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
}