提交 7f36a04c 编写于 作者: Z zhijianwen

show

Signed-off-by: Nzhijianwen <zhijianwen@huawei.com>
上级 5fd1c9d3
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import notification from '@system.notification' import notification from '@system.notification'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function ActsNotificationShowTest() { export default function ActsNotificationShowTest() {
describe('ActsNotificationShowTest', function () { describe('ActsNotificationShowTest', function () {
console.info("ActsNotificationShowTest start"); const TAG = 'ActsNotificationShowTest ===> '
console.info(TAG + "ActsNotificationShowTest START")
/* /*
* @tc.number: ActsNotificationShowTest_0100 * @tc.number: ActsNotificationShowTest_0100
...@@ -26,17 +26,17 @@ describe('ActsNotificationShowTest', function () { ...@@ -26,17 +26,17 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0100', 0, async function (done) { it('ActsNotificationShowTest_0100', 0, async function (done) {
console.info(TAG + 'ActsNotificationShowTest_0100 START ')
let ShowNotificationOptions = { let ShowNotificationOptions = {
contentTitle: 'Title1', contentTitle: 'Title1',
contentText: 'This is a notification 001' contentText: 'This is a notification 001'
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title1'); console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 001'); console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
console.log('ActsNotificationShowTest_0100 success' expect(ShowNotificationOptions.contentTitle).assertEqual('Title1')
+ ShowNotificationOptions.contentTitle expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 001')
+ ShowNotificationOptions.contentText); done()
done();
}) })
/* /*
...@@ -45,19 +45,16 @@ describe('ActsNotificationShowTest', function () { ...@@ -45,19 +45,16 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0200', 0, async function (done) { it('ActsNotificationShowTest_0200', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0200 START ')
let ShowNotificationOptions = {
contentTitle: 123, contentTitle: 123,
contentText: 'This is a notification 002' contentText: 'This is a notification 002'
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
if(ShowNotificationOptions.contentTitle == 123){ console.info(TAG + ' conteneTitle is number:' + ShowNotificationOptions.contentTitle)
console.log('ActsNotificationShowTest_0200 conteneTitle is number:' console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
+ ShowNotificationOptions.contentTitle); expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 002')
} done()
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 002');
console.log(' ActsNotificationShowTest_0200 success'
+ ShowNotificationOptions.contentText);
done();
}) })
/* /*
...@@ -66,11 +63,11 @@ describe('ActsNotificationShowTest', function () { ...@@ -66,11 +63,11 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0300', 0, async function (done) { it('ActsNotificationShowTest_0300', 0, async function (done) {
let ShowNotificationOptions ={} console.info(TAG + 'ActsNotificationShowTest_0300 START ')
notification.show(ShowNotificationOptions); let ShowNotificationOptions = {}
expect(ShowNotificationOptions.contentTitle).assertEqual(undefined); notification.show(ShowNotificationOptions)
console.log(' ActsNotificationShowTest_0300 success '); expect(ShowNotificationOptions.contentTitle).assertEqual(undefined)
done(); done()
}) })
/* /*
...@@ -79,7 +76,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -79,7 +76,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0400', 0, async function (done) { it('ActsNotificationShowTest_0400', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0400 START ')
let ShowNotificationOptions = {
contentTitle: 'Title4', contentTitle: 'Title4',
contentText: 'This is a notification 004', contentText: 'This is a notification 004',
ActionResult: { ActionResult: {
...@@ -88,19 +86,18 @@ describe('ActsNotificationShowTest', function () { ...@@ -88,19 +86,18 @@ describe('ActsNotificationShowTest', function () {
uri: '/', uri: '/',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title4'); console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 004'); console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
console.log('ActsNotificationShowTest_0400 success' expect(ShowNotificationOptions.contentTitle).assertEqual('Title4')
+ ShowNotificationOptions.contentTitle expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 004')
+ ShowNotificationOptions.contentText expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
+ ShowNotificationOptions.ActionResult.bundleName expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
+ ShowNotificationOptions.ActionResult.abilityName expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/')
+ ShowNotificationOptions.ActionResult.uri); done()
done();
}) })
/* /*
...@@ -109,7 +106,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -109,7 +106,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0500', 0, async function (done) { it('ActsNotificationShowTest_0500', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0500 START ')
let ShowNotificationOptions = {
contentTitle: 'Title5', contentTitle: 'Title5',
contentText: 'This is a notification 005', contentText: 'This is a notification 005',
ActionResult: { ActionResult: {
...@@ -118,19 +116,18 @@ describe('ActsNotificationShowTest', function () { ...@@ -118,19 +116,18 @@ describe('ActsNotificationShowTest', function () {
uri: 'pages/index/index', uri: 'pages/index/index',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title5'); console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 005'); console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('pages/index/index'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
console.log('ActsNotificationShowTest_0500 success' expect(ShowNotificationOptions.contentTitle).assertEqual('Title5')
+ ShowNotificationOptions.contentTitle expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 005')
+ ShowNotificationOptions.contentText expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
+ ShowNotificationOptions.ActionResult.bundleName expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
+ ShowNotificationOptions.ActionResult.abilityName expect(ShowNotificationOptions.ActionResult.uri).assertEqual('pages/index/index')
+ ShowNotificationOptions.ActionResult.uri); done()
done();
}) })
/* /*
...@@ -139,7 +136,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -139,7 +136,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0600', 0, async function (done) { it('ActsNotificationShowTest_0600', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0600 START ')
let ShowNotificationOptions = {
contentTitle: 'Title6', contentTitle: 'Title6',
contentText: 'This is a notification 006', contentText: 'This is a notification 006',
ActionResult: { ActionResult: {
...@@ -148,21 +146,17 @@ describe('ActsNotificationShowTest', function () { ...@@ -148,21 +146,17 @@ describe('ActsNotificationShowTest', function () {
uri: '/', uri: '/',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
if(ShowNotificationOptions.ActionResult.bundleName == ''){ console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
console.log('ActsNotificationShowTest_0200 bundleName is null:' console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
+ ShowNotificationOptions.ActionResult.bundleName); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
} console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title6'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 006'); expect(ShowNotificationOptions.contentTitle).assertEqual('Title6')
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 006')
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/'); expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
console.log(' ActsNotificationShowTest_0600 success' expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/')
+ ShowNotificationOptions.contentTitle done()
+ ShowNotificationOptions.contentText
+ ShowNotificationOptions.ActionResult.abilityName
+ ShowNotificationOptions.ActionResult.uri);
done();
}) })
/* /*
...@@ -171,7 +165,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -171,7 +165,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0700', 0, async function (done) { it('ActsNotificationShowTest_0700', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0700 START ')
let ShowNotificationOptions = {
contentTitle: 'Title7', contentTitle: 'Title7',
contentText: 'This is a notification 007', contentText: 'This is a notification 007',
ActionResult: { ActionResult: {
...@@ -180,21 +175,17 @@ describe('ActsNotificationShowTest', function () { ...@@ -180,21 +175,17 @@ describe('ActsNotificationShowTest', function () {
uri: '/', uri: '/',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
if(ShowNotificationOptions.ActionResult.abilityName == ''){ console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
console.log('ActsNotificationShowTest_0200 abilityName is null:' console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
+ ShowNotificationOptions.ActionResult.abilityName); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
} console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title7'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 007'); expect(ShowNotificationOptions.contentTitle).assertEqual('Title7')
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 007')
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/'); expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
console.log('ActsNotificationShowTest_0700 success' expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/')
+ ShowNotificationOptions.contentTitle done()
+ ShowNotificationOptions.contentText
+ ShowNotificationOptions.ActionResult.bundleName
+ ShowNotificationOptions.ActionResult.uri);
done();
}) })
/* /*
...@@ -203,7 +194,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -203,7 +194,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0800', 0, async function (done) { it('ActsNotificationShowTest_0800', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0800 START ')
let ShowNotificationOptions = {
contentTitle: 'Title8', contentTitle: 'Title8',
contentText: 'This is a notification 008', contentText: 'This is a notification 008',
ActionResult: { ActionResult: {
...@@ -212,20 +204,17 @@ describe('ActsNotificationShowTest', function () { ...@@ -212,20 +204,17 @@ describe('ActsNotificationShowTest', function () {
uri: '', uri: '',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
if(ShowNotificationOptions.ActionResult.uri == ''){ console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
console.log('ActsNotificationShowTest_0200 uri is null: ' + ShowNotificationOptions.ActionResult.uri); console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
} console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title8'); console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 008'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); expect(ShowNotificationOptions.contentTitle).assertEqual('Title8')
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 008')
console.log('ActsNotificationShowTest_0800 success' expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
+ ShowNotificationOptions.contentTitle expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
+ ShowNotificationOptions.contentText done()
+ ShowNotificationOptions.ActionResult.bundleName
+ ShowNotificationOptions.ActionResult.abilityName);
done();
}) })
/* /*
...@@ -234,7 +223,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -234,7 +223,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_0900', 0, async function (done) { it('ActsNotificationShowTest_0900', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_0900 START ')
let ShowNotificationOptions = {
contentText: 'This is a notification 009', contentText: 'This is a notification 009',
ActionResult: { ActionResult: {
bundleName: 'com.example.notification', bundleName: 'com.example.notification',
...@@ -242,17 +232,16 @@ describe('ActsNotificationShowTest', function () { ...@@ -242,17 +232,16 @@ describe('ActsNotificationShowTest', function () {
uri: '/', uri: '/',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 009'); console.info(TAG + ' contentText:' + ShowNotificationOptions.contentText)
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
console.log('ActsNotificationShowTest_0900 success' expect(ShowNotificationOptions.contentText).assertEqual('This is a notification 009')
+ ShowNotificationOptions.contentText expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
+ ShowNotificationOptions.ActionResult.bundleName expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
+ ShowNotificationOptions.ActionResult.abilityName expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/')
+ ShowNotificationOptions.ActionResult.uri); done()
done();
}) })
/* /*
...@@ -261,7 +250,8 @@ describe('ActsNotificationShowTest', function () { ...@@ -261,7 +250,8 @@ describe('ActsNotificationShowTest', function () {
* @tc.desc: verify the function of show * @tc.desc: verify the function of show
*/ */
it('ActsNotificationShowTest_1000', 0, async function (done) { it('ActsNotificationShowTest_1000', 0, async function (done) {
let ShowNotificationOptions ={ console.info(TAG + 'ActsNotificationShowTest_1000 START ')
let ShowNotificationOptions = {
contentTitle: 'Title10', contentTitle: 'Title10',
ActionResult: { ActionResult: {
bundleName: 'com.example.notification', bundleName: 'com.example.notification',
...@@ -269,18 +259,21 @@ describe('ActsNotificationShowTest', function () { ...@@ -269,18 +259,21 @@ describe('ActsNotificationShowTest', function () {
uri: '/', uri: '/',
} }
} }
notification.show(ShowNotificationOptions); notification.show(ShowNotificationOptions)
expect(ShowNotificationOptions.contentTitle).assertEqual('Title10'); console.info(TAG + ' conteneTitle:' + ShowNotificationOptions.contentTitle)
expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification'); console.info(TAG + ' ActionResult bundleName:' + ShowNotificationOptions.ActionResult.bundleName)
expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility'); console.info(TAG + ' ActionResult abilityName:' + ShowNotificationOptions.ActionResult.abilityName)
expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/'); console.info(TAG + ' ActionResult uri:' + ShowNotificationOptions.ActionResult.uri)
console.log('ActsNotificationShowTest_1000 success ' expect(ShowNotificationOptions.contentTitle).assertEqual('Title10')
+ ShowNotificationOptions.contentTitle expect(ShowNotificationOptions.ActionResult.bundleName).assertEqual('com.example.notification')
+ ShowNotificationOptions.ActionResult.bundleName expect(ShowNotificationOptions.ActionResult.abilityName).assertEqual('com.example.notification.MainAbility')
+ ShowNotificationOptions.ActionResult.abilityName expect(ShowNotificationOptions.ActionResult.uri).assertEqual('/')
+ ShowNotificationOptions.ActionResult.uri); done()
done(); })
console.info(TAG + "ActsNotificationShowTest END");
}) })
})
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册