• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
18import hilog from '@ohos.hilog'
19
20const BUNDLE = 'Scan'
21const TAG = '[Sample_Scan]'
22const DOMAIN = 0xF811
23
24export default function appTest() {
25  describe('appTest', function () {
26    it(BUNDLE + '_startAbility', 0, async function (done) {
27      hilog.info(DOMAIN, TAG, BUNDLE + "_startAbility start")
28      let want = {
29        bundleName: 'com.example.scan',
30        abilityName: 'MainAbility'
31      }
32      var abilityDelegator: any
33      abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
34      await abilityDelegator.startAbility(want, (err, data) => {
35        hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility get err ' + JSON.stringify(err))
36        expect(0).assertEqual(err.code)
37        done()
38        hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility end')
39      })
40    })
41    // 证明拉起白屏
42    it(BUNDLE + '_IndexPage_btnAgree', 0, async function () {
43      hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_BtnAgree start')
44      let driver = await UiDriver.create()
45      await driver.delayMs(1000)
46      await driver.assertComponentExist(BY.text('允许', MatchPattern.CONTAINS))
47      await driver.delayMs(1000)
48      hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_BtnAgree end')
49    })
50  })
51}
52