summaryrefslogtreecommitdiff
path: root/src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2018-02-12 11:06:48 -0800
committerCedric BAIL <cedric@osg.samsung.com>2018-05-01 10:39:01 -0700
commit702bcd7de9049776ebf97492775ffe6e35c7caf4 (patch)
tree95474d7100b32b4f7bda76e2881e241576e28b81 /src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c
parent37374c8da6443a4ad2f35215799a91a2091d9726 (diff)
eldbus: migrate tests to use new Efl.Model API.
Diffstat (limited to '')
-rw-r--r--src/tests/eldbus/eldbus_test_fake_server_eldbus_model_proxy.c61
1 files changed, 46 insertions, 15 deletions
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 47259d4038..c4bdba2bd0 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
@@ -31,7 +31,10 @@ _setup(void)
31 }; 31 };
32 fake_server = fake_server_start(&fake_server_data); 32 fake_server = fake_server_start(&fake_server_data);
33 33
34 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_object_custom_constructor(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE, FAKE_SERVER_BUS, FAKE_SERVER_PATH)); 34 fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(),
35 eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE),
36 eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS),
37 eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH));
35 ck_assert_ptr_ne(NULL, fake_server_object); 38 ck_assert_ptr_ne(NULL, fake_server_object);
36 39
37 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); 40 fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE);
@@ -50,7 +53,8 @@ EFL_START_TEST(properties_get)
50 const Eina_Array *properties = efl_model_properties_get(fake_server_proxy); 53 const Eina_Array *properties = efl_model_properties_get(fake_server_proxy);
51 ck_assert_ptr_ne(NULL, properties); 54 ck_assert_ptr_ne(NULL, properties);
52 55
53 const unsigned int expected_properties_count = 3; // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties 56 // FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_WRITEONLY_PROPERTY and FAKE_SERVER_READWRITE_PROPERTY properties
57 const unsigned int expected_properties_count = 3;
54 const unsigned int actual_properties_count = eina_array_count(properties); 58 const unsigned int actual_properties_count = eina_array_count(properties);
55 ck_assert_int_eq(expected_properties_count, actual_properties_count); 59 ck_assert_int_eq(expected_properties_count, actual_properties_count);
56 60
@@ -58,15 +62,43 @@ EFL_START_TEST(properties_get)
58} 62}
59EFL_END_TEST 63EFL_END_TEST
60 64
65static Eina_Future *f = NULL;
66
67static Eina_Value
68_leave(void *data EINA_UNUSED, const Eina_Value v,
69 const Eina_Future *dead EINA_UNUSED)
70{
71 ecore_main_loop_quit();
72 f = NULL;
73 return v;
74}
75
76static void
77_property_ready(void *data EINA_UNUSED, const Efl_Event *ev)
78{
79 if (f) return ;
80 f = efl_loop_job(efl_provider_find(ev->object, EFL_LOOP_CLASS));
81 eina_future_then(f, _leave, NULL);
82}
83
61EFL_START_TEST(property_get) 84EFL_START_TEST(property_get)
62{ 85{
86 Eina_Value *value;
87
88 efl_event_callback_add(fake_server_proxy, EFL_MODEL_EVENT_PROPERTIES_CHANGED, _property_ready, NULL);
89 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY);
90 eina_value_free(value);
91 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY);
92 eina_value_free(value);
93
94 ecore_main_loop_begin();
95
63 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE); 96 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, FAKE_SERVER_READONLY_PROPERTY_VALUE);
64 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE); 97 check_efl_model_property_int_eq(fake_server_proxy, FAKE_SERVER_READWRITE_PROPERTY, FAKE_SERVER_READWRITE_PROPERTY_VALUE);
65 98
66 // Write-only property returns error 99 // Write-only property returns error
67 Efl_Future *future; 100 value = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY);
68 future = efl_model_property_get(fake_server_proxy, FAKE_SERVER_WRITEONLY_PROPERTY); 101 eina_value_free(value);
69 (void)future;
70 //ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status); 102 //ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status);
71 103
72 _teardown(); 104 _teardown();
@@ -89,12 +121,13 @@ _check_property_set(const char *property_name, int expected_property_value, int
89 121
90EFL_START_TEST(property_set) 122EFL_START_TEST(property_set)
91{ 123{
124 Eina_Future *future;
125 Eina_Value dummy = EINA_VALUE_EMPTY;
126
92 _check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property); 127 _check_property_set(FAKE_SERVER_WRITEONLY_PROPERTY, 0x12345678, &fake_server_data.writeonly_property);
93 _check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property); 128 _check_property_set(FAKE_SERVER_READWRITE_PROPERTY, 0x76543210, &fake_server_data.readwrite_property);
94 129
95 // Read-only property returns error 130 // Read-only property returns error
96 Efl_Future *future;
97 Eina_Value dummy = {0};
98 future = efl_model_property_set(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, &dummy); 131 future = efl_model_property_set(fake_server_proxy, FAKE_SERVER_READONLY_PROPERTY, &dummy);
99 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY); 132 check_efl_model_future_error(future, &EFL_MODEL_ERROR_READ_ONLY);
100 133
@@ -155,20 +188,18 @@ EFL_END_TEST
155EFL_START_TEST(child_del) 188EFL_START_TEST(child_del)
156{ 189{
157 // Tests that it is not possible to delete children 190 // Tests that it is not possible to delete children
158 Efl_Future *future; 191 Eo *child;
159 unsigned int expected_children_count = 0; 192 unsigned int expected_children_count = 0;
160 future = efl_model_children_count_get(fake_server_proxy); 193 unsigned int actual_children_count = 0;
161 expected_children_count = efl_model_future_then_u(future); 194
195 expected_children_count = efl_model_children_count_get(fake_server_proxy);
162 ck_assert_msg(expected_children_count, "There must be at least 1 child to test"); 196 ck_assert_msg(expected_children_count, "There must be at least 1 child to test");
163 197
164 // efl_model_child_del always returns ERROR 198 // efl_model_child_del always returns ERROR
165 Eo *child = efl_model_first_child_get(fake_server_proxy); 199 child = efl_model_first_child_get(fake_server_proxy);
166 efl_model_child_del(fake_server_proxy, child); 200 efl_model_child_del(fake_server_proxy, child);
167 201
168 unsigned int actual_children_count = 0; 202 actual_children_count = efl_model_children_count_get(fake_server_proxy);
169 future = efl_model_children_count_get(fake_server_proxy);
170 actual_children_count = efl_model_future_then_u(future);
171
172 ck_assert_int_le(expected_children_count, actual_children_count); 203 ck_assert_int_le(expected_children_count, actual_children_count);
173 204
174 _teardown(); 205 _teardown();