summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-10-29 10:05:06 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-10-31 09:58:54 -0400
commit07d8223005de648c9d61deca7f0a37d15dfd56c0 (patch)
tree17fede96f1f9cd73419a848d52d79f6956ed2feb
parent8e711d6ce87cd96548e85b6f2c3300f5ed6c55f6 (diff)
tests/evas: replace macro with function in mesh loader/saver test
this was totally impossible to debug no functional changes Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D10551
-rw-r--r--src/tests/evas/evas_test_mesh.c111
1 files changed, 57 insertions, 54 deletions
diff --git a/src/tests/evas/evas_test_mesh.c b/src/tests/evas/evas_test_mesh.c
index 95138e2e1f..c413f731ca 100644
--- a/src/tests/evas/evas_test_mesh.c
+++ b/src/tests/evas/evas_test_mesh.c
@@ -38,54 +38,6 @@
38 } \ 38 } \
39 } 39 }
40 40
41#define CHECK_MESHES_IN_FOLDER(folder, ext) \
42 it = eina_file_direct_ls(folder); \
43 EINA_ITERATOR_FOREACH(it, file) \
44 { \
45 int set_ok, save_ok; \
46 Eina_File *f; \
47 const Eina_File *f_get = NULL; \
48 const char *filename = NULL; \
49 const char *key = NULL; \
50 mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, e); \
51 mesh2 = efl_add(EVAS_CANVAS3D_MESH_CLASS, e); \
52 fail_if(mesh == NULL); \
53 fail_if(mesh2 == NULL); \
54 snprintf(buffer, PATH_MAX, "%s%s", tmp, ext); \
55 set_ok = efl_file_simple_load(mesh, file->path, NULL); \
56 save_ok = efl_file_save(mesh, buffer, NULL, NULL); \
57 fail_if(!set_ok); \
58 fail_if(!save_ok); \
59 set_ok = efl_file_simple_load(mesh2, buffer, NULL); \
60 fail_if(!set_ok); \
61 efl_file_simple_get(mesh2, &filename, &key); \
62 fail_if(!filename); \
63 fail_if(!!key); \
64 res = _compare_meshes(mesh, mesh2); \
65 fail_if(res == 1); \
66 f = eina_file_open(file->path, 0); \
67 fail_if(!f); \
68 set_ok = efl_file_simple_mmap_load(mesh, f, NULL); \
69 efl_file_simple_mmap_get(mesh, &f_get, &key); \
70 fail_if(!f_get); \
71 fail_if(!!key); \
72 eina_file_close(f); \
73 save_ok = efl_file_save(mesh, buffer, NULL, NULL); \
74 fail_if(!set_ok); \
75 fail_if(!save_ok); \
76 f = eina_file_open(buffer, 0); \
77 fail_if(!f); \
78 set_ok = efl_file_simple_mmap_load(mesh2, f, NULL); \
79 eina_file_close(f); \
80 fail_if(!set_ok); \
81 res = _compare_meshes(mesh, mesh2); \
82 fail_if(res == 1); \
83 efl_del(mesh2); \
84 efl_del(mesh); \
85 unlink(buffer); \
86 } \
87 eina_iterator_free(it);
88
89static Evas_Canvas3D_Mesh_Frame * 41static Evas_Canvas3D_Mesh_Frame *
90return_zero_frame(Evas_Canvas3D_Mesh_Data *pd) 42return_zero_frame(Evas_Canvas3D_Mesh_Data *pd)
91{ 43{
@@ -139,16 +91,68 @@ static int _compare_meshes(Evas_Canvas3D_Mesh *mesh1, Evas_Canvas3D_Mesh *mesh2)
139 return 0; 91 return 0;
140} 92}
141 93
142EFL_START_TEST(evas_object_mesh_loader_saver) 94static void
95check_meshes_in_folder(Eina_Tmpstr *tmp, const char *folder, const char *ext)
143{ 96{
144 char buffer[PATH_MAX]; 97 char buffer[PATH_MAX];
145 Evas *e = _setup_evas(); 98 Evas *e = _setup_evas();
146 Eina_Tmpstr *tmp;
147 Eo *mesh, *mesh2; 99 Eo *mesh, *mesh2;
148 Eina_Iterator *it; 100 Eina_Iterator *it;
149 char *file_mask = strdup("evas_test_mesh_XXXXXX"); 101 int res = 0;
150 int res = 0, tmpfd;
151 const Eina_File_Direct_Info *file; 102 const Eina_File_Direct_Info *file;
103 it = eina_file_direct_ls(folder);
104 EINA_ITERATOR_FOREACH(it, file)
105 {
106 int set_ok, save_ok;
107 Eina_File *f;
108 const Eina_File *f_get = NULL;
109 const char *filename = NULL;
110 const char *key = NULL;
111 mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, e);
112 mesh2 = efl_add(EVAS_CANVAS3D_MESH_CLASS, e);
113 fail_if(mesh == NULL);
114 fail_if(mesh2 == NULL);
115 snprintf(buffer, PATH_MAX, "%s%s", tmp, ext);
116 set_ok = efl_file_simple_load(mesh, file->path, NULL);
117 fail_if(!set_ok);
118 save_ok = efl_file_save(mesh, buffer, NULL, NULL);
119 fail_if(!save_ok);
120 set_ok = efl_file_simple_load(mesh2, buffer, NULL);
121 fail_if(!set_ok);
122 efl_file_simple_get(mesh2, &filename, &key);
123 fail_if(!filename);
124 fail_if(!!key);
125 res = _compare_meshes(mesh, mesh2);
126 fail_if(res == 1);
127 f = eina_file_open(file->path, 0);
128 fail_if(!f);
129 set_ok = efl_file_simple_mmap_load(mesh, f, NULL);
130 efl_file_simple_mmap_get(mesh, &f_get, &key);
131 fail_if(!f_get);
132 fail_if(!!key);
133 eina_file_close(f);
134 save_ok = efl_file_save(mesh, buffer, NULL, NULL);
135 fail_if(!set_ok);
136 fail_if(!save_ok);
137 f = eina_file_open(buffer, 0);
138 fail_if(!f);
139 set_ok = efl_file_simple_mmap_load(mesh2, f, NULL);
140 eina_file_close(f);
141 fail_if(!set_ok);
142 res = _compare_meshes(mesh, mesh2);
143 fail_if(res == 1);
144 efl_del(mesh2);
145 efl_del(mesh);
146 unlink(buffer);
147 }
148 eina_iterator_free(it);
149 evas_free(e);
150}
151EFL_START_TEST(evas_object_mesh_loader_saver)
152{
153 Eina_Tmpstr *tmp;
154 char *file_mask = strdup("evas_test_mesh_XXXXXX");
155 int tmpfd;
152 struct 156 struct
153 { 157 {
154 const char *dir; 158 const char *dir;
@@ -166,12 +170,11 @@ EFL_START_TEST(evas_object_mesh_loader_saver)
166 fail_if(tmpfd == -1); 170 fail_if(tmpfd == -1);
167 fail_if(!!close(tmpfd)); 171 fail_if(!!close(tmpfd));
168 172
169 CHECK_MESHES_IN_FOLDER(values[_i].dir, values[_i].fmt) 173 check_meshes_in_folder(tmp, values[_i].dir, values[_i].fmt);
170 174
171 unlink(tmp); 175 unlink(tmp);
172 176
173 free(file_mask); 177 free(file_mask);
174 evas_free(e);
175} 178}
176EFL_END_TEST 179EFL_END_TEST
177 180