• 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 { common } from '@kit.AbilityKit';
18import { camera } from '@kit.CameraKit';
19import { isEmpty } from '../common';
20
21const TAG = "CameraXts.getCameraManagerTest";
22
23let testContext: common.UIAbilityContext = AppStorage.get('testContext') as common.UIAbilityContext;
24
25export default function getCameraManagerTest() {
26  describe('getCameraManagerTest', () => {
27    beforeAll(async () => {
28      console.info(TAG, 'beforeAll case.');
29    });
30
31    beforeEach(() => {
32      console.info(TAG, 'beforeEach case.');
33    });
34
35    afterEach(() => {
36      console.info(TAG, 'afterEach case.');
37    });
38
39    afterAll(() => {
40      console.info(TAG, 'afterAll case.');
41    });
42
43    /**
44     * @tc.number    : CAMERA_CAMERA_GET_CAMERA_MANAGER_001
45     * @tc.name      : getCameraManager_001
46     * @tc.desc      : No abnormal scenarios
47     * @tc.size      : MEDIUM
48     * @tc.type      : Function
49     * @tc.level     : Level 0
50     */
51    it('getCameraManager_001', Level.LEVEL0, (done: Function) => {
52      const testName = 'getCameraManager_001';
53      console.info(TAG, testName);
54      let cameraManager = camera.getCameraManager(testContext);
55      expect(isEmpty(cameraManager)).assertFalse();
56      done();
57    })
58
59    /**
60     * @tc.number    : CAMERA_CAMERA_GET_CAMERA_MANAGER_001
61     * @tc.name      : getCameraManager_002
62     * @tc.desc      : context-null
63     * @tc.size      : MEDIUM
64     * @tc.type      : Function
65     * @tc.level     : Level 0
66     */
67    it('getCameraManager_002', Level.LEVEL0, (done: Function) => {
68      const testName = 'getCameraManager_002';
69      console.info(TAG, testName);
70      try {
71        let cameraManager = camera.getCameraManager(null);
72        console.info(TAG, testName + ' cameraManager: ' + isEmpty(cameraManager));
73        expect(isEmpty(cameraManager)).assertFalse();
74        done();
75      } catch (error) {
76        console.error(TAG, testName + ' cameraManager is null. err: ' + error.code + ', msg: ' + error.message);
77        expect().assertFail();
78        done();
79      }
80    })
81
82    /**
83     * @tc.number    : CAMERA_CAMERA_GET_CAMERA_MANAGER_001
84     * @tc.name      : getCameraManager_003
85     * @tc.desc      : context-undefined
86     * @tc.size      : MEDIUM
87     * @tc.type      : Function
88     * @tc.level     : Level 0
89     */
90    it('getCameraManager_003', Level.LEVEL0, (done: Function) => {
91      const testName = 'getCameraManager_003';
92      console.info(TAG, testName);
93      try {
94        let cameraManager = camera.getCameraManager(undefined);
95        console.info(TAG, testName + ' cameraManager: ' + isEmpty(cameraManager));
96        expect(isEmpty(cameraManager)).assertFalse();
97        done();
98      } catch (error) {
99        console.error(TAG, testName + ' cameraManager is null. err: ' + error.code + ', msg: ' + error.message);
100        expect().assertFail();
101        done();
102      }
103    })
104  })
105}