summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:52:49 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commit21746ce8dcb87fe6fa0f2d133f551944a66c41d0 (patch)
tree177b7b52b7a09aea87dfd85859e95ede54d5935d
parente15c61beb37d39c3420a9c2fcc78c99424b24f94 (diff)
Test rework #13: ElDbus
-rw-r--r--src/tests/eldbus/eldbus_fake_server.c5
-rw-r--r--src/tests/eldbus/eldbus_suite.c97
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model.c12
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model.h2
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_connection.c8
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_method.c10
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_object.c8
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_proxy.c8
-rw-r--r--src/tests/eldbus/eldbus_test_eldbus_model_signal.c10
-rw-r--r--src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c12
10 files changed, 44 insertions, 128 deletions
diff --git a/src/tests/eldbus/eldbus_fake_server.c b/src/tests/eldbus/eldbus_fake_server.c
index da1f402..ea6e4ea 100644
--- a/src/tests/eldbus/eldbus_fake_server.c
+++ b/src/tests/eldbus/eldbus_fake_server.c
@@ -2,11 +2,10 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include "eldbus_fake_server.h"
6
7#include <Ecore.h> 5#include <Ecore.h>
8 6
9#include <check.h> 7#include "eldbus_suite.h"
8#include "eldbus_fake_server.h"
10 9
11#define FAKE_SERVER_DATA_KEY "data" 10#define FAKE_SERVER_DATA_KEY "data"
12 11
diff --git a/src/tests/eldbus/eldbus_suite.c b/src/tests/eldbus/eldbus_suite.c
index 8b6a181..dd79e33 100644
--- a/src/tests/eldbus/eldbus_suite.c
+++ b/src/tests/eldbus/eldbus_suite.c
@@ -2,22 +2,10 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include <stdlib.h>
6#include <stdio.h>
7
8#include <Eldbus.h>
9
10#include "eldbus_suite.h" 5#include "eldbus_suite.h"
6#include "../efl_check.h"
11 7
12typedef struct _Eldbus_Test_Case Eldbus_Test_Case; 8static const Efl_Test_Case etc[] = {
13
14struct _Eldbus_Test_Case
15{
16 const char *test_case;
17 void (*build)(TCase *tc);
18};
19
20static const Eldbus_Test_Case etc[] = {
21 { "eldbus_init", eldbus_test_eldbus_init }, 9 { "eldbus_init", eldbus_test_eldbus_init },
22 { "eldbus_model", eldbus_test_eldbus_model }, 10 { "eldbus_model", eldbus_test_eldbus_model },
23 { "eldbus_model_connection", eldbus_test_eldbus_model_connection }, 11 { "eldbus_model_connection", eldbus_test_eldbus_model_connection },
@@ -29,89 +17,18 @@ static const Eldbus_Test_Case etc[] = {
29 { NULL, NULL } 17 { NULL, NULL }
30}; 18};
31 19
32static void
33_list_tests(void)
34{
35 const Eldbus_Test_Case *itr;
36
37 itr = etc;
38 fputs("Available Test Cases:\n", stderr);
39 for (; itr->test_case; itr++)
40 printf("\t%s\n", itr->test_case);
41}
42
43static Eina_Bool
44_use_test(int argc, const char **argv, const char *test_case)
45{
46 if (argc < 1)
47 return 1;
48
49 for (; argc > 0; argc--, argv++)
50 {
51 if (strcmp(test_case, *argv) == 0)
52 return 1;
53 }
54 return 0;
55}
56
57static Suite *
58eldbus_suite_build(int argc, const char **argv)
59{
60 TCase *tc;
61 Suite *s;
62 int i;
63
64 s = suite_create("Eldbus");
65
66 for (i = 0; etc[i].test_case; ++i)
67 {
68 if (!_use_test(argc, argv, etc[i].test_case)) continue;
69 tc = tcase_create(etc[i].test_case);
70
71 etc[i].build(tc);
72
73 suite_add_tcase(s, tc);
74#ifndef _WIN32
75 tcase_set_timeout(tc, 0);
76#endif
77 }
78
79 return s;
80}
81
82int 20int
83main(int argc, char **argv) 21main(int argc, char **argv)
84{ 22{
85 Suite *s; 23 int failed_count;
86 SRunner *sr;
87 int i, failed_count;
88 24
89 for (i = 1; i < argc; i++) 25 if (!_efl_test_option_disp(argc, argv, etc))
90 if ((strcmp(argv[i], "-h") == 0) || 26 return 0;
91 (strcmp(argv[i], "--help") == 0))
92 {
93 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
94 argv[0]);
95 _list_tests();
96 return 0;
97 }
98 else if ((strcmp(argv[i], "-l") == 0) ||
99 (strcmp(argv[i], "--list") == 0))
100 {
101 _list_tests();
102 return 0;
103 }
104 27
105 putenv("EFL_RUN_IN_TREE=1"); 28 putenv("EFL_RUN_IN_TREE=1");
106 29
107 s = eldbus_suite_build(argc - 1, (const char **)argv + 1); 30 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
108 sr = srunner_create(s); 31 "Eldbus", etc);
109
110 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
111
112 srunner_run_all(sr, CK_ENV);
113 failed_count = srunner_ntests_failed(sr);
114 srunner_free(sr);
115 32
116 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE; 33 return (failed_count == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
117} 34}
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model.c b/src/tests/eldbus/eldbus_test_eldbus_model.c
index ebf91d7..771d942 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model.c
@@ -2,17 +2,17 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_suite.h" 5#include <stdbool.h>
6#include "eldbus_test_eldbus_model.h" 6#include <stdio.h>
7#include <unistd.h>
7 8
8#include <Ecore.h>
9#include <Eina.h> 9#include <Eina.h>
10#include <Ecore.h>
10#include <Eldbus.h> 11#include <Eldbus.h>
11#include <Eldbus_Model.h> 12#include <Eldbus_Model.h>
12 13
13#include <stdbool.h> 14#include "eldbus_test_eldbus_model.h"
14#include <stdio.h> 15#include "eldbus_suite.h"
15#include <unistd.h>
16 16
17static Eina_Bool 17static Eina_Bool
18_eo_event_quit_cb(void *data EINA_UNUSED, 18_eo_event_quit_cb(void *data EINA_UNUSED,
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model.h b/src/tests/eldbus/eldbus_test_eldbus_model.h
index 2d8603a..b190917 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model.h
+++ b/src/tests/eldbus/eldbus_test_eldbus_model.h
@@ -1,9 +1,9 @@
1#ifndef _ELDBUS_TEST_ELDBUS_MODEL_H 1#ifndef _ELDBUS_TEST_ELDBUS_MODEL_H
2#define _ELDBUS_TEST_ELDBUS_MODEL_H 2#define _ELDBUS_TEST_ELDBUS_MODEL_H
3 3
4#include <Eo.h>
4#include <Eldbus_Model.h> 5#include <Eldbus_Model.h>
5#include <Efl.h> 6#include <Efl.h>
6#include <Eo.h>
7 7
8void check_init(void); 8void check_init(void);
9void check_shutdown(void); 9void check_shutdown(void);
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
index 4dc9f3d..ffcc795 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_connection.c
@@ -2,14 +2,14 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_suite.h" 5#include <stdbool.h>
6#include "eldbus_test_eldbus_model.h"
7 6
8#include <Ecore.h>
9#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
10#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
11 10
12#include <stdbool.h> 11#include "eldbus_test_eldbus_model.h"
12#include "eldbus_suite.h"
13 13
14static Eo *connection = NULL; 14static Eo *connection = NULL;
15static Eo *unloaded_connection = NULL; 15static Eo *unloaded_connection = NULL;
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_method.c b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
index 6c9dc5b..e4f7a81 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_method.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_method.c
@@ -2,15 +2,15 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_fake_server.h" 5#include <stdbool.h>
6#include "eldbus_suite.h"
7#include "eldbus_test_eldbus_model.h"
8 6
9#include <Ecore.h>
10#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
11#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
12 10
13#include <stdbool.h> 11#include "eldbus_fake_server.h"
12#include "eldbus_test_eldbus_model.h"
13#include "eldbus_suite.h"
14 14
15#define ARGUMENT_A "arg0" 15#define ARGUMENT_A "arg0"
16#define ARGUMENT_B "arg1" 16#define ARGUMENT_B "arg1"
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_object.c b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
index a03edcc..c1f1248 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_object.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_object.c
@@ -2,14 +2,14 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_suite.h" 5#include <stdbool.h>
6#include "eldbus_test_eldbus_model.h"
7 6
8#include <Ecore.h>
9#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
10#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
11 10
12#include <stdbool.h> 11#include "eldbus_test_eldbus_model.h"
12#include "eldbus_suite.h"
13 13
14static Eo *object = NULL; 14static Eo *object = NULL;
15static Eo *unloaded_object = NULL; 15static Eo *unloaded_object = NULL;
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
index e0fca2a..98ce124 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_proxy.c
@@ -2,14 +2,14 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_suite.h" 5#include <stdbool.h>
6#include "eldbus_test_eldbus_model.h"
7 6
8#include <Ecore.h>
9#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
10#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
11 10
12#include <stdbool.h> 11#include "eldbus_test_eldbus_model.h"
12#include "eldbus_suite.h"
13 13
14static Eo *dbus_object1 = NULL; 14static Eo *dbus_object1 = NULL;
15static Eo *dbus_object2 = NULL; 15static Eo *dbus_object2 = NULL;
diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
index 1a7e907..3185f2e 100644
--- a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
+++ b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c
@@ -2,15 +2,15 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_fake_server.h" 5#include <stdbool.h>
6#include "eldbus_suite.h"
7#include "eldbus_test_eldbus_model.h"
8 6
9#include <Ecore.h>
10#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
11#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
12 10
13#include <stdbool.h> 11#include "eldbus_fake_server.h"
12#include "eldbus_test_eldbus_model.h"
13#include "eldbus_suite.h"
14 14
15#define ARGUMENT_A "arg0" 15#define ARGUMENT_A "arg0"
16 16
diff --git a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
index d4161b6..7a12d32 100644
--- a/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
+++ b/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
@@ -2,15 +2,15 @@
2# include <config.h> 2# include <config.h>
3#endif 3#endif
4 4
5#include "eldbus_fake_server.h" 5#include <stdbool.h>
6#include "eldbus_suite.h"
7#include "eldbus_test_eldbus_model.h"
8 6
9#include <Ecore.h>
10#include <Eina.h> 7#include <Eina.h>
8#include <Ecore.h>
11#include <Eldbus_Model.h> 9#include <Eldbus_Model.h>
12 10
13#include <stdbool.h> 11#include "eldbus_fake_server.h"
12#include "eldbus_test_eldbus_model.h"
13#include "eldbus_suite.h"
14 14
15static Eo *fake_server_object = NULL; 15static Eo *fake_server_object = NULL;
16static Eo *fake_server_proxy = NULL; 16static Eo *fake_server_proxy = NULL;
@@ -92,7 +92,7 @@ START_TEST(property_get)
92 Efl_Model_Load_Status status; 92 Efl_Model_Load_Status status;
93 eo_do(fake_server_proxy, status = efl_model_property_get(FAKE_SERVER_WRITEONLY_PROPERTY, &dummy)); 93 eo_do(fake_server_proxy, status = efl_model_property_get(FAKE_SERVER_WRITEONLY_PROPERTY, &dummy));
94 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status); 94 ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
95 95
96 _teardown(); 96 _teardown();
97} 97}
98END_TEST 98END_TEST