mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-03-07 11:44:41 +00:00
!35629 form_renderer_delegate_proxy文件添加TDD用例
Merge pull request !35629 from fumeng10/master
This commit is contained in:
commit
6f4634c3f4
82
test/mock/interfaces/mock_i_remote_object_form.h
Normal file
82
test/mock/interfaces/mock_i_remote_object_form.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_MOCK_I_REMOTE_OBJECT_FORM_H
|
||||
#define FOUNDATION_ACE_INTERFACE_INNERKITS_FORM_MOCK_I_REMOTE_OBJECT_FORM_H
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class MockFormIRemoteObject : public IRemoteObject {
|
||||
public:
|
||||
MockFormIRemoteObject() : IRemoteObject(u"mock_i_remote_object") {}
|
||||
|
||||
~MockFormIRemoteObject() {}
|
||||
|
||||
int32_t GetObjectRefCount() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
MOCK_METHOD(int, SendRequest, (uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option));
|
||||
|
||||
bool IsProxyObject() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CheckObjectLegality() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AddDeathRecipient(const sptr<DeathRecipient> &recipient) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RemoveDeathRecipient(const sptr<DeathRecipient> &recipient) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Marshalling(Parcel &parcel) const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<IRemoteBroker> AsInterface() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Dump(int fd, const std::vector<std::u16string> &args) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::u16string GetObjectDescriptor() const
|
||||
{
|
||||
std::u16string descriptor = std::u16string();
|
||||
return descriptor;
|
||||
}
|
||||
};
|
||||
} // namespace Notification
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -202,6 +202,80 @@ ohos_unittest("form_render_group_test") {
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("form_render_delegate_proxy_test") {
|
||||
module_out_path = interface_test_output_path
|
||||
include_dirs = [ "$ace_root/interfaces/inner_api/form_render/include" ]
|
||||
sources = [
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_delegate_impl.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_delegate_proxy.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_delegate_stub.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_dispatcher_impl.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_dispatcher_proxy.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_dispatcher_stub.cpp",
|
||||
"$ace_root/interfaces/inner_api/form_render/src/form_renderer_group.cpp",
|
||||
"$ace_root/test/mock/base/mock_ace_performance_check.cpp",
|
||||
"$ace_root/test/mock/base/mock_ace_performance_monitor.cpp",
|
||||
"$ace_root/test/mock/base/mock_engine_helper.cpp",
|
||||
"$ace_root/test/mock/base/mock_frame_trace_adapter.cpp",
|
||||
"$ace_root/test/mock/base/mock_ressched_report.cpp",
|
||||
"$ace_root/test/mock/base/mock_system_properties.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_ace_application_info.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_container.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_frame_report.cpp",
|
||||
"$ace_root/test/mock/core/common/mock_raw_recognizer.cpp",
|
||||
"$ace_root/test/mock/core/event/mock_touch_event.cpp",
|
||||
"$ace_root/test/mock/core/image_provider/mock_image_source_info.cpp",
|
||||
"$ace_root/test/mock/core/pipeline/mock_element_register.cpp",
|
||||
"$ace_root/test/mock/core/pipeline/mock_pipeline_context.cpp",
|
||||
"$ace_root/test/mock/core/render/mock_animation_utils.cpp",
|
||||
"$ace_root/test/mock/core/render/mock_modifier_adapter.cpp",
|
||||
"$ace_root/test/mock/core/render/mock_render_context_creator.cpp",
|
||||
"$ace_root/test/mock/interfaces/mock_uicontent_creator.cpp",
|
||||
"form_render_delegate_proxy_test.cpp",
|
||||
]
|
||||
|
||||
configs = [ "$ace_root/test/unittest:ace_unittest_config" ]
|
||||
|
||||
deps = [
|
||||
"$ace_root/test/unittest:ace_base",
|
||||
"$ace_root/test/unittest:ace_components_base",
|
||||
"$ace_root/test/unittest:ace_components_event",
|
||||
"$ace_root/test/unittest:ace_components_gestures",
|
||||
"$ace_root/test/unittest:ace_components_layout",
|
||||
"$ace_root/test/unittest:ace_components_manager",
|
||||
"$ace_root/test/unittest:ace_components_pattern",
|
||||
"$ace_root/test/unittest:ace_components_property",
|
||||
"$ace_root/test/unittest:ace_components_render",
|
||||
"$ace_root/test/unittest:ace_components_syntax",
|
||||
"$ace_root/test/unittest:ace_core_animation",
|
||||
"$ace_root/test/unittest:ace_core_extra",
|
||||
"$ace_root/test/unittest:ace_engine_unittest_flutter_deps",
|
||||
"$ace_root/test/unittest:ace_unittest_log",
|
||||
"$ace_root/test/unittest:ace_unittest_trace",
|
||||
"//third_party/googletest:gmock_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:runtime",
|
||||
"accessibility:accessibility_common",
|
||||
"ace_engine:ace_uicontent",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"form_fwk:form_manager",
|
||||
"graphic_2d:librender_service_client",
|
||||
"graphic_surface:surface",
|
||||
"hilog:libhilog",
|
||||
"input:libmmi-client",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("drawable_descriptor_test") {
|
||||
module_out_path = interface_test_output_path
|
||||
|
||||
@ -370,6 +444,7 @@ group("interfaces_unittest") {
|
||||
":ace_forward_compatibility_test",
|
||||
":drawable_descriptor_test",
|
||||
":extension_custom_node_test_ng",
|
||||
":form_render_delegate_proxy_test",
|
||||
":form_render_group_test",
|
||||
":form_render_test",
|
||||
":native_node_napi_test",
|
||||
|
261
test/unittest/interfaces/form_render_delegate_proxy_test.cpp
Normal file
261
test/unittest/interfaces/form_render_delegate_proxy_test.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "interfaces/inner_api/form_render/include/form_renderer.h"
|
||||
#include "interfaces/inner_api/form_render/include/form_renderer_delegate_impl.h"
|
||||
#include "interfaces/inner_api/form_render/include/form_renderer_delegate_proxy.h"
|
||||
#include "interfaces/inner_api/form_render/include/form_renderer_group.h"
|
||||
#include "test/mock/interfaces/mock_i_remote_object_form.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS::Ace {
|
||||
namespace {
|
||||
constexpr double FORM_WIDTH = 100.0f;
|
||||
constexpr double FORM_HEIGHT = 100.0f;
|
||||
constexpr double FORM_BORDER_WIDTH = 10.0f;
|
||||
} // namespace
|
||||
class FormRenderDelegateProxyTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase() {};
|
||||
|
||||
static void TearDownTestCase() {};
|
||||
};
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_001
|
||||
* @tc.desc: Test OnSurfaceCreate() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_001, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
OHOS::AAFwk::Want newWant;
|
||||
OHOS::AppExecFwk::FormJsInfo formJsInfo;
|
||||
formJsInfo.bundleName = "bundleName";
|
||||
formJsInfo.moduleName = "moduleName";
|
||||
formJsInfo.formId = 1;
|
||||
EXPECT_EQ(formJsInfo.formId, 1);
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceCreate(nullptr, formJsInfo, newWant), ERR_INVALID_VALUE);
|
||||
|
||||
std::string surfaceNodeName = "ArkTSCardNode";
|
||||
struct Rosen::RSSurfaceNodeConfig surfaceNodeConfig = { .SurfaceNodeName = surfaceNodeName };
|
||||
std::shared_ptr<Rosen::RSSurfaceNode> rsNode = OHOS::Rosen::RSSurfaceNode::Create(surfaceNodeConfig, true);
|
||||
ASSERT_NE(rsNode, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceCreate(rsNode, formJsInfo, newWant), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceCreate(rsNode, formJsInfo, newWant), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_002
|
||||
* @tc.desc: Test OnSurfaceReuse() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_002, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
OHOS::AAFwk::Want newWant;
|
||||
OHOS::AppExecFwk::FormJsInfo formJsInfo;
|
||||
formJsInfo.bundleName = "bundleName";
|
||||
formJsInfo.moduleName = "moduleName";
|
||||
formJsInfo.formId = 1;
|
||||
EXPECT_EQ(formJsInfo.formId, 1);
|
||||
|
||||
std::string surfaceNodeName = "ArkTSCardNode";
|
||||
struct Rosen::RSSurfaceNodeConfig surfaceNodeConfig = { .SurfaceNodeName = surfaceNodeName };
|
||||
std::shared_ptr<Rosen::RSSurfaceNode> rsNode = OHOS::Rosen::RSSurfaceNode::Create(surfaceNodeConfig, true);
|
||||
ASSERT_NE(rsNode, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceReuse(rsNode->GetId(), formJsInfo, newWant), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceReuse(rsNode->GetId(), formJsInfo, newWant), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_003
|
||||
* @tc.desc: Test OnSurfaceDetach() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_003, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
std::string surfaceNodeName = "ArkTSCardNode";
|
||||
struct Rosen::RSSurfaceNodeConfig surfaceNodeConfig = { .SurfaceNodeName = surfaceNodeName };
|
||||
std::shared_ptr<Rosen::RSSurfaceNode> rsNode = OHOS::Rosen::RSSurfaceNode::Create(surfaceNodeConfig, true);
|
||||
ASSERT_NE(rsNode, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceDetach(rsNode->GetId()), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceDetach(rsNode->GetId()), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_004
|
||||
* @tc.desc: Test OnSurfaceRelease() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_004, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
std::string surfaceNodeName = "ArkTSCardNode";
|
||||
struct Rosen::RSSurfaceNodeConfig surfaceNodeConfig = { .SurfaceNodeName = surfaceNodeName };
|
||||
std::shared_ptr<Rosen::RSSurfaceNode> rsNode = OHOS::Rosen::RSSurfaceNode::Create(surfaceNodeConfig, true);
|
||||
ASSERT_NE(rsNode, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceRelease(rsNode->GetId()), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceRelease(rsNode->GetId()), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_005
|
||||
* @tc.desc: Test OnActionEvent() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_005, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnActionEvent(""), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnActionEvent(""), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_006
|
||||
* @tc.desc: Test OnError() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_006, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnError("", ""), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnError("", ""), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_007
|
||||
* @tc.desc: Test OnSurfaceChange() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_007, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnSurfaceChange(FORM_WIDTH, FORM_HEIGHT, FORM_BORDER_WIDTH), ERR_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_008
|
||||
* @tc.desc: Test OnFormLinkInfoUpdate() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_008, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
std::vector<std::string> info = {};
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnFormLinkInfoUpdate(info), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnFormLinkInfoUpdate(info), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_009
|
||||
* @tc.desc: Test OnGetRectRelativeToWindow() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_009, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
int32_t top = 0;
|
||||
int32_t left = 0;
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnGetRectRelativeToWindow(top, left), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnGetRectRelativeToWindow(top, left), ERR_INVALID_VALUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* @tc.name: FormRenderDelegateProxyTest_010
|
||||
* @tc.desc: Test OnEnableForm() function.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FormRenderDelegateProxyTest, FormRenderDelegateProxyTest_010, TestSize.Level1)
|
||||
{
|
||||
sptr<AppExecFwk::MockFormIRemoteObject> iremoteObject = new (std::nothrow) AppExecFwk::MockFormIRemoteObject();
|
||||
sptr<FormRendererDelegateProxy> renderDelegate =
|
||||
new FormRendererDelegateProxy(static_cast<FormRendererDelegateProxy>(iremoteObject));
|
||||
ASSERT_NE(renderDelegate, nullptr);
|
||||
|
||||
OHOS::AppExecFwk::FormJsInfo formJsInfo;
|
||||
formJsInfo.bundleName = "bundleName";
|
||||
formJsInfo.moduleName = "moduleName";
|
||||
formJsInfo.formId = 1;
|
||||
EXPECT_EQ(formJsInfo.formId, 1);
|
||||
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_OK));
|
||||
EXPECT_EQ(renderDelegate->OnEnableForm(formJsInfo, true), ERR_OK);
|
||||
EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1).WillRepeatedly(Return(ERR_INVALID_VALUE));
|
||||
EXPECT_EQ(renderDelegate->OnEnableForm(formJsInfo, true), ERR_INVALID_VALUE);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user