• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, Level } from '@ohos/hypium';
17import { camera } from '@kit.CameraKit';
18import { common } from '@kit.AbilityKit';
19import {
20  cameraErrorCode,
21  closeFd,
22  COMMON_WAIT_DURATION,
23  driveFn,
24  getFd,
25  getPermission,
26  isEmpty,
27  resourceName,
28  sleep
29} from '../common';
30import { indexSurfaceId } from '../../testability/pages/Index';
31import { BusinessError } from '@kit.BasicServicesKit';
32import { media } from '@kit.MediaKit';
33
34const TAG = "CameraXts.VideoOutputTest";
35
36let mCameraManager: camera.CameraManager;
37let mCameraDeviceArray: Array<camera.CameraDevice>;
38let mSupportedModes: Array<camera.SceneMode>;
39let mCameraInput: camera.CameraInput;
40let mCameraOutputCap: camera.CameraOutputCapability;
41let mPreviewProfilesArray: Array<camera.Profile>;
42let mPreviewProfile: camera.Profile | undefined;
43let mVideoSurfaceId: string;
44let mVideoProfile: camera.VideoProfile;
45let mPreviewOutput: camera.PreviewOutput;
46let mVideoOutput: camera.VideoOutput;
47let mVideoSession: camera.VideoSession;
48let mAVRecorder: media.AVRecorder;
49let fdNumber: number;
50let fdPath: string;
51let testContext: common.UIAbilityContext = AppStorage.get('testContext') as common.UIAbilityContext;
52
53let videoProfile: media.AVRecorderProfile = {
54  audioBitrate: 48000,
55  audioChannels: 2,
56  audioCodec: media.CodecMimeType.AUDIO_AAC,
57  audioSampleRate: 48000,
58  fileFormat: media.ContainerFormatType.CFT_MPEG_4,
59  videoBitrate: 2000000,
60  videoCodec: media.CodecMimeType.VIDEO_AVC,
61  videoFrameWidth: 640,
62  videoFrameHeight: 480,
63  videoFrameRate: 30
64};
65
66let videoConfig: media.AVRecorderConfig = {
67  videoSourceType: media.VideoSourceType.VIDEO_SOURCE_TYPE_SURFACE_YUV,
68  profile: videoProfile,
69  url: 'file://',
70  location: { latitude: 30, longitude: 130 } as camera.Location,
71  rotation: 0
72};
73
74function getCameraManager() {
75  console.info(TAG, 'getCameraManager.');
76  mCameraManager = camera.getCameraManager(testContext);
77  if (isEmpty(mCameraManager)) {
78    return false;
79  }
80  console.info(TAG, 'mCameraManager created successfully.');
81  return true;
82}
83
84function getSupportedCameraDeviceArray() {
85  console.info(TAG, 'getSupportedCameraDeviceArray.');
86  mCameraDeviceArray = mCameraManager.getSupportedCameras();
87  if (isEmpty(mCameraDeviceArray)) {
88    return false;
89  }
90  console.info(TAG, 'getSupportedCameraDeviceArray length: ' + mCameraDeviceArray.length);
91  return true;
92}
93
94function getCameraInput() {
95  console.info(TAG, 'getCameraInput.');
96  mCameraInput = mCameraManager.createCameraInput(mCameraDeviceArray[0]);
97  if (isEmpty(mCameraInput)) {
98    return false;
99  }
100  console.info(TAG, 'cameraInput created successfully.');
101  return true;
102}
103
104function getSupportedModes() {
105  console.info(TAG, 'getSupportedModes.');
106  for (let i = 0; i < mCameraDeviceArray.length; i++) {
107    mSupportedModes = mCameraManager.getSupportedSceneModes(mCameraDeviceArray[i]);
108    if (isEmpty(mSupportedModes)) {
109      return false;
110    }
111    console.info(TAG, 'mSupportedModes: ' + JSON.stringify(mSupportedModes));
112  }
113  return true;
114}
115
116function getOutputCapability() {
117  console.info(TAG, 'getOutputCapability.');
118  mCameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDeviceArray[0], mSupportedModes[1]);
119  console.info(TAG, 'camera, output cap: ' + JSON.stringify(mCameraOutputCap));
120  mPreviewProfilesArray = mCameraOutputCap.previewProfiles;
121  mVideoProfile = mCameraOutputCap.videoProfiles[0];
122  expect(isEmpty(mVideoProfile)).assertFalse();
123  videoProfile.videoFrameWidth = mVideoProfile.size.width;
124  videoProfile.videoFrameHeight = mVideoProfile.size.height;
125}
126
127function getPreviewProfile() {
128  mPreviewProfile = mPreviewProfilesArray.find((previewProfile: camera.Profile) => {
129    return Math.abs((previewProfile.size.width / previewProfile.size.height) -
130      (mVideoProfile.size.width / mVideoProfile.size.height)) < Number.EPSILON;
131  });
132}
133
134async function getVideoSurfaceId() {
135  console.info(TAG, 'getVideoSurfaceId begin.');
136  let fileName: string = resourceName();
137  fdNumber = await getFd(fileName);
138  fdPath = "fd://" + fdNumber;
139  console.info(TAG, 'case fdPath is: ' + fdPath);
140  videoConfig.url = fdPath;
141  console.info(TAG, 'get videoConfig url.');
142  mAVRecorder = await media.createAVRecorder();
143  expect(isEmpty(mAVRecorder)).assertFalse();
144  console.info(TAG, 'createAVRecorder passed. state: ' + mAVRecorder.state);
145  await mAVRecorder.prepare(videoConfig).then(() => {
146    console.info('prepare success');
147  }).catch((error: BusinessError) => {
148    console.error(TAG, 'failed to prepare, err: ' + error.code + ', msg: ' + error.message);
149  });
150  console.info(TAG, 'AVRecorder state: ' + mAVRecorder.state);
151  mVideoSurfaceId = await mAVRecorder.getInputSurface();
152  console.info(TAG, 'mVideoSurfaceId: ' + mVideoSurfaceId);
153}
154
155async function getVideoSession(testName: string, previewOutput: camera.PreviewOutput, videoOutput: camera.VideoOutput) {
156  console.info(TAG, 'getVideoSession.');
157  mVideoSession = mCameraManager.createSession(mSupportedModes[1]);
158  mVideoSession.beginConfig();
159  console.info(TAG, testName + ' beginConfig passed.');
160  mVideoSession.addInput(mCameraInput);
161  console.info(TAG, testName + ' addInput passed.');
162  await mCameraInput.open();
163  console.info(TAG, testName + ' camera open passed.');
164  mVideoSession.addOutput(previewOutput);
165  console.info(TAG, testName + ' addOutput previewOutput passed.');
166  mVideoSession.addOutput(videoOutput);
167  console.info(TAG, testName + ' addOutput videoOutput passed.');
168  await mVideoSession.commitConfig();
169  console.info(TAG, testName + ' session commitConfig successfully.');
170}
171
172async function releaseVideoSession() {
173  console.info(TAG, 'releaseSession.');
174  await mPreviewOutput?.release();
175  await mVideoOutput?.release();
176  await mVideoSession?.release();
177}
178
179function onErrorListen(testName: string, videoOutput: camera.VideoOutput) {
180  videoOutput.on('error', (error) => {
181    if (error !== undefined && error.code !== 0) {
182      console.error(TAG, testName + ' failed to listen on, err: ' + error.code + ', msg: ' + error.message);
183      expect().assertFail();
184    } else {
185      console.info(TAG, testName + ' listen on passed.');
186      expect(true).assertTrue();
187    }
188  });
189}
190
191export default function VideoOutputTest() {
192  describe('VideoOutputTest', () => {
193    beforeAll(async () => {
194      console.info(TAG, 'beforeAll case.');
195      getCameraManager();
196      getSupportedCameraDeviceArray();
197      getSupportedModes();
198      getOutputCapability();
199      await getPermission();
200      await driveFn();
201      getCameraInput();
202      getPreviewProfile();
203    });
204
205    beforeEach(() => {
206      console.info(TAG, 'beforeEach case.');
207    });
208
209    afterEach(async () => {
210      console.info(TAG, 'afterEach case.');
211      if (!isEmpty(mAVRecorder)) {
212        await mAVRecorder.release();
213      }
214      await sleep(COMMON_WAIT_DURATION);
215    });
216
217    afterAll(async () => {
218      console.info(TAG, 'afterAll case.');
219      await closeFd(fdNumber);
220    });
221
222    /**
223     * @tc.number    : CAMERA_OUTPUT_VIDEO_001
224     * @tc.name      : start_video_output_callback_001
225     * @tc.desc      : No abnormal scenarios-start()-callback
226     * @tc.size      : MEDIUM
227     * @tc.type      : Function
228     * @tc.level     : Level 0
229     */
230    it('start_video_output_callback_001', Level.LEVEL0, async (done: Function) => {
231      const testName = 'start_video_output_callback_001';
232      console.info(TAG, testName + ' begin.');
233      try {
234        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
235          console.info(TAG, testName + ' cameraManager is null.');
236          expect().assertFail();
237        } else {
238          if (isEmpty(mPreviewProfile)) {
239            console.info(TAG, testName + ' no same resolution preview.');
240            expect(isEmpty(mPreviewProfile)).assertTrue();
241          } else {
242            await getVideoSurfaceId();
243            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
244            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
245            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
246            mVideoOutput.start((error) => {
247              if (error !== undefined && error.code !== 0) {
248                console.error(TAG, testName + ' failed to start, err: ' + error.code + ', msg: ' + error.message);
249                expect().assertFail();
250              } else {
251                console.info(TAG, testName + ' start passed.');
252                expect(true).assertTrue();
253              }
254            });
255            console.info(TAG, testName + ' start end.');
256            await releaseVideoSession();
257          }
258        }
259        done();
260      } catch (error) {
261        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
262        expect().assertFail();
263        done();
264      }
265    })
266
267    /**
268     * @tc.number    : CAMERA_OUTPUT_VIDEO_002
269     * @tc.name      : start_video_output_promise_001
270     * @tc.desc      : No abnormal scenarios-start()-promise
271     * @tc.size      : MEDIUM
272     * @tc.type      : Function
273     * @tc.level     : Level 0
274     */
275    it('start_video_output_promise_001', Level.LEVEL0, async (done: Function) => {
276      const testName = 'start_video_output_promise_001';
277      console.info(TAG, testName + ' begin.');
278      try {
279        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
280          console.info(TAG, testName + ' cameraManager is null.');
281          expect().assertFail();
282        } else {
283          if (isEmpty(mPreviewProfile)) {
284            console.info(TAG, testName + ' No preview with the same resolution.');
285            expect(isEmpty(mPreviewProfile)).assertTrue();
286          } else {
287            await getVideoSurfaceId();
288            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
289            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
290            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
291            await mVideoOutput.start().then(() => {
292              console.info(TAG, testName + ' start passed.');
293              expect(true).assertTrue();
294            }).catch((error: BusinessError) => {
295              console.error(TAG, testName + ' failed to start, err: ' + error.code + ', msg: ' + error.message);
296              expect().assertFail();
297            });
298            console.info(TAG, testName + ' start end.');
299            await releaseVideoSession();
300          }
301        }
302        done();
303      } catch (error) {
304        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
305        expect().assertFail();
306        done();
307      }
308    })
309
310    /**
311     * @tc.number    : CAMERA_OUTPUT_VIDEO_003
312     * @tc.name      : stop_video_output_callback_001
313     * @tc.desc      : No abnormal scenarios-stop()-callback
314     * @tc.size      : MEDIUM
315     * @tc.type      : Function
316     * @tc.level     : Level 0
317     */
318    it('stop_video_output_callback_001', Level.LEVEL0, async (done: Function) => {
319      const testName = 'stop_video_output_callback_001';
320      console.info(TAG, testName + ' begin.');
321      try {
322        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
323          console.info(TAG, testName + ' cameraManager is null.');
324          expect().assertFail();
325        } else {
326          if (isEmpty(mPreviewProfile)) {
327            console.info(TAG, testName + ' No preview with the same resolution.');
328            expect(isEmpty(mPreviewProfile)).assertTrue();
329          } else {
330            await getVideoSurfaceId();
331            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
332            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
333            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
334            mVideoOutput.stop((error) => {
335              if (error !== undefined && error.code !== 0) {
336                console.error(TAG, testName + ' failed to stop, err: ' + error.code + ', msg: ' + error.message);
337                expect().assertFail();
338              } else {
339                console.info(TAG, testName + ' stop passed.');
340                expect(true).assertTrue();
341              }
342            });
343            console.info(TAG, testName + ' stop end.');
344            await releaseVideoSession();
345          }
346        }
347        done();
348      } catch (error) {
349        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
350        expect().assertFail();
351        done();
352      }
353    })
354
355    /**
356     * @tc.number    : CAMERA_OUTPUT_VIDEO_004
357     * @tc.name      : stop_video_output_promise_001
358     * @tc.desc      : No abnormal scenarios-stop()-promise
359     * @tc.size      : MEDIUM
360     * @tc.type      : Function
361     * @tc.level     : Level 0
362     */
363    it('stop_video_output_promise_001', Level.LEVEL0, async (done: Function) => {
364      const testName = 'stop_video_output_promise_001';
365      console.info(TAG, testName + ' begin.');
366      try {
367        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
368          console.info(TAG, testName + ' cameraManager is null.');
369          expect().assertFail();
370        } else {
371          if (isEmpty(mPreviewProfile)) {
372            console.info(TAG, testName + ' No preview with the same resolution.');
373            expect(isEmpty(mPreviewProfile)).assertTrue();
374          } else {
375            await getVideoSurfaceId();
376            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
377            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
378            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
379            await mVideoOutput.stop().then(() => {
380              console.info(TAG, testName + ' stop passed.');
381              expect(true).assertTrue();
382            }).catch((error: BusinessError) => {
383              console.error(TAG, testName + ' failed to stop, err: ' + error.code + ', msg: ' + error.message);
384              expect().assertFail();
385            });
386            console.info(TAG, testName + ' stop end.');
387            await releaseVideoSession();
388          }
389        }
390        done();
391      } catch (error) {
392        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
393        expect().assertFail();
394        done();
395      }
396    })
397
398    /**
399     * @tc.number    : CAMERA_OUTPUT_VIDEO_005
400     * @tc.name      : on_error_listen_video_output_001
401     * @tc.desc      : No abnormal scenarios-listen on error
402     * @tc.size      : MEDIUM
403     * @tc.type      : Function
404     * @tc.level     : Level 0
405     */
406    it('on_error_listen_video_output_001', Level.LEVEL0, async (done: Function) => {
407      const testName = 'on_error_listen_video_output_001';
408      console.info(TAG, testName + ' begin.');
409      try {
410        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
411          console.info(TAG, testName + ' cameraManager is null.');
412          expect().assertFail();
413        } else {
414          if (isEmpty(mPreviewProfile)) {
415            console.info(TAG, testName + ' No preview with the same resolution.');
416            expect(isEmpty(mPreviewProfile)).assertTrue();
417          } else {
418            await getVideoSurfaceId();
419            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
420            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
421            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
422            onErrorListen(testName, mVideoOutput);
423            console.info(TAG, testName + ' on error listen end.');
424            await releaseVideoSession();
425          }
426        }
427        done();
428      } catch (error) {
429        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
430        expect(error.code == cameraErrorCode.SERVICE_FATAL_ERROR).assertFail();
431        await releaseVideoSession();
432        done();
433      }
434    })
435
436    /**
437     * @tc.number    : CAMERA_OUTPUT_VIDEO_006
438     * @tc.name      : off_error_listen_video_output_001
439     * @tc.desc      : No abnormal scenarios-listen on error
440     * @tc.size      : MEDIUM
441     * @tc.type      : Function
442     * @tc.level     : Level 0
443     */
444    it('off_error_listen_video_output_001', Level.LEVEL0, async (done: Function) => {
445      const testName = 'off_error_listen_video_output_001';
446      console.info(TAG, testName + ' begin.');
447      try {
448        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
449          console.info(TAG, testName + ' cameraManager is null.');
450          expect().assertFail();
451        } else {
452          if (isEmpty(mPreviewProfile)) {
453            console.info(TAG, testName + ' No preview with the same resolution.');
454            expect(isEmpty(mPreviewProfile)).assertTrue();
455          } else {
456            await getVideoSurfaceId();
457            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
458            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
459            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
460            onErrorListen(testName, mVideoOutput);
461            mVideoOutput.off('error');
462            console.info(TAG, testName + ' off error listen end.');
463            await releaseVideoSession();
464          }
465        }
466        done();
467      } catch (error) {
468        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
469        expect(error.code == cameraErrorCode.SERVICE_FATAL_ERROR).assertFail();
470        await releaseVideoSession();
471        done();
472      }
473    })
474
475    /**
476     * @tc.number    : CAMERA_OUTPUT_VIDEO_007
477     * @tc.name      : on_error_listen_video_output_abnormal_001
478     * @tc.desc      : No config, only listen error -> error_code: 7400201
479     * @tc.size      : MEDIUM
480     * @tc.type      : Function
481     * @tc.level     : Level 0
482     */
483    it('on_error_listen_video_output_abnormal_001', Level.LEVEL0, async (done: Function) => {
484      const testName = 'on_error_listen_video_output_abnormal_001';
485      console.info(TAG, testName + ' begin.');
486      try {
487        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
488          console.info(TAG, testName + ' cameraManager is null.');
489          expect().assertFail();
490        } else {
491          if (isEmpty(mPreviewProfile)) {
492            console.info(TAG, testName + ' No preview with the same resolution.');
493            expect(isEmpty(mPreviewProfile)).assertTrue();
494          } else {
495            await getVideoSurfaceId();
496            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
497            onErrorListen(testName, mVideoOutput);
498            console.info(TAG, testName + ' on error listen end.');
499            await mVideoOutput.release();
500            console.info(TAG, testName + ' release session end.');
501          }
502        }
503        done();
504      } catch (error) {
505        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
506        expect(error.code == cameraErrorCode.SERVICE_FATAL_ERROR).assertTrue();
507        await releaseVideoSession();
508        done();
509      }
510    })
511
512    /**
513     * @tc.number    : CAMERA_OUTPUT_VIDEO_008
514     * @tc.name      : off_error_listen_video_output_abnormal_001
515     * @tc.desc      : No config, only listen error -> error_code: 7400201
516     * @tc.size      : MEDIUM
517     * @tc.type      : Function
518     * @tc.level     : Level 0
519     */
520    it('off_error_listen_video_output_abnormal_001', Level.LEVEL0, async (done: Function) => {
521      const testName = 'off_error_listen_video_output_abnormal_001';
522      console.info(TAG, testName + ' begin.');
523      try {
524        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
525          console.info(TAG, testName + ' cameraManager is null.');
526          expect().assertFail();
527        } else {
528          if (isEmpty(mPreviewProfile)) {
529            console.info(TAG, testName + ' No preview with the same resolution.');
530            expect(isEmpty(mPreviewProfile)).assertTrue();
531          } else {
532            await getVideoSurfaceId();
533            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
534            onErrorListen(testName, mVideoOutput);
535            mVideoOutput.off('error');
536            console.info(TAG, testName + ' off error listen end.');
537            await mVideoOutput.release();
538            console.info(TAG, testName + ' release session end.');
539          }
540        }
541        done();
542      } catch (error) {
543        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
544        expect(error.code == cameraErrorCode.SERVICE_FATAL_ERROR).assertTrue();
545        done();
546      }
547    })
548
549    /**
550     * @tc.number    : CAMERA_OUTPUT_VIDEO_009
551     * @tc.name      : release_video_output_callback_001
552     * @tc.desc      : video output release-callback
553     * @tc.size      : MEDIUM
554     * @tc.type      : Function
555     * @tc.level     : Level 0
556     */
557    it('release_video_output_callback_001', Level.LEVEL0, async (done: Function) => {
558      const testName = 'release_video_output_callback_001';
559      console.info(TAG, testName + ' begin.');
560      try {
561        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
562          console.info(TAG, testName + ' cameraManager is null.');
563          expect().assertFail();
564        } else {
565          if (isEmpty(mPreviewProfile)) {
566            console.info(TAG, testName + ' No preview with the same resolution.');
567            expect(isEmpty(mPreviewProfile)).assertTrue();
568          } else {
569            await getVideoSurfaceId();
570            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
571            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
572            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
573            console.info(TAG, testName + ' getPhotoSession passed.');
574            mVideoOutput.release((error) => {
575              if (error !== undefined && error.code !== 0) {
576                console.error(TAG,
577                  testName + ' failed to release previewOutput, err: ' + error.code + ', msg: ' + error.message);
578                expect().assertFail();
579              } else {
580                console.info(TAG, testName + ' release passed.');
581                expect(true).assertTrue();
582              }
583            });
584            await mPreviewOutput.release();
585            await mVideoSession.release();
586            console.info(TAG, testName + ' end.');
587          }
588        }
589        done();
590      } catch (error) {
591        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
592        expect().assertFail();
593        await releaseVideoSession();
594        done();
595      }
596    })
597
598    /**
599     * @tc.number    : CAMERA_OUTPUT_VIDEO_010
600     * @tc.name      : release_video_output_promise_001
601     * @tc.desc      : video output release-promise
602     * @tc.size      : MEDIUM
603     * @tc.type      : Function
604     * @tc.level     : Level 0
605     */
606    it('release_video_output_promise_001', Level.LEVEL0, async (done: Function) => {
607      const testName = 'release_video_output_promise_001';
608      console.info(TAG, testName + ' begin.');
609      try {
610        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
611          console.info(TAG, testName + ' cameraManager is null.');
612          expect().assertFail();
613        } else {
614          if (isEmpty(mPreviewProfile)) {
615            console.info(TAG, testName + ' No preview with the same resolution.');
616            expect(isEmpty(mPreviewProfile)).assertTrue();
617          } else {
618            await getVideoSurfaceId();
619            mVideoOutput = mCameraManager.createVideoOutput(mVideoProfile, mVideoSurfaceId);
620            mPreviewOutput = mCameraManager.createPreviewOutput(mPreviewProfile, indexSurfaceId);
621            await getVideoSession(testName, mPreviewOutput, mVideoOutput);
622            console.info(TAG, testName + ' getPhotoSession passed.');
623            await mVideoOutput.release().then(() => {
624              console.info(TAG, testName + ' release videoOutput passed.');
625              expect(true).assertTrue();
626            }).catch((error: BusinessError) => {
627              console.error(TAG,
628                testName + ' failed to release videoOutput, err: ' + error.code + ', msg: ' + error.message);
629              expect().assertFail();
630            });
631            await mPreviewOutput.release();
632            await mVideoSession.release();
633            console.info(TAG, testName + ' end.');
634          }
635        }
636        done();
637      } catch (error) {
638        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
639        expect().assertFail();
640        await releaseVideoSession();
641        done();
642      }
643    })
644  })
645}