summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2016-02-04 14:55:35 +0100
committerTom Hacohen <tom@stosb.com>2016-02-16 12:41:06 +0000
commit7555493b909515fd2fa6c7f23ef7390578b32ac8 (patch)
tree53a474c6ab4dce19310b5f9c228c01a8b02709bc /src
parent21746ce8dcb87fe6fa0f2d133f551944a66c41d0 (diff)
Test rework #14: ElDbus_Cxx
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Eldbus_Cxx.am3
-rw-r--r--src/tests/eldbus_cxx/eldbus_cxx_suite.cc101
-rw-r--r--src/tests/eldbus_cxx/eldbus_cxx_suite.h12
-rw-r--r--src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc15
-rw-r--r--src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc10
5 files changed, 32 insertions, 109 deletions
diff --git a/src/Makefile_Eldbus_Cxx.am b/src/Makefile_Eldbus_Cxx.am
index d265b2c3f9..8f9b2cde64 100644
--- a/src/Makefile_Eldbus_Cxx.am
+++ b/src/Makefile_Eldbus_Cxx.am
@@ -48,7 +48,8 @@ TESTS += tests/eldbus_cxx/eldbus_cxx_suite
48tests_eldbus_cxx_eldbus_cxx_suite_SOURCES = \ 48tests_eldbus_cxx_eldbus_cxx_suite_SOURCES = \
49tests/eldbus_cxx/eldbus_cxx_suite.cc \ 49tests/eldbus_cxx/eldbus_cxx_suite.cc \
50tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc \ 50tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc \
51tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc 51tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc \
52tests/eldbus_cxx/eldbus_cxx_suite.h
52 53
53tests_eldbus_cxx_eldbus_cxx_suite_CPPFLAGS = \ 54tests_eldbus_cxx_eldbus_cxx_suite_CPPFLAGS = \
54-I$(top_builddir)/src/bindings/eina_cxx \ 55-I$(top_builddir)/src/bindings/eina_cxx \
diff --git a/src/tests/eldbus_cxx/eldbus_cxx_suite.cc b/src/tests/eldbus_cxx/eldbus_cxx_suite.cc
index c7b6b527d1..ca15b776c8 100644
--- a/src/tests/eldbus_cxx/eldbus_cxx_suite.cc
+++ b/src/tests/eldbus_cxx/eldbus_cxx_suite.cc
@@ -1,112 +1,27 @@
1
2#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
3# include <config.h> 2# include <config.h>
4#endif 3#endif
5 4
6#include <Eina.h> 5#include "eldbus_cxx_suite.h"
7#include "Eldbus.hh" 6#include "../efl_check.h"
8
9#include <cassert>
10#include <algorithm>
11
12#include <check.h>
13
14void eldbus_test_connection(TCase* tc);
15void eldbus_test_client(TCase* tc);
16
17typedef struct _Eldbus_Test_Case Eldbus_Test_Case;
18struct _Eldbus_Test_Case
19{
20 const char *test_case;
21 void (*build)(TCase *tc);
22};
23 7
24static const Eldbus_Test_Case etc[] = { 8static const Efl_Test_Case etc[] = {
25 { "connection", eldbus_test_connection }, 9 { "connection", eldbus_test_connection },
26 { "client", eldbus_test_client }, 10 { "client", eldbus_test_client },
27 { NULL, NULL } 11 { NULL, NULL }
28}; 12};
29 13
30static void
31_list_tests(void)
32{
33 const Eldbus_Test_Case *itr = etc;
34 fputs("Available Test Cases:\n", stderr);
35 for (; itr->test_case; itr++)
36 fprintf(stderr, "\t%s\n", itr->test_case);
37}
38
39static Eina_Bool
40_use_test(int argc, const char **argv, const char *test_case)
41{
42 if (argc < 1)
43 return 1;
44
45 for (; argc > 0; argc--, argv++)
46 if (strcmp(test_case, *argv) == 0)
47 return 1;
48
49 return 0;
50}
51
52Suite *
53eldbus_build_suite(int argc, const char **argv)
54{
55 TCase *tc;
56 Suite *s;
57 int i;
58
59 s = suite_create("Eldbus");
60
61 for (i = 0; etc[i].test_case; ++i)
62 {
63 if (!_use_test(argc, argv, etc[i].test_case))
64 continue;
65
66 tc = tcase_create(etc[i].test_case);
67#ifndef _WIN32
68 tcase_set_timeout(tc, 0);
69#endif
70
71 etc[i].build(tc);
72 suite_add_tcase(s, tc);
73 }
74
75 return s;
76}
77
78int main(int argc, char* argv[]) 14int main(int argc, char* argv[])
79{ 15{
80 Suite *s; 16 int failed_count;
81 SRunner *sr;
82 int i, failed_count;
83 17
84 for (i = 1; i < argc; i++) 18 if (!_efl_test_option_disp(argc, argv, etc))
85 if ((strcmp(argv[i], "-h") == 0) || 19 return 0;
86 (strcmp(argv[i], "--help") == 0))
87 {
88 fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
89 argv[0]);
90 _list_tests();
91 return 0;
92 }
93 else if ((strcmp(argv[i], "-l") == 0) ||
94 (strcmp(argv[i], "--list") == 0))
95 {
96 _list_tests();
97 return 0;
98 }
99 20
100 putenv(const_cast<char*>("EFL_RUN_IN_TREE=1")); 21 putenv(const_cast<char*>("EFL_RUN_IN_TREE=1"));
101 22
102 s = eldbus_build_suite(argc - 1, (const char **)argv + 1); 23 failed_count = _efl_suite_build_and_run(argc - 1, (const char **)argv + 1,
103 sr = srunner_create(s); 24 "Eldbus C++", etc);
104
105 srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");
106
107 srunner_run_all(sr, CK_ENV);
108 failed_count = srunner_ntests_failed(sr);
109 srunner_free(sr);
110 25
111 return (failed_count == 0) ? 0 : 255; 26 return (failed_count == 0) ? 0 : 255;
112} 27}
diff --git a/src/tests/eldbus_cxx/eldbus_cxx_suite.h b/src/tests/eldbus_cxx/eldbus_cxx_suite.h
new file mode 100644
index 0000000000..1dd4a6461a
--- /dev/null
+++ b/src/tests/eldbus_cxx/eldbus_cxx_suite.h
@@ -0,0 +1,12 @@
1#ifndef _ELDBUS_CXX_SUITE_H
2#define _ELDBUS_CXX_SUITE_H
3
4#include <cassert>
5#include <algorithm>
6
7#include <check.h>
8
9void eldbus_test_connection(TCase* tc);
10void eldbus_test_client(TCase* tc);
11
12#endif /* _ELDBUS_CXX_SUITE_H */
diff --git a/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc b/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc
index e54645bcfc..95eed8c8c4 100644
--- a/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc
+++ b/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_client.cc
@@ -1,18 +1,15 @@
1
2#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
3# include <config.h> 2# include <config.h>
4#endif 3#endif
5 4
6#include "Eldbus.hh"
7#include "Ecore.hh"
8
9#include <eldbus_freedesktop.hh>
10
11#include <algorithm> 5#include <algorithm>
12
13#include <iostream> 6#include <iostream>
14 7
15#include <check.h> 8#include <Ecore.hh>
9#include <Eldbus.hh>
10#include <eldbus_freedesktop.hh>
11
12#include "eldbus_cxx_suite.h"
16 13
17const char g_bus[] = "org.Enlightenment"; 14const char g_bus[] = "org.Enlightenment";
18const char g_path[] = "/org/enlightenment"; 15const char g_path[] = "/org/enlightenment";
@@ -396,7 +393,7 @@ START_TEST(eldbus_cxx_client)
396 ("SendStringAndBool" 393 ("SendStringAndBool"
397 , -1 394 , -1
398 , std::bind 395 , std::bind
399 ([expected_string, expected_bool] 396 ([expected_string, expected_bool]
400 (std::error_code const& ec, edb::const_message const& msg, std::string i, bool b) 397 (std::error_code const& ec, edb::const_message const& msg, std::string i, bool b)
401 { 398 {
402 if(!ec) 399 if(!ec)
diff --git a/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc b/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc
index ffac324b9a..7c4be04b6a 100644
--- a/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc
+++ b/src/tests/eldbus_cxx/eldbus_cxx_test_eldbus_connect.cc
@@ -1,16 +1,14 @@
1
2#ifdef HAVE_CONFIG_H 1#ifdef HAVE_CONFIG_H
3# include <config.h> 2# include <config.h>
4#endif 3#endif
5 4
6#include "Eldbus.hh"
7#include "Ecore.hh"
8
9#include <algorithm> 5#include <algorithm>
10
11#include <iostream> 6#include <iostream>
12 7
13#include <check.h> 8#include <Ecore.hh>
9#include <Eldbus.hh>
10
11#include "eldbus_cxx_suite.h"
14 12
15START_TEST(eldbus_cxx_session_connection) 13START_TEST(eldbus_cxx_session_connection)
16{ 14{