1/* 2 * Copyright (c) 2023 Hunan OpenValley Digital Industry Development 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 UIAbility from '@ohos.app.ability.UIAbility'; 17import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 18import hilog from '@ohos.hilog'; 19import Want from '@ohos.app.ability.Want'; 20import AbilityConstant from '@ohos.app.ability.AbilityConstant'; 21import { Hypium } from '@ohos/hypium'; 22import window from '@ohos.window'; 23import testsuite from '../test/List.test'; 24 25 26export default class TestAbility extends UIAbility { 27 onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { 28 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); 29 hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); 30 hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); 31 let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator 32 abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 33 let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs 34 abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() 35 hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); 36 Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) 37 } 38 39 onDestroy() { 40 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); 41 } 42 43 onWindowStageCreate(windowStage: window.WindowStage) { 44 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); 45 windowStage.loadContent('testability/pages/Index', (err, data) => { 46 if (err.code) { 47 hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 48 return; 49 } 50 hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', 51 JSON.stringify(data) ?? ''); 52 }); 53 } 54 55 onWindowStageDestroy() { 56 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); 57 } 58 59 onForeground() { 60 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); 61 } 62 63 onBackground() { 64 hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); 65 } 66}