1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "gtest/gtest.h" 17 #define private public 18 #define protected public 19 #include "test/mock/core/common/mock_container.h" 20 #include "test/mock/core/pipeline/mock_pipeline_context.h" 21 22 using namespace testing; 23 using namespace testing::ext; 24 25 namespace OHOS::Ace::NG { 26 class ContainerTest : public testing::Test { 27 public: SetUpTestSuite()28 static void SetUpTestSuite() 29 { 30 NG::MockPipelineContext::SetUp(); 31 MockContainer::SetUp(); 32 MockContainer::Current()->pipelineContext_ = PipelineBase::GetCurrentContext(); 33 } TearDownTestSuite()34 static void TearDownTestSuite() 35 { 36 MockContainer::Current()->pipelineContext_ = nullptr; 37 NG::MockPipelineContext::TearDown(); 38 } SetUp()39 void SetUp() {}; TearDown()40 void TearDown() {}; 41 }; 42 43 /** 44 * @tc.name: ContainerTest001 45 * @tc.desc: Test autofill interface with native call 46 * @tc.type: FUNC 47 */ 48 HWTEST_F(ContainerTest, ContainerTest001, TestSize.Level1) 49 { 50 bool isNative = true; 51 bool isPopup = false; 52 uint32_t autoFillSessionId = 0; 53 AceAutoFillType type = AceAutoFillType::ACE_USER_NAME; 54 int32_t autoFillRet = 55 MockContainer::Current()->RequestAutoFill(nullptr, type, false, isPopup, autoFillSessionId, isNative); 56 EXPECT_EQ(autoFillRet, AceAutoFillError::ACE_AUTO_FILL_SUCCESS); 57 58 bool updateRet = MockContainer::Current()->UpdatePopupUIExtension(nullptr, autoFillSessionId, isNative); 59 EXPECT_EQ(updateRet, false); 60 61 bool closeRet = MockContainer::Current()->ClosePopupUIExtension(autoFillSessionId); 62 EXPECT_EQ(closeRet, false); 63 } 64 65 /** 66 * @tc.name: ContainerTest002 67 * @tc.desc: Test autofill interface with web call 68 * @tc.type: FUNC 69 */ 70 HWTEST_F(ContainerTest, ContainerTest002, TestSize.Level1) 71 { 72 bool isNative = false; 73 bool isPopup = false; 74 uint32_t autoFillSessionId = 0; 75 AceAutoFillType type = AceAutoFillType::ACE_USER_NAME; 76 int32_t autoFillRet = 77 MockContainer::Current()->RequestAutoFill(nullptr, type, false, isPopup, autoFillSessionId, isNative); 78 EXPECT_EQ(autoFillRet, AceAutoFillError::ACE_AUTO_FILL_SUCCESS); 79 80 bool updateRet = MockContainer::Current()->UpdatePopupUIExtension(nullptr, autoFillSessionId, isNative); 81 EXPECT_EQ(updateRet, false); 82 83 bool closeRet = MockContainer::Current()->ClosePopupUIExtension(autoFillSessionId); 84 EXPECT_EQ(closeRet, false); 85 } 86 } // namespace OHOS::Ace::NG