提交 cb391745 编写于 作者: Z zhijianwen

--slot--

Signed-off-by: Nzhijianwen <zhijianwen@huawei.com>
上级 39147fb2
...@@ -20,6 +20,10 @@ export default function ActsNotificationManagerSlotTest() { ...@@ -20,6 +20,10 @@ export default function ActsNotificationManagerSlotTest() {
let TAG = 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST ===>' let TAG = 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST ===>'
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST START') console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST START')
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
afterEach(async function (done) { afterEach(async function (done) {
console.info(`${TAG} afterEach START`) console.info(`${TAG} afterEach START`)
try { try {
...@@ -1359,73 +1363,50 @@ export default function ActsNotificationManagerSlotTest() { ...@@ -1359,73 +1363,50 @@ export default function ActsNotificationManagerSlotTest() {
*/ */
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700', 0, async function (done) { it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700 START') console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4700 START')
try {
await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, (err) => { await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
if (err) { console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`)
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) expect(true).assertTrue()
expect(false).assertTrue() }).catch((err) => {
done() console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`)
} else {
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION).then(() => {
console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot SERVICE_INFORMATION success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot SERVICE_INFORMATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot SERVICE_INFORMATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => {
console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot CONTENT_INFORMATION success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot CONTENT_INFORMATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot CONTENT_INFORMATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES).then(() => {
console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot OTHER_TYPES success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot OTHER_TYPES success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot OTHER_TYPES errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
await sleep(1000)
try { try {
await notificationManager.getSlots((err, NotificationSlot) => { await notificationManager.getSlots((err, NotificationSlot) => {
...@@ -1435,10 +1416,18 @@ export default function ActsNotificationManagerSlotTest() { ...@@ -1435,10 +1416,18 @@ export default function ActsNotificationManagerSlotTest() {
done() done()
} else { } else {
console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot)) console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot))
expect(NotificationSlot[0].type).assertEqual(1) for (let i = 0; i < NotificationSlot.length; i++) {
expect(NotificationSlot[1].type).assertEqual(2) console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type))
expect(NotificationSlot[2].type).assertEqual(3) if (NotificationSlot[i].type == 1) {
expect(NotificationSlot[3].type).assertEqual(65535) expect(NotificationSlot[i].type).assertEqual(1)
} else if (NotificationSlot[i].type == 2) {
expect(NotificationSlot[i].type).assertEqual(2)
} else if (NotificationSlot[i].type == 3) {
expect(NotificationSlot[i].type).assertEqual(3)
} else {
expect(NotificationSlot[i].type).assertEqual(65535)
}
}
done() done()
} }
}) })
...@@ -1459,80 +1448,64 @@ export default function ActsNotificationManagerSlotTest() { ...@@ -1459,80 +1448,64 @@ export default function ActsNotificationManagerSlotTest() {
it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800', 0, async function (done) { it('SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800', 0, async function (done) {
console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800 START') console.info(TAG + 'SUB_NOTIFICATION_ANS_MANAGER_SLOT_TEST_4800 START')
try { await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION).then(() => {
await notificationManager.addSlot(notificationManager.SlotType.SOCIAL_COMMUNICATION, (err) => { console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`)
if (err) { expect(true).assertTrue()
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`) }).catch((err) => {
expect(false).assertTrue() console.info(`${TAG} addSlot SOCIAL_COMMUNICATION err: ${err}, errMes: ${err.message}`)
done()
} else {
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot SOCIAL_COMMUNICATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.SERVICE_INFORMATION).then(() => {
console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot SERVICE_INFORMATION success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot SERVICE_INFORMATION err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot SERVICE_INFORMATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot SERVICE_INFORMATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.CONTENT_INFORMATION).then(() => {
console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot CONTENT_INFORMATION success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot CONTENT_INFORMATION err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot CONTENT_INFORMATION success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot CONTENT_INFORMATION errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
try { await sleep(1000)
await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES, (err) => {
if (err) { await notificationManager.addSlot(notificationManager.SlotType.OTHER_TYPES).then(() => {
console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`) console.info(`${TAG} addSlot OTHER_TYPES success`)
expect(false).assertTrue() expect(true).assertTrue()
done() }).catch((err) => {
} else { console.info(`${TAG} addSlot OTHER_TYPES err: ${err}, errMes: ${err.message}`)
console.info(`${TAG} addSlot OTHER_TYPES success`)
expect(true).assertTrue()
}
})
} catch (err) {
console.info(`${TAG} addSlot OTHER_TYPES errCode: ${err}, errMes: ${err.message}`)
expect(false).assertTrue() expect(false).assertTrue()
done() done()
} })
await sleep(1000)
await notificationManager.getSlots().then((NotificationSlot) => { await notificationManager.getSlots().then((NotificationSlot) => {
console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot)) console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot))
expect(NotificationSlot[0].type).assertEqual(1) for (let i = 0; i < NotificationSlot.length; i++) {
expect(NotificationSlot[1].type).assertEqual(2) console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type))
expect(NotificationSlot[2].type).assertEqual(3) if (NotificationSlot[i].type == 1) {
expect(NotificationSlot[3].type).assertEqual(65535) expect(NotificationSlot[i].type).assertEqual(1)
} else if (NotificationSlot[i].type == 2) {
expect(NotificationSlot[i].type).assertEqual(2)
} else if (NotificationSlot[i].type == 3) {
expect(NotificationSlot[i].type).assertEqual(3)
} else {
expect(NotificationSlot[i].type).assertEqual(65535)
}
}
done() done()
}).catch((err) => { }).catch((err) => {
console.info(`${TAG} getSlots Promise err: ${err}, errMes: ${err.message}`) console.info(`${TAG} getSlots Promise err: ${err}, errMes: ${err.message}`)
......
...@@ -20,6 +20,10 @@ export default function ActsNotificationSlotTest() { ...@@ -20,6 +20,10 @@ export default function ActsNotificationSlotTest() {
let TAG = 'SUB_NOTIFICATION_ANS_SLOT_TEST ===>' let TAG = 'SUB_NOTIFICATION_ANS_SLOT_TEST ===>'
console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST START') console.info(TAG + 'SUB_NOTIFICATION_ANS_SLOT_TEST START')
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}
afterEach(async function (done) { afterEach(async function (done) {
console.info(`${TAG} afterEach START`) console.info(`${TAG} afterEach START`)
await notification.removeAllSlots((err) => { await notification.removeAllSlots((err) => {
...@@ -1220,6 +1224,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1220,6 +1224,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => { await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`) console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`)
...@@ -1231,6 +1237,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1231,6 +1237,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => { await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`) console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`)
...@@ -1242,6 +1250,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1242,6 +1250,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => { await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`) console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`)
...@@ -1253,6 +1263,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1253,6 +1263,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.getSlots((err, NotificationSlot) => { await notification.getSlots((err, NotificationSlot) => {
if (err.code) { if (err.code) {
console.info(`${TAG} getSlots AsyncCallback err: + ${err.code}`) console.info(`${TAG} getSlots AsyncCallback err: + ${err.code}`)
...@@ -1260,10 +1272,18 @@ export default function ActsNotificationSlotTest() { ...@@ -1260,10 +1272,18 @@ export default function ActsNotificationSlotTest() {
done() done()
} else { } else {
console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot)) console.info(`${TAG} getSlots AsyncCallback success:` + JSON.stringify(NotificationSlot))
expect(NotificationSlot[0].type).assertEqual(1) for (let i = 0; i < NotificationSlot.length; i++) {
expect(NotificationSlot[1].type).assertEqual(2) console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type))
expect(NotificationSlot[2].type).assertEqual(3) if (NotificationSlot[i].type == 1) {
expect(NotificationSlot[3].type).assertEqual(65535) expect(NotificationSlot[i].type).assertEqual(1)
} else if (NotificationSlot[i].type == 2) {
expect(NotificationSlot[i].type).assertEqual(2)
} else if (NotificationSlot[i].type == 3) {
expect(NotificationSlot[i].type).assertEqual(3)
} else {
expect(NotificationSlot[i].type).assertEqual(65535)
}
}
done() done()
} }
}) })
...@@ -1290,6 +1310,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1290,6 +1310,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => { await notification.addSlot(notification.SlotType.SERVICE_INFORMATION, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`) console.info(`${TAG} addSlot SERVICE_INFORMATION err: + ${err.code}`)
...@@ -1301,6 +1323,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1301,6 +1323,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => { await notification.addSlot(notification.SlotType.CONTENT_INFORMATION, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`) console.info(`${TAG} addSlot CONTENT_INFORMATION err: + ${err.code}`)
...@@ -1312,6 +1336,8 @@ export default function ActsNotificationSlotTest() { ...@@ -1312,6 +1336,8 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => { await notification.addSlot(notification.SlotType.OTHER_TYPES, (err) => {
if (err.code) { if (err.code) {
console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`) console.info(`${TAG} addSlot OTHER_TYPES err: + ${err.code}`)
...@@ -1323,12 +1349,22 @@ export default function ActsNotificationSlotTest() { ...@@ -1323,12 +1349,22 @@ export default function ActsNotificationSlotTest() {
} }
}) })
await sleep(1000)
await notification.getSlots().then((NotificationSlot) => { await notification.getSlots().then((NotificationSlot) => {
console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot)) console.info(`${TAG} getSlots Promise success:` + JSON.stringify(NotificationSlot))
expect(NotificationSlot[0].type).assertEqual(1) for (let i = 0; i < NotificationSlot.length; i++) {
expect(NotificationSlot[1].type).assertEqual(2) console.info(`${TAG} NotificationSlot[${i}].type:` + JSON.stringify(NotificationSlot[i].type))
expect(NotificationSlot[2].type).assertEqual(3) if (NotificationSlot[i].type == 1) {
expect(NotificationSlot[3].type).assertEqual(65535) expect(NotificationSlot[i].type).assertEqual(1)
} else if (NotificationSlot[i].type == 2) {
expect(NotificationSlot[i].type).assertEqual(2)
} else if (NotificationSlot[i].type == 3) {
expect(NotificationSlot[i].type).assertEqual(3)
} else {
expect(NotificationSlot[i].type).assertEqual(65535)
}
}
done() done()
}).catch((err) => { }).catch((err) => {
console.info(`${TAG} getSlots Promise err: + ${err.code}`) console.info(`${TAG} getSlots Promise err: + ${err.code}`)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册