summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-11 10:14:42 +0100
committerXavi Artigas <xavierartigas@yahoo.es>2019-11-11 10:20:48 +0100
commit6b1de6a4ac4afac779d873f292757c943331540d (patch)
tree53ad2b862eaadecf597118efd7dbcaa765de80bf
parent0a2c9f57ef9864f30a94abfd847870d3765f874c (diff)
efl_canvas_animation: correctly handle double signness
Summary: start_delay and duration both have to be > 0.0 otherwise there should be an error. This also adds the neccessary checks, to ensure that. For now this is only added to the normal evas test suite, maybe we eed to refactor these efl_* API tests into theire own test suite. However, not for now. Reviewers: segfaultxavi Reviewed By: segfaultxavi Subscribers: segfaultxavi, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10617
-rw-r--r--src/lib/evas/canvas/efl_canvas_animation.c3
-rw-r--r--src/tests/evas/efl_canvas_animation.c40
-rw-r--r--src/tests/evas/evas_suite.c1
-rw-r--r--src/tests/evas/evas_suite.h1
-rw-r--r--src/tests/evas/meson.build1
5 files changed, 45 insertions, 1 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_animation.c b/src/lib/evas/canvas/efl_canvas_animation.c
index 119384b5eb..33ffa035ac 100644
--- a/src/lib/evas/canvas/efl_canvas_animation.c
+++ b/src/lib/evas/canvas/efl_canvas_animation.c
@@ -7,6 +7,7 @@ _efl_canvas_animation_duration_set(Eo *eo_obj EINA_UNUSED,
7 Efl_Canvas_Animation_Data *pd, 7 Efl_Canvas_Animation_Data *pd,
8 double sec) 8 double sec)
9{ 9{
10 EINA_SAFETY_ON_FALSE_RETURN(sec > 0.0);
10 pd->duration = sec; 11 pd->duration = sec;
11} 12}
12 13
@@ -69,7 +70,7 @@ _efl_canvas_animation_start_delay_set(Eo *eo_obj EINA_UNUSED,
69 Efl_Canvas_Animation_Data *pd, 70 Efl_Canvas_Animation_Data *pd,
70 double sec) 71 double sec)
71{ 72{
72 EINA_SAFETY_ON_FALSE_RETURN(sec < 0.0); 73 EINA_SAFETY_ON_FALSE_RETURN(sec >= 0.0);
73 74
74 pd->start_delay_time = sec; 75 pd->start_delay_time = sec;
75} 76}
diff --git a/src/tests/evas/efl_canvas_animation.c b/src/tests/evas/efl_canvas_animation.c
new file mode 100644
index 0000000000..cef036341c
--- /dev/null
+++ b/src/tests/evas/efl_canvas_animation.c
@@ -0,0 +1,40 @@
1#ifdef HAVE_CONFIG_H
2# include "config.h"
3#endif
4
5#include <stdio.h>
6
7#include <Evas.h>
8
9#include "evas_suite.h"
10#include "evas_tests_helpers.h"
11
12EFL_START_TEST(efl_canvas_animation_negative_double_checking)
13{
14 Efl_Canvas_Animation *animation = efl_new(EFL_CANVAS_ANIMATION_CLASS);
15
16 efl_animation_duration_set(animation, 1.0);
17 ck_assert_int_eq(efl_animation_duration_get(animation), 1.0);
18 efl_animation_duration_set(animation, 3.0);
19 ck_assert_int_eq(efl_animation_duration_get(animation), 3.0);
20 EXPECT_ERROR_START;
21 efl_animation_duration_set(animation, -1.0);
22 ck_assert_int_eq(efl_animation_duration_get(animation), 3.0);
23 EXPECT_ERROR_END;
24
25 efl_animation_start_delay_set(animation, 1.0);
26 ck_assert(EINA_DBL_EQ(efl_animation_start_delay_get(animation), 1.0));
27 efl_animation_start_delay_set(animation, 0.0);
28 ck_assert(EINA_DBL_EQ(efl_animation_start_delay_get(animation), 0.0));
29 EXPECT_ERROR_START;
30 efl_animation_start_delay_set(animation, -1.0);
31 ck_assert_int_eq(efl_animation_start_delay_get(animation), 0.0);
32 EXPECT_ERROR_END;
33
34}
35EFL_END_TEST
36
37void efl_test_canvas_animation(TCase *tc)
38{
39 tcase_add_test(tc, efl_canvas_animation_negative_double_checking);
40}
diff --git a/src/tests/evas/evas_suite.c b/src/tests/evas/evas_suite.c
index 5e3d0d5571..eded3ae08f 100644
--- a/src/tests/evas/evas_suite.c
+++ b/src/tests/evas/evas_suite.c
@@ -29,6 +29,7 @@ static const Efl_Test_Case etc[] = {
29 { "Object Smart", evas_test_object_smart }, 29 { "Object Smart", evas_test_object_smart },
30 { "Matrix", evas_test_matrix }, 30 { "Matrix", evas_test_matrix },
31 { "Events", evas_test_events }, 31 { "Events", evas_test_events },
32 { "Efl Canvas Animation", efl_test_canvas_animation },
32 { NULL, NULL } 33 { NULL, NULL }
33}; 34};
34 35
diff --git a/src/tests/evas/evas_suite.h b/src/tests/evas/evas_suite.h
index 6fee2236d0..90a7ac0860 100644
--- a/src/tests/evas/evas_suite.h
+++ b/src/tests/evas/evas_suite.h
@@ -23,5 +23,6 @@ void evas_test_evasgl(TCase *tc);
23void evas_test_object_smart(TCase *tc); 23void evas_test_object_smart(TCase *tc);
24void evas_test_matrix(TCase *tc); 24void evas_test_matrix(TCase *tc);
25void evas_test_events(TCase *tc); 25void evas_test_events(TCase *tc);
26void efl_test_canvas_animation(TCase *tc);
26 27
27#endif /* _EVAS_SUITE_H */ 28#endif /* _EVAS_SUITE_H */
diff --git a/src/tests/evas/meson.build b/src/tests/evas/meson.build
index 62d744a5db..0e92eba83e 100644
--- a/src/tests/evas/meson.build
+++ b/src/tests/evas/meson.build
@@ -21,6 +21,7 @@ evas_suite_src = [
21 'efl_test_canvas.c', 21 'efl_test_canvas.c',
22 'efl_test_canvas2.c', 22 'efl_test_canvas2.c',
23 'efl_test_canvas3.c', 23 'efl_test_canvas3.c',
24 'efl_canvas_animation.c',
24] 25]
25 26
26evas_suite = executable('evas_suite', 27evas_suite = executable('evas_suite',