diff --git a/test/unittest/adapter/BUILD.gn b/test/unittest/adapter/BUILD.gn index 5ccc83a3a39..d56e3793d33 100644 --- a/test/unittest/adapter/BUILD.gn +++ b/test/unittest/adapter/BUILD.gn @@ -15,5 +15,8 @@ import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") group("adapter_unittest") { testonly = true - deps = [ "ohos/capability:capability_unittest" ] + deps = [ + "ohos/capability:capability_unittest", + "ohos/entrance:entrance_unittest", + ] } diff --git a/test/unittest/adapter/ohos/entrance/BUILD.gn b/test/unittest/adapter/ohos/entrance/BUILD.gn new file mode 100644 index 00000000000..37d4a4f09a8 --- /dev/null +++ b/test/unittest/adapter/ohos/entrance/BUILD.gn @@ -0,0 +1,46 @@ +# 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. + +import("//foundation/arkui/ace_engine/test/unittest/ace_unittest.gni") + +ohos_unittest("container_test") { + module_out_path = adapter_test_output_path + sources = [ "container_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_mock", + "$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", + "$graphic_2d_path/rosen/modules/render_service_client:librender_service_client", + "//third_party/googletest:gmock_main", + ] +} + +group("entrance_unittest") { + testonly = true + deps = [ ":container_test" ] +} diff --git a/test/unittest/adapter/ohos/entrance/container_test.cpp b/test/unittest/adapter/ohos/entrance/container_test.cpp new file mode 100644 index 00000000000..ef8b2dc570b --- /dev/null +++ b/test/unittest/adapter/ohos/entrance/container_test.cpp @@ -0,0 +1,85 @@ +/* + * 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 "gtest/gtest.h" +#define private public +#define protected public +#include "test/mock/core/common/mock_container.h" +#include "test/mock/core/pipeline/mock_pipeline_context.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS::Ace::NG { +class ContainerTest : public testing::Test { +public: + static void SetUpTestSuite() + { + NG::MockPipelineContext::SetUp(); + MockContainer::SetUp(); + MockContainer::Current()->pipelineContext_ = PipelineBase::GetCurrentContext(); + } + static void TearDownTestSuite() + { + MockContainer::Current()->pipelineContext_ = nullptr; + NG::MockPipelineContext::TearDown(); + } + void SetUp() {}; + void TearDown() {}; +}; + +/** + * @tc.name: ContainerTest001 + * @tc.desc: Test autofill interface with native call + * @tc.type: FUNC + */ +HWTEST_F(ContainerTest, ContainerTest001, TestSize.Level1) +{ + bool isNative = true; + bool isPopup = false; + uint32_t autoFillSessionId = 0; + AceAutoFillType type = AceAutoFillType::ACE_USER_NAME; + bool ret = MockContainer::Current()->RequestAutoFill(nullptr, type, false, isPopup, autoFillSessionId, isNative); + EXPECT_EQ(ret, false); + + ret = MockContainer::Current()->UpdatePopupUIExtension(nullptr, autoFillSessionId, isNative); + EXPECT_EQ(ret, false); + + ret = MockContainer::Current()->ClosePopupUIExtension(autoFillSessionId); + EXPECT_EQ(ret, false); +} + + +/** + * @tc.name: ContainerTest002 + * @tc.desc: Test autofill interface with web call + * @tc.type: FUNC + */ +HWTEST_F(ContainerTest, ContainerTest002, TestSize.Level1) +{ + bool isNative = false; + bool isPopup = false; + uint32_t autoFillSessionId = 0; + AceAutoFillType type = AceAutoFillType::ACE_USER_NAME; + bool ret = MockContainer::Current()->RequestAutoFill(nullptr, type, false, isPopup, autoFillSessionId, isNative); + EXPECT_EQ(ret, false); + + ret = MockContainer::Current()->UpdatePopupUIExtension(nullptr, autoFillSessionId, isNative); + EXPECT_EQ(ret, false); + + ret = MockContainer::Current()->ClosePopupUIExtension(autoFillSessionId); + EXPECT_EQ(ret, false); +} +} // namespace OHOS::Ace::NG \ No newline at end of file