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 "image_source_processor_test.h"
17
18 using namespace testing::ext;
19
20 namespace OHOS {
21 namespace DistributedHardware {
SetUpTestCase(void)22 void ImageSourceProcessorTest::SetUpTestCase(void) {}
23
TearDownTestCase(void)24 void ImageSourceProcessorTest::TearDownTestCase(void) {}
25
SetUp(void)26 void ImageSourceProcessorTest::SetUp(void) {}
27
TearDown(void)28 void ImageSourceProcessorTest::TearDown(void) {}
29
30 /**
31 * @tc.name: ConfigureImageProcessor_001
32 * @tc.desc: Verify the ConfigureImageProcessor function.
33 * @tc.type: FUNC
34 * @tc.require: Issue Number
35 */
36 HWTEST_F(ImageSourceProcessorTest, ConfigureImageProcessor_001, TestSize.Level1)
37 {
38 VideoParam localParam;
39 VideoParam remoteParam;
40 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
41
42 int32_t actual = processor.ConfigureImageProcessor(localParam, remoteParam, listener);
43
44 EXPECT_EQ(ERR_DH_SCREEN_CODEC_CONFIGURE_FAILED, actual);
45 }
46
47 /**
48 * @tc.name: ConfigureImageProcessor_002
49 * @tc.desc: Verify the ConfigureImageProcessor function.
50 * @tc.type: FUNC
51 * @tc.require: Issue Number
52 */
53 HWTEST_F(ImageSourceProcessorTest, ConfigureImageProcessor_002, TestSize.Level1)
54 {
55 VideoParam localParam;
56 VideoParam remoteParam;
57 localParam.SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264);
58 localParam.SetVideoWidth(DSCREEN_MAX_VIDEO_DATA_WIDTH);
59 localParam.SetVideoHeight(DSCREEN_MAX_VIDEO_DATA_HEIGHT);
60
61 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
62 int32_t actual = processor.ConfigureImageProcessor(localParam, remoteParam, listener);
63
64 EXPECT_EQ(DH_SUCCESS, actual);
65 }
66
67 /**
68 * @tc.name: ReleaseImageProcessor_001
69 * @tc.desc: Verify the ReleaseImageProcessor function.
70 * @tc.type: FUNC
71 * @tc.require: Issue Number
72 */
73 HWTEST_F(ImageSourceProcessorTest, ReleaseImageProcessor_001, TestSize.Level1)
74 {
75 int32_t actual = processor.ReleaseImageProcessor();
76
77 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
78 }
79
80 /**
81 * @tc.name: ReleaseImageProcessor_002
82 * @tc.desc: Verify the ReleaseImageProcessor function.
83 * @tc.type: FUNC
84 * @tc.require: Issue Number
85 */
86 HWTEST_F(ImageSourceProcessorTest, ReleaseImageProcessor_002, TestSize.Level1)
87 {
88 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
89 processor.imageEncoder_ = std::make_shared<ImageSourceEncoder>(listener);
90 int32_t actual = processor.ReleaseImageProcessor();
91
92 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
93 }
94
95 /**
96 * @tc.name: StartImageProcessor_001
97 * @tc.desc: Verify the StartImageProcessor function.
98 * @tc.type: FUNC
99 * @tc.require: Issue Number
100 */
101 HWTEST_F(ImageSourceProcessorTest, StartImageProcessor_001, TestSize.Level1)
102 {
103 int32_t actual = processor.StartImageProcessor();
104
105 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
106 }
107
108 /**
109 * @tc.name: StartImageProcessor_002
110 * @tc.desc: Verify the StartImageProcessor function.
111 * @tc.type: FUNC
112 * @tc.require: Issue Number
113 */
114 HWTEST_F(ImageSourceProcessorTest, StartImageProcessor_002, TestSize.Level1)
115 {
116 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
117 processor.imageEncoder_ = std::make_shared<ImageSourceEncoder>(listener);
118 int32_t actual = processor.StartImageProcessor();
119
120 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
121 }
122
123 /**
124 * @tc.name: StopImageProcessor_001
125 * @tc.desc: Verify the StopImageProcessor function.
126 * @tc.type: FUNC
127 * @tc.require: Issue Number
128 */
129 HWTEST_F(ImageSourceProcessorTest, StopImageProcessor_001, TestSize.Level1)
130 {
131 int32_t actual = processor.StopImageProcessor();
132
133 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
134 }
135
136 /**
137 * @tc.name: StopImageProcessor_002
138 * @tc.desc: Verify the StopImageProcessor function.
139 * @tc.type: FUNC
140 * @tc.require: Issue Number
141 */
142 HWTEST_F(ImageSourceProcessorTest, StopImageProcessor_002, TestSize.Level1)
143 {
144 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
145 processor.imageEncoder_ = std::make_shared<ImageSourceEncoder>(listener);
146 int32_t actual = processor.StopImageProcessor();
147
148 EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, actual);
149 }
150
151 /**
152 * @tc.name: GetImageSurface_001
153 * @tc.desc: Verify the GetImageSurface function.
154 * @tc.type: FUNC
155 * @tc.require: Issue Number
156 */
157 HWTEST_F(ImageSourceProcessorTest, GetImageSurface_001, TestSize.Level1)
158 {
159 std::shared_ptr<IImageSourceProcessorListener> listener = nullptr;
160 processor.imageEncoder_ = std::make_shared<ImageSourceEncoder>(listener);
161 sptr<Surface> actual = processor.GetImageSurface();
162
163 EXPECT_EQ(nullptr, actual);
164 }
165 } // DistributedHardware
166 } // OHOS