179a732c7Sopenharmony_ci/* 279a732c7Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 379a732c7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 479a732c7Sopenharmony_ci * you may not use this file except in compliance with the License. 579a732c7Sopenharmony_ci * You may obtain a copy of the License at 679a732c7Sopenharmony_ci * 779a732c7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 879a732c7Sopenharmony_ci * 979a732c7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1079a732c7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1179a732c7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1279a732c7Sopenharmony_ci * See the License for the specific language governing permissions and 1379a732c7Sopenharmony_ci * limitations under the License. 1479a732c7Sopenharmony_ci */ 1579a732c7Sopenharmony_ci 1679a732c7Sopenharmony_ci#include "UTTest_pin_auth_ui.h" 1779a732c7Sopenharmony_ci 1879a732c7Sopenharmony_ci#include <unistd.h> 1979a732c7Sopenharmony_ci#include <memory> 2079a732c7Sopenharmony_ci 2179a732c7Sopenharmony_ci#include "dm_ability_manager.h" 2279a732c7Sopenharmony_ci#include "dm_constants.h" 2379a732c7Sopenharmony_ci#include "dm_log.h" 2479a732c7Sopenharmony_ci#include "nlohmann/json.hpp" 2579a732c7Sopenharmony_ci#include "device_manager_service_listener.h" 2679a732c7Sopenharmony_ci 2779a732c7Sopenharmony_cinamespace OHOS { 2879a732c7Sopenharmony_cinamespace DistributedHardware { 2979a732c7Sopenharmony_civoid PinAuthUiTest::SetUp() 3079a732c7Sopenharmony_ci{ 3179a732c7Sopenharmony_ci} 3279a732c7Sopenharmony_ci 3379a732c7Sopenharmony_civoid PinAuthUiTest::TearDown() 3479a732c7Sopenharmony_ci{ 3579a732c7Sopenharmony_ci} 3679a732c7Sopenharmony_ci 3779a732c7Sopenharmony_civoid PinAuthUiTest::SetUpTestCase() 3879a732c7Sopenharmony_ci{ 3979a732c7Sopenharmony_ci} 4079a732c7Sopenharmony_ci 4179a732c7Sopenharmony_civoid PinAuthUiTest::TearDownTestCase() 4279a732c7Sopenharmony_ci{ 4379a732c7Sopenharmony_ci} 4479a732c7Sopenharmony_ci 4579a732c7Sopenharmony_cinamespace { 4679a732c7Sopenharmony_cistd::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>(); 4779a732c7Sopenharmony_cistd::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>(); 4879a732c7Sopenharmony_cistd::shared_ptr<HiChainConnector> hiChainConnector = std::make_shared<HiChainConnector>(); 4979a732c7Sopenharmony_cistd::shared_ptr<HiChainAuthConnector> hiChainAuthConnector = std::make_shared<HiChainAuthConnector>(); 5079a732c7Sopenharmony_cistd::shared_ptr<DmAuthManager> authManager = 5179a732c7Sopenharmony_ci std::make_shared<DmAuthManager>(softbusConnector, hiChainConnector, listener, hiChainAuthConnector); 5279a732c7Sopenharmony_ci/** 5379a732c7Sopenharmony_ci * @tc.name: PinAuthUi::ShowPinDialog_001 5479a732c7Sopenharmony_ci * @tc.desc: Call ShowPinDialog to check whether the return value is ERR_DM_POINT_NULL 5579a732c7Sopenharmony_ci * @tc.type: FUNC 5679a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 5779a732c7Sopenharmony_ci */ 5879a732c7Sopenharmony_ciHWTEST_F(PinAuthUiTest, ShowPinDialog_001, testing::ext::TestSize.Level0) 5979a732c7Sopenharmony_ci{ 6079a732c7Sopenharmony_ci std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>(); 6179a732c7Sopenharmony_ci int32_t code = 123456; 6279a732c7Sopenharmony_ci int32_t ret = pinAuthUi->ShowPinDialog(code, nullptr); 6379a732c7Sopenharmony_ci ASSERT_EQ(ret, ERR_DM_FAILED); 6479a732c7Sopenharmony_ci} 6579a732c7Sopenharmony_ci 6679a732c7Sopenharmony_ci/** 6779a732c7Sopenharmony_ci * @tc.name: PinAuthUi::ShowPinDialog_002 6879a732c7Sopenharmony_ci * @tc.desc: Call ShowPinDialog to check whether the return value is DM_OK 6979a732c7Sopenharmony_ci * @tc.type: FUNC 7079a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 7179a732c7Sopenharmony_ci */ 7279a732c7Sopenharmony_ciHWTEST_F(PinAuthUiTest, ShowPinDialog_002, testing::ext::TestSize.Level0) 7379a732c7Sopenharmony_ci{ 7479a732c7Sopenharmony_ci std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>(); 7579a732c7Sopenharmony_ci int32_t code = 123456; 7679a732c7Sopenharmony_ci int32_t ret = pinAuthUi->ShowPinDialog(code, authManager); 7779a732c7Sopenharmony_ci ASSERT_EQ(ret, ERR_DM_FAILED); 7879a732c7Sopenharmony_ci} 7979a732c7Sopenharmony_ci 8079a732c7Sopenharmony_ci/** 8179a732c7Sopenharmony_ci * @tc.name: PinAuthUi::ShowPinDialog_001 8279a732c7Sopenharmony_ci * @tc.desc: Call InputPinDialog to check whether the return value is ERR_DM_POINT_NULL 8379a732c7Sopenharmony_ci * @tc.type: FUNC 8479a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 8579a732c7Sopenharmony_ci */ 8679a732c7Sopenharmony_ciHWTEST_F(PinAuthUiTest, InputPinDialog_001, testing::ext::TestSize.Level0) 8779a732c7Sopenharmony_ci{ 8879a732c7Sopenharmony_ci std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>(); 8979a732c7Sopenharmony_ci int32_t ret = pinAuthUi->InputPinDialog(nullptr); 9079a732c7Sopenharmony_ci ASSERT_EQ(ret, ERR_DM_FAILED); 9179a732c7Sopenharmony_ci} 9279a732c7Sopenharmony_ci 9379a732c7Sopenharmony_ci/** 9479a732c7Sopenharmony_ci * @tc.name: PinAuthUi::ShowPinDialog_001 9579a732c7Sopenharmony_ci * @tc.desc: Call InputPinDialog to check whether the return value is DM_OK 9679a732c7Sopenharmony_ci * @tc.type: FUNC 9779a732c7Sopenharmony_ci * @tc.require: AR000GHSJK 9879a732c7Sopenharmony_ci */ 9979a732c7Sopenharmony_ciHWTEST_F(PinAuthUiTest, InputPinDialog_002, testing::ext::TestSize.Level0) 10079a732c7Sopenharmony_ci{ 10179a732c7Sopenharmony_ci std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>(); 10279a732c7Sopenharmony_ci int32_t ret = pinAuthUi->InputPinDialog(authManager); 10379a732c7Sopenharmony_ci ASSERT_EQ(ret, ERR_DM_FAILED); 10479a732c7Sopenharmony_ci} 10579a732c7Sopenharmony_ci} 10679a732c7Sopenharmony_ci} // namespace DistributedHardware 10779a732c7Sopenharmony_ci} // namespace OHOS 108