[unit] Test for gbinder_idle_callback_invoke_later(). JB#53719

This commit is contained in:
Slava Monich
2021-03-31 13:23:04 +03:00
parent b60960d955
commit a6a5df963f
2 changed files with 37 additions and 11 deletions

View File

@@ -1,4 +1,3 @@
#!/bin/bash #!/bin/bash
# #
# This script requires lcov, dirname # This script requires lcov, dirname
@@ -65,9 +64,13 @@ for t in $TESTS ; do
popd popd
done done
# Sometimes you need this, sometimes that :S
BASE_DIR="$TOP_DIR"
#BASE_DIR="$TOP_DIR/src"
FULL_COV="$COV_DIR/full.gcov" FULL_COV="$COV_DIR/full.gcov"
LIB_COV="$COV_DIR/lib.gcov" LIB_COV="$COV_DIR/lib.gcov"
rm -f "$FULL_COV" "$LIB_COV" rm -f "$FULL_COV" "$LIB_COV"
lcov $LCOV_OPT -c -d "$TOP_DIR/build/coverage" -b "$TOP_DIR/src" -o "$FULL_COV" || exit 1 lcov $LCOV_OPT -c -d "$TOP_DIR/build/coverage" -b "$BASE_DIR" -o "$FULL_COV" || exit 1
lcov $LCOV_OPT -e "$FULL_COV" "$TOP_DIR/src/*" -o "$LIB_COV" || exit 1 lcov $LCOV_OPT -e "$FULL_COV" "$BASE_DIR/*" -o "$LIB_COV" || exit 1
genhtml $GENHTML_OPT "$LIB_COV" -t "libgbinder" --output-directory "$COV_DIR/report" || exit 1 genhtml $GENHTML_OPT "$LIB_COV" -t "libgbinder" --output-directory "$COV_DIR/report" || exit 1

View File

@@ -48,6 +48,14 @@ test_unreached_proc(
return G_SOURCE_CONTINUE; return G_SOURCE_CONTINUE;
} }
static
void
test_quit_cb(
gpointer data)
{
g_main_loop_quit((GMainLoop*)data);
}
/*==========================================================================* /*==========================================================================*
* Test event loop integration * Test event loop integration
*==========================================================================*/ *==========================================================================*/
@@ -212,14 +220,6 @@ test_timeout(
* callback * callback
*==========================================================================*/ *==========================================================================*/
static
void
test_quit_cb(
gpointer data)
{
g_main_loop_quit((GMainLoop*)data);
}
static static
void void
test_callback( test_callback(
@@ -238,6 +238,28 @@ test_callback(
g_main_loop_unref(loop); g_main_loop_unref(loop);
} }
/*==========================================================================*
* invoke
*==========================================================================*/
static
void
test_invoke(
void)
{
GMainLoop* loop = g_main_loop_new(NULL, FALSE);
gbinder_eventloop_set(NULL);
gbinder_idle_callback_invoke_later(test_quit_cb, loop, NULL);
test_run(&test_opt, loop);
gbinder_eventloop_set(NULL);
gbinder_idle_callback_invoke_later(NULL, loop, test_quit_cb);
test_run(&test_opt, loop);
g_main_loop_unref(loop);
}
/*==========================================================================* /*==========================================================================*
* Common * Common
*==========================================================================*/ *==========================================================================*/
@@ -251,6 +273,7 @@ int main(int argc, char* argv[])
g_test_add_func(TEST_("idle"), test_idle); g_test_add_func(TEST_("idle"), test_idle);
g_test_add_func(TEST_("timeout"), test_timeout); g_test_add_func(TEST_("timeout"), test_timeout);
g_test_add_func(TEST_("callback"), test_callback); g_test_add_func(TEST_("callback"), test_callback);
g_test_add_func(TEST_("invoke"), test_invoke);
test_init(&test_opt, argc, argv); test_init(&test_opt, argc, argv);
return g_test_run(); return g_test_run();
} }