• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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 } from '@ohos/hypium';
17import { Want } from '@kit.AbilityKit';
18import { Log } from '../../../main/ets/common/utils/utils';
19import GlobalExtensionAbility from '../../../main/ets/GlobalExtAbility/GlobalExtAbility';
20
21let want1: Want = {
22  abilityName: '',
23  parameters: {
24    'ohos.sensitive.resource': 'microphone'
25  }
26};
27
28let want2: Want = {
29  abilityName: '',
30  parameters: {
31    'ohos.sensitive.resource': 'camera'
32  }
33};
34
35export default function GlobalExtAbilityTest() {
36  describe('GlobalExtAbilityTest', () => {
37    // Defines a test suite. Two parameters are supported: test suite name and test suite function.
38    beforeAll(() => {
39      // Presets an action, which is performed only once before all test cases of the test suite start.
40      // This API supports only one parameter: preset action function.
41    })
42    beforeEach(() => {
43      // Presets an action, which is performed before each unit test case starts.
44      // The number of execution times is the same as the number of test cases defined by **it**.
45      // This API supports only one parameter: preset action function.
46    })
47    afterEach(() => {
48      // Presets a clear action, which is performed after each unit test case ends.
49      // The number of execution times is the same as the number of test cases defined by **it**.
50      // This API supports only one parameter: clear action function.
51    })
52    afterAll(() => {
53      // Presets a clear action, which is performed after all test cases of the test suite end.
54      // This API supports only one parameter: clear action function.
55    })
56
57    it('GlobalExtAbilityTest_000', 0, () => {
58      Log.info(`GlobalExtAbilityTest_000 begin`);
59      let ability = new GlobalExtensionAbility();
60      ability.onCreate(want1);
61    })
62
63    it('GlobalExtAbilityTest_001', 0, () => {
64      Log.info(`GlobalExtAbilityTest_001 begin`);
65      let ability = new GlobalExtensionAbility();
66      ability.onCreate(want2);
67    })
68
69    it('GlobalExtAbilityTest_002', 0, () => {
70      Log.info(`GlobalExtAbilityTest_002 begin`);
71      let ability = new GlobalExtensionAbility();
72      ability.onRequest(want1, 1);
73    })
74
75    it('GlobalExtAbilityTest_003', 0, () => {
76      Log.info(`GlobalExtAbilityTest_003 begin`);
77      let ability = new GlobalExtensionAbility();
78      ability.onDestroy();
79    })
80  })
81}