diff --git a/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js b/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js index e1725afd0b25ce0fcabc3b155a7a952cbebc940c..1b2d7038496c633597bf0661b6beee71be4b27f9 100644 --- a/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js +++ b/notification/ans_standard/actsNotificationManagerSlotTest/src/main/js/test/ActsNotificationManagerSlotTest.js @@ -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 { @@ -1356,73 +1360,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) => { @@ -1432,10 +1413,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() } }) @@ -1456,80 +1445,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}`) diff --git a/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js b/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js index a472e47ba386421f3e4d0cf71bef66654cc85baf..5d01d296e820aec610f2c2ee4b567494f9243371 100644 --- a/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js +++ b/notification/ans_standard/actsNotificationSlotTest/src/main/js/test/ActsNotificationSlotTest.js @@ -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}`)