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 MainAbility from '../../../main/ets/MainAbility/MainAbility'; 20import window from '@ohos.window'; 21 22let want: Want = { 23 abilityName: '', 24 parameters: { 25 'ohos.sensitive.resource': 'microphone', 26 'ohos.display.id': 0 27 } 28}; 29 30// let stage: window.WindowStage = window.createWindow(); 31 32export default function MainAbilityTest() { 33 describe('MainAbilityTest', () => { 34 // Defines a test suite. Two parameters are supported: test suite name and test suite function. 35 beforeAll(() => { 36 // Presets an action, which is performed only once before all test cases of the test suite start. 37 // This API supports only one parameter: preset action function. 38 }) 39 beforeEach(() => { 40 // Presets an action, which is performed before each unit test case starts. 41 // The number of execution times is the same as the number of test cases defined by **it**. 42 // This API supports only one parameter: preset action function. 43 }) 44 afterEach(() => { 45 // Presets a clear action, which is performed after each unit test case ends. 46 // The number of execution times is the same as the number of test cases defined by **it**. 47 // This API supports only one parameter: clear action function. 48 }) 49 afterAll(() => { 50 // Presets a clear action, which is performed after all test cases of the test suite end. 51 // This API supports only one parameter: clear action function. 52 }) 53 54 it('MainAbilityTest_000', 0, () => { 55 Log.info(`MainAbilityTest_000 begin`); 56 let ability = new MainAbility(); 57 ability.onCreate(want, null); 58 }) 59 60 it('MainAbilityTest_002', 0, () => { 61 Log.info(`MainAbilityTest_002 begin`); 62 let ability = new MainAbility(); 63 ability.onNewWant(want); 64 }) 65 66 it('MainAbilityTest_003', 0, () => { 67 Log.info(`MainAbilityTest_003 begin`); 68 let ability = new MainAbility(); 69 ability.onForeground(); 70 }) 71 72 it('MainAbilityTest_004', 0, () => { 73 Log.info(`MainAbilityTest_004 begin`); 74 let ability = new MainAbility(); 75 ability.onBackground(); 76 }) 77 78 it('MainAbilityTest_005', 0, () => { 79 Log.info(`MainAbilityTest_005 begin`); 80 let ability = new MainAbility(); 81 ability.onWindowStageDestroy(); 82 }) 83 84 it('MainAbilityTest_006', 0, () => { 85 Log.info(`MainAbilityTest_006 begin`); 86 let ability = new MainAbility(); 87 ability.onDestroy(); 88 }) 89 }) 90}