• 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 { cameraErrorCode, driveFn, getPermission, isEmpty } from '../common';
20import { indexSurfaceId } from '../../testability/pages/Index';
21import { BusinessError } from '@kit.BasicServicesKit';
22import { image } from '@kit.ImageKit';
23import { photoAccessHelper } from '@kit.MediaLibraryKit';
24
25const TAG = "CameraXts.PhotoOutputTest";
26const InvalidParam = -1;
27const captureLocation: camera.Location = {
28  latitude: 0,
29  longitude: 0,
30  altitude: 0
31};
32const InvalidLocation: camera.Location = {
33  latitude: InvalidParam,
34  longitude: InvalidParam,
35  altitude: InvalidParam
36};
37const NewCaptureLocation: camera.Location = {
38  latitude: 99999,
39  longitude: 99999,
40  altitude: 99999
41};
42
43let mCameraManager: camera.CameraManager;
44let mCameraDeviceArray: Array<camera.CameraDevice>;
45let mSupportedModes: Array<camera.SceneMode>;
46let mCameraInput: camera.CameraInput;
47let mCameraOutputCap: camera.CameraOutputCapability;
48let mPreviewOutput: camera.PreviewOutput;
49let mPhotoOutput: camera.PhotoOutput;
50let mPhotoSession: camera.PhotoSession;
51let testContext: common.UIAbilityContext = AppStorage.get('testContext') as common.UIAbilityContext;
52
53function getCameraManager() {
54  console.info(TAG, 'getCameraManager.');
55  mCameraManager = camera.getCameraManager(testContext);
56  if (isEmpty(mCameraManager)) {
57    return false;
58  }
59  console.info(TAG, 'mCameraManager created successfully.');
60  return true;
61}
62
63function getSupportedCameraDeviceArray() {
64  console.info(TAG, 'getSupportedCameraDeviceArray.');
65  mCameraDeviceArray = mCameraManager.getSupportedCameras();
66  if (isEmpty(mCameraDeviceArray)) {
67    return false;
68  }
69  console.info(TAG, 'getSupportedCameraDeviceArray length: ' + mCameraDeviceArray.length);
70  return true;
71}
72
73function getCameraInput() {
74  console.info(TAG, 'getCameraInput.');
75  mCameraInput = mCameraManager.createCameraInput(mCameraDeviceArray[0]);
76  if (isEmpty(mCameraInput)) {
77    return false;
78  }
79  console.info(TAG, 'cameraInput created successfully.');
80  return true;
81}
82
83function getSupportedModes() {
84  console.info(TAG, 'getSupportedModes.');
85  for (let i = 0; i < mCameraDeviceArray.length; i++) {
86    mSupportedModes = mCameraManager.getSupportedSceneModes(mCameraDeviceArray[i]);
87    if (isEmpty(mSupportedModes)) {
88      return false;
89    }
90    console.info(TAG, 'mSupportedModes: ' + JSON.stringify(mSupportedModes));
91  }
92  return true;
93}
94
95function getOutputCapability() {
96  console.info(TAG, 'getOutputCapability.');
97  mCameraOutputCap = mCameraManager.getSupportedOutputCapability(mCameraDeviceArray[0], mSupportedModes[0]);
98  console.info(TAG, 'camera, output cap: ' + JSON.stringify(mCameraOutputCap));
99}
100
101async function getPhotoSession(testName: string, previewOutput: camera.PreviewOutput, photoOutput: camera.PhotoOutput) {
102  console.info(TAG, 'getPhotoSession.');
103  mPhotoSession = mCameraManager.createSession(mSupportedModes[0]);
104  console.info(TAG, testName + ' createSession passed.');
105  mPhotoSession.beginConfig();
106  console.info(TAG, testName + ' beginConfig passed.');
107  mPhotoSession.addInput(mCameraInput);
108  console.info(TAG, testName + ' addInput passed.');
109  await mCameraInput.open();
110  console.info(TAG, testName + ' open passed.');
111  mPhotoSession.addOutput(previewOutput);
112  console.info(TAG, testName + ' addOutput previewOutput passed.');
113  mPhotoSession.addOutput(photoOutput);
114  console.info(TAG, testName + ' addOutput photoOutput passed.');
115  await mPhotoSession.commitConfig();
116  console.info(TAG, testName + ' commitConfig passed.');
117}
118
119async function releasePhotoSession() {
120  console.info(TAG, 'releasePhotoSession.');
121  await mPreviewOutput?.release();
122  await mPhotoOutput?.release();
123  await mPhotoSession?.release();
124}
125
126async function captureWithSettingsCallback(done: Function, testName: string,
127  settings: camera.PhotoCaptureSetting | undefined | null) {
128  console.info(TAG, testName + ' begin.');
129  try {
130    if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
131      console.info(TAG, testName + ' cameraManager is null.');
132      expect().assertFail();
133    } else {
134      mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
135      mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
136      await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
137      mPhotoOutput.capture(settings as camera.PhotoCaptureSetting, (error) => {
138        if (error !== undefined && error.code !== 0) {
139          console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
140          expect().assertFail();
141        } else {
142          console.info(TAG, testName + ' capture passed.');
143          expect(true).assertTrue();
144        }
145      });
146      console.info(TAG, testName + ' capture end.');
147      await releasePhotoSession();
148    }
149    done();
150  } catch (error) {
151    console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
152    expect(error.code == cameraErrorCode.INVALID_ARGUMENT).assertTrue();
153    await releasePhotoSession();
154    done();
155  }
156}
157
158async function captureWithSettingsPromise(done: Function, testName: string,
159  settings: camera.PhotoCaptureSetting | undefined | null) {
160  console.info(TAG, testName + ' begin.');
161  try {
162    if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
163      console.info(TAG, testName + ' cameraManager is null.');
164      expect().assertFail();
165    } else {
166      mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
167      mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
168      await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
169      await mPhotoOutput.capture(settings as camera.PhotoCaptureSetting).then(() => {
170        console.info(TAG, testName + ' capture passed.');
171        expect(true).assertTrue();
172      }).catch(async (error: BusinessError) => {
173        console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
174        expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
175        done();
176      });
177      console.info(TAG, testName + ' capture end.');
178      await releasePhotoSession();
179    }
180    done();
181  } catch (error) {
182    console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
183    expect(error.code == cameraErrorCode.INVALID_ARGUMENT).assertTrue();
184    await releasePhotoSession();
185    done();
186  }
187}
188
189export default function PhotoOutputTest() {
190  describe('PhotoOutputTest', () => {
191    beforeAll(async () => {
192      console.info(TAG, 'beforeAll case.');
193      getCameraManager();
194      getSupportedCameraDeviceArray();
195      getSupportedModes();
196      getOutputCapability();
197      await getPermission();
198      await driveFn();
199      getCameraInput();
200    });
201
202    beforeEach(() => {
203      console.info(TAG, 'beforeEach case.');
204    });
205
206    afterEach(() => {
207      console.info(TAG, 'afterEach case.');
208    });
209
210    afterAll(() => {
211      console.info(TAG, 'afterAll case.');
212    });
213
214    /**
215     * @tc.number    : CAMERA_OUTPUT_PHOTO_001
216     * @tc.name      : capture_callback_001
217     * @tc.desc      : No abnormal scenarios-capture-callback
218     * @tc.size      : MEDIUM
219     * @tc.type      : Function
220     * @tc.level     : Level 0
221     */
222    it('capture_callback_001', Level.LEVEL0, async (done: Function) => {
223      const testName = 'capture_callback_001';
224      console.info(TAG, testName + ' begin.');
225      try {
226        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
227          console.info(TAG, testName + ' cameraManager is null.');
228          expect().assertFail();
229        } else {
230          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
231          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
232          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
233          mPhotoOutput.capture((error) => {
234            if (error !== undefined && error.code !== 0) {
235              console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
236              expect().assertFail();
237            } else {
238              console.info(TAG, testName + ' capture passed.');
239              expect(true).assertTrue();
240            }
241          });
242          console.info(TAG, testName + ' capture end.');
243          await releasePhotoSession();
244          console.info(TAG, testName + ' release session.');
245        }
246        done();
247      } catch (error) {
248        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
249        expect().assertFail();
250        await releasePhotoSession();
251        done();
252      }
253    })
254
255    /**
256     * @tc.number    : CAMERA_OUTPUT_PHOTO_002
257     * @tc.name      : capture_promise_001
258     * @tc.desc      : No abnormal scenarios-capture-promise
259     * @tc.size      : MEDIUM
260     * @tc.type      : Function
261     * @tc.level     : Level 0
262     */
263    it('capture_promise_001', Level.LEVEL0, async (done: Function) => {
264      const testName = 'capture_promise_001';
265      console.info(TAG, testName + ' begin.');
266      try {
267        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
268          console.info(TAG, testName + ' cameraManager is null.');
269          expect().assertFail();
270        } else {
271          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
272          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
273          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
274          await mPhotoOutput.capture().then(() => {
275            console.info(TAG, testName + ' capture passed.');
276            expect(true).assertTrue();
277          }).catch((error: BusinessError) => {
278            console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
279            expect().assertFail();
280          });
281          console.info(TAG, testName + ' capture end.');
282          await releasePhotoSession();
283          console.info(TAG, testName + ' release session.');
284        }
285        done();
286      } catch (error) {
287        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
288        expect().assertFail();
289        await releasePhotoSession();
290        done();
291      }
292    })
293
294    /**
295     * @tc.number    : CAMERA_OUTPUT_PHOTO_003
296     * @tc.name      : capture_callback_with_setting_001
297     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_HIGH
298     * @tc.size      : MEDIUM
299     * @tc.type      : Function
300     * @tc.level     : Level 0
301     */
302    it('capture_callback_with_setting_001', Level.LEVEL0, async (done: Function) => {
303      const testName = 'capture_callback_with_setting_001';
304      let settings: camera.PhotoCaptureSetting = {
305        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
306        rotation: camera.ImageRotation.ROTATION_0,
307        location: captureLocation,
308        mirror: false
309      };
310      captureWithSettingsCallback(done, testName, settings);
311    })
312
313    /**
314     * @tc.number    : CAMERA_OUTPUT_PHOTO_004
315     * @tc.name      : capture_callback_with_setting_002
316     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_MEDIUM
317     * @tc.size      : MEDIUM
318     * @tc.type      : Function
319     * @tc.level     : Level 0
320     */
321    it('capture_callback_with_setting_002', Level.LEVEL0, async (done: Function) => {
322      const testName = 'capture_callback_with_setting_002';
323      let settings: camera.PhotoCaptureSetting = {
324        quality: camera.QualityLevel.QUALITY_LEVEL_MEDIUM,
325        rotation: camera.ImageRotation.ROTATION_0,
326        location: captureLocation,
327        mirror: false
328      };
329      await captureWithSettingsCallback(done, testName, settings);
330    })
331
332    /**
333     * @tc.number    : CAMERA_OUTPUT_PHOTO_005
334     * @tc.name      : capture_callback_with_setting_003
335     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_LOW
336     * @tc.size      : MEDIUM
337     * @tc.type      : Function
338     * @tc.level     : Level 0
339     */
340    it('capture_callback_with_setting_003', Level.LEVEL0, async (done: Function) => {
341      const testName = 'capture_callback_with_setting_003';
342      let settings: camera.PhotoCaptureSetting = {
343        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
344        rotation: camera.ImageRotation.ROTATION_0,
345        location: captureLocation,
346        mirror: false
347      };
348      await captureWithSettingsCallback(done, testName, settings);
349    })
350
351    /**
352     * @tc.number    : CAMERA_OUTPUT_PHOTO_006
353     * @tc.name      : capture_callback_with_setting_004
354     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_90
355     * @tc.size      : MEDIUM
356     * @tc.type      : Function
357     * @tc.level     : Level 0
358     */
359    it('capture_callback_with_setting_004', Level.LEVEL0, async (done: Function) => {
360      const testName = 'capture_callback_with_setting_004';
361      let settings: camera.PhotoCaptureSetting = {
362        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
363        rotation: camera.ImageRotation.ROTATION_90,
364        location: captureLocation,
365        mirror: false
366      };
367      await captureWithSettingsCallback(done, testName, settings);
368    })
369
370    /**
371     * @tc.number    : CAMERA_OUTPUT_PHOTO_007
372     * @tc.name      : capture_callback_with_setting_005
373     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_180
374     * @tc.size      : MEDIUM
375     * @tc.type      : Function
376     * @tc.level     : Level 0
377     */
378    it('capture_callback_with_setting_005', Level.LEVEL0, async (done: Function) => {
379      const testName = 'capture_callback_with_setting_005';
380      let settings: camera.PhotoCaptureSetting = {
381        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
382        rotation: camera.ImageRotation.ROTATION_180,
383        location: captureLocation,
384        mirror: false
385      };
386      await captureWithSettingsCallback(done, testName, settings);
387    })
388
389    /**
390     * @tc.number    : CAMERA_OUTPUT_PHOTO_008
391     * @tc.name      : capture_callback_with_setting_006
392     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_270
393     * @tc.size      : MEDIUM
394     * @tc.type      : Function
395     * @tc.level     : Level 0
396     */
397    it('capture_callback_with_setting_006', Level.LEVEL0, async (done: Function) => {
398      const testName = 'capture_callback_with_setting_006';
399      let settings: camera.PhotoCaptureSetting = {
400        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
401        rotation: camera.ImageRotation.ROTATION_270,
402        location: captureLocation,
403        mirror: false
404      };
405      await captureWithSettingsCallback(done, testName, settings);
406    })
407
408    /**
409     * @tc.number    : CAMERA_OUTPUT_PHOTO_009
410     * @tc.name      : capture_callback_with_setting_007
411     * @tc.desc      : No abnormal scenarios-location
412     * @tc.size      : MEDIUM
413     * @tc.type      : Function
414     * @tc.level     : Level 0
415     */
416    it('capture_callback_with_setting_007', Level.LEVEL0, async (done: Function) => {
417      const testName = 'capture_callback_with_setting_007';
418      let settings: camera.PhotoCaptureSetting = {
419        location: NewCaptureLocation,
420      };
421      await captureWithSettingsCallback(done, testName, settings);
422    })
423
424    /**
425     * @tc.number    : CAMERA_OUTPUT_PHOTO_010
426     * @tc.name      : capture_callback_with_setting_008
427     * @tc.desc      : No abnormal scenarios-mirror-true
428     * @tc.size      : MEDIUM
429     * @tc.type      : Function
430     * @tc.level     : Level 0
431     */
432    it('capture_callback_with_setting_008', Level.LEVEL0, async (done: Function) => {
433      const testName = 'capture_callback_with_setting_008';
434      let settings: camera.PhotoCaptureSetting = {
435        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
436        rotation: camera.ImageRotation.ROTATION_0,
437        mirror: true
438      };
439      await captureWithSettingsCallback(done, testName, settings);
440    })
441
442    /**
443     * @tc.number    : CAMERA_OUTPUT_PHOTO_011
444     * @tc.name      : capture_promise_with_setting_001
445     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_HIGH
446     * @tc.size      : MEDIUM
447     * @tc.type      : Function
448     * @tc.level     : Level 0
449     */
450    it('capture_promise_with_setting_001', Level.LEVEL0, async (done: Function) => {
451      const testName = 'capture_promise_with_setting_001';
452      let settings: camera.PhotoCaptureSetting = {
453        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
454        rotation: camera.ImageRotation.ROTATION_0,
455        location: captureLocation,
456        mirror: false
457      };
458      await captureWithSettingsPromise(done, testName, settings);
459    })
460
461    /**
462     * @tc.number    : CAMERA_OUTPUT_PHOTO_012
463     * @tc.name      : capture_promise_with_setting_002
464     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_MEDIUM
465     * @tc.size      : MEDIUM
466     * @tc.type      : Function
467     * @tc.level     : Level 0
468     */
469    it('capture_promise_with_setting_002', Level.LEVEL0, async (done: Function) => {
470      const testName = 'capture_promise_with_setting_002';
471      let settings: camera.PhotoCaptureSetting = {
472        quality: camera.QualityLevel.QUALITY_LEVEL_MEDIUM,
473        rotation: camera.ImageRotation.ROTATION_0,
474        location: captureLocation,
475        mirror: false
476      };
477      await captureWithSettingsPromise(done, testName, settings);
478    })
479
480    /**
481     * @tc.number    : CAMERA_OUTPUT_PHOTO_013
482     * @tc.name      : capture_promise_with_setting_003
483     * @tc.desc      : No abnormal scenarios-quality-QUALITY_LEVEL_LOW
484     * @tc.size      : MEDIUM
485     * @tc.type      : Function
486     * @tc.level     : Level 0
487     */
488    it('capture_promise_with_setting_003', Level.LEVEL0, async (done: Function) => {
489      const testName = 'capture_promise_with_setting_003';
490      let settings: camera.PhotoCaptureSetting = {
491        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
492        rotation: camera.ImageRotation.ROTATION_0,
493        location: captureLocation,
494        mirror: false
495      };
496      await captureWithSettingsPromise(done, testName, settings);
497    })
498
499    /**
500     * @tc.number    : CAMERA_OUTPUT_PHOTO_014
501     * @tc.name      : capture_promise_with_setting_004
502     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_90
503     * @tc.size      : MEDIUM
504     * @tc.type      : Function
505     * @tc.level     : Level 0
506     */
507    it('capture_promise_with_setting_004', Level.LEVEL0, async (done: Function) => {
508      const testName = 'capture_promise_with_setting_004';
509      let settings: camera.PhotoCaptureSetting = {
510        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
511        rotation: camera.ImageRotation.ROTATION_90,
512        location: captureLocation,
513        mirror: false
514      };
515      await captureWithSettingsPromise(done, testName, settings);
516    })
517
518    /**
519     * @tc.number    : CAMERA_OUTPUT_PHOTO_015
520     * @tc.name      : capture_promise_with_setting_005
521     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_180
522     * @tc.size      : MEDIUM
523     * @tc.type      : Function
524     * @tc.level     : Level 0
525     */
526    it('capture_promise_with_setting_005', Level.LEVEL0, async (done: Function) => {
527      const testName = 'capture_promise_with_setting_005';
528      let settings: camera.PhotoCaptureSetting = {
529        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
530        rotation: camera.ImageRotation.ROTATION_180,
531        location: captureLocation,
532        mirror: false
533      };
534      await captureWithSettingsPromise(done, testName, settings);
535    })
536
537    /**
538     * @tc.number    : CAMERA_OUTPUT_PHOTO_016
539     * @tc.name      : capture_promise_with_setting_006
540     * @tc.desc      : No abnormal scenarios
541     * @tc.size      : MEDIUM
542     * @tc.type      : Function
543     * @tc.level     : Level 0
544     */
545    it('capture_promise_with_setting_006', Level.LEVEL0, async (done: Function) => {
546      const testName = 'capture_promise_with_setting_006';
547      let settings: camera.PhotoCaptureSetting = {
548        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
549        rotation: camera.ImageRotation.ROTATION_270,
550        location: captureLocation,
551        mirror: false
552      };
553      await captureWithSettingsPromise(done, testName, settings);
554    })
555
556    /**
557     * @tc.number    : CAMERA_OUTPUT_PHOTO_017
558     * @tc.name      : capture_promise_with_setting_007
559     * @tc.desc      : No abnormal scenarios-rotation-ROTATION_270
560     * @tc.size      : MEDIUM
561     * @tc.type      : Function
562     * @tc.level     : Level 0
563     */
564    it('capture_promise_with_setting_007', Level.LEVEL0, async (done: Function) => {
565      const testName = 'capture_promise_with_setting_007';
566      let settings: camera.PhotoCaptureSetting = {
567        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
568        rotation: camera.ImageRotation.ROTATION_0,
569        location: NewCaptureLocation,
570        mirror: false
571      };
572      await captureWithSettingsPromise(done, testName, settings);
573    })
574
575    /**
576     * @tc.number    : CAMERA_OUTPUT_PHOTO_018
577     * @tc.name      : capture_promise_with_setting_008
578     * @tc.desc      : No abnormal scenarios-mirror-true
579     * @tc.size      : MEDIUM
580     * @tc.type      : Function
581     * @tc.level     : Level 0
582     */
583    it('capture_promise_with_setting_008', Level.LEVEL0, async (done: Function) => {
584      const testName = 'capture_promise_with_setting_008';
585      let settings: camera.PhotoCaptureSetting = {
586        quality: camera.QualityLevel.QUALITY_LEVEL_LOW,
587        rotation: camera.ImageRotation.ROTATION_0,
588        location: captureLocation,
589        mirror: true
590      };
591      await captureWithSettingsPromise(done, testName, settings);
592    })
593
594    /**
595     * @tc.number    : CAMERA_OUTPUT_PHOTO_019
596     * @tc.name      : on_photoAvailable_listen_001
597     * @tc.desc      : No abnormal scenarios
598     * @tc.size      : MEDIUM
599     * @tc.type      : Function
600     * @tc.level     : Level 0
601     */
602    it('on_photoAvailable_listen_001', Level.LEVEL0, async (done: Function) => {
603      const testName = 'on_photoAvailable_listen_001';
604      console.info(TAG, testName + ' begin.');
605      try {
606        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
607          console.info(TAG, testName + ' cameraManager is null.');
608          expect().assertFail();
609        } else {
610          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
611          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
612          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
613          mPhotoOutput.on('photoAvailable', (error, photo) => {
614            if (error !== undefined && error.code !== 0) {
615              console.error(TAG,
616                testName + ' failed to listen photoAvailable on, err: ' + error.code + ', msg: ' + error.message);
617              expect().assertFail();
618            } else {
619              let mainImage: image.Image = photo.main;
620              console.info(TAG, testName + ' succeed to listen photoAvailable on.');
621              expect(isEmpty(mainImage)).assertFalse();
622            }
623          });
624          await releasePhotoSession();
625        }
626        done();
627      } catch (error) {
628        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
629        expect().assertFail();
630        await releasePhotoSession();
631        done();
632      }
633    })
634
635    /**
636     * @tc.number    : CAMERA_OUTPUT_PHOTO_020
637     * @tc.name      : off_photoAvailable_listen_001
638     * @tc.desc      : No abnormal scenarios
639     * @tc.size      : MEDIUM
640     * @tc.type      : Function
641     * @tc.level     : Level 0
642     */
643    it('off_photoAvailable_listen_001', Level.LEVEL0, async (done: Function) => {
644      const testName = 'off_photoAvailable_listen_001';
645      console.info(TAG, testName + ' begin.');
646      try {
647        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
648          console.info(TAG, testName + ' cameraManager is null.');
649          expect().assertFail();
650        } else {
651          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
652          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
653          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
654          mPhotoOutput.on('photoAvailable', (error, photo) => {
655            if (error !== undefined && error.code !== 0) {
656              console.error(TAG,
657                testName + ' failed to listen photoAvailable on, err: ' + error.code + ', msg: ' + error.message);
658              expect().assertFail();
659            } else {
660              let mainImage: image.Image = photo.main;
661              console.info(TAG, testName + ' succeed to listen photoAvailable on.');
662              expect(isEmpty(mainImage)).assertFalse();
663            }
664          });
665          mPhotoOutput.off('photoAvailable', (error, photo) => {
666            if (error !== undefined && error.code !== 0) {
667              console.error(TAG,
668                testName + ' failed to listen photoAvailable off, err: ' + error.code + ', msg: ' + error.message);
669              expect().assertFail();
670            } else {
671              let mainImage: image.Image = photo.main;
672              console.info(TAG, testName + ' succeed to listen photoAvailable off.');
673              expect(isEmpty(mainImage)).assertFalse();
674            }
675          });
676          await releasePhotoSession();
677        }
678        done();
679      } catch (error) {
680        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
681        expect().assertFail();
682        await releasePhotoSession();
683        done();
684      }
685    })
686
687    /**
688     * @tc.number    : CAMERA_OUTPUT_PHOTO_021
689     * @tc.name      : on_photoAssetAvailable_listen_001
690     * @tc.desc      : No abnormal scenarios
691     * @tc.size      : MEDIUM
692     * @tc.type      : Function
693     * @tc.level     : Level 0
694     */
695    it('on_photoAssetAvailable_listen_001', Level.LEVEL0, async (done: Function) => {
696      const testName = 'on_photoAssetAvailable_listen_001';
697      console.info(TAG, testName + ' begin.');
698      try {
699        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
700          console.info(TAG, testName + ' cameraManager is null.');
701          expect().assertFail();
702        } else {
703          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
704          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
705          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
706          mPhotoOutput.on('photoAssetAvailable', (error, photoAsset: photoAccessHelper.PhotoAsset) => {
707            if ((error !== undefined && error.code !== 0) || photoAsset === undefined) {
708              console.error(TAG,
709                testName + ' failed to listen photoAvailable on, err: ' + error.code + ', msg: ' + error.message);
710              expect().assertFail();
711            } else {
712              console.info(TAG,
713                testName + ' succeed to listen photoAvailable on, photoAsset: ' + JSON.stringify(photoAsset));
714              expect(isEmpty(photoAsset)).assertFalse();
715            }
716          });
717          await mPhotoOutput.capture();
718          await releasePhotoSession();
719        }
720        done();
721      } catch (error) {
722        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
723        expect().assertFail();
724        await releasePhotoSession();
725        done();
726      }
727    })
728
729    /**
730     * @tc.number    : CAMERA_OUTPUT_PHOTO_022
731     * @tc.name      : off_photoAssetAvailable_listen_001
732     * @tc.desc      : No abnormal scenarios
733     * @tc.size      : MEDIUM
734     * @tc.type      : Function
735     * @tc.level     : Level 0
736     */
737    it('off_photoAssetAvailable_listen_001', Level.LEVEL0, async (done: Function) => {
738      const testName = 'off_photoAssetAvailable_listen_001';
739      console.info(TAG, testName + ' begin.');
740      try {
741        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
742          console.info(TAG, testName + ' cameraManager is null.');
743          expect().assertFail();
744        } else {
745          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
746          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
747          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
748          mPhotoOutput.on('photoAssetAvailable', (error, photoAsset: photoAccessHelper.PhotoAsset) => {
749            if (error !== undefined && error.code !== 0) {
750              console.error(TAG,
751                testName + ' failed to listen photoAssetAvailable on, err: ' + error.code + ', msg: ' + error.message);
752              expect().assertFail();
753            } else {
754              console.info(TAG,
755                testName + ' succeed to listen photoAssetAvailable on, photoAsset: ' + JSON.stringify(photoAsset));
756              expect(isEmpty(photoAsset)).assertFalse();
757            }
758          });
759          mPhotoOutput.off('photoAvailable', (error) => {
760            if (error !== undefined && error.code !== 0) {
761              console.error(TAG,
762                testName + ' failed to listen photoAssetAvailable off, err: ' + error.code + ', msg: ' + error.message);
763              expect().assertFail();
764              done();
765            } else {
766              console.info(TAG,
767                testName + ' succeed to listen photoAssetAvailable off.');
768              expect(true).assertTrue();
769              done();
770            }
771          });
772          await releasePhotoSession();
773        }
774        done();
775      } catch (error) {
776        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
777        expect().assertFail();
778        await releasePhotoSession();
779        done();
780      }
781    })
782
783    /**
784     * @tc.number    : CAMERA_OUTPUT_PHOTO_023
785     * @tc.name      : release_callback_photo_001
786     * @tc.desc      : No abnormal scenarios-release-callback
787     * @tc.size      : MEDIUM
788     * @tc.type      : Function
789     * @tc.level     : Level 0
790     */
791    it('release_callback_photo_001', Level.LEVEL0, async (done: Function) => {
792      const testName = 'release_callback_photo_001';
793      console.info(TAG, testName + ' begin.');
794      try {
795        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
796          console.info(TAG, testName + ' cameraManager is null.');
797          expect().assertFail();
798        } else {
799          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
800          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
801          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
802          console.info(TAG, testName + ' getPhotoSession passed.');
803          await mPreviewOutput.release();
804          mPhotoOutput.release((error) => {
805            if (error !== undefined && error.code !== 0) {
806              console.error(TAG,
807                testName + ' failed to release photoOutput, err: ' + error.code + ', msg: ' + error.message);
808              expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
809            } else {
810              console.info(TAG, testName + ' release passed.');
811              expect(true).assertTrue();
812            }
813          });
814          await mPhotoSession.release();
815          console.info(TAG, testName + ' end.');
816        }
817        done();
818      } catch (error) {
819        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
820        expect().assertFail();
821        done();
822      }
823    })
824
825    /**
826     * @tc.number    : CAMERA_OUTPUT_PHOTO_024
827     * @tc.name      : release_promise_photo_001
828     * @tc.desc      : No abnormal scenarios-release-promise
829     * @tc.size      : MEDIUM
830     * @tc.type      : Function
831     * @tc.level     : Level 0
832     */
833    it('release_promise_photo_001', Level.LEVEL0, async (done: Function) => {
834      const testName = 'release_promise_photo_001';
835      console.info(TAG, testName + ' begin.');
836      try {
837        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
838          console.info(TAG, testName + ' cameraManager is null.');
839          expect().assertFail();
840        } else {
841          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
842          mPreviewOutput = mCameraManager.createPreviewOutput(mCameraOutputCap.previewProfiles[0], indexSurfaceId);
843          await getPhotoSession(testName, mPreviewOutput, mPhotoOutput);
844          console.info(TAG, testName + ' getPhotoSession passed.');
845          await mPreviewOutput.release();
846          await mPhotoOutput.release().then(() => {
847            console.info(TAG, testName + ' release passed.');
848            expect(true).assertTrue();
849          }).catch((error: BusinessError) => {
850            console.error(TAG,
851              testName + ' failed to release photoOutput, err: ' + error.code + ', msg: ' + error.message);
852            expect().assertFail();
853          });
854          await mPhotoSession.release();
855          console.info(TAG, testName + ' end.');
856        }
857        done();
858      } catch (error) {
859        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
860        expect().assertFail();
861        done();
862      }
863    })
864
865    /**
866     * @tc.number    : CAMERA_OUTPUT_PHOTO_025
867     * @tc.name      : capture_callback_with_setting_abnormal_001
868     * @tc.desc      : callback, settings-undefined -> error_code: 7400101
869     * @tc.size      : MEDIUM
870     * @tc.type      : Function
871     * @tc.level     : Level 0
872     */
873    it('capture_callback_with_setting_abnormal_001', Level.LEVEL0, async (done: Function) => {
874      const testName = 'capture_callback_with_setting_abnormal_001';
875      let settings: camera.PhotoCaptureSetting | undefined = undefined;
876      await captureWithSettingsCallback(done, testName, settings);
877    })
878
879    /**
880     * @tc.number    : CAMERA_OUTPUT_PHOTO_026
881     * @tc.name      : capture_callback_with_setting_abnormal_002
882     * @tc.desc      : callback, settings quality-abnormal -> error_code: 7400101
883     * @tc.size      : MEDIUM
884     * @tc.type      : Function
885     * @tc.level     : Level 0
886     */
887    it('capture_callback_with_setting_abnormal_002', Level.LEVEL0, async (done: Function) => {
888      const testName = 'capture_callback_with_setting_abnormal_002';
889      let settings: camera.PhotoCaptureSetting = {
890        quality: InvalidParam,
891        rotation: camera.ImageRotation.ROTATION_0,
892        location: captureLocation,
893        mirror: false
894      };
895      await captureWithSettingsCallback(done, testName, settings);
896    })
897
898    /**
899     * @tc.number    : CAMERA_OUTPUT_PHOTO_027
900     * @tc.name      : capture_callback_with_setting_abnormal_003
901     * @tc.desc      : callback, settings rotation-abnormal -> error_code: 7400101
902     * @tc.size      : MEDIUM
903     * @tc.type      : Function
904     * @tc.level     : Level 0
905     */
906    it('capture_callback_with_setting_abnormal_003', Level.LEVEL0, async (done: Function) => {
907      const testName = 'capture_callback_with_setting_abnormal_003';
908      let settings: camera.PhotoCaptureSetting = {
909        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
910        rotation: InvalidParam,
911        location: captureLocation,
912        mirror: false
913      };
914      await captureWithSettingsCallback(done, testName, settings);
915    })
916
917    /**
918     * @tc.number    : CAMERA_OUTPUT_PHOTO_028
919     * @tc.name      : capture_callback_with_setting_abnormal_004
920     * @tc.desc      : callback, settings location-abnormal -> passed
921     * @tc.size      : MEDIUM
922     * @tc.type      : Function
923     * @tc.level     : Level 0
924     */
925    it('capture_callback_with_setting_abnormal_004', Level.LEVEL0, async (done: Function) => {
926      const testName = 'capture_callback_with_setting_abnormal_004';
927      let settings: camera.PhotoCaptureSetting = {
928        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
929        rotation: camera.ImageRotation.ROTATION_0,
930        location: InvalidLocation,
931        mirror: false
932      };
933      await captureWithSettingsCallback(done, testName, settings);
934    })
935
936    /**
937     * @tc.number    : CAMERA_OUTPUT_PHOTO_029
938     * @tc.name      : capture_callback_with_setting_abnormal_005
939     * @tc.desc      : callback, settings-null -> error_code: 7400101
940     * @tc.size      : MEDIUM
941     * @tc.type      : Function
942     * @tc.level     : Level 0
943     */
944    it('capture_callback_with_setting_abnormal_005', Level.LEVEL0, async (done: Function) => {
945      const testName = 'capture_callback_with_setting_abnormal_005';
946      let settings: camera.PhotoCaptureSetting | null = null;
947      await captureWithSettingsCallback(done, testName, settings);
948    })
949
950    /**
951     * @tc.number    : CAMERA_OUTPUT_PHOTO_030
952     * @tc.name      : capture_promise_with_setting_abnormal_001
953     * @tc.desc      : promise, settings-undefined -> error_code: 7400101
954     * @tc.size      : MEDIUM
955     * @tc.type      : Function
956     * @tc.level     : Level 0
957     */
958    it('capture_promise_with_setting_abnormal_001', Level.LEVEL0, async (done: Function) => {
959      const testName = 'capture_promise_with_setting_abnormal_001';
960      let settings: camera.PhotoCaptureSetting | undefined = undefined;
961      await captureWithSettingsPromise(done, testName, settings);
962    })
963
964    /**
965     * @tc.number    : CAMERA_OUTPUT_PHOTO_031
966     * @tc.name      : capture_promise_with_setting_abnormal_002
967     * @tc.desc      : promise, settings quality-abnormal -> error_code: 7400101
968     * @tc.size      : MEDIUM
969     * @tc.type      : Function
970     * @tc.level     : Level 0
971     */
972    it('capture_promise_with_setting_abnormal_002', Level.LEVEL0, async (done: Function) => {
973      const testName = 'capture_promise_with_setting_abnormal_002';
974      let settings: camera.PhotoCaptureSetting = {
975        quality: InvalidParam,
976        rotation: camera.ImageRotation.ROTATION_0,
977        location: captureLocation,
978        mirror: false
979      };
980      await captureWithSettingsPromise(done, testName, settings);
981    })
982
983    /**
984     * @tc.number    : CAMERA_OUTPUT_PHOTO_032
985     * @tc.name      : capture_promise_with_setting_abnormal_003
986     * @tc.desc      : promise, settings rotation-abnormal -> error_code: 7400101
987     * @tc.size      : MEDIUM
988     * @tc.type      : Function
989     * @tc.level     : Level 0
990     */
991    it('capture_promise_with_setting_abnormal_003', Level.LEVEL0, async (done: Function) => {
992      const testName = 'capture_promise_with_setting_abnormal_003';
993      let settings: camera.PhotoCaptureSetting = {
994        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
995        rotation: InvalidParam,
996        location: captureLocation,
997        mirror: false
998      };
999      await captureWithSettingsPromise(done, testName, settings);
1000    })
1001
1002    /**
1003     * @tc.number    : CAMERA_OUTPUT_PHOTO_033
1004     * @tc.name      : capture_promise_with_setting_abnormal_004
1005     * @tc.desc      : promise, settings location-abnormal -> passed
1006     * @tc.size      : MEDIUM
1007     * @tc.type      : Function
1008     * @tc.level     : Level 0
1009     */
1010    it('capture_promise_with_setting_abnormal_004', Level.LEVEL0, async (done: Function) => {
1011      const testName = 'capture_promise_with_setting_abnormal_004';
1012      let settings: camera.PhotoCaptureSetting = {
1013        quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
1014        rotation: camera.ImageRotation.ROTATION_0,
1015        location: InvalidLocation,
1016        mirror: false
1017      };
1018      await captureWithSettingsPromise(done, testName, settings);
1019    })
1020
1021    /**
1022     * @tc.number    : CAMERA_OUTPUT_PHOTO_034
1023     * @tc.name      : capture_promise_with_setting_abnormal_005
1024     * @tc.desc      : settings-undefined -> error_code: 7400101
1025     * @tc.size      : MEDIUM
1026     * @tc.type      : Function
1027     * @tc.level     : Level 0
1028     */
1029    it('capture_promise_with_setting_abnormal_005', Level.LEVEL0, async (done: Function) => {
1030      const testName = 'capture_promise_with_setting_abnormal_005';
1031      let settings: camera.PhotoCaptureSetting | null = null;
1032      await captureWithSettingsPromise(done, testName, settings);
1033    })
1034
1035    /**
1036     * @tc.number    : CAMERA_OUTPUT_PHOTO_035
1037     * @tc.name      : capture_callback_error_001
1038     * @tc.desc      : No session, only capture-callback -> error_code: 7400104
1039     * @tc.size      : MEDIUM
1040     * @tc.type      : Function
1041     * @tc.level     : Level 0
1042     */
1043    it('capture_callback_error_001', Level.LEVEL0, async (done: Function) => {
1044      const testName = 'capture_callback_error_001';
1045      console.info(TAG, testName + ' begin.');
1046      try {
1047        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
1048          console.info(TAG, testName + ' cameraManager is null.');
1049          expect().assertFail();
1050        } else {
1051          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
1052          await mCameraInput.open();
1053          console.info(TAG, testName + ' open passed.');
1054          mPhotoOutput.capture(async (error) => {
1055            if (error !== undefined && error.code !== 0) {
1056              console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
1057              expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
1058            } else {
1059              console.info(TAG, testName + ' capture passed.');
1060              expect(true).assertTrue();
1061            }
1062          });
1063          console.info(TAG, testName + ' capture end.');
1064          await mPhotoOutput.release();
1065          console.info(TAG, testName + ' release photoOutput.');
1066        }
1067        done();
1068      } catch (error) {
1069        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
1070        expect().assertFail();
1071        done();
1072      }
1073    })
1074
1075    /**
1076     * @tc.number    : CAMERA_OUTPUT_PHOTO_036
1077     * @tc.name      : capture_promise_error_001
1078     * @tc.desc      : No session, only capture-promise -> error_code: 7400104
1079     * @tc.size      : MEDIUM
1080     * @tc.type      : Function
1081     * @tc.level     : Level 0
1082     */
1083    it('capture_promise_error_001', Level.LEVEL0, async (done: Function) => {
1084      const testName = 'capture_promise_error_001';
1085      console.info(TAG, testName + ' begin.');
1086      try {
1087        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
1088          console.info(TAG, testName + ' cameraManager is null.');
1089          expect().assertFail();
1090        } else {
1091          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
1092          await mCameraInput.open();
1093          await mPhotoOutput.capture().then(() => {
1094            console.info(TAG, testName + ' capture passed.');
1095            expect(true).assertTrue();
1096          }).catch(async (error: BusinessError) => {
1097            console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
1098            expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
1099            done();
1100          });
1101          console.info(TAG, testName + ' capture end.');
1102          await mPhotoOutput.release();
1103          console.info(TAG, testName + ' release photoOutput.');
1104        }
1105        done();
1106      } catch (error) {
1107        console.error(TAG, testName + ' capture failed. err: ' + error.code + ', msg: ' + error.message);
1108        expect().assertFail();
1109        done();
1110      }
1111    })
1112
1113    /**
1114     * @tc.number    : CAMERA_OUTPUT_PHOTO_037
1115     * @tc.name      : capture_callback_with_setting_error_001
1116     * @tc.desc      : No session, only capture with settings-callback -> error_code: 7400104
1117     * @tc.size      : MEDIUM
1118     * @tc.type      : Function
1119     * @tc.level     : Level 0
1120     */
1121    it('capture_callback_with_setting_error_001', Level.LEVEL0, async (done: Function) => {
1122      const testName = 'capture_callback_with_setting_error_001';
1123      console.info(TAG, testName + ' begin.');
1124      try {
1125        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
1126          console.info(TAG, testName + ' cameraManager is null.');
1127          expect().assertFail();
1128        } else {
1129          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
1130          await mCameraInput.open();
1131          console.info(TAG, testName + ' open passed.');
1132          let settings: camera.PhotoCaptureSetting = {
1133            quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
1134            rotation: camera.ImageRotation.ROTATION_0
1135          }
1136          mPhotoOutput.capture(settings, async (error) => {
1137            if (error !== undefined && error.code !== 0) {
1138              console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
1139              expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
1140            } else {
1141              console.info(TAG, testName + ' capture passed.');
1142              expect(true).assertTrue();
1143            }
1144          });
1145          console.info(TAG, testName + ' capture end.');
1146          await mPhotoOutput.release();
1147          console.info(TAG, testName + ' release photoOutput.');
1148        }
1149        done();
1150      } catch (error) {
1151        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
1152        expect().assertFail();
1153        done();
1154      }
1155    })
1156
1157    /**
1158     * @tc.number    : CAMERA_OUTPUT_PHOTO_038
1159     * @tc.name      : capture_promise_with_setting_error_001
1160     * @tc.desc      : No session, only capture with settings-promise -> error_code: 7400104
1161     * @tc.size      : MEDIUM
1162     * @tc.type      : Function
1163     * @tc.level     : Level 0
1164     */
1165    it('capture_promise_with_setting_error_001', Level.LEVEL0, async (done: Function) => {
1166      const testName = 'capture_promise_with_setting_error_001';
1167      console.info(TAG, testName + ' begin.');
1168      try {
1169        if (isEmpty(mCameraManager) && isEmpty(mCameraDeviceArray)) {
1170          console.info(TAG, testName + ' cameraManager is null.');
1171          expect().assertFail();
1172        } else {
1173          mPhotoOutput = mCameraManager.createPhotoOutput(mCameraOutputCap.photoProfiles[0]);
1174          await mCameraInput.open();
1175          console.info(TAG, testName + ' open passed.');
1176          let settings: camera.PhotoCaptureSetting = {
1177            quality: camera.QualityLevel.QUALITY_LEVEL_HIGH,
1178            rotation: camera.ImageRotation.ROTATION_0
1179          }
1180          await mPhotoOutput.capture(settings).then(() => {
1181            console.info(TAG, testName + ' capture passed.');
1182            expect(true).assertTrue();
1183          }).catch(async (error: BusinessError) => {
1184            console.error(TAG, testName + ' failed to capture, err: ' + error.code + ', msg: ' + error.message);
1185            expect(error.code == cameraErrorCode.SESSION_NOT_RUNNING).assertTrue();
1186            done();
1187          });
1188          console.info(TAG, testName + ' capture end.');
1189          await mPhotoOutput.release();
1190          console.info(TAG, testName + ' release photoOutput.');
1191        }
1192        done();
1193      } catch (error) {
1194        console.error(TAG, testName + ' failed. err: ' + error.code + ', msg: ' + error.message);
1195        expect().assertFail();
1196        done();
1197      }
1198    })
1199  })
1200}