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_MediaQuery]' 22const DOMAIN = 0xF811 23const BUNDLE = 'MediaQuery_' 24 25export default function appTest() { 26 describe('appTest', function () { 27 it('testClick_001', 0, async function (done) { 28 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 begin') 29 let parameter = { 30 "want": { 31 bundleName: "ohos.samples.etsmediaquery", 32 abilityName: "ohos.samples.etsmediaquery.MainAbility" 33 } 34 } 35 await featureAbility.startAbility(parameter, (err, data) => { 36 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001,err.code:' + err.code) 37 expect(0).assertEqual(err.code) 38 done() 39 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 end') 40 }) 41 }) 42 43 /** 44 * 进入应用 45 */ 46 it(BUNDLE + 'CreateFunction_001', 0, async function () { 47 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 begin') 48 let driver = await UiDriver.create() 49 await driver.delayMs(1000) 50 // 点击冬日养猫日常 51 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 newTitle1') 52 await driver.assertComponentExist(BY.text('冬日养猫日常', MatchPattern.CONTAINS)) 53 let newTitle1 = await driver.findComponent(BY.text('冬日养猫日常', MatchPattern.CONTAINS)) 54 await newTitle1.click() 55 await driver.delayMs(1000) 56 await driver.pressBack() 57 await driver.delayMs(2000) 58 // 点击冬奥美食记 59 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 newTitle2') 60 await driver.assertComponentExist(BY.text('冬奥美食记', MatchPattern.CONTAINS)) 61 let newTitle2 = await driver.findComponent(BY.text('冬奥美食记', MatchPattern.CONTAINS)) 62 await newTitle2.click() 63 await driver.delayMs(1000) 64 await driver.pressBack() 65 await driver.delayMs(2000) 66 // 点击疫情期间你在干什么 67 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 newTitle3') 68 await driver.assertComponentExist(BY.text('疫情期间你在干什么', MatchPattern.CONTAINS)) 69 let newTitle3 = await driver.findComponent(BY.text('疫情期间你在干什么', MatchPattern.CONTAINS)) 70 await newTitle3.click() 71 await driver.delayMs(1000) 72 await driver.pressBack() 73 await driver.delayMs(2000) 74 // 点击精致女人穿搭技巧 75 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 newTitle4') 76 await driver.assertComponentExist(BY.text('精致女人穿搭技巧', MatchPattern.CONTAINS)) 77 let newTitle4 = await driver.findComponent(BY.text('精致女人穿搭技巧', MatchPattern.CONTAINS)) 78 await newTitle4.click() 79 await driver.delayMs(1000) 80 await driver.pressBack() 81 await driver.delayMs(2000) 82 hilog.info(DOMAIN, TAG, BUNDLE + 'CreateFunction_001 end') 83 }) 84 }) 85}