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 featureAbility from '@ohos.ability.featureAbility' 19import hilog from '@ohos.hilog' 20 21const TAG = '[Sample_XmlTextConvert]' 22const DOMAIN = 0xF811 23const BUNDLE = 'XmlTextConvert_' 24 25export default function appTest() { 26 describe('appTest', function () { 27 it(BUNDLE + 'StartAbilityFunction_001', 0, async function (done) { 28 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 begin') 29 let parameter = { 30 "want": { 31 bundleName: "ohos.samples.etsxmltextconvert", 32 abilityName: "ohos.samples.etsxmltextconvert.MainAbility" 33 } 34 } 35 await featureAbility.startAbility(parameter, (err, data) => { 36 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001,err.code:' + err.code) 37 expect(0).assertEqual(err.code) 38 done() 39 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbilityFunction_001 end') 40 }) 41 }) 42 /** 43 * 点击生成、解析、转换Xml 44 */ 45 it(BUNDLE + 'ClickXmlFunction_001', 0, async function () { 46 hilog.info(DOMAIN, TAG, BUNDLE + 'ClickXmlFunction_001 begin') 47 let driver = await UiDriver.create() 48 await driver.delayMs(1000) 49 hilog.info(DOMAIN, TAG, BUNDLE + 'ClickXmlFunction_001 clickSerializerXml') 50 // 点击Xml生成 51 await driver.assertComponentExist(BY.text('Xml 生成', MatchPattern.CONTAINS)) 52 let serializer = await driver.findComponent(BY.text('Xml 生成', MatchPattern.CONTAINS)) 53 await serializer.click() 54 await driver.delayMs(1000) 55 hilog.info(DOMAIN, TAG, BUNDLE + 'ClickXmlFunction_001 clickParserXml') 56 // 点击Xml解析 57 await driver.assertComponentExist(BY.text('Xml 解析', MatchPattern.CONTAINS)) 58 let parser = await driver.findComponent(BY.text('Xml 解析', MatchPattern.CONTAINS)) 59 await parser.click() 60 await driver.delayMs(1000) 61 hilog.info(DOMAIN, TAG, BUNDLE + 'ClickXmlFunction_001 clickConvertXml') 62 // 点击Xml转换 63 let convert = await driver.findComponent(BY.text('Xml 转换', MatchPattern.CONTAINS)) 64 await convert.click() 65 await driver.delayMs(1000) 66 hilog.info(DOMAIN, TAG, BUNDLE + 'ClickXmlFunction_001 end') 67 }) 68 }) 69}