summaryrefslogtreecommitdiff
path: root/src/tests/evas/evas_test_mesh.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/evas/evas_test_mesh.c')
-rw-r--r--src/tests/evas/evas_test_mesh.c124
1 files changed, 65 insertions, 59 deletions
diff --git a/src/tests/evas/evas_test_mesh.c b/src/tests/evas/evas_test_mesh.c
index 95138e2..3bf3c30 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,26 +91,81 @@ 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 *loadext, 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 if (file->path[file->name_start] == '.') continue; //some hidden git file or whatever
112 if (!eina_str_has_extension(file->path + file->name_start, loadext)) continue; //some other file
113 mesh = efl_add(EVAS_CANVAS3D_MESH_CLASS, e);
114 mesh2 = efl_add(EVAS_CANVAS3D_MESH_CLASS, e);
115 fail_if(mesh == NULL);
116 fail_if(mesh2 == NULL);
117 snprintf(buffer, PATH_MAX, "%s%s", tmp, ext);
118 set_ok = efl_file_simple_load(mesh, file->path, NULL);
119 fail_if(!set_ok);
120 save_ok = efl_file_save(mesh, buffer, NULL, NULL);
121 fail_if(!save_ok);
122 set_ok = efl_file_simple_load(mesh2, buffer, NULL);
123 fail_if(!set_ok);
124 efl_file_simple_get(mesh2, &filename, &key);
125 fail_if(!filename);
126 fail_if(!!key);
127 res = _compare_meshes(mesh, mesh2);
128 fail_if(res == 1);
129 f = eina_file_open(file->path, 0);
130 fail_if(!f);
131 set_ok = efl_file_simple_mmap_load(mesh, f, NULL);
132 efl_file_simple_mmap_get(mesh, &f_get, &key);
133 fail_if(!f_get);
134 fail_if(!!key);
135 eina_file_close(f);
136 save_ok = efl_file_save(mesh, buffer, NULL, NULL);
137 fail_if(!set_ok);
138 fail_if(!save_ok);
139 f = eina_file_open(buffer, 0);
140 fail_if(!f);
141 set_ok = efl_file_simple_mmap_load(mesh2, f, NULL);
142 eina_file_close(f);
143 fail_if(!set_ok);
144 res = _compare_meshes(mesh, mesh2);
145 fail_if(res == 1);
146 efl_del(mesh2);
147 efl_del(mesh);
148 unlink(buffer);
149 }
150 eina_iterator_free(it);
151 evas_free(e);
152}
153EFL_START_TEST(evas_object_mesh_loader_saver)
154{
155 Eina_Tmpstr *tmp;
156 char *file_mask = strdup("evas_test_mesh_XXXXXX");
157 int tmpfd;
152 struct 158 struct
153 { 159 {
154 const char *dir; 160 const char *dir;
155 const char *fmt; 161 const char *loadfmt;
162 const char *savefmt;
156 } values[4] = 163 } values[4] =
157 { 164 {
158 { TESTS_OBJ_MESH_DIR, ".eet" }, 165 { TESTS_OBJ_MESH_DIR, ".obj", ".eet" },
159 { TESTS_MD2_MESH_DIR, ".eet" }, 166 { TESTS_MD2_MESH_DIR, ".md2", ".eet" },
160 { TESTS_PLY_MESH_DIR, ".eet" }, 167 { TESTS_PLY_MESH_DIR, ".ply", ".eet" },
161 { TESTS_PLY_MESH_DIR, ".ply" }, 168 { TESTS_PLY_MESH_DIR, ".ply", ".ply" },
162 }; 169 };
163 170
164 /* create tmp file name, assume tmp.eet and tmp.ply also work */ 171 /* create tmp file name, assume tmp.eet and tmp.ply also work */
@@ -166,12 +173,11 @@ EFL_START_TEST(evas_object_mesh_loader_saver)
166 fail_if(tmpfd == -1); 173 fail_if(tmpfd == -1);
167 fail_if(!!close(tmpfd)); 174 fail_if(!!close(tmpfd));
168 175
169 CHECK_MESHES_IN_FOLDER(values[_i].dir, values[_i].fmt) 176 check_meshes_in_folder(tmp, values[_i].dir, values[_i].loadfmt, values[_i].savefmt);
170 177
171 unlink(tmp); 178 unlink(tmp);
172 179
173 free(file_mask); 180 free(file_mask);
174 evas_free(e);
175} 181}
176EFL_END_TEST 182EFL_END_TEST
177 183