| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include "config.h" |
| 22 |
|
| 23 |
#include <libdex.h> |
| 24 |
|
| 25 |
static gboolean did_flush; |
| 26 |
|
| 27 |
static gboolean |
| 28 |
mark_flushed_cb (gpointer user_data) |
| 29 |
{ |
| 30 |
did_flush = TRUE; |
| 31 |
|
| 32 |
return G_SOURCE_REMOVE; |
| 33 |
} |
| 34 |
|
| 35 |
static gboolean |
| 36 |
resolve_cb (gpointer user_data) |
| 37 |
{ |
| 38 |
DexPromise *promise = user_data; |
| 39 |
|
| 40 |
dex_promise_resolve_boolean (promise, TRUE); |
| 41 |
dex_unref (promise); |
| 42 |
|
| 43 |
return G_SOURCE_REMOVE; |
| 44 |
} |
| 45 |
|
| 46 |
static void |
| 47 |
test_test_add_func (void) |
| 48 |
{ |
| 49 |
GError * error = NULL; |
| 50 |
DexPromise * promise = NULL; |
| 51 |
|
| 52 |
g_assert_true (DEX_IS_SCHEDULER (dex_scheduler_get_thread_default ())); |
| 53 |
|
| 54 |
promise = dex_promise_new (); |
| 55 |
g_idle_add (resolve_cb, dex_ref (promise)); |
| 56 |
|
| 57 |
g_assert_true (dex_await (dex_ref (promise), &error)); |
| 58 |
g_assert_no_error (error); |
| 59 |
|
| 60 |
g_idle_add (mark_flushed_cb, NULL); |
| 61 |
} |
| 62 |
|
| 63 |
static void |
| 64 |
test_test_add_func_flushed (void) |
| 65 |
{ |
| 66 |
g_assert_true (did_flush); |
| 67 |
} |
| 68 |
|
| 69 |
int |
| 70 |
main (int argc, |
| 71 |
char *argv[]) |
| 72 |
{ |
| 73 |
dex_init (); |
| 74 |
g_test_init (&argc, &argv, NULL); |
| 75 |
dex_test_add_func ("/Dex/TestSuite/Test/add_func", test_test_add_func); |
| 76 |
g_test_add_func ("/Dex/TestSuite/Test/add_func/flushed", test_test_add_func_flushed); |
| 77 |
return g_test_run (); |
| 78 |
} |