add style copy + minor refactoring
This commit is contained in:
@@ -63,7 +63,6 @@ static void create_delete_change_parent(void)
|
||||
lv_obj_t * obj = lv_obj_create(lv_scr_act(), NULL);
|
||||
lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation");
|
||||
lv_test_assert_int_eq(0, lv_obj_count_children(obj), "New object's children count after creation");
|
||||
lv_test_assert_img_eq("lv_test_obj_1_1.png", "Draw test");
|
||||
|
||||
lv_test_print("Delete the created object");
|
||||
lv_obj_del(obj);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
static void empty_style(void);
|
||||
static void add_remove_read_prop(void);
|
||||
static void cascade(void);
|
||||
static void copy(void);
|
||||
static void states(void);
|
||||
static void mem_leak(void);
|
||||
|
||||
@@ -48,6 +49,7 @@ void lv_test_style(void)
|
||||
empty_style();
|
||||
add_remove_read_prop();
|
||||
cascade();
|
||||
copy();
|
||||
states();
|
||||
mem_leak();
|
||||
}
|
||||
@@ -259,6 +261,52 @@ static void cascade(void)
|
||||
lv_style_list_reset(&style_list);
|
||||
}
|
||||
|
||||
static void copy(void)
|
||||
{
|
||||
lv_test_print("");
|
||||
lv_test_print("Copy styles and style lists");
|
||||
lv_test_print("---------------------------");
|
||||
|
||||
|
||||
lv_test_print("Copy a style");
|
||||
lv_style_t style_src;
|
||||
lv_style_init(&style_src);
|
||||
lv_style_set_int(&style_src, LV_STYLE_LINE_SPACE, 5);
|
||||
|
||||
lv_style_t style_dest;
|
||||
lv_style_copy(&style_dest, &style_src);
|
||||
|
||||
int16_t weight;
|
||||
lv_style_int_t value;
|
||||
|
||||
weight = lv_style_get_int(&style_dest, LV_STYLE_LINE_SPACE, &value);
|
||||
lv_test_assert_int_eq(0, weight, "Get a copied property from a style");
|
||||
lv_test_assert_int_eq(5, value, "Get the value of a copied from a property");
|
||||
|
||||
lv_test_print("Copy a style list");
|
||||
lv_style_list_t list_src;
|
||||
lv_style_list_init(&list_src);
|
||||
lv_style_list_add_style(&list_src, &style_src);
|
||||
lv_style_list_set_local_int(&list_src, LV_STYLE_LINE_DASH_WIDTH, 20);
|
||||
|
||||
lv_style_list_t list_dest;
|
||||
lv_style_list_copy(&list_dest, &list_src);
|
||||
|
||||
lv_res_t found;
|
||||
found = lv_style_list_get_int(&list_dest, LV_STYLE_LINE_SPACE, &value);
|
||||
lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied property from a list");
|
||||
lv_test_assert_int_eq(5, value, "Get the value of a copied property from a list");
|
||||
found = lv_style_list_get_int(&list_dest, LV_STYLE_LINE_DASH_WIDTH, &value);
|
||||
lv_test_assert_int_eq(LV_RES_OK, found, "Get a copied local property from a list");
|
||||
lv_test_assert_int_eq(20, value, "Get the value of a copied local property from a list");
|
||||
|
||||
/*Clean up*/
|
||||
lv_style_list_reset(&list_dest);
|
||||
lv_style_list_reset(&list_src);
|
||||
|
||||
lv_style_reset(&style_dest);
|
||||
lv_style_reset(&style_src);
|
||||
}
|
||||
|
||||
static void states(void)
|
||||
{
|
||||
|
||||
76
tests/lv_test_objx/lv_test_cont.c
Normal file
76
tests/lv_test_objx/lv_test_cont.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @file lv_test_cont.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../lvgl.h"
|
||||
#include "../lv_test_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void create_copy(void);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_test_cont(void)
|
||||
{
|
||||
lv_test_print("");
|
||||
lv_test_print("===================");
|
||||
lv_test_print("Start lv_cont tests");
|
||||
lv_test_print("===================");
|
||||
|
||||
create_copy();
|
||||
}
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void create_copy(void)
|
||||
{
|
||||
lv_test_print("");
|
||||
lv_test_print("Create and copy a container");
|
||||
lv_test_print("---------------------------");
|
||||
|
||||
lv_test_print("Create a container");
|
||||
lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count before creation");
|
||||
|
||||
lv_obj_t * obj = lv_cont_create(lv_scr_act(), NULL);
|
||||
lv_test_assert_int_eq(1, lv_obj_count_children(lv_scr_act()), "Screen's children count after creation");
|
||||
|
||||
lv_test_print("Test the default values");
|
||||
lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_left(obj), "Default left fit");
|
||||
lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_right(obj), "Default right fit");
|
||||
lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_top(obj), "Default top fit");
|
||||
lv_test_assert_int_eq(LV_FIT_NONE, lv_cont_get_fit_bottom(obj), "Default bottom fit");
|
||||
lv_test_assert_int_eq(LV_LAYOUT_OFF, lv_cont_get_layout(obj), "Default layout");
|
||||
|
||||
lv_test_print("Delete the container");
|
||||
lv_obj_del(obj);
|
||||
obj = NULL;
|
||||
lv_test_assert_int_eq(0, lv_obj_count_children(lv_scr_act()), "Screen's children count after delete");
|
||||
|
||||
}
|
||||
38
tests/lv_test_objx/lv_test_cont.h
Normal file
38
tests/lv_test_objx/lv_test_cont.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @file lv_test_obj.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_TEST_CONT_H
|
||||
#define LV_TEST_CONT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
void lv_test_cont(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_TEST_CONT_H*/
|
||||
Reference in New Issue
Block a user