From: Olaf Wintermann Date: Tue, 13 Jan 2026 19:34:35 +0000 (+0100) Subject: add test_note_store_new_notebook_async X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fmain;p=note.git add test_note_store_new_notebook_async --- diff --git a/application/tests/test-store.c b/application/tests/test-store.c index ad931e2..e5fe6dc 100644 --- a/application/tests/test-store.c +++ b/application/tests/test-store.c @@ -179,3 +179,46 @@ CX_TEST(test_note_store_new_resource_async) { ui_close(obj); } } + +static void test_new_notebook_result(UiEvent *event, int64_t newid, int error, void *userdata) { + int64_t *ptr = userdata; + ptr[0] = newid; + ptr[1] = error; +} + +CX_TEST(test_note_store_new_notebook_async) { + CX_TEST_DO { + UiObject *obj = ui_dummy_object(); + + NoteStore *store = note_store_get(); + CX_TEST_ASSERT(store); + + Resource res0 = { 0 }; + res0.nodename = "note_store_new_notebook_async"; + res0.parent_id = store->root->resource_id; + res0.iscollection = TRUE; + + int64_t result[2] = { 0, -1 }; + note_store_new_notebook_async(obj, &res0, test_new_notebook_result, result); + ui_exec_buffered_mainthread_calls_wait(3); + + CX_TEST_ASSERT(result[0] > 0); + CX_TEST_ASSERT(result[1] == 0); + + CX_TEST_ASSERT(!note_store_reload()); + store = note_store_get(); + + CX_TEST_ASSERT(store && store->root && store->root->children); + int res_found = 0; + CxIterator i = cxListIterator(store->root->children); + cx_foreach(Resource *, resource, i) { + if(!cx_strcmp(resource->nodename, res0.nodename)) { + res_found = 1; + break; + } + } + CX_TEST_ASSERT(res_found); + + ui_close(obj); + } +} diff --git a/application/tests/test-store.h b/application/tests/test-store.h index f4c1b31..341e349 100644 --- a/application/tests/test-store.h +++ b/application/tests/test-store.h @@ -41,6 +41,7 @@ CX_TEST(test_user_settings_is_valid); CX_TEST(test_note_store_reload); CX_TEST(test_note_store_new_resource_async); +CX_TEST(test_note_store_new_notebook_async); #ifdef __cplusplus diff --git a/application/tests/testmain.c b/application/tests/testmain.c index 79a4207..278e024 100644 --- a/application/tests/testmain.c +++ b/application/tests/testmain.c @@ -58,6 +58,7 @@ int main(int argc, char **argv) { cx_test_register(suite, test_user_settings_is_valid); cx_test_register(suite, test_note_store_reload); cx_test_register(suite, test_note_store_new_resource_async); + cx_test_register(suite, test_note_store_new_notebook_async); cx_test_register(suite, test_parse_markdown_para); cx_test_register(suite, test_parse_markdown_formatting_simple);