From a6f00f1f2ce904f355a2dfab4a6c3607ddea8a92 Mon Sep 17 00:00:00 2001 From: hekun Date: Thu, 17 Nov 2022 20:24:59 +0800 Subject: [PATCH] test case Signed-off-by: hekun --- .../entry/src/main/cpp/napi/napi_test.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp b/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp index e8ba3311e..6d571668f 100644 --- a/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp +++ b/arkui/ace_napi_test/entry/src/main/cpp/napi/napi_test.cpp @@ -1396,8 +1396,9 @@ static napi_value napiDefineClass(napi_env env, napi_callback_info info) static napi_value napiRunScriptPath(napi_env env, napi_callback_info info) { napi_value value; - const char* path = "test/path"; - napi_status status = napi_run_script_path(env, &path, &value); + //char const* path = "/index/name"; + const char* path = "22"; + napi_status status = napi_run_script_path(env, path, &value); NAPI_ASSERT(env, status == napi_ok, "napi_run_script_path ok"); napi_value _value; @@ -1439,16 +1440,16 @@ static napi_value napiCallThreadsafeFunction(napi_env env, napi_callback_info in return value; } -static void TsFuncFinalTotalFour(napi_env env) +static void TsFuncFinalTotalFour(napi_env env, void* finalizeData, void* hint) { static uv_thread_t guvThreadTest7; uv_thread_join(&guvThreadTest7); } -static void TsFuncCallJsFour(napi_env env, napi_value tsfn_cb) +static void TsFuncCallJsFour(napi_env env, napi_value tsfn_cb, void* context, void* data) { - napi_value value; - NAPI_CALL(env, napi_create_int32(env, 0, &value)); + int* pData = (int*)data; + printf("TsFuncCallJsFour is %p \n", pData); } static napi_value napiCreateThreadsafeFunction(napi_env env, napi_callback_info info) @@ -1459,7 +1460,7 @@ static napi_value napiCreateThreadsafeFunction(napi_env env, napi_callback_info int32_t callJstCbDataTestId = 101; int32_t finalCbtDataTestID = 1001; napi_status status = napi_create_threadsafe_function(env, nullptr, nullptr, resourceName, - 0, 1, &callJstCbDataTestId, TsFuncFinalTotalFour, + 0, 1, &callJstCbDataTestId, TsFuncFinalTotalFour, &finalCbtDataTestID, TsFuncCallJsFour, &tsFunc); NAPI_ASSERT(env, status == napi_ok, "napi_create_threadsafe_function"); @@ -1516,9 +1517,8 @@ static napi_value napiRefthreadSafeFunction(napi_env env, napi_callback_info inf napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName); int32_t callJsCbDataTestId = 101; int32_t finalCbDataTestId = 1001; - napi_status status = napi_create_threadsafe_function(env, nullptr, nullptr, resourceName, - 0, 1, &callJsCbDataTestId, TsFuncFinalTotalFour, - &finalCbDataTestId, TsFuncCallJsFour, &tsFunc); + napi_status status = napi_create_threadsafe_function(env, nullptr, nullptr, resourceName, + 0, 1, &callJsCbDataTestId, TsFuncFinalTotalFour, &finalCbDataTestId, TsFuncCallJsFour, &tsFunc); NAPI_ASSERT(env, status == napi_ok, "napi_create_threadsafe_function"); status = napi_ref_threadsafe_function(env, tsFunc); -- GitLab