1 /*
2 * Copyright (C) 2025 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 <cstdio>
17 #include <cstdlib>
18 #include <ctime>
19 #include <fstream>
20 #include <memory>
21 #include <string>
22
23 #include <dlfcn.h>
24
25 #include <gtest/gtest.h>
26
27 #include "external_window.h"
28 #include "surface/window.h"
29
30 #include "algorithm_errors.h"
31 #include "algorithm_utils.h"
32 #include "algorithm_video.h"
33
34 using namespace testing::ext;
35
36 namespace {
37 constexpr int64_t NANOS_IN_SECOND = 1000000000L;
38 constexpr int64_t NANOS_IN_MICRO = 1000L;
39 constexpr uint32_t DEFAULT_WIDTH = 1920;
40 constexpr uint32_t DEFAULT_HEIGHT = 1080;
41
GetSystemTime()42 int64_t GetSystemTime()
43 {
44 struct timespec now;
45 clock_gettime(CLOCK_BOOTTIME, &now);
46 int64_t nanoTime = reinterpret_cast<int64_t>(now.tv_sec) * NANOS_IN_SECOND + now.tv_nsec;
47
48 return nanoTime / NANOS_IN_MICRO;
49 }
50 } // namespace
51
52 namespace OHOS {
53 namespace Media {
54 namespace VideoProcessingEngine {
55 class DetailEnhancerVideoCallbackImpl : public VpeVideoCallback {
56 public:
57 DetailEnhancerVideoCallbackImpl() = default;
58 ~DetailEnhancerVideoCallbackImpl() override = default;
59 DetailEnhancerVideoCallbackImpl(const DetailEnhancerVideoCallbackImpl&) = delete;
60 DetailEnhancerVideoCallbackImpl& operator=(const DetailEnhancerVideoCallbackImpl&) = delete;
61 DetailEnhancerVideoCallbackImpl(DetailEnhancerVideoCallbackImpl&&) = delete;
62 DetailEnhancerVideoCallbackImpl& operator=(DetailEnhancerVideoCallbackImpl&&) = delete;
63
64 void OnError(VPEAlgoErrCode errorCode) final;
65 void OnState(VPEAlgoState state) final;
66 void OnEffectChange(uint32_t type) final;
67 void OnOutputFormatChanged(const Format& format) final;
68 void OnOutputBufferAvailable(uint32_t index, VpeBufferFlag flag) final;
69 void OnOutputBufferAvailable(uint32_t index, const VpeBufferInfo& info) final;
70 };
71
OnError(VPEAlgoErrCode errorCode)72 void DetailEnhancerVideoCallbackImpl::OnError(VPEAlgoErrCode errorCode)
73 {
74 std::cout << "OnError:" << AlgorithmUtils::ToString(errorCode) << std::endl;
75 }
76
OnState(VPEAlgoState state)77 void DetailEnhancerVideoCallbackImpl::OnState(VPEAlgoState state)
78 {
79 std::cout << "OnState:" << AlgorithmUtils::ToString(state) << std::endl;
80 }
81
OnEffectChange(uint32_t type)82 void DetailEnhancerVideoCallbackImpl::OnEffectChange(uint32_t type)
83 {
84 std::cout << "OnEffectChange:0x" << std::hex << type << std::endl;
85 }
86
OnOutputFormatChanged(const Format & format)87 void DetailEnhancerVideoCallbackImpl::OnOutputFormatChanged(const Format& format)
88 {
89 std::cout << "OnOutputFormatChanged:" << format.Stringify() << std::endl;
90 }
91
OnOutputBufferAvailable(uint32_t index,VpeBufferFlag flag)92 void DetailEnhancerVideoCallbackImpl::OnOutputBufferAvailable(uint32_t index, VpeBufferFlag flag)
93 {
94 std::cout << "OnOutputBufferAvailable: index=" << index << " flag=" << flag << std::endl;
95 }
96
OnOutputBufferAvailable(uint32_t index,const VpeBufferInfo & info)97 void DetailEnhancerVideoCallbackImpl::OnOutputBufferAvailable(uint32_t index, const VpeBufferInfo& info)
98 {
99 std::cout << "OnOutputBufferAvailable: index=" << index << " flag=" << info.flag <<
100 " pts=" << info.presentationTimestamp << std::endl;
101 }
102
103 class DetailEnhancerVideoInnerAPIUnitTest : public testing::Test {
104 public:
105 static void SetUpTestCase(void);
106 static void TearDownTestCase(void);
107
108 void SetUp();
109 void TearDown();
110
111 protected:
112 uint32_t FlushSurf(OHNativeWindowBuffer* ohNativeWindowBuffer);
113
114 sptr<Surface> surface{};
115 OHNativeWindow* nativeWindow{};
116 };
117
SetUpTestCase(void)118 void DetailEnhancerVideoInnerAPIUnitTest::SetUpTestCase(void)
119 {
120 std::cout << "[SetUpTestCase]: " << std::endl;
121 }
122
TearDownTestCase(void)123 void DetailEnhancerVideoInnerAPIUnitTest::TearDownTestCase(void)
124 {
125 std::cout << "[TearDownTestCase]: " << std::endl;
126 }
127
SetUp(void)128 void DetailEnhancerVideoInnerAPIUnitTest::SetUp(void)
129 {
130 std::cout << "[SetUp]: SetUp!!!" << std::endl;
131 }
132
TearDown(void)133 void DetailEnhancerVideoInnerAPIUnitTest::TearDown(void)
134 {
135 std::cout << "[TearDown]: over!!!" << std::endl;
136 }
137
FlushSurf(OHNativeWindowBuffer * ohNativeWindowBuffer)138 uint32_t DetailEnhancerVideoInnerAPIUnitTest::FlushSurf(OHNativeWindowBuffer* ohNativeWindowBuffer)
139 {
140 struct Region region;
141 struct Region::Rect rect;
142 rect.x = 0;
143 rect.y = 0;
144 rect.w = DEFAULT_WIDTH;
145 rect.h = DEFAULT_HEIGHT;
146 region.rects = ▭
147 NativeWindowHandleOpt(nativeWindow, SET_UI_TIMESTAMP, GetSystemTime());
148 int32_t err = OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow, ohNativeWindowBuffer, -1, region);
149 if (err != 0) {
150 std::cout << "FlushBuffer failed" << std::endl;
151 return 1;
152 }
153 return 0;
154 }
155
156 // detail enhancer init
157 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_init_01, TestSize.Level1)
158 {
159 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
160 EXPECT_NE(detailEnh, nullptr);
161 }
162
163 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_02, TestSize.Level1)
164 {
165 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
166 std::shared_ptr<VpeVideoCallback> cb = nullptr;
167 auto ret = detailEnh->RegisterCallback(cb);
168 EXPECT_NE(ret, VPE_ALGO_ERR_OK);
169 }
170
171 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_03, TestSize.Level1)
172 {
173 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
174 Format param{};
175 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
176 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
177 }
178
179 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_04, TestSize.Level1)
180 {
181 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
182 Format param{};
183 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_MEDIUM), true);
184 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
185 }
186
187 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_05, TestSize.Level1)
188 {
189 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
190 Format param{};
191 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_LOW), true);
192 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
193 }
194
195 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_06, TestSize.Level1)
196 {
197 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
198 auto ret = detailEnh->GetInputSurface();
199 EXPECT_NE(ret, nullptr);
200 }
201
202 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_07, TestSize.Level1)
203 {
204 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
205 auto ret = detailEnh->GetInputSurface();
206 ret = detailEnh->GetInputSurface();
207 EXPECT_EQ(ret, nullptr);
208 }
209
210 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_08, TestSize.Level1)
211 {
212 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
213 sptr<Surface> surface = nullptr;
214 auto ret = detailEnh->SetOutputSurface(surface);
215 EXPECT_NE(ret, VPE_ALGO_ERR_OK);
216 }
217
218 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_09, TestSize.Level1)
219 {
220 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
221 auto ret = detailEnh->ReleaseOutputBuffer(0, true);
222 EXPECT_NE(ret, VPE_ALGO_ERR_OK);
223 }
224
225 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_10, TestSize.Level1)
226 {
227 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
228 int64_t renderTimestamp = 0;
229 auto ret = detailEnh->RenderOutputBufferAtTime(0, renderTimestamp);
230 EXPECT_NE(ret, VPE_ALGO_ERR_OK);
231 }
232
233 // set parameter to midium
234 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_11, TestSize.Level1)
235 {
236 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
237 Format param{};
238 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_MEDIUM), true);
239 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
240 }
241
242 // set parameter to low
243 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_12, TestSize.Level1)
244 {
245 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
246 Format param{};
247 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_LOW), true);
248 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
249 }
250
251 // set parameter to none
252 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_13, TestSize.Level1)
253 {
254 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
255 Format param{};
256 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_NONE), true);
257 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
258 }
259
260 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_14, TestSize.Level1)
261 {
262 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
263 Format param{};
264 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
265 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
266 }
267
268 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_15, TestSize.Level1)
269 {
270 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
271 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
272 auto res = detailEnh->RegisterCallback(cb);
273 EXPECT_EQ(res, VPE_ALGO_ERR_OK);
274 }
275
276 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_16, TestSize.Level1)
277 {
278 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
279 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
280 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
281 Format param{};
282 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
283 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
284 EXPECT_NE(detailEnh->GetInputSurface(), nullptr);
285 EXPECT_NE(detailEnh->Start(), VPE_ALGO_ERR_OK);
286 }
287
288 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_17, TestSize.Level1)
289 {
290 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
291 auto res = detailEnh->Stop();
292 EXPECT_NE(res, VPE_ALGO_ERR_OK);
293 }
294
295 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_18, TestSize.Level1)
296 {
297 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
298 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
299 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
300 Format param{};
301 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
302 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
303 auto surface1 = detailEnh->GetInputSurface();
304 EXPECT_EQ(detailEnh->SetOutputSurface(surface1), VPE_ALGO_ERR_OK);
305 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
306 }
307
308 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_19, TestSize.Level1)
309 {
310 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
311 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
312 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
313 Format param{};
314 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
315 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
316 auto surface1 = detailEnh->GetInputSurface();
317 EXPECT_EQ(detailEnh->SetOutputSurface(surface1), VPE_ALGO_ERR_OK);
318 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
319 EXPECT_NE(detailEnh->ReleaseOutputBuffer(100, true), VPE_ALGO_ERR_OK);
320 }
321
322 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_20, TestSize.Level1)
323 {
324 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
325 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
326 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
327 Format param{};
328 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
329 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
330 auto surface1 = detailEnh->GetInputSurface();
331 EXPECT_EQ(detailEnh->SetOutputSurface(surface1), VPE_ALGO_ERR_OK);
332 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
333 EXPECT_NE(detailEnh->RenderOutputBufferAtTime(100, 0), VPE_ALGO_ERR_OK);
334 }
335
336 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_21, TestSize.Level1)
337 {
338 OHNativeWindowBuffer* ohNativeWindowBuffer;
339 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
340 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
341 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
342 Format param{};
343 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
344 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
345 auto surface = detailEnh->GetInputSurface();
346 auto detailEnh2 = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
347 auto surface2 = detailEnh2->GetInputSurface();
348 EXPECT_EQ(detailEnh->SetOutputSurface(surface2), VPE_ALGO_ERR_OK);
349 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
350
351 int fenceFd = -1;
352 nativeWindow = CreateNativeWindowFromSurface(&surface);
353 auto ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_FORMAT, GRAPHIC_PIXEL_FMT_YCBCR_420_SP);
354 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
355 ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_BUFFER_GEOMETRY, DEFAULT_WIDTH, DEFAULT_HEIGHT);
356 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
357 ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &ohNativeWindowBuffer, &fenceFd);
358 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
359 ret = FlushSurf(ohNativeWindowBuffer);
360 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
361 OH_NativeWindow_DestroyNativeWindow(nativeWindow);
362 }
363
364 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_22, TestSize.Level1)
365 {
366 OHNativeWindowBuffer* ohNativeWindowBuffer;
367 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
368 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
369 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
370 Format param{};
371 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
372 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
373 auto surface = detailEnh->GetInputSurface();
374 auto detailEnh2 = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
375 auto surface2 = detailEnh2->GetInputSurface();
376 surface2->SetRequestWidthAndHeight(10, 10);
377 EXPECT_EQ(detailEnh->SetOutputSurface(surface2), VPE_ALGO_ERR_OK);
378 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
379
380 int fenceFd = -1;
381 nativeWindow = CreateNativeWindowFromSurface(&surface);
382 auto ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_FORMAT, GRAPHIC_PIXEL_FMT_YCBCR_420_SP);
383 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
384 ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_BUFFER_GEOMETRY, DEFAULT_WIDTH, DEFAULT_HEIGHT);
385 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
386 ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &ohNativeWindowBuffer, &fenceFd);
387 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
388 ret = FlushSurf(ohNativeWindowBuffer);
389 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
390 OH_NativeWindow_DestroyNativeWindow(nativeWindow);
391 }
392
393 HWTEST_F(DetailEnhancerVideoInnerAPIUnitTest, detailenhancer_23, TestSize.Level1)
394 {
395 OHNativeWindowBuffer* ohNativeWindowBuffer;
396 auto detailEnh = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
397 std::shared_ptr<VpeVideoCallback> cb = std::make_shared<DetailEnhancerVideoCallbackImpl>();
398 EXPECT_EQ(detailEnh->RegisterCallback(cb), VPE_ALGO_ERR_OK);
399 Format param{};
400 EXPECT_EQ(param.PutIntValue(ParameterKey::DETAIL_ENHANCER_QUALITY_LEVEL, DETAIL_ENHANCER_LEVEL_HIGH), true);
401 EXPECT_EQ(detailEnh->SetParameter(param), VPE_ALGO_ERR_OK);
402 auto surface = detailEnh->GetInputSurface();
403 auto detailEnh2 = VpeVideo::Create(VIDEO_TYPE_DETAIL_ENHANCER);
404 auto surface2 = detailEnh2->GetInputSurface();
405 surface2->SetRequestWidthAndHeight(10, 0);
406 EXPECT_EQ(detailEnh->SetOutputSurface(surface2), VPE_ALGO_ERR_OK);
407 EXPECT_EQ(detailEnh->Start(), VPE_ALGO_ERR_OK);
408
409 int fenceFd = -1;
410 nativeWindow = CreateNativeWindowFromSurface(&surface);
411 auto ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_FORMAT, GRAPHIC_PIXEL_FMT_YCBCR_420_SP);
412 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
413 ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, SET_BUFFER_GEOMETRY, DEFAULT_WIDTH, DEFAULT_HEIGHT);
414 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
415 ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow, &ohNativeWindowBuffer, &fenceFd);
416 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
417 ret = FlushSurf(ohNativeWindowBuffer);
418 ASSERT_EQ(ret, VPE_ALGO_ERR_OK);
419 OH_NativeWindow_DestroyNativeWindow(nativeWindow);
420 }
421 } // namespace VideoProcessingEngine
422 } // namespace Media
423 } // namespace OHOS
424