return TCORE_HOOK_RETURN_CONTINUE;
}
+static TReturn __on_test_comm_send_response(Communicator *comm, UserRequest *ur,
+ enum tcore_response_command command, unsigned int data_len, const void *data)
+{
+ std::cout <<" __on_test_comm_send_response()" << std::endl;
+ return TCORE_RETURN_SUCCESS;
+}
+
+static TReturn __on_test_comm_send_notification(Communicator *comm, CoreObject *source,
+ enum tcore_notification_command command, unsigned int data_len, const void *data)
+{
+ std::cout <<" __on_test_comm_send_notification()" << std::endl;
+ return TCORE_RETURN_SUCCESS;
+}
+
+/*
+ * communicator operations
+ */
+struct tcore_communicator_operations test_communicator_ops = {
+ .send_response = __on_test_comm_send_response,
+ .send_notification = __on_test_comm_send_notification,
+};
+
TEST(LIBTCORE_SERVER, test_server)
{
Server *s;
ret = tcore_server_add_plugin(s, p);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
EXPECT_TRUE(tcore_server_ref_plugins(s));
+ EXPECT_EQ(tcore_plugin_ref_server(p), s);
TcorePlugin *ref_plugin = tcore_server_search_plugin_list(s, "TEST_PLUGIN");
EXPECT_EQ(ref_plugin, p);
EXPECT_TRUE(tcore_server_ref_manager(s));
/* add communicator */
- c = tcore_communicator_new(p, "test_communicator", NULL);
+ c = tcore_communicator_new(p, "test_communicator", &test_communicator_ops);
ASSERT_TRUE(c);
+
+ EXPECT_EQ(tcore_communicator_ref_plugin(c), p);
+ std::cout << " [communicator] name: " << tcore_communicator_ref_name(c) << std::endl;
+
+ char comm_data[] = "comm_data";
+ ret = tcore_communicator_link_user_data(c, comm_data);
+ EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
+ std::cout << " [communicator] user_data: " << (char *)tcore_communicator_ref_user_data(c)<< std::endl;
+
ret = tcore_server_add_communicator(s, c);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
EXPECT_TRUE(tcore_server_ref_communicators(s));
EXPECT_EQ(tcore_server_find_communicator(s, "test_communicator"), c);
+ ret = tcore_communicator_send_response(c, NULL, TRESP_CUSTOM, 0, NULL);
+ EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
+
+ ret = tcore_communicator_send_notification(c, NULL, TNOTI_CUSTOM, 0, NULL);
+ EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
+
+ UserRequest *ur_comm;
+
+ ur_comm = tcore_user_request_new(c, "test_modem_plugin");
+ ASSERT_TRUE(ur_comm);
+
+ ret = tcore_user_request_set_command(ur_comm, TREQ_CUSTOM);
+ EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
+
+ tcore_communicator_dispatch_request(c, ur_comm);
+
ret = tcore_server_remove_communicator(s, c);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
tcore_communicator_free(c);
/* Get modem count */
gint modem_count = tcore_server_get_modems_count(s);
- std::cout << std::endl << " [server] modem count: " << modem_count << std::endl;
+ std::cout << " [server] modem count: " << modem_count << std::endl;
EXPECT_TRUE(tcore_server_get_cp_name_list(s));
tcore_server_print_modems(s);
/* dispatch user request */
UserRequest * ur;
- ur = tcore_user_request_new(NULL, NULL);
+ ur = tcore_user_request_new(NULL, "test_modem_plugin");
ASSERT_TRUE(ur);
ret = tcore_user_request_set_command(ur, TREQ_CUSTOM);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS) << "tcore_object_set_free_hook() is failed" << std::endl;
EXPECT_EQ(tcore_object_ref_subscription_type(co) , TELEPHONY_SUBSCRIPTION_TYPE_DEFAULT) << "subscription type is not matched" << std::endl;
+ EXPECT_TRUE(tcore_object_ref_plugin(co));
- tcore_object_ref_plugin(co);
+ EXPECT_EQ(tcore_plugin_ref_core_object(test_plugin, CORE_OBJECT_TYPE_DEFAULT), co);
+ EXPECT_TRUE(tcore_plugin_get_core_objects(test_plugin));
+ EXPECT_TRUE(tcore_plugin_get_core_objects_bytype(test_plugin, CORE_OBJECT_TYPE_DEFAULT));
char po[] = "test_object";
char *ref_po = NULL;
ret = tcore_object_link_object(co, po);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS) << "tcore_object_link_object() is failed" << std::endl;
ref_po = (char *)tcore_object_ref_object(co);
- std::cout << std::endl << " ref_object: " << ref_po << std::endl;
+ std::cout << " ref_object: " << ref_po << std::endl;
EXPECT_EQ(strcmp(po, ref_po), 0) << "object is not matched" << std::endl;
ret = tcore_object_set_hal(co, NULL);
ret = tcore_object_link_user_data(co, userdata);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS) << "tcore_object_link_user_data() is failed" << std::endl;
ref_userdata = (char *)tcore_object_ref_user_data(co);
- std::cout << std::endl << " ref_userdata: " << ref_userdata<< std::endl;
+ std::cout << " ref_userdata: " << ref_userdata<< std::endl;
EXPECT_EQ(strcmp(userdata, ref_userdata), 0) << "userdata is not matched" << std::endl;
ret = tcore_object_set_name(co, "test2");
EXPECT_EQ(TCORE_RETURN_SUCCESS, ret) << "tcore_object_set_name() is failed" << std::endl;
- std::cout << std::endl << " Name: " << tcore_object_ref_name(co) << std::endl;
+ std::cout << " Name: " << tcore_object_ref_name(co) << std::endl;
EXPECT_EQ(strcmp(tcore_object_ref_name(co), "test2"), 0) << "object name is not matched" << std::endl;
tcore_object_set_type(co, CORE_OBJECT_TYPE_CUSTOM);
TcoreATRequest *getReq = tcore_at_get_request(at);
if (getReq && getReq->cmd)
- std::cout << std::endl << " ATRequest->cmd : " << getReq->cmd << std::endl;
+ std::cout << " ATRequest->cmd : " << getReq->cmd << std::endl;
else
- std::cout << std::endl << " ATRequest is none" << std::endl;
+ std::cout << " ATRequest is none" << std::endl;
msg = (char *)"+CMGR: 1,,105\r\n12345678901234567890\r\nOK\r\n";
bSuccess = tcore_at_process(at, strlen(msg), msg);
TcoreATResponse *getResp = tcore_at_get_response(at);
if (getResp && getResp->final_response)
- std::cout << std::endl << " ATResponse->final_response : " << getResp->final_response<< std::endl;
+ std::cout << " ATResponse->final_response : " << getResp->final_response<< std::endl;
else
- std::cout << std::endl << " ATResponse is none" << std::endl;
+ std::cout << " ATResponse is none" << std::endl;
tcore_at_free(at);
}
*checked = 1;
- std::cout << std::endl;
std::cout <<" data = " << (char *)lines->data << std::endl;
return TRUE;
*checked = 2;
- std::cout << std::endl;
std::cout <<" data1 = " << (char *)lines->data << std::endl;
std::cout <<" data2 = " << (char *)lines->next->data << std::endl;
static gboolean __on_atcmd_test(TcoreAT *at, const GSList *lines, void *user_data)
{
- std::cout << std::endl;
std::cout <<" __on_atcmd_test() data = " << (char *)lines->data << std::endl;
return TRUE;
static enum tcore_hook_return __on_send_hook(TcoreHal *hal, guint data_len, void *data, void *user_data)
{
- std::cout << std::endl << " __on__send_hook()" << std::endl;
+ std::cout << " __on__send_hook()" << std::endl;
return TCORE_HOOK_RETURN_CONTINUE;
}
{
g_assert(data_len == 3);
g_assert_cmpstr((char *)data, ==, "123");
- std::cout << std::endl << " hal_recv_callback()" << std::endl;
+ std::cout << " hal_recv_callback()" << std::endl;
g_flag++;
}
char *hal_name = tcore_hal_get_name(h);
if(hal_name) {
- std::cout << std::endl << " HAL name : " << hal_name << std::endl;
+ std::cout << " HAL name : " << hal_name << std::endl;
free(hal_name);
hal_name = NULL;
}
hal_name = tcore_hal_ref_name(h);
if(hal_name)
- std::cout << std::endl << " HAL name : " << hal_name << std::endl;
+ std::cout << " HAL name : " << hal_name << std::endl;
TcoreAT *hal_at = tcore_hal_get_at(h);
int hal_mode = tcore_hal_get_mode(h);
EXPECT_EQ(hal_mode, TCORE_HAL_MODE_AT);
- std::cout << std::endl << " HAL mode : TCORE_HAL_MODE_AT" << std::endl;
+ std::cout << " HAL mode : TCORE_HAL_MODE_AT" << std::endl;
ret = tcore_hal_set_mode(h, TCORE_HAL_MODE_CUSTOM);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " HAL mode : TCORE_HAL_MODE_CUSTOM" << std::endl;
+ std::cout << " HAL mode : TCORE_HAL_MODE_CUSTOM" << std::endl;
hal_mode = tcore_hal_get_mode(h);
EXPECT_EQ(hal_mode, TCORE_HAL_MODE_CUSTOM);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS) << "tcore_hal_link_user_data() is failed" << std::endl;
ref_userdata = (char *)tcore_hal_ref_user_data(h);
- std::cout << std::endl << " ref_userdata: " << ref_userdata<< std::endl;
+ std::cout << " ref_userdata: " << ref_userdata<< std::endl;
EXPECT_EQ(strcmp(userdata, ref_userdata), 0) << "userdata is not matched" << std::endl;
ret = tcore_hal_set_power_state(h, TRUE);
gboolean power_state = tcore_hal_get_power_state(h);
EXPECT_EQ(power_state, TRUE);
- std::cout << std::endl << " HAL power state : " <<power_state << std::endl;
+ std::cout << " HAL power state : " <<power_state << std::endl;
tcore_hal_add_recv_callback(h, __on_recv_callback, NULL);
static TReturn __hal_power(TcoreHal *hal, gboolean enable)
{
- std::cout << std::endl << " __hal_power(): enable = " << enable << std::endl;
+ std::cout << " __hal_power(): enable = " << enable << std::endl;
return TCORE_RETURN_SUCCESS;
}
static TReturn __hal_send(TcoreHal *hal, unsigned int data_len, void *data)
{
- std::cout << std::endl << " __hal_send()" << std::endl;
+ std::cout << " __hal_send()" << std::endl;
return TCORE_RETURN_SUCCESS;
}
static TReturn __hal_setup_netif(CoreObject *co, TcoreHalSetupNetifCallback func, void *user_data,
guint cid, gboolean enable)
{
- std::cout << std::endl << " __hal_setup_netif()" << std::endl;
+ std::cout << " __hal_setup_netif()" << std::endl;
return TCORE_RETURN_SUCCESS;
}
static TReturn __hal_control_nvdata(TcoreHal *hal, int option)
{
- std::cout << std::endl << " __hal_control_nvdata() : option = " << option << std::endl;
+ std::cout << " __hal_control_nvdata() : option = " << option << std::endl;
return TCORE_RETURN_SUCCESS;
}
static TReturn __hal_reset(TcoreHal *hal, int option)
{
- std::cout << std::endl << " __hal_reset(): option = " << option << std::endl;
+ std::cout << " __hal_reset(): option = " << option << std::endl;
return TCORE_RETURN_SUCCESS;
}
/* get pending id */
unsigned int id = tcore_pending_get_id(pending1);
- std::cout << std::endl << " pending1 id = " << id << std::endl;
+ std::cout << " pending1 id = " << id << std::endl;
/* get pending send status */
gboolean send_status;
ret = tcore_pending_get_send_status(pending1, &send_status);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending1 send_status = " << send_status << std::endl;
+ std::cout << " pending1 send_status = " << send_status << std::endl;
/* second item */
pending2 = tcore_pending_new(NULL, 1);
tcore_pending_set_auto_free_status_after_sent(pending2, TRUE);
gboolean auto_free_status = tcore_pending_get_auto_free_status_after_sent(pending2);
- std::cout << std::endl << " pending2 audo_free_status = " << auto_free_status << std::endl;
+ std::cout << " pending2 audo_free_status = " << auto_free_status << std::endl;
EXPECT_EQ(auto_free_status, TRUE);
/* set pending data */
unsigned int data_len;
char *ref_data = (char *)tcore_pending_ref_request_data(pending2, &data_len);
EXPECT_EQ(strcmp(pending_data1, ref_data), 0);
- std::cout << std::endl << " pending2 data = " << ref_data << std::endl;
+ std::cout << " pending2 data = " << ref_data << std::endl;
/* set pending data */
char pending_data2[] = "pending_data2";
/* get pending data */
ref_data = (char *)tcore_pending_ref_request_data(pending2, &data_len);
EXPECT_EQ(strcmp(pending_data2, ref_data), 0);
- std::cout << std::endl << " pending2 data = " << ref_data << std::endl;
+ std::cout << " pending2 data = " << ref_data << std::endl;
/* third item */
pending3 = tcore_pending_new(NULL, 1);
unsigned int timeout = tcore_pending_get_timeout(pending3);
EXPECT_EQ(timeout, 5000);
- std::cout << std::endl << " pending3 timeout = " << timeout << std::endl;
+ std::cout << " pending3 timeout = " << timeout << std::endl;
/* send pending1 */
ret = tcore_hal_send_request(h, pending1);
TcoreHal *ref_hal = tcore_queue_ref_hal(q);
EXPECT_EQ(ref_hal, h);
- std::cout << std::endl << " q's reference hal is matched with h " << std::endl;
+ std::cout << " q's reference hal is matched with h " << std::endl;
/* first item */
pending1 = tcore_pending_new(NULL, 1);
ret = tcore_queue_push(q, pending1);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending1 is pushed into queue successufully " << std::endl;
+ std::cout << " pending1 is pushed into queue successufully " << std::endl;
/* second item */
pending2 = tcore_pending_new(NULL, 1);
ret = tcore_queue_push(q, pending2);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending2 is pushed into queue successufully " << std::endl;
+ std::cout << " pending2 is pushed into queue successufully " << std::endl;
/* third item, but push to second item position */
pending3 = tcore_pending_new(NULL, 1);
ret = tcore_queue_push(q, pending3);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending3 is pushed into queue successufully " << std::endl;
+ std::cout << " pending3 is pushed into queue successufully " << std::endl;
pending = tcore_queue_ref_next_pending(q);
EXPECT_EQ(pending, pending1);
- std::cout << std::endl << " tcore_queue_ref_next_pending is pending1" << std::endl;
+ std::cout << " tcore_queue_ref_next_pending is pending1" << std::endl;
TcorePending *head = tcore_queue_ref_head(q);
EXPECT_EQ(head, pending1);
- std::cout << std::endl << " head is pending1" << std::endl;
+ std::cout << " head is pending1" << std::endl;
TcorePending *tail = tcore_queue_ref_tail(q);
EXPECT_EQ(tail, pending2);
- std::cout << std::endl << " tail is pending2" << std::endl;
+ std::cout << " tail is pending2" << std::endl;
unsigned int q_len = tcore_queue_get_length(q);
- std::cout << std::endl << " queue length is " << q_len << std::endl;
+ std::cout << " queue length is " << q_len << std::endl;
unsigned int q_normal_len = tcore_queue_get_normal_length(q);
- std::cout << std::endl << " queue normal length is " << q_normal_len << std::endl;
+ std::cout << " queue normal length is " << q_normal_len << std::endl;
/* pop test (order by priority) */
pending = tcore_queue_pop_by_id(q, 1);
EXPECT_EQ(pending, pending1);
- std::cout << std::endl << " pending1 is poped from queue successufully " << std::endl;
+ std::cout << " pending1 is poped from queue successufully " << std::endl;
tcore_pending_free(pending);
pending = tcore_queue_pop_by_id(q, 1);
EXPECT_EQ(pending, pending3);
- std::cout << std::endl << " pending3 is poped from queue successufully " << std::endl;
+ std::cout << " pending3 is poped from queue successufully " << std::endl;
tcore_pending_free(pending);
pending = tcore_queue_pop_by_id(q, 1);
EXPECT_EQ(pending, pending2);
- std::cout << std::endl << " pending2 is poped from queue successufully " << std::endl;
+ std::cout << " pending2 is poped from queue successufully " << std::endl;
tcore_pending_free(pending);
/* 4th item push */
ret = tcore_queue_push(q, pending4);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending4 is pushed into queue successufully " << std::endl;
+ std::cout << " pending4 is pushed into queue successufully " << std::endl;
TcorePlugin *ref_plugin = tcore_pending_ref_plugin(pending4);
EXPECT_TRUE(!ref_plugin);
CoreObject *ref_co = tcore_pending_ref_core_object(pending4);
ret = tcore_queue_push(q, pending5);
EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
- std::cout << std::endl << " pending5 is pushed into queue successufully " << std::endl;
+ std::cout << " pending5 is pushed into queue successufully " << std::endl;
/* pop by pending */
pending = tcore_queue_pop_by_pending(q, pending4);
EXPECT_EQ(pending, pending4);
- std::cout << std::endl << " pending4 is poped from queue successufully " << std::endl;
+ std::cout << " pending4 is poped from queue successufully " << std::endl;
tcore_pending_free(pending);
/* pop head pending */
pending = tcore_queue_pop(q);
EXPECT_EQ(pending, pending5);
- std::cout << std::endl << " pending5 is poped from queue successufully " << std::endl;
+ std::cout << " pending5 is poped from queue successufully " << std::endl;
tcore_pending_free(pending);
tcore_queue_free(q);
/* get modem name of user request */
char *modem_name = tcore_user_request_get_modem_name(ur);
- std::cout << std::endl << " ur modem name = " << modem_name << std::endl;
+ std::cout << " ur modem name = " << modem_name << std::endl;
/* set userinfo of user request */
char user_info[] = "test_userinfo";
/* get userinfo */
char *ref_user_info = (char *)tcore_user_request_ref_user_info(ur);
- std::cout << std::endl << " ur user_info = " << ref_user_info << std::endl;
+ std::cout << " ur user_info = " << ref_user_info << std::endl;
/* set data of user request */
char data[] = "test_data";
/* get data */
unsigned int data_len;
char *ref_data = (char *)tcore_user_request_ref_data(ur, &data_len);
- std::cout << std::endl << " ur data_length = " << data_len << " data = " << ref_data << std::endl;
+ std::cout << " ur data_length = " << data_len << " data = " << ref_data << std::endl;
/* set metainfo of user request */
char metainfo[] = "test_metainfo";
/* get metainfo */
unsigned int metainfo_len;
char *ref_metainfo = (char *)tcore_user_request_ref_metainfo(ur, &metainfo_len);
- std::cout << std::endl << " ur metainfo_len = " << metainfo_len << " metainfo = " << ref_metainfo << std::endl;
+ std::cout<< " ur metainfo_len = " << metainfo_len << " metainfo = " << ref_metainfo << std::endl;
tcore_user_request_free(ur);
static void __on_pending_send_callback(TcorePending *pending, gboolean result, void *user_data)
{
- std::cout << std::endl << " __on_pending_send_callback() result =" << result << std::endl;
+ std::cout << " __on_pending_send_callback() result =" << result << std::endl;
}
int g_response_flag = 0;
static void __on_pending_response_callback(TcorePending *pending, int data_len, const void *data, void *user_data)
{
- std::cout << std::endl << " __on_pending_response_callback()" << std::endl;
+ std::cout << " __on_pending_response_callback()" << std::endl;
g_response_flag++;
if (data_len > 0 && data) {
static void __on_pending_timeout_callback(TcorePending *p, void *user_data)
{
- std::cout << std::endl << " __on_pending_timeout_callback()" << std::endl;
+ std::cout << " __on_pending_timeout_callback()" << std::endl;
}
static void __on_ur_free_hook(UserRequest *ur)
{
struct dbus_request_info *user_info;
- std::cout << std::endl << " _on_ur_free_hook()" << std::endl;
+ std::cout << " _on_ur_free_hook()" << std::endl;
user_info = (struct dbus_request_info *)tcore_user_request_ref_user_info(ur);
if (user_info)
static void __on_ur_response_hook(UserRequest *ur, enum tcore_response_command command,
unsigned int data_len, const void *data, void *user_data)
{
- std::cout << std::endl << " __on_ur_response_hook()" << std::endl;
+ std::cout << " __on_ur_response_hook()" << std::endl;
if (data_len > 0 && data) {
char *resp_data = (char *)data;
/* get command */
EXPECT_EQ(tcore_user_request_get_command(ur2), TREQ_NETWORK_SEARCH);
- std::cout << std::endl << " ur2 command = TREQ_NETWORK_SEARCH" << std::endl;
+ std::cout << " ur2 command = TREQ_NETWORK_SEARCH" << std::endl;
pending2 = tcore_pending_new(NULL, 1);
ASSERT_TRUE(pending2);
{
struct dbus_request_info *user_info;
- std::cout << std::endl << " __on_manager_request_handler()" << std::endl;
+ std::cout << " __on_manager_request_handler()" << std::endl;
user_info = (struct dbus_request_info *)tcore_user_request_ref_user_info(ur);
if (user_info)
enum tcore_notification_command command,
unsigned int data_len, void *data)
{
- std::cout << std::endl << " __on_manager_notification_handler()" << std::endl;
+ std::cout << " __on_manager_notification_handler()" << std::endl;
if (command == TNOTI_CUSTOM)
std::cout << " command = TNOTI_CUSTOM" << std::endl;
Manager *m;
TReturn ret;
- p = tcore_plugin_new(NULL, NULL, NULL, NULL);
+ p = tcore_plugin_new(NULL, &test_plugin_define_desc, "test_plugin", NULL);
ASSERT_TRUE(p);
+ EXPECT_TRUE(tcore_plugin_get_description(p));
+ std::cout << " tcore_plugin_get_filename() = " << tcore_plugin_get_filename(p) << std::endl;
+ std::cout << " tcore_plugin_ref_plugin_name() = " << tcore_plugin_ref_plugin_name(p) << std::endl;
+
+ char plugin_data[] = "plugin_data";
+ ret = tcore_plugin_link_user_data(p, plugin_data);
+ EXPECT_EQ(ret, TCORE_RETURN_SUCCESS);
+ std::cout << " tcore_plugin_ref_user_data() = " << (char *)tcore_plugin_ref_user_data(p) << std::endl;
+
+ int *smsp_record_len = NULL;
+ /* Storing smsp record length */
+ smsp_record_len = (int *)g_try_malloc0(sizeof(int));
+ ASSERT_TRUE(smsp_record_len);
+ *smsp_record_len = 100;
+ tcore_plugin_link_property(p, "SMSPRECORDLEN", smsp_record_len);
+ int *ref_property = (int *)tcore_plugin_ref_property(p, "SMSPRECORDLEN");
+ EXPECT_TRUE(ref_property);
+ std::cout << " SMSPRECORDLEN = " << *ref_property << std::endl;
+
m = tcore_manager_new(p);
ASSERT_TRUE(m);
tcore_plugin_free(p);
}
+static void *__create_handle(Storage *strg, const char *path)
+{
+ std::cout << " __create_handle()" << std::endl;
+
+ void *tmp = NULL;
+ if (!strg)
+ return NULL;
+
+ tmp = malloc(sizeof(char));
+ return tmp;
+}
+static gboolean __remove_handle(Storage *strg, void *handle)
+{
+ std::cout << " __remove_handle()" << std::endl;
+
+ if (!strg || !handle)
+ return FALSE;
+
+ free(handle);
+ return TRUE;
+}
+static gboolean __set_int(Storage *strg, enum tcore_storage_key key, int value)
+{
+ std::cout << " __set_int() :" << value << std::endl;
+ return TRUE;
+}
+static gboolean __set_bool(Storage *strg, enum tcore_storage_key key, gboolean value)
+{
+ std::cout << " __set_bool() : " << value << std::endl;
+ return TRUE;
+}
+static gboolean __set_string(Storage *strg, enum tcore_storage_key key, const char *value)
+{
+ std::cout << " __set_string() : " << value << std::endl;
+ return TRUE;
+}
+static int __get_int(Storage *strg, enum tcore_storage_key key)
+{
+ std::cout << " __get_int()" << std::endl;
+ return 0;
+}
+static gboolean __get_bool(Storage *strg, enum tcore_storage_key key)
+{
+ std::cout << " __get_bool()" << std::endl;
+ return TRUE;
+}
+static char * __get_string(Storage *strg, enum tcore_storage_key key)
+{
+ std::cout << " __get_string()" << std::endl;
+ return NULL;
+}
+static gboolean __set_key_callback(Storage *strg,
+ enum tcore_storage_key key, TcoreStorageDispatchCallback cb)
+{
+ std::cout << " __set_key_callback()" << std::endl;
+ return TRUE;
+}
+static gboolean __remove_key_callback(Storage *strg,
+ enum tcore_storage_key key)
+{
+ std::cout << " __remove_key_callback()" << std::endl;
+ return TRUE;
+}
+static gboolean __update_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+{
+ std::cout << " __update_query_database()" << std::endl;
+ return TRUE;
+}
+static gboolean __read_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param,
+ GHashTable **out_param, int out_param_cnt)
+{
+ std::cout << " __read_query_database()" << std::endl;
+ return TRUE;
+}
+static gboolean __read_query_database_in_order(Storage *strg, void *handle, const char *query, GHashTable *in_param,
+ GSList **out_param, int out_param_cnt)
+{
+ std::cout << " __read_query_database_in_order()" << std::endl;
+ return TRUE;
+}
+static gboolean __insert_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+{
+ std::cout << " __insert_query_database()" << std::endl;
+ return TRUE;
+}
+static gboolean __remove_query_database(Storage *strg, void *handle, const char *query, GHashTable *in_param)
+{
+ std::cout << " __remove_query_database()" << std::endl;
+ return TRUE;
+}
+
+static struct storage_operations test_strg_ops = {
+ .create_handle = __create_handle,
+ .remove_handle = __remove_handle,
+ .set_int = __set_int,
+ .set_string = __set_string,
+ .set_bool = __set_bool,
+ .get_int = __get_int,
+ .get_string = __get_string,
+ .get_bool = __get_bool,
+ .set_key_callback = __set_key_callback,
+ .remove_key_callback = __remove_key_callback,
+ .update_query_database = __update_query_database,
+ .read_query_database = __read_query_database,
+ .read_query_database_in_order = __read_query_database_in_order,
+ .insert_query_database = __insert_query_database,
+ .remove_query_database = __remove_query_database,
+};
+
+void __storage_key_callback(enum tcore_storage_key key, void *value, void *user_data)
+{
+ std::cout << " __storage_key_callback()" << std::endl;
+}
+
+TEST(LIBTCORE_STORAGE, test_storage)
+{
+ Storage *strg;
+ void *handle;
+
+ strg = tcore_storage_new(NULL, "test_storage", &test_strg_ops);
+ ASSERT_TRUE(strg);
+ std::cout << " storage name = " << tcore_storage_ref_name(strg) << std::endl;
+
+ handle = tcore_storage_create_handle(strg, "test_storage.db");
+ tcore_storage_set_key_callback(strg, STORAGE_KEY_TELEPHONY_INT, __storage_key_callback, NULL);
+
+ tcore_storage_set_int(strg, STORAGE_KEY_TELEPHONY_INT, 100);
+ tcore_storage_get_int(strg, STORAGE_KEY_TELEPHONY_INT);
+ tcore_storage_set_bool(strg, STORAGE_KEY_TELEPHONY_BOOL, 1);
+ tcore_storage_get_bool(strg, STORAGE_KEY_TELEPHONY_BOOL);
+ tcore_storage_set_string(strg, STORAGE_KEY_TELEPHONY_STRING, "test_strg_string");
+ tcore_storage_get_string(strg, STORAGE_KEY_TELEPHONY_STRING);
+
+ tcore_storage_update_query_database(strg, handle, "update", NULL);
+ tcore_storage_read_query_database(strg, handle, "read", NULL, NULL, 1);
+ tcore_storage_read_query_database_in_order(strg, handle, "read_in_order", NULL, NULL, 1);
+ tcore_storage_insert_query_database(strg, handle, "insert", NULL);
+ tcore_storage_remove_query_database(strg, handle, "remove", NULL);
+
+ tcore_storage_remove_key_callback(strg, STORAGE_KEY_TELEPHONY_INT, __storage_key_callback);
+ tcore_storage_remove_handle(strg, handle);
+ tcore_storage_free(strg);
+
+}
+
int main(int argc, char **argv)
{
int ret = -1;