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_ArkUIAnimation]' 22const DOMAIN = 0xF811 23const BUNDLE = 'ArkUIAnimation_' 24 25export default function appTest() { 26 describe('appTest', function () { 27 it(BUNDLE + 'StartAbility_001', 0, async function (done) { 28 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAbility_001 begin') 29 let parameter = { 30 "want": { 31 bundleName: "ohos.samples.etsarkuianimation", 32 abilityName: "ohos.samples.etsarkuianimation.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 + 'StartAnimation_001', 0, async function () { 47 // create UiDriver 48 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAnimation_001 begin') 49 let driver = await UiDriver.create() 50 await driver.delayMs(1000) 51 // 点击主图标 开启动画 52 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAnimation_001 start') 53 await driver.assertComponentExist(BY.key('mainImg')) 54 let mainImg = await driver.findComponent(BY.key('mainImg')) 55 await mainImg.click() 56 await driver.delayMs(1000) 57 // 再次点击主图标 结束动画 58 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAnimation_001 finish') 59 await mainImg.click() 60 await driver.delayMs(1000) 61 hilog.info(DOMAIN, TAG, BUNDLE + 'StartAnimation_001 end') 62 }) 63 64 /** 65 * 启动小动画 66 */ 67 it(BUNDLE + 'SmallAnimation_001', 0, async function () { 68 // create UiDriver 69 hilog.info(DOMAIN, TAG, BUNDLE + 'SmallAnimation_001 begin') 70 let driver = await UiDriver.create() 71 await driver.delayMs(1000) 72 // 点击主图标 出现小动画 73 hilog.info(DOMAIN, TAG, BUNDLE + 'SmallAnimation_001 mainImg') 74 await driver.assertComponentExist(BY.key('mainImg')) 75 let mainImg = await driver.findComponent(BY.key('mainImg')) 76 await mainImg.click() 77 await driver.delayMs(1000) 78 hilog.info(DOMAIN, TAG, BUNDLE + 'SmallAnimation_001 end') 79 }) 80 81 /** 82 * 增加、减少小动画 83 */ 84 it(BUNDLE + 'AddSmallAnimation_001', 0, async function () { 85 // create UiDriver 86 hilog.info(DOMAIN, TAG, BUNDLE + 'AddSmallAnimation_001 begin') 87 let driver = await UiDriver.create() 88 await driver.delayMs(1000) 89 // 增加小动画 90 hilog.info(DOMAIN, TAG, BUNDLE + 'AddSmallAnimation_001 add') 91 await driver.assertComponentExist(BY.key('add')) 92 let addBtn = await driver.findComponent(BY.key('add')) 93 await addBtn.click() 94 await driver.delayMs(1000) 95 await addBtn.click() 96 await driver.delayMs(1000) 97 await addBtn.click() 98 await driver.delayMs(1000) 99 // 减少小动画 100 hilog.info(DOMAIN, TAG, BUNDLE + 'AddSmallAnimation_001 reduce') 101 await driver.assertComponentExist(BY.key('reduce')) 102 let reduceBtn = await driver.findComponent(BY.key('reduce')) 103 await reduceBtn.click() 104 await driver.delayMs(1000) 105 // 关闭动画 106 hilog.info(DOMAIN, TAG, BUNDLE + 'AddSmallAnimation_001 mainImg') 107 await driver.assertComponentExist(BY.key('mainImg')) 108 let mainImg = await driver.findComponent(BY.key('mainImg')) 109 await mainImg.click() 110 await driver.delayMs(1000) 111 hilog.info(DOMAIN, TAG, BUNDLE + 'AddSmallAnimation_001 end') 112 }) 113 }) 114}