summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-14 23:57:43 +0000
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-14 23:57:43 +0000
commit702d50a74d83459f910886ad6848509ad4cce625 (patch)
tree6b59aef669d378769dd9b0a01d4f3115942296c1
parent7874c8c2fe4b019046e2f2260e69eeb647e50654 (diff)
test_sqlite uses esql_query_callback_set() instead of ecore events as data is passed from esql_query()
-rw-r--r--src/tests/test_sqlite.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/src/tests/test_sqlite.c b/src/tests/test_sqlite.c
index 7bfbd9c..d438b00 100644
--- a/src/tests/test_sqlite.c
+++ b/src/tests/test_sqlite.c
@@ -27,7 +27,6 @@ struct ctx {
27 unsigned int errors; 27 unsigned int errors;
28 unsigned int res; 28 unsigned int res;
29}; 29};
30static Ecore_Event_Handler *evh = NULL;
31#define INSERTED_ROWS 10 30#define INSERTED_ROWS 10
32 31
33static void 32static void
@@ -37,11 +36,10 @@ _assert(Eina_Bool expr, const char* file, int line)
37} 36}
38#define assert(_expr) _assert(_expr, __FILE__, __LINE__); 37#define assert(_expr) _assert(_expr, __FILE__, __LINE__);
39 38
40static Eina_Bool 39static void
41on_query_results(void *data, int type __UNUSED__, void *event_info) 40on_query_results(Esql_Res *res, void *data)
42{ 41{
43 struct ctx *ctx = data; 42 struct ctx *ctx = data;
44 Esql_Res *res = event_info;
45 const Esql_Row *row; 43 const Esql_Row *row;
46 Eina_Iterator *itr; 44 Eina_Iterator *itr;
47 const char *cname; 45 const char *cname;
@@ -87,15 +85,12 @@ on_query_results(void *data, int type __UNUSED__, void *event_info)
87 eina_iterator_free(itr); 85 eina_iterator_free(itr);
88 86
89 ecore_main_loop_quit(); 87 ecore_main_loop_quit();
90
91 return EINA_TRUE;
92} 88}
93 89
94static Eina_Bool 90static void
95on_query_populate(void *data, int type __UNUSED__, void *event_info) 91on_query_populate(Esql_Res *res, void *data)
96{ 92{
97 struct ctx *ctx = data; 93 struct ctx *ctx = data;
98 Esql_Res *res = event_info;
99 94
100 assert(esql_res_rows_count(res) == 0); 95 assert(esql_res_rows_count(res) == 0);
101 assert(esql_res_cols_count(res) == 0); 96 assert(esql_res_cols_count(res) == 0);
@@ -107,13 +102,8 @@ on_query_populate(void *data, int type __UNUSED__, void *event_info)
107 Esql *e = esql_res_esql_get(res); 102 Esql *e = esql_res_esql_get(res);
108 Esql_Query_Id id = esql_query(e, ctx, "SELECT i, s FROM t"); 103 Esql_Query_Id id = esql_query(e, ctx, "SELECT i, s FROM t");
109 assert(id > 0); 104 assert(id > 0);
110 //esql_query_callback_set(id, on_query_results, ctx); 105 esql_query_callback_set(id, on_query_results);
111 ecore_event_handler_del(evh);
112 evh = ecore_event_handler_add(ESQL_EVENT_RESULT, on_query_results, ctx);
113 return EINA_FALSE;
114 } 106 }
115
116 return EINA_TRUE;
117} 107}
118 108
119static Eina_Bool 109static Eina_Bool
@@ -124,12 +114,9 @@ on_connect(void *data, int type __UNUSED__, void *event_info)
124 Esql_Query_Id id; 114 Esql_Query_Id id;
125 int i; 115 int i;
126 116
127 /* TODO: esql_query_callback_set() should get void* and use it instead! */
128 evh = ecore_event_handler_add(ESQL_EVENT_RESULT, on_query_populate, ctx);
129
130 id = esql_query(e, ctx, "CREATE TABLE t (i INTEGER, s VARCHAR(100))"); 117 id = esql_query(e, ctx, "CREATE TABLE t (i INTEGER, s VARCHAR(100))");
131 assert(id > 0); 118 assert(id > 0);
132 //esql_query_callback_set(id, on_query_populate, ctx); 119 esql_query_callback_set(id, on_query_populate);
133 120
134 for (i = 0; i < INSERTED_ROWS; i++) 121 for (i = 0; i < INSERTED_ROWS; i++)
135 { 122 {
@@ -138,12 +125,7 @@ on_connect(void *data, int type __UNUSED__, void *event_info)
138 id = esql_query_args(e, ctx, "INSERT INTO t (i, s) VALUES (%d, '%s')", 125 id = esql_query_args(e, ctx, "INSERT INTO t (i, s) VALUES (%d, '%s')",
139 i, buf); 126 i, buf);
140 assert(id > 0); 127 assert(id > 0);
141 //esql_query_callback_set(id, on_query_populate, ctx); 128 esql_query_callback_set(id, on_query_populate);
142 }
143
144 {
145 id = esql_query(e, ctx, "SELECT i, s FROM t");
146 assert(id > 0);
147 } 129 }
148 130
149 ctx->conns++; 131 ctx->conns++;