summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-08-16 21:34:29 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-08-16 21:34:29 +0000
commit7a759f05b6bf0f57df833e63fad9a7392cf6f7fc (patch)
tree0bb13258cf1c692647f27be75c22ffbde28ec58f /legacy
parent1278ec57bfbabeb5a88adb88c010fea57c96d5d0 (diff)
EPhysics: support running only specified test
SVN revision: 75325
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ephysics/README10
-rw-r--r--legacy/ephysics/src/bin/test.c97
2 files changed, 80 insertions, 27 deletions
diff --git a/legacy/ephysics/README b/legacy/ephysics/README
index 8b2dad4143..9ac090ac59 100644
--- a/legacy/ephysics/README
+++ b/legacy/ephysics/README
@@ -38,6 +38,16 @@ well, that showcases EPhysics capabilites. Run
38 $ ephysics_test 38 $ ephysics_test
39 39
40to see these examples. 40to see these examples.
41
42It supports to launch a specified test on command line, like
43
44 $ ephysics_test "Jumping Balls"
45
46Also, it can run only the test, avoiding the main menu, with parameter
47--test-win-only or -to (it must to be passed before the test name):
48
49 $ ephysics_test -to Camera
50
41---- 51----
42 52
43DOCS 53DOCS
diff --git a/legacy/ephysics/src/bin/test.c b/legacy/ephysics/src/bin/test.c
index 11c666305c..6971894368 100644
--- a/legacy/ephysics/src/bin/test.c
+++ b/legacy/ephysics/src/bin/test.c
@@ -8,6 +8,12 @@
8 8
9int _ephysics_test_log_dom = -1; 9int _ephysics_test_log_dom = -1;
10 10
11typedef struct _EPhysics_Test EPhysics_Test;
12struct _EPhysics_Test {
13 const char *name;
14 void (*func)(void *data, Evas_Object *obj, void *event_info);
15};
16
11/* examples prototypes */ 17/* examples prototypes */
12void test_bouncing_ball(void *data, Evas_Object *obj, void *event_info); 18void test_bouncing_ball(void *data, Evas_Object *obj, void *event_info);
13void test_bouncing_text(void *data, Evas_Object *obj, void *event_info); 19void test_bouncing_text(void *data, Evas_Object *obj, void *event_info);
@@ -29,6 +35,28 @@ void test_shapes(void *data, Evas_Object *obj, void *event_info);
29void test_sleeping(void *data, Evas_Object *obj, void *event_info); 35void test_sleeping(void *data, Evas_Object *obj, void *event_info);
30void test_slider(void *data, Evas_Object *obj, void *event_info); 36void test_slider(void *data, Evas_Object *obj, void *event_info);
31 37
38static const EPhysics_Test tests[] = {
39 {"Bouncing Ball", test_bouncing_ball},
40 {"Bouncing Text", test_bouncing_text},
41 {"Camera", test_camera},
42 {"Camera Track", test_camera_track},
43 {"Colliding Balls", test_colliding_balls},
44 {"Collision Detection", test_collision},
45 {"Collision Filter", test_collision_filter},
46 {"Collision High Speed", test_collision_speed},
47 {"Constraint", test_constraint},
48 {"Delete Body", test_delete},
49 {"Falling Letters", test_falling_letters},
50 {"Growing Balls", test_growing_balls},
51 {"Jumping Balls", test_jumping_balls},
52 {"No Gravity", test_no_gravity},
53 {"Rotate", test_rotate},
54 {"Velocity", test_velocity},
55 {"Shapes", test_shapes},
56 {"Sleeping Threshold", test_sleeping},
57 {"Slider", test_slider},
58};
59
32static void 60static void
33_win_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) 61_win_del(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
34{ 62{
@@ -133,14 +161,28 @@ test_win_add(Test_Data *test_data, const char *title, Eina_Bool autodel)
133 test_data->layout = ly; 161 test_data->layout = ly;
134} 162}
135 163
136#define ADD_TEST(_name, _func) \ 164static void
137 elm_list_item_append(list, _name, NULL, NULL, _func, NULL); 165_test_run(char *autorun)
166{
167 unsigned int i;
168
169 for (i = 0; i < EINA_C_ARRAY_LENGTH(tests); i++)
170 {
171 EPhysics_Test test = tests[i];
172 if (!strcmp(test.name, autorun))
173 {
174 test.func(NULL, NULL, NULL);
175 return;
176 }
177 }
178}
138 179
139/* FIXME add autorun and test_win_only features */
140static void 180static void
141_main_win_add(char *autorun __UNUSED__, Eina_Bool test_win_only __UNUSED__) 181_main_win_add(char *autorun)
142{ 182{
183 Elm_Object_Item *selected = NULL;
143 Evas_Object *win, *list; 184 Evas_Object *win, *list;
185 unsigned int i;
144 186
145 win = elm_win_add(NULL, "main", ELM_WIN_BASIC); 187 win = elm_win_add(NULL, "main", ELM_WIN_BASIC);
146 elm_win_title_set(win, "EPhysics Tests"); 188 elm_win_title_set(win, "EPhysics Tests");
@@ -155,30 +197,27 @@ _main_win_add(char *autorun __UNUSED__, Eina_Bool test_win_only __UNUSED__)
155 elm_win_resize_object_add(win, list); 197 elm_win_resize_object_add(win, list);
156 evas_object_show(list); 198 evas_object_show(list);
157 199
158 ADD_TEST("BOUNCING BALL", test_bouncing_ball); 200 for (i = 0; i < EINA_C_ARRAY_LENGTH(tests); i++)
159 ADD_TEST("BOUNCING TEXT", test_bouncing_text); 201 {
160 ADD_TEST("CAMERA", test_camera); 202 Elm_Object_Item *item;
161 ADD_TEST("CAMERA TRACK", test_camera_track); 203 EPhysics_Test test;
162 ADD_TEST("COLLIDING BALLS", test_colliding_balls); 204
163 ADD_TEST("COLLISION DETECTION", test_collision); 205 test = tests[i];
164 ADD_TEST("COLLISION FILTER", test_collision_filter); 206 item = elm_list_item_append(list, test.name, NULL, NULL, test.func,
165 ADD_TEST("COLLISION HIGH SPEED", test_collision_speed); 207 NULL);
166 ADD_TEST("CONSTRAINT", test_constraint); 208
167 ADD_TEST("DELETE BODY", test_delete); 209 if ((autorun) && (!strcmp(test.name, autorun)))
168 ADD_TEST("FALLING LETTERS", test_falling_letters); 210 selected = item;
169 ADD_TEST("GROWING BALLS", test_growing_balls); 211 }
170 ADD_TEST("JUMPING BALLS", test_jumping_balls);
171 ADD_TEST("NO GRAVITY", test_no_gravity);
172 ADD_TEST("ROTATE", test_rotate);
173 ADD_TEST("VELOCITY", test_velocity);
174 ADD_TEST("SHAPES", test_shapes);
175 ADD_TEST("SLEEPING THRESHOLD", test_sleeping);
176 ADD_TEST("SLIDER", test_slider);
177 212
178 elm_list_go(list); 213 elm_list_go(list);
179}
180 214
181#undef ADD_TEST 215 if (selected)
216 elm_list_item_bring_in(selected);
217
218 if (autorun)
219 _test_run(autorun);
220}
182 221
183EAPI_MAIN int 222EAPI_MAIN int
184elm_main(int argc, char **argv) 223elm_main(int argc, char **argv)
@@ -201,7 +240,7 @@ elm_main(int argc, char **argv)
201 240
202 /* if called with a single argument try to autorun a test with 241 /* if called with a single argument try to autorun a test with
203 * the same name as the given param 242 * the same name as the given param
204 * ex: elementary_test "Box Vert 2" */ 243 * ex: ephysics_test "Jumping Balls" */
205 if (argc == 2) 244 if (argc == 2)
206 autorun = argv[1]; 245 autorun = argv[1];
207 else if (argc == 3) 246 else if (argc == 3)
@@ -216,7 +255,11 @@ elm_main(int argc, char **argv)
216 255
217 elm_theme_extension_add(NULL, 256 elm_theme_extension_add(NULL,
218 PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj"); 257 PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj");
219 _main_win_add(autorun, test_win_only); 258
259 if (test_win_only)
260 _test_run(autorun);
261 else
262 _main_win_add(autorun);
220 263
221 elm_run(); 264 elm_run();
222 265