提交 cb391745 编写于 作者: Z zhijianwen

--slot--

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