1/* 2 * Copyright (c) 2022 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 { UiDriver, BY, UiComponent, MatchPattern } from '@ohos.uitest' 18import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' 19import hilog from '@ohos.hilog' 20 21const BUNDLE = "Debug" 22const TAG = '[Sample_Debug]' 23const DOMAIN = 0xF811 24 25export default function appTest() { 26 describe('appTest', function () { 27 it(BUNDLE + '_startAbility', 0, async function (done) { 28 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility start') 29 let want = { 30 bundleName: "ohos.samples.debug", 31 abilityName: "MainAbility" 32 } 33 var abilityDelegator: any 34 abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 35 await abilityDelegator.startAbility(want, (err, data) => { 36 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility get err ' + JSON.stringify(err)) 37 expect(0).assertEqual(err.code) 38 done() 39 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility end') 40 }) 41 }) 42 /** 43 * debug接口信息的显示与隐藏 44 */ 45 it(BUNDLE + '_IndexPage_BtnDebugIcon', 0, async () => { 46 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_MsgShow start') 47 let driver = await UiDriver.create() 48 await driver.delayMs(1000) 49 // 点击显示信息 50 await driver.assertComponentExist(BY.key('btnDebug')) 51 let msgShow = await driver.findComponent(BY.key('btnDebug')) 52 await msgShow.click() 53 await driver.delayMs(1000) 54 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_MsgShow end') 55 // 点击隐藏信息 56 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_MsgDispay start') 57 await driver.assertComponentExist(BY.key('btnDebug')) 58 let msgDisplay = await driver.findComponent(BY.key('btnDebug')) 59 await msgDisplay.click() 60 await driver.delayMs(1000) 61 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_MsgDispay end') 62 }) 63 }) 64} 65