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 */ 15import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 16import { UiDriver, BY, UiComponent, MatchPattern } from '@ohos.uitest' 17import featureAbility from '@ohos.ability.featureAbility'; 18import hilog from '@ohos.hilog'; 19 20const BUNDLE = 'DeviceManager' 21const TAG = '[Sample_DeviceManager]' 22const DOMAIN = 0xF811 23 24export default function appTest() { 25 describe('appTest', function () { 26 /** 27 * 启动Ability 28 */ 29 it(BUNDLE + '_startAbility', 0, async function (done) { 30 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility start') 31 let parameter = { 32 "want": { 33 bundleName: "ohos.samples.etsdevicemanager", 34 abilityName: "ohos.samples.etsdevicemanager.MainAbility" 35 } 36 } 37 await featureAbility.startAbility(parameter, (err, data) => { 38 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility get err ' + JSON.stringify(err)) 39 expect(0).assertEqual(err.code) 40 done() 41 hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility end') 42 }) 43 }) 44 /** 45 * 进入首页 46 */ 47 it(BUNDLE + '_IndexPage_Enter', 0, async () => { 48 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_Enter start') 49 let driver = await UiDriver.create() 50 await driver.delayMs(500) 51 await driver.assertComponentExist(BY.text('设备管理', MatchPattern.CONTAINS)) 52 let titleComponent = await driver.findComponent(BY.text('设备管理', MatchPattern.CONTAINS)) 53 let titleContent = await titleComponent.getText() 54 await driver.delayMs(200) 55 await expect('设备管理').assertEqual(titleContent) 56 await driver.delayMs(200) 57 hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_Enter end') 58 }) 59 }) 60} 61