• 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 <gtest/gtest.h>
17 
18 #include "distributed_camera_sink_proxy.h"
19 #include "distributed_camera_sink_stub.h"
20 #include "distributed_hardware_log.h"
21 #include "mock_distributed_camera_sink_stub.h"
22 
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 class DcameraSinkStubTest : public testing::Test {
28 public:
29     static void SetUpTestCase(void);
30     static void TearDownTestCase(void);
31     void SetUp();
32     void TearDown();
33 };
34 
SetUpTestCase(void)35 void DcameraSinkStubTest::SetUpTestCase(void)
36 {
37     DHLOGI("DcameraSinkStubTest::SetUpTestCase");
38 }
39 
TearDownTestCase(void)40 void DcameraSinkStubTest::TearDownTestCase(void)
41 {
42     DHLOGI("DcameraSinkStubTest::TearDownTestCase");
43 }
44 
SetUp(void)45 void DcameraSinkStubTest::SetUp(void)
46 {
47     DHLOGI("DcameraSinkStubTest::SetUp");
48 }
49 
TearDown(void)50 void DcameraSinkStubTest::TearDown(void)
51 {
52     DHLOGI("DcameraSinkStubTest::TearDown");
53 }
54 
55 /**
56  * @tc.name: dcamera_sink_stub_test_001
57  * @tc.desc: Verify the InitSink function.
58  * @tc.type: FUNC
59  * @tc.require: issue
60  */
61 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_001, TestSize.Level1)
62 {
63     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_001");
64     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
65     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
66     std::string params = "params000";
67     int32_t ret = sinkProxy.InitSink(params);
68     EXPECT_EQ(DCAMERA_OK, ret);
69 }
70 
71 /**
72  * @tc.name: dcamera_sink_stub_test_002
73  * @tc.desc: Verify the ReleaseSink function.
74  * @tc.type: FUNC
75  * @tc.require: issue
76  */
77 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_002, TestSize.Level1)
78 {
79     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_002");
80     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
81     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
82     int32_t ret = sinkProxy.ReleaseSink();
83     EXPECT_EQ(DCAMERA_OK, ret);
84 }
85 
86 /**
87  * @tc.name: dcamera_sink_stub_test_003
88  * @tc.desc: Verify the SubscribeLocalHardware function.
89  * @tc.type: FUNC
90  * @tc.require: issue
91  */
92 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_003, TestSize.Level1)
93 {
94     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_003");
95     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
96     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
97     std::string dhId = "dhId000";
98     std::string params = "params000";
99     int32_t ret = sinkProxy.SubscribeLocalHardware(dhId, params);
100     EXPECT_EQ(DCAMERA_OK, ret);
101 }
102 
103 /**
104  * @tc.name: dcamera_sink_stub_test_004
105  * @tc.desc: Verify the UnsubscribeLocalHardware function.
106  * @tc.type: FUNC
107  * @tc.require: issue
108  */
109 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_004, TestSize.Level1)
110 {
111     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_004");
112     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
113     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
114     std::string dhId = "dhId000";
115     int32_t ret = sinkProxy.UnsubscribeLocalHardware(dhId);
116     EXPECT_EQ(DCAMERA_OK, ret);
117 }
118 
119 /**
120  * @tc.name: dcamera_sink_stub_test_005
121  * @tc.desc: Verify the StopCapture function.
122  * @tc.type: FUNC
123  * @tc.require: issue
124  */
125 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_005, TestSize.Level1)
126 {
127     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_005");
128     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
129     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
130     std::string dhId = "dhId000";
131     int32_t ret = sinkProxy.StopCapture(dhId);
132     EXPECT_EQ(DCAMERA_OK, ret);
133 }
134 
135 /**
136  * @tc.name: dcamera_sink_stub_test_006
137  * @tc.desc: Verify the ChannelNeg function.
138  * @tc.type: FUNC
139  * @tc.require: issue
140  */
141 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_006, TestSize.Level1)
142 {
143     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_006");
144     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
145     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
146     std::string dhId = "dhId000";
147     std::string channelInfo = "channelInfo000";
148     int32_t ret = sinkProxy.ChannelNeg(dhId, channelInfo);
149     EXPECT_EQ(DCAMERA_OK, ret);
150 }
151 
152 /**
153  * @tc.name: dcamera_sink_stub_test_007
154  * @tc.desc: Verify the GetCameraInfo function.
155  * @tc.type: FUNC
156  * @tc.require: issue
157  */
158 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_007, TestSize.Level1)
159 {
160     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_007");
161     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
162     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
163     std::string dhId = "dhId000";
164     std::string cameraInfo = "cameraInfo000";
165     int32_t ret = sinkProxy.GetCameraInfo(dhId, cameraInfo);
166     EXPECT_EQ(DCAMERA_OK, ret);
167 }
168 
169 /**
170  * @tc.name: dcamera_sink_stub_test_008
171  * @tc.desc: Verify the OpenChannel function.
172  * @tc.type: FUNC
173  * @tc.require: issue
174  */
175 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_008, TestSize.Level1)
176 {
177     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_008");
178     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
179     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
180     std::string dhId = "dhId000";
181     std::string openInfo = "openInfo000";
182     int32_t ret = sinkProxy.OpenChannel(dhId, openInfo);
183     EXPECT_EQ(DCAMERA_OK, ret);
184 }
185 
186 /**
187  * @tc.name: dcamera_sink_stub_test_009
188  * @tc.desc: Verify the CloseChannel function.
189  * @tc.type: FUNC
190  * @tc.require: issue
191  */
192 HWTEST_F(DcameraSinkStubTest, dcamera_sink_stub_test_009, TestSize.Level1)
193 {
194     DHLOGI("DcameraSinkStubTest::dcamera_sink_stub_test_009");
195     sptr<IRemoteObject> sinkStubPtr = new MockDistributedCameraSinkStub();
196     DistributedCameraSinkProxy sinkProxy(sinkStubPtr);
197     std::string dhId = "dhId000";
198     int32_t ret = sinkProxy.CloseChannel(dhId);
199     EXPECT_EQ(DCAMERA_OK, ret);
200 }
201 } // namespace DistributedHardware
202 } // namespace OHOS