• 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 "screen_source_trans_test.h"
17 #include "screentrans_test_utils.h"
18 
19 using namespace testing::ext;
20 
21 namespace OHOS {
22 namespace DistributedHardware {
SetUpTestCase(void)23 void ScreenSourceTransTest::SetUpTestCase(void) {}
24 
TearDownTestCase(void)25 void ScreenSourceTransTest::TearDownTestCase(void) {}
26 
SetUp(void)27 void ScreenSourceTransTest::SetUp(void)
28 {
29     trans = std::make_shared<ScreenSourceTrans>();
30 }
31 
TearDown(void)32 void ScreenSourceTransTest::TearDown(void) {}
33 
34 /**
35  * @tc.name: SetUp_001
36  * @tc.desc: Verify the SetUp function.
37  * @tc.type: FUNC
38  * @tc.require: Issue Number
39  */
40 HWTEST_F(ScreenSourceTransTest, SetUp_001, TestSize.Level1)
41 {
42     VideoParam localParam;
43     VideoParam remoteParam;
44     std::string peerDevId;
45 
46     int32_t actual = trans->SetUp(localParam, remoteParam, peerDevId);
47 
48     EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
49 }
50 
51 /**
52  * @tc.name: SetUp_002
53  * @tc.desc: Verify the SetUp function.
54  * @tc.type: FUNC
55  * @tc.require: Issue Number
56  */
57 HWTEST_F(ScreenSourceTransTest, SetUp_002, TestSize.Level1)
58 {
59     VideoParam localParam;
60     localParam.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264;
61     localParam.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420;
62     localParam.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH;
63     localParam.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT;
64     localParam.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH;
65     localParam.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT;
66     VideoParam remoteParam;
67     remoteParam.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264;
68     remoteParam.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420;
69     remoteParam.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH;
70     remoteParam.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT;
71     remoteParam.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH;
72     remoteParam.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT;
73     std::string peerDevId = "hello";
74 
75     int32_t actual = trans->SetUp(localParam, remoteParam, peerDevId);
76 
77     EXPECT_EQ(DH_SUCCESS, actual);
78 }
79 
80 /**
81  * @tc.name: Release_001
82  * @tc.desc: Verify the Release function.
83  * @tc.type: FUNC
84  * @tc.require: Issue Number
85  */
86 HWTEST_F(ScreenSourceTransTest, Release_001, TestSize.Level1)
87 {
88     int32_t actual = trans->Release();
89 
90     EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
91 }
92 
93 /**
94  * @tc.name: Release_002
95  * @tc.desc: Verify the Release function.
96  * @tc.type: FUNC
97  * @tc.require: Issue Number
98  */
99 HWTEST_F(ScreenSourceTransTest, Release_002, TestSize.Level1)
100 {
101     trans->imageProcessor_ = std::make_shared<ImageSourceProcessor>();
102     std::string peerDevId = "hello";
103     trans->screenChannel_ = std::make_shared<ScreenDataChannelImpl>(peerDevId);
104     int32_t actual = trans->Release();
105 
106     EXPECT_EQ(DH_SUCCESS, actual);
107 }
108 
109 /**
110  * @tc.name: Start_001
111  * @tc.desc: Verify the Start function.
112  * @tc.type: FUNC
113  * @tc.require: Issue Number
114  */
115 HWTEST_F(ScreenSourceTransTest, Start_001, TestSize.Level1)
116 {
117     int32_t actual = trans->Start();
118 
119     EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
120 }
121 
122 /**
123  * @tc.name: Start_002
124  * @tc.desc: Verify the Start function.
125  * @tc.type: FUNC
126  * @tc.require: Issue Number
127  */
128 HWTEST_F(ScreenSourceTransTest, Start_002, TestSize.Level1)
129 {
130     trans->imageProcessor_ = std::make_shared<ImageSourceProcessor>();
131     std::string peerDevId = "hello";
132     trans->screenChannel_ = std::make_shared<ScreenDataChannelImpl>(peerDevId);
133     int32_t actual = trans->Start();
134 
135     EXPECT_EQ(ERR_DH_SCREEN_TRANS_ERROR, actual);
136 }
137 
138 /**
139  * @tc.name: RegisterStateCallback_001
140  * @tc.desc: Verify the RegisterStateCallback function.
141  * @tc.type: FUNC
142  * @tc.require: Issue Number
143  */
144 HWTEST_F(ScreenSourceTransTest, RegisterStateCallback_001, TestSize.Level1)
145 {
146     std::shared_ptr<IScreenSourceTransCallback> callback = nullptr;
147     int32_t actual = trans->RegisterStateCallback(callback);
148 
149     EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
150 }
151 
152 /**
153  * @tc.name: RegisterStateCallback_002
154  * @tc.desc: Verify the RegisterStateCallback function.
155  * @tc.type: FUNC
156  * @tc.require: Issue Number
157  */
158 HWTEST_F(ScreenSourceTransTest, RegisterStateCallback_002, TestSize.Level1)
159 {
160     std::shared_ptr<IScreenSourceTransCallback> callback =
161         std::make_shared<MockIScreenSourceTransCallback>();
162     int32_t actual = trans->RegisterStateCallback(callback);
163 
164     EXPECT_EQ(DH_SUCCESS, actual);
165 }
166 
167 /**
168  * @tc.name: CheckTransParam_001
169  * @tc.desc: Verify the CheckTransParam function.
170  * @tc.type: FUNC
171  * @tc.require: Issue Number
172  */
173 HWTEST_F(ScreenSourceTransTest, CheckTransParam_001, TestSize.Level1)
174 {
175     VideoParam localParam;
176     VideoParam remoteParam;
177     std::string peerDevId;
178     int32_t actual = trans->CheckTransParam(localParam, remoteParam, peerDevId);
179 
180     EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
181 }
182 
183 /**
184  * @tc.name: CheckTransParam_002
185  * @tc.desc: Verify the CheckTransParam function.
186  * @tc.type: FUNC
187  * @tc.require: Issue Number
188  */
189 HWTEST_F(ScreenSourceTransTest, CheckTransParam_002, TestSize.Level1)
190 {
191     VideoParam localParam;
192     localParam.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264;
193     localParam.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420;
194     localParam.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH;
195     localParam.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT;
196     localParam.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH;
197     localParam.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT;
198     VideoParam remoteParam;
199     remoteParam.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264;
200     remoteParam.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420;
201     remoteParam.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH;
202     remoteParam.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT;
203     remoteParam.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH;
204     remoteParam.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT;
205     std::string peerDevId = "hello";
206     int32_t actual = trans->CheckTransParam(localParam, remoteParam, peerDevId);
207 
208     EXPECT_EQ(DH_SUCCESS, actual);
209 }
210 
211 /**
212  * @tc.name: OnSessionOpened_001
213  * @tc.desc: Verify the OnSessionOpened function.
214  * @tc.type: FUNC
215  * @tc.require: Issue Number
216  */
217 HWTEST_F(ScreenSourceTransTest, OnSessionOpened_001, TestSize.Level1)
218 {
219     trans->imageProcessor_ = std::make_shared<ImageSourceProcessor>();
220 
221     trans->OnSessionOpened();
222 
223     EXPECT_EQ(false, trans->isChannelReady_);
224 }
225 }
226 }
227