• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "UTTest_pin_auth_ui.h"
17 
18 #include <unistd.h>
19 #include <memory>
20 
21 #include "dm_ability_manager.h"
22 #include "dm_constants.h"
23 #include "dm_log.h"
24 #include "nlohmann/json.hpp"
25 #include "device_manager_service_listener.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
SetUp()29 void PinAuthUiTest::SetUp()
30 {
31 }
32 
TearDown()33 void PinAuthUiTest::TearDown()
34 {
35 }
36 
SetUpTestCase()37 void PinAuthUiTest::SetUpTestCase()
38 {
39 }
40 
TearDownTestCase()41 void PinAuthUiTest::TearDownTestCase()
42 {
43 }
44 
45 namespace {
46 std::shared_ptr<SoftbusConnector> softbusConnector = std::make_shared<SoftbusConnector>();
47 std::shared_ptr<DeviceManagerServiceListener> listener = std::make_shared<DeviceManagerServiceListener>();
48 std::shared_ptr<HiChainConnector> hiChainConnector = std::make_shared<HiChainConnector>();
49 std::shared_ptr<DmAuthManager> authManager =
50         std::make_shared<DmAuthManager>(softbusConnector, listener, hiChainConnector);
51 /**
52  * @tc.name: PinAuthUi::ShowPinDialog_001
53  * @tc.desc: Call ShowPinDialog to check whether the return value is ERR_DM_FAILED
54  * @tc.type: FUNC
55  * @tc.require: AR000GHSJK
56  */
57 HWTEST_F(PinAuthUiTest, ShowPinDialog_001, testing::ext::TestSize.Level0)
58 {
59     std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>();
60     int32_t code = 123456;
61     int32_t ret = pinAuthUi->ShowPinDialog(code, nullptr);
62     ASSERT_EQ(ret, ERR_DM_FAILED);
63 }
64 
65 /**
66  * @tc.name: PinAuthUi::ShowPinDialog_002
67  * @tc.desc: Call ShowPinDialog to check whether the return value is DM_OK
68  * @tc.type: FUNC
69  * @tc.require: AR000GHSJK
70  */
71 HWTEST_F(PinAuthUiTest, ShowPinDialog_002, testing::ext::TestSize.Level0)
72 {
73     std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>();
74     int32_t code = 123456;
75     int32_t ret = pinAuthUi->ShowPinDialog(code, authManager);
76     ASSERT_EQ(ret, DM_OK);
77 }
78 
79 /**
80  * @tc.name: PinAuthUi::ShowPinDialog_001
81  * @tc.desc: Call InputPinDialog to check whether the return value is ERR_DM_FAILED
82  * @tc.type: FUNC
83  * @tc.require: AR000GHSJK
84  */
85 HWTEST_F(PinAuthUiTest, InputPinDialog_001, testing::ext::TestSize.Level0)
86 {
87     std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>();
88     int32_t ret = pinAuthUi->InputPinDialog(nullptr);
89     ASSERT_EQ(ret, ERR_DM_FAILED);
90 }
91 
92 /**
93  * @tc.name: PinAuthUi::ShowPinDialog_001
94  * @tc.desc: Call InputPinDialog to check whether the return value is DM_OK
95  * @tc.type: FUNC
96  * @tc.require: AR000GHSJK
97  */
98 HWTEST_F(PinAuthUiTest, InputPinDialog_002, testing::ext::TestSize.Level0)
99 {
100     std::shared_ptr<PinAuthUi> pinAuthUi = std::make_shared<PinAuthUi>();
101     int32_t ret = pinAuthUi->InputPinDialog(authManager);
102     ASSERT_EQ(ret, DM_OK);
103 }
104 }
105 } // namespace DistributedHardware
106 } // namespace OHOS
107