• 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 = 'VideoShow'
21const TAG = '[Sample_VideoShow]'
22const DOMAIN = 0xF811
23
24export default function appTest() {
25  describe('appTest', function () {
26    /**
27     * 拉起一个ability
28     */
29    it(BUNDLE + '_startAbility', 0, async function (done) {
30      hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility start')
31      let driver = await UiDriver.create()
32      await driver.delayMs(1000)
33      let want = {
34        bundleName: 'com.example.videoshow',
35        abilityName: 'MainAbility'
36      }
37      var abilityDelegator: any
38      abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
39      await abilityDelegator.startAbility(want, (err, data) => {
40        hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility get err ' + JSON.stringify(err))
41        expect(0).assertEqual(err.code)
42        done()
43        driver.delayMs(1000)
44        hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility end')
45      })
46    })
47    /**
48     * 进入直播间,并进行向上滑动以及向下滑动
49     */
50    it(BUNDLE + '_IndexPage_LiveVideo', 0, async function () {
51      hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_LiveVideo start')
52      let driver = await UiDriver.create()
53      await driver.delayMs(1000)
54      // 点击进入直播间
55      await driver.assertComponentExist(BY.key('directVideo'))
56      let enterVideoComp = await driver.findComponent(BY.key('directVideo'))
57      await enterVideoComp.click()
58      await driver.delayMs(1000)
59      hilog.info(DOMAIN, TAG, BUNDLE + '_IndexPage_LiveVideo end')
60    })
61  })
62}
63