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
This commit is contained in:
Marcel Hollerbach 2019-11-11 10:14:42 +01:00 committed by Xavi Artigas
parent 0a2c9f57ef
commit 6b1de6a4ac
5 changed files with 45 additions and 1 deletions

View File

@ -7,6 +7,7 @@ _efl_canvas_animation_duration_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Data *pd,
double sec)
{
EINA_SAFETY_ON_FALSE_RETURN(sec > 0.0);
pd->duration = sec;
}
@ -69,7 +70,7 @@ _efl_canvas_animation_start_delay_set(Eo *eo_obj EINA_UNUSED,
Efl_Canvas_Animation_Data *pd,
double sec)
{
EINA_SAFETY_ON_FALSE_RETURN(sec < 0.0);
EINA_SAFETY_ON_FALSE_RETURN(sec >= 0.0);
pd->start_delay_time = sec;
}

View File

@ -0,0 +1,40 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <Evas.h>
#include "evas_suite.h"
#include "evas_tests_helpers.h"
EFL_START_TEST(efl_canvas_animation_negative_double_checking)
{
Efl_Canvas_Animation *animation = efl_new(EFL_CANVAS_ANIMATION_CLASS);
efl_animation_duration_set(animation, 1.0);
ck_assert_int_eq(efl_animation_duration_get(animation), 1.0);
efl_animation_duration_set(animation, 3.0);
ck_assert_int_eq(efl_animation_duration_get(animation), 3.0);
EXPECT_ERROR_START;
efl_animation_duration_set(animation, -1.0);
ck_assert_int_eq(efl_animation_duration_get(animation), 3.0);
EXPECT_ERROR_END;
efl_animation_start_delay_set(animation, 1.0);
ck_assert(EINA_DBL_EQ(efl_animation_start_delay_get(animation), 1.0));
efl_animation_start_delay_set(animation, 0.0);
ck_assert(EINA_DBL_EQ(efl_animation_start_delay_get(animation), 0.0));
EXPECT_ERROR_START;
efl_animation_start_delay_set(animation, -1.0);
ck_assert_int_eq(efl_animation_start_delay_get(animation), 0.0);
EXPECT_ERROR_END;
}
EFL_END_TEST
void efl_test_canvas_animation(TCase *tc)
{
tcase_add_test(tc, efl_canvas_animation_negative_double_checking);
}

View File

@ -29,6 +29,7 @@ static const Efl_Test_Case etc[] = {
{ "Object Smart", evas_test_object_smart },
{ "Matrix", evas_test_matrix },
{ "Events", evas_test_events },
{ "Efl Canvas Animation", efl_test_canvas_animation },
{ NULL, NULL }
};

View File

@ -23,5 +23,6 @@ void evas_test_evasgl(TCase *tc);
void evas_test_object_smart(TCase *tc);
void evas_test_matrix(TCase *tc);
void evas_test_events(TCase *tc);
void efl_test_canvas_animation(TCase *tc);
#endif /* _EVAS_SUITE_H */

View File

@ -21,6 +21,7 @@ evas_suite_src = [
'efl_test_canvas.c',
'efl_test_canvas2.c',
'efl_test_canvas3.c',
'efl_canvas_animation.c',
]
evas_suite = executable('evas_suite',