mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-27 09:00:55 +00:00
参数校验修改
Signed-off-by: tanchenghao <tanchenghao@h-partners.com>
This commit is contained in:
parent
f31da24f03
commit
974cba5b00
@ -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<JsWindow>(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");
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<SessionMocker> session = sptr<SessionMocker>::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<Ace::UIContentMocker>();
|
||||
|
Loading…
Reference in New Issue
Block a user