• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 featureAbility from '@ohos.ability.featureAbility';
18import hilog from '@ohos.hilog';
19
20const BUNDLE = 'Notification'
21const TAG = '[Sample_Notification]'
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 parameter = {
29        "want": {
30          bundleName: "ohos.samples.etsnotification",
31          abilityName: "ohos.samples.etsnotification.MainAbility"
32        }
33      }
34      await featureAbility.startAbility(parameter, (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     * 创建通道
43     */
44    it(BUNDLE + '_IndexPage_CreateSlot', 0, async () => {
45      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_CreateSlot start")
46      let driver = await UiDriver.create()
47      await driver.delayMs(200)
48      await driver.assertComponentExist(BY.key('createSlot'))
49      let slotComp = await driver.findComponent(BY.key('createSlot'))
50      await slotComp.click()
51      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_CreateSlot end")
52    })
53    /**
54     * 发布通知
55     */
56    it(BUNDLE + '_IndexPage_PublishNotice', 0, async () => {
57      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_PublishNotice start")
58      let driver = await UiDriver.create()
59      await driver.delayMs(200)
60      // 选择长文本类型
61      await driver.assertComponentExist(BY.key('longText'))
62      let longTextComp = await driver.findComponent(BY.key('longText'))
63      await longTextComp.click()
64      await driver.delayMs(1000)
65      await driver.assertComponentExist(BY.key('publishNotice'))
66      let PublishComp = await driver.findComponent(BY.key('publishNotice'))
67      await PublishComp.click()
68      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_PublishNotice end")
69    })
70    /**
71     * 取消最近通知以及全部通知
72     */
73    it(BUNDLE + '_IndexPage_CancelNotice', 0, async () => {
74      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_CancelNotice start")
75      let driver = await UiDriver.create()
76      await driver.delayMs(200)
77      // 取消最近通知
78      await driver.assertComponentExist(BY.key('longText'))
79      let cancelLastComp = await driver.findComponent(BY.key('cancelLast'))
80      await cancelLastComp.click()
81      await driver.delayMs(1000)
82      // 再次发布通知
83      await driver.assertComponentExist(BY.key('publishNotice'))
84      let PublishComp = await driver.findComponent(BY.key('publishNotice'))
85      await PublishComp.click()
86      await driver.delayMs(1000)
87      // 取消全部通知
88      await driver.assertComponentExist(BY.key('cancelAll'))
89      let cancelAll = await driver.findComponent(BY.key('cancelAll'))
90      await cancelAll.click()
91      await driver.delayMs(1000)
92      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_CancelNotice end")
93    })
94    /**
95     * 删除通道
96     */
97    it(BUNDLE + '_IndexPage_DeleteSlot', 0, async () => {
98      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_DeleteSlot start")
99      let driver = await UiDriver.create()
100      await driver.delayMs(200)
101      await driver.assertComponentExist(BY.key('deleteSlot'))
102      let slotComp = await driver.findComponent(BY.key('deleteSlot'))
103      await slotComp.click()
104      hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_DeleteSlot end")
105    })
106  })
107}
108