diff --git a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp index 6f0c56d6b7..60c5387a9d 100644 --- a/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp +++ b/interfaces/kits/napi/window_runtime/window_napi/js_window.cpp @@ -837,7 +837,7 @@ napi_value JsWindow::SetWindowDecorVisible(napi_env env, napi_callback_info info napi_value JsWindow::SetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) { - TLOGI(WmsLogTag::WMS_LAYOUT, "[NAPI]"); + TLOGD(WmsLogTag::WMS_LAYOUT, "[NAPI]"); JsWindow* me = CheckParamsAndGetThis(env, info); return (me != nullptr) ? me->OnSetWindowTitleMoveEnabled(env, info) : nullptr; } @@ -6161,29 +6161,22 @@ napi_value JsWindow::OnSetWindowDecorVisible(napi_env env, napi_callback_info in napi_value JsWindow::OnSetWindowTitleMoveEnabled(napi_env env, napi_callback_info info) { - size_t argc = 4; - napi_value argv[4] = {nullptr}; + size_t argc = FOUR_PARAMS_SIZE; + napi_value argv[FOUR_PARAMS_SIZE] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc != 1) { TLOGE(WmsLogTag::WMS_LAYOUT, "Argc is invalid: %{public}zu", argc); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } - if (windowToken_ == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "WindowToken_ is nullptr"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); - } - napi_value nativeVal = argv[0]; - if (nativeVal == nullptr) { - TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to visible"); - return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); - } bool enable = true; - WmErrorCode errCode = WmErrorCode::WM_OK; - CHECK_NAPI_RETCODE(errCode, WmErrorCode::WM_ERROR_INVALID_PARAM, - napi_get_value_bool(env, nativeVal, &enable)); - if (errCode == WmErrorCode::WM_ERROR_INVALID_PARAM) { + if (!ConvertFromJsValue(env, argv[INDEX_ZERO], enable)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to convert parameter to enable"); return NapiThrowError(env, WmErrorCode::WM_ERROR_INVALID_PARAM); } + if (windowToken_ == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "windowToken is nullptr"); + return NapiThrowError(env, WmErrorCode::WM_ERROR_STATE_ABNORMALLY); + } WmErrorCode ret = WM_JS_TO_ERROR_CODE_MAP.at(windowToken_->SetWindowTitleMoveEnabled(enable)); if (ret != WmErrorCode::WM_OK) { TLOGE(WmsLogTag::WMS_LAYOUT, "Window set title move enable failed"); diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index ab55b07e79..8abc2af41b 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -1928,7 +1928,7 @@ WMError WindowSessionImpl::SetWindowTitleMoveEnabled(bool enable) return WMError::WM_ERROR_NULLPTR; } uiContent->EnableContainerModalGesture(enable); - TLOGI(WmsLogTag::WMS_LAYOUT, "end"); + TLOGI(WmsLogTag::WMS_LAYOUT, "enable:%{public}d end", enable); return WMError::WM_OK; } diff --git a/wm/test/unittest/window_session_impl_test4.cpp b/wm/test/unittest/window_session_impl_test4.cpp index f15318836d..051b74eb52 100644 --- a/wm/test/unittest/window_session_impl_test4.cpp +++ b/wm/test/unittest/window_session_impl_test4.cpp @@ -274,7 +274,6 @@ HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest ASSERT_NE(window, nullptr); WMError res = window->SetWindowTitleMoveEnabled(true); EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW); - ASSERT_NE(window->property_, nullptr); window->property_->SetPersistentId(1); SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"}; sptr session = sptr::MakeSptr(sessionInfo); @@ -284,10 +283,10 @@ HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest res = window->SetWindowTitleMoveEnabled(true); EXPECT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT); window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW; - window_->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION); res = window->SetWindowTitleMoveEnabled(true); EXPECT_EQ(res, WMError::WM_ERROR_INVALID_CALLING); - window_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); + window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW); res = window->SetWindowTitleMoveEnabled(true); EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR); window->uiContent_ = std::make_unique();