1 /*
2  * Copyright (c) 2021-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 "distributed_input_sinkhandler_test.h"
17 #include "dinput_errcode.h"
18 
19 using namespace testing::ext;
20 using namespace OHOS::DistributedHardware::DistributedInput;
21 using namespace std;
22 
23 namespace OHOS {
24 namespace DistributedHardware {
25 namespace DistributedInput {
SetUp()26 void DistributedInputSinkHandlerTest::SetUp()
27 {
28 }
29 
TearDown()30 void DistributedInputSinkHandlerTest::TearDown()
31 {
32 }
33 
SetUpTestCase()34 void DistributedInputSinkHandlerTest::SetUpTestCase()
35 {
36 }
37 
TearDownTestCase()38 void DistributedInputSinkHandlerTest::TearDownTestCase()
39 {
40 }
41 
42 HWTEST_F(DistributedInputSinkHandlerTest, InitSink01, testing::ext::TestSize.Level0)
43 {
44     int32_t ret = DistributedInputSinkHandler::GetInstance().InitSink("params");
45     EXPECT_EQ(DH_SUCCESS, ret);
46 }
47 
48 HWTEST_F(DistributedInputSinkHandlerTest, InitSink02, testing::ext::TestSize.Level0)
49 {
50     std::string params = "";
51     int32_t ret = DistributedInputSinkHandler::GetInstance().InitSink(params);
52     EXPECT_EQ(DH_SUCCESS, ret);
53 }
54 HWTEST_F(DistributedInputSinkHandlerTest, InitSink03, testing::ext::TestSize.Level0)
55 {
56     std::string params = "params";
57     int32_t ret = DistributedInputSinkHandler::GetInstance().InitSink(params);
58     EXPECT_EQ(DH_SUCCESS, ret);
59 }
60 
61 HWTEST_F(DistributedInputSinkHandlerTest, ReleaseSink01, testing::ext::TestSize.Level0)
62 {
63     int32_t ret = DistributedInputSinkHandler::GetInstance().ReleaseSink();
64     EXPECT_EQ(DH_SUCCESS, ret);
65 }
66 
67 HWTEST_F(DistributedInputSinkHandlerTest, SubscribeLocalHardware01, testing::ext::TestSize.Level0)
68 {
69     int32_t ret = DistributedInputSinkHandler::GetInstance().SubscribeLocalHardware("dhId", "params");
70     EXPECT_EQ(DH_SUCCESS, ret);
71 }
72 
73 HWTEST_F(DistributedInputSinkHandlerTest, SubscribeLocalHardware02, testing::ext::TestSize.Level0)
74 {
75     std::string dhId = "SubscribeLocalHardware02";
76     std::string params = "test2";
77     int32_t ret = DistributedInputSinkHandler::GetInstance().SubscribeLocalHardware(dhId, params);
78     EXPECT_EQ(DH_SUCCESS, ret);
79 }
80 
81 HWTEST_F(DistributedInputSinkHandlerTest, SubscribeLocalHardware03, testing::ext::TestSize.Level0)
82 {
83     std::string dhId = "SubscribeLocalHardware03";
84     std::string params = "test3";
85     int32_t ret = DistributedInputSinkHandler::GetInstance().SubscribeLocalHardware(dhId, params);
86     EXPECT_EQ(DH_SUCCESS, ret);
87 }
88 
89 HWTEST_F(DistributedInputSinkHandlerTest, UnsubscribeLocalHardware01, testing::ext::TestSize.Level0)
90 {
91     int32_t ret = DistributedInputSinkHandler::GetInstance().UnsubscribeLocalHardware("dhId");
92     EXPECT_EQ(DH_SUCCESS, ret);
93 }
94 
95 HWTEST_F(DistributedInputSinkHandlerTest, UnsubscribeLocalHardware02, testing::ext::TestSize.Level0)
96 {
97     std::string dhId = "UnsubscribeLocalHardware02";
98     int32_t ret = DistributedInputSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId);
99     EXPECT_EQ(DH_SUCCESS, ret);
100 }
101 
102 HWTEST_F(DistributedInputSinkHandlerTest, UnsubscribeLocalHardware03, testing::ext::TestSize.Level0)
103 {
104     std::string dhId = "UnsubscribeLocalHardware03";
105     int32_t ret = DistributedInputSinkHandler::GetInstance().UnsubscribeLocalHardware(dhId);
106     EXPECT_EQ(DH_SUCCESS, ret);
107 }
108 } // namespace DistributedInput
109 } // namespace DistributedHardware
110 } // namespace OHOS