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 { Configuration } from '@ohos.app.ability.Configuration'; 19import { Log } from '../../../main/ets/common/utils/utils'; 20import ServiceExtAbility from '../../../main/ets/ServiceExtAbility/ServiceExtAbility'; 21 22let want: Want = { 23 abilityName: '', 24 parameters: { 25 'ohos.sensitive.resource': 'microphone', 26 'ohos.display.id': 0 27 } 28}; 29 30export default function ServiceExtAbilityTest() { 31 describe('ServiceExtAbilityTest', () => { 32 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 33 beforeAll(() => { 34 // Presets an action, which is performed only once before all test cases of the test suite start. 35 // This API supports only one parameter: preset action function. 36 }) 37 beforeEach(() => { 38 // Presets an action, which is performed before each unit test case starts. 39 // The number of execution times is the same as the number of test cases defined by **it**. 40 // This API supports only one parameter: preset action function. 41 }) 42 afterEach(() => { 43 // Presets a clear action, which is performed after each unit test case ends. 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: clear action function. 46 }) 47 afterAll(() => { 48 // Presets a clear action, which is performed after all test cases of the test suite end. 49 // This API supports only one parameter: clear action function. 50 }) 51 52 it('ServiceExtAbilityTest_000', 0, () => { 53 Log.info(`ServiceExtAbilityTest_000 begin`); 54 let ability = new ServiceExtAbility(); 55 ability.onCreate(want); 56 }) 57 58 it('ServiceExtAbilityTest_001', 0, () => { 59 Log.info(`ServiceExtAbilityTest_001 begin`); 60 let ability = new ServiceExtAbility(); 61 ability.onRequest(want, 1); 62 }) 63 64 it('ServiceExtAbilityTest_002', 0, () => { 65 Log.info(`ServiceExtAbilityTest_002 begin`); 66 let ability = new ServiceExtAbility(); 67 ability.onDestroy(); 68 }) 69 }) 70}