• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2025 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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
17import { describe, it, expect } from '@ohos/hypium';
18import { Driver, ON } from '@ohos.UiTest';
19
20const TAG = '[Sample_DrawingAPI]';
21
22export default function abilityTest() {
23
24  describe('ActsAbilityTest', () => {
25    /**
26     * 打开应用
27     */
28    it('StartAbility_001', 0, async (done: Function) => {
29      console.info(TAG, 'StartAbility_001 begin');
30      let driver = Driver.create();
31      let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
32      try {
33        await abilityDelegator.startAbility({
34          bundleName: 'com.samples.drawing',
35          abilityName: 'EntryAbility'
36        });
37      } catch (exception) {
38        console.info(TAG, `StartAbility_001 exception = ${JSON.stringify(exception)}`);
39        expect().assertFail();
40      }
41      await driver.delayMs(1000);
42      await driver.assertComponentExist(ON.text('Draw Text'));
43      done();
44      console.info(TAG, 'StartAbility_001 end');
45    })
46
47    /**
48     * 点击按钮,绘制文本
49     */
50    it('DrawTextMetricsTEST_001', 2, async () => {
51      console.info(TAG, 'DrawTextMetricsTEST_001 begin');
52      let driver = Driver.create();
53      let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
54      try {
55        await abilityDelegator.startAbility({
56          bundleName: 'com.samples.drawing',
57          abilityName: 'EntryAbility'
58        });
59      } catch (exception) {
60        console.info(TAG, `DrawTextMetricsTEST_001 exception = ${JSON.stringify(exception)}`);
61        expect().assertFail();
62      }
63      await driver.delayMs(1000);
64      await driver.assertComponentExist(ON.text('Draw Text'));
65      let drawTextBtn = await driver.findComponent(ON.text('Draw Text'));
66      // 点击'Draw Text'按钮
67      await drawTextBtn.click();
68      await driver.delayMs(1000);
69      console.info(TAG, 'DrawTextMetricsTEST_001 end');
70    })
71
72  })
73}