diff --git a/notification/ans_standard/BUILD.gn b/notification/ans_standard/BUILD.gn index c80061bb44caa1008e94ff01c2a1d489c7d29c48..d030ccfd837b87d60e1dda6ae264ecacb50fc690 100644 --- a/notification/ans_standard/BUILD.gn +++ b/notification/ans_standard/BUILD.gn @@ -16,7 +16,7 @@ group("ans_standard") { testonly = true if (is_standard_system) { deps = [ - "actsansnotificationcancel:ActsAnsNotificationCancelTest", + #"actsansnotificationcancel:ActsAnsNotificationCancelTest", "actsansnotificationremove:ActsAnsNotificationRemoveTest", "actsansslottest:ActsAnsSlotTest", "publish_test:publish_test", diff --git a/notification/ans_standard/publish_test/BUILD.gn b/notification/ans_standard/publish_test/BUILD.gn index a7041307c163b6f2c177f5bda57cf38a7f3a65c7..1765df2814955da1d09f5771c6efbf582e82bfbd 100644 --- a/notification/ans_standard/publish_test/BUILD.gn +++ b/notification/ans_standard/publish_test/BUILD.gn @@ -26,14 +26,14 @@ group("publish_test") { #"publishcontentype:publishcontentype", #"subscribe:subscribe", "activebtn:activebtn", - "actsansdistributedtest:ActsAnsDistributeTest", + #"actsansdistributedtest:ActsAnsDistributeTest", "actsansgetallactive:ActsAnsGetAllActiveTestXts", "ansactscancelgroup:ActsAnsCancelGroupTest", "ansactsremovegroup:ActsAnsRemoveGroupTest", "donotdisturbmode:ActsAnsDoNotDisturbTest", "publish:ActsAnsNotificationPublishXts", "publishsound:ActsAnsPublishSoundTest", - "publishvibra:ActsAnsPublishVibraTest", + #"publishvibra:ActsAnsPublishVibraTest", "sub:ActsAnsSubTestXts", "unsubscribe:ActsAnsUnSubscriberTest", "wantagent:wantagent", diff --git a/notification/ans_standard/publish_test/activebtn/activebutton/entry/src/main/js/test/ActiveButton.js b/notification/ans_standard/publish_test/activebtn/activebutton/entry/src/main/js/test/ActiveButton.js index 078d8d1b6861915bc58f087b9731e8deae5cce5f..5dabc010dd1124887f715b00002cdd0226eac534 100644 --- a/notification/ans_standard/publish_test/activebtn/activebutton/entry/src/main/js/test/ActiveButton.js +++ b/notification/ans_standard/publish_test/activebtn/activebutton/entry/src/main/js/test/ActiveButton.js @@ -234,742 +234,5 @@ describe('ActsAnsActionButtonTest', function () { } }); } - - /* - * @tc.number: ActsActiveButton_test_0300 - * @tc.name: subscribe() - * @tc.desc: verify the function of subscribe - */ - it('ActsActiveButton_test_0300', 0, async function (done) { - console.debug("===ActsActiveButton_test_0300===begin===>"); - - var subInfo ={ - onConsume:consumeCallbackC - } - await notify.subscribe(subInfo); - - var agentInfoC = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoD = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var wantAgentDataC = await WantAgent.getWantAgent(agentInfoC); - var wantAgentDataD = await WantAgent.getWantAgent(agentInfoD); - var notificationRequest = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, - longText : { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText", - longText: "long_text", - briefText: "long_briefText", - expandedTitle: "long_expandedTitle" - }, - }, - id: 3, - slotType : notify.SlotType.SERVICE_INFORMATION, - actionButtons: [{title:"buttonC", wantAgent:wantAgentDataC},{title:"buttonD", wantAgent:wantAgentDataD}] - } - notify.publish(notificationRequest, publishCallbackb); - setTimeout((async function(){ - notify.unsubscribe(subInfo); - console.info("======ActsActiveButton_test_0300 setTimeout unsubscribe===>"); - done(); - }),300); - }) - - function consumeCallbackD(data) { - console.debug("===>consumeCallbackD data : ===>" +JSON.stringify(data)); - var triggerInfoE = { - code:4 - } - var triggerInfoF = { - code:5 - } - expect(data.request.actionButtons[0].title).assertEqual("buttonE") - expect(data.request.actionButtons[1].title).assertEqual("buttonF") - var wantAgentE = data.request.actionButtons[0].wantAgent - var wantAgentF = data.request.actionButtons[1].wantAgent - console.debug("===>wantAgentC: ===>" + JSON.stringify(wantAgentE)) - console.debug("===>wantAgentD: ===>" + JSON.stringify(wantAgentF)) - WantAgent.trigger(wantAgentE, triggerInfoE, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerInfoE success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerInfoE failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentF, triggerInfoF, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerInfoF success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerInfoF failed!----'+err.code); - } - }); - } - - /* - * @tc.number: ActsActiveButton_test_0400 - * @tc.name: subscribe() - * @tc.desc: verify the function of subscribe - */ - it('ActsActiveButton_test_0400', 0, async function (done) { - console.debug("===ActsActiveButton_test_0400===begin===>"); - - var subInfo ={ - onConsume:consumeCallbackD - } - await notify.subscribe(subInfo); - - var agentInfoE = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoF = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var wantAgentDataE = await WantAgent.getWantAgent(agentInfoE); - var wantAgentDataF = await WantAgent.getWantAgent(agentInfoF); - var notificationRequest = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, - longText : { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText", - longText: "long_text", - briefText: "long_briefText", - expandedTitle: "long_expandedTitle" - }, - }, - id: 3, - slotType : notify.SlotType.SERVICE_INFORMATION, - actionButtons: [{title:"buttonE", wantAgent:wantAgentDataE},{title:"buttonF", wantAgent:wantAgentDataF}] - } - notify.publish(notificationRequest).then(()=>{ - console.info("======ActsActiveButton_test_0400 promise===>"); - }); - setTimeout((async function(){ - notify.unsubscribe(subInfo); - console.info("======ActsActiveButton_test_0400 setTimeout unsubscribe===>"); - done(); - }),300); - }) - - function consumeCallbackE(data) { - console.debug("===>consumeCallbackE data : ===>" +JSON.stringify(data)); - var triggerInfoG = { - code:1 - } - var triggerInfoH = { - code:2 - } - var triggerInfoI = { - code:3 - } - expect(data.request.actionButtons[0].title).assertEqual("buttonG") - expect(data.request.actionButtons[1].title).assertEqual("buttonH") - expect(data.request.actionButtons[2].title).assertEqual("buttonI") - var wantAgentG = data.request.actionButtons[0].wantAgent - var wantAgentH = data.request.actionButtons[1].wantAgent - var wantAgentI = data.request.actionButtons[2].wantAgent - console.debug("===>wantAgentG: ===>" + JSON.stringify(wantAgentG)) - console.debug("===>wantAgentH: ===>" + JSON.stringify(wantAgentH)) - console.debug("===>wantAgentI: ===>" + JSON.stringify(wantAgentI)) - WantAgent.trigger(wantAgentG, triggerInfoG, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerG success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerG failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentH, triggerInfoH, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerH success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerH failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentI, triggerInfoI, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerI success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerI failed!----'+err.code); - } - }); - } - - /* - * @tc.number: ActsActiveButton_test_0500 - * @tc.name: subscribe() - * @tc.desc: verify the function of subscribe - */ - it('ActsActiveButton_test_0500', 0, async function (done) { - console.debug("===ActsActiveButton_test_0500===begin===>"); - - var subInfo ={ - onConsume:consumeCallbackE - } - await notify.subscribe(subInfo); - - var agentInfoG = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoH = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoI = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var wantAgentDataG = await WantAgent.getWantAgent(agentInfoG); - var wantAgentDataH = await WantAgent.getWantAgent(agentInfoH); - var wantAgentDataI = await WantAgent.getWantAgent(agentInfoI); - var notificationRequest = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, - longText : { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText", - longText: "long_text", - briefText: "long_briefText", - expandedTitle: "long_expandedTitle" - }, - }, - id: 1, - slotType : notify.SlotType.SERVICE_INFORMATION, - actionButtons: [{title:"buttonG", wantAgent:wantAgentDataG},{title:"buttonH", wantAgent:wantAgentDataH},{title:"buttonI", wantAgent:wantAgentDataI}] - } - notify.publish(notificationRequest, publishCallbackc); - setTimeout((async function(){ - notify.unsubscribe(subInfo); - console.info("======ActsActiveButton_test_0500 setTimeout unsubscribe===>"); - done(); - }),300); - }) - - function consumeCallbackF(data) { - console.debug("===>consumeCallbackF data : ===>" +JSON.stringify(data)); - var triggerInfoJ = { - code:4 - } - var triggerInfoK = { - code:5 - } - var triggerInfoL = { - code:6 - } - expect(data.request.actionButtons[0].title).assertEqual("buttonJ") - expect(data.request.actionButtons[1].title).assertEqual("buttonK") - expect(data.request.actionButtons[2].title).assertEqual("buttonL") - var wantAgentJ = data.request.actionButtons[0].wantAgent - var wantAgentK = data.request.actionButtons[1].wantAgent - var wantAgentL = data.request.actionButtons[2].wantAgent - console.debug("===>wantAgentJ: ===>" + JSON.stringify(wantAgentJ)) - console.debug("===>wantAgentK: ===>" + JSON.stringify(wantAgentK)) - console.debug("===>wantAgentL: ===>" + JSON.stringify(wantAgentL)) - WantAgent.trigger(wantAgentJ, triggerInfoJ, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerJ success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerJ failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentK, triggerInfoK, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerK success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerK failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentL, triggerInfoL, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerI success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerI failed!----'+err.code); - } - }); - } - - /* - * @tc.number: ActsActiveButton_test_0600 - * @tc.name: subscribe() - * @tc.desc: verify the function of subscribe - */ - it('ActsActiveButton_test_0600', 0, async function (done) { - console.debug("===ActsActiveButton_test_0600===begin===>"); - - var subInfo ={ - onConsume:consumeCallbackF - } - await notify.subscribe(subInfo); - - var agentInfoJ = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoK = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoL = { - wants: [ - { - deviceId: "deviceId", - bundleName: "com.example.wantAgentTest", - abilityName: "com.example.wantAgentTest.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var wantAgentDataJ = await WantAgent.getWantAgent(agentInfoJ); - var wantAgentDataK = await WantAgent.getWantAgent(agentInfoK); - var wantAgentDataL = await WantAgent.getWantAgent(agentInfoL); - var notificationRequest = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, - longText : { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText", - longText: "long_text", - briefText: "long_briefText", - expandedTitle: "long_expandedTitle" - }, - }, - id: 1, - slotType : notify.SlotType.SERVICE_INFORMATION, - actionButtons: [{title:"buttonJ", wantAgent:wantAgentDataJ},{title:"buttonK", wantAgent:wantAgentDataK},{title:"buttonL", wantAgent:wantAgentDataL}] - } - notify.publish(notificationRequest).then(()=>{ - console.info("======ActsActiveButton_test_0600 promise===>"); - }); - setTimeout((async function(){ - notify.unsubscribe(subInfo); - console.info("======ActsActiveButton_test_0600 setTimeout unsubscribe===>"); - done(); - }),300); - }) - function consumeCallbackG(data) { - console.debug("===>consumeCallbackG data : ===>" +JSON.stringify(data)); - var triggerInfoM = { - code:7 - } - var triggerInfoN = { - code:8 - } - var triggerInfoO = { - code:9 - } - // expect(data.request.actionButtons.length).assertEqual(3) - expect(data.request.actionButtons[0].title).assertEqual("buttonM") - expect(data.request.actionButtons[1].title).assertEqual("buttonN") - expect(data.request.actionButtons[2].title).assertEqual("buttonO") - var wantAgentM = data.request.actionButtons[0].wantAgent - var wantAgentN = data.request.actionButtons[1].wantAgent - var wantAgentO = data.request.actionButtons[2].wantAgent - console.debug("===>wantAgentM: ===>" + JSON.stringify(wantAgentM)) - console.debug("===>wantAgentN: ===>" + JSON.stringify(wantAgentN)) - console.debug("===>wantAgentO: ===>" + JSON.stringify(wantAgentO)) - WantAgent.trigger(wantAgentM, triggerInfoM, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerM success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerM failed!----'+err.code); - } - }); - WantAgent.trigger(wantAgentN, triggerInfoN, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerN success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerN failed!----'+err.code); - } - }); - setTimeout((function(){ - WantAgent.trigger(wantAgentO, triggerInfoO, - (err, data) => { - if (err.code == 0) { - console.info('==== triggerO success' + err.code+JSON.stringify(data) ); - } else { - console.info('----triggerO failed!----'+err.code); - } - }); - }),300); - } - - /* - * @tc.number: ActsActiveButton_test_0700 - * @tc.name: subscribe() - * @tc.desc: verify the function of subscribe - */ - it('ActsActiveButton_test_0700', 0, async function (done) { - console.debug("===ActsActiveButton_test_0700===begin===>"); - - var subInfo ={ - onConsume:consumeCallbackG - } - await notify.subscribe(subInfo); - - var agentInfoM = { - wants: [ - { - bundleName: "com.example.wantAgentTestA", - abilityName: "com.example.wantAgentTestA.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoN = { - wants: [ - { - bundleName: "com.example.wantAgentTestB", - abilityName: "com.example.wantAgentTestB.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoO = { - wants: [ - { - bundleName: "com.example.wantAgentTestC", - abilityName: "com.example.wantAgentTestC.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var agentInfoP = { - wants: [ - { - bundleName: "com.example.wantAgentTestA", - abilityName: "com.example.wantAgentTestA.MainAbility", - action: "action1", - entities: ["entity1"], - type: "MIMETYPE", - uri: "key={true,true,false}", - parameters: - { - mykey0: 2222, - mykey1: [1, 2, 3], - mykey2: "[1, 2, 3]", - mykey3: "ssssssssssssssssssssssssss", - mykey4: [false, true, false], - mykey5: ["qqqqq", "wwwwww", "aaaaaaaaaaaaaaaaa"], - mykey6: true, - } - } - ], - operationType: OperationType.START_ABILITY, - requestCode: 0, - wantAgentFlags:[WantAgentFlags.UPDATE_PRESENT_FLAG] - }; - var wantAgentDataM = await WantAgent.getWantAgent(agentInfoM); - var wantAgentDataN = await WantAgent.getWantAgent(agentInfoN); - var wantAgentDataO = await WantAgent.getWantAgent(agentInfoO); - var wantAgentDataP = await WantAgent.getWantAgent(agentInfoP); - var notificationRequest = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_LONG_TEXT, - longText : { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText", - longText: "long_text", - briefText: "long_briefText", - expandedTitle: "long_expandedTitle" - }, - }, - id: 1, - slotType : notify.SlotType.SERVICE_INFORMATION, - actionButtons: [{title:"buttonM", wantAgent:wantAgentDataM},{title:"buttonN", wantAgent:wantAgentDataN},{title:"buttonO", wantAgent:wantAgentDataO},{title:"buttonP", wantAgent:wantAgentDataP}] - } - notify.publish(notificationRequest).then(()=>{ - console.info("======ActsActiveButton_test_0700 promise===>"); - }); - setTimeout((async function(){ - notify.unsubscribe(subInfo); - console.info("======ActsActiveButton_test_0700 setTimeout unsubscribe===>"); - done(); - }),300); - }) }) diff --git a/notification/ans_standard/publish_test/actsansgetallactive/entry/src/main/js/test/getAllActive.js b/notification/ans_standard/publish_test/actsansgetallactive/entry/src/main/js/test/getAllActive.js index 515ca1942ffdaca7391d914f317956b9bea61c95..5775a552f028bfc0c892a1b79531d50e5490fc47 100644 --- a/notification/ans_standard/publish_test/actsansgetallactive/entry/src/main/js/test/getAllActive.js +++ b/notification/ans_standard/publish_test/actsansgetallactive/entry/src/main/js/test/getAllActive.js @@ -95,342 +95,5 @@ describe('ActsAnsGetAllActiveTestXts', function () { done(); }, time); }) - - /* - * @tc.number: Ans_GetAllActive_xts_0200 - * @tc.name: getAllActiveNotifications(): Promise> - * @tc.desc: Verify: After the current app and other apps publish two notifications, - get all active notifications in the system(promise) - */ - it('Ans_GetAllActive_xts_0200', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0200 start==================>"); - await notify.cancelAll(); - var notificationRequestOfOtherApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_otherApp", - text: "test_text_otherApp", - additionalText: "test_additionalText_otherApp" - }, - }, - id: 2, - label: "otherApp", - } - await notify.publish(notificationRequestOfOtherApp); - console.debug("===============Ans_GetAllActive_0200 publish OtherApp notify end==================>"); - var notificationRequestOfCurrentApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_currentApp", - text: "test_text_currentApp", - additionalText: "test_additionalText_currentApp" - }, - }, - id: 1, - label: "currentApp_0200", - } - await notify.publish(notificationRequestOfCurrentApp); - console.debug("===============Ans_GetAllActive_0200 publish CurrentApp notify end==================>"); - var promiseData = await notify.getAllActiveNotifications(); - console.debug("===============Ans_GetAllActive_0200 getActiveNotifications end==================>"); - expect(promiseData.length).assertEqual(2); - var i; - for (i = 0; i < promiseData.length; i++) { - if (i == 0){ - expect(promiseData[i].content.normal.title).assertEqual("test_title_otherApp"); - console.log("=======Ans_GetAllActive_0200 title=====>"+promiseData[i].content.normal.title) - expect(promiseData[i].content.normal.text).assertEqual("test_text_otherApp"); - console.log("=======Ans_GetAllActive_0200 text========>"+promiseData[i].content.normal.text) - expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp"); - console.log("===Ans_GetAllActive_0200 text====>"+promiseData[i].content.normal.additionalText) - expect(promiseData[i].id).assertEqual(2); - console.log("============Ans_GetAllActive_0200 id============>"+promiseData[i].id) - expect(promiseData[i].label).assertEqual("otherApp"); - console.log("============Ans_GetAllActive_0200 label=====>"+promiseData[i].label) - }else if(i == 1){ - expect(promiseData[i].content.normal.title).assertEqual("test_title_currentApp"); - console.log("====Ans_GetAllActive_0200 title=====>"+promiseData[i].content.normal.title) - expect(promiseData[i].content.normal.text).assertEqual("test_text_currentApp"); - console.log("======Ans_GetAllActive_0200 text=====>"+promiseData[i].content.normal.text) - expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_currentApp"); - console.log("Ans_GetAllActive_0200 text===>"+promiseData[i].content.normal.additionalText) - expect(promiseData[i].id).assertEqual(1); - console.log("============Ans_GetAllActive_0200 id============>"+promiseData[i].id) - expect(promiseData[i].label).assertEqual("currentApp_0200"); - console.log("============Ans_GetAllActive_0200 label=====>"+promiseData[i].label) - } - } - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0200 setTimeout==================>"); - done(); - }, time); - }) - - function getAllCallbackThree(err, data){ - console.log("Ans_GetAllActive_0300 getAllCallbackThree ============>"); - console.log("Ans_GetAllActive_0300 getAllCallbackThree data.length============>"+data.length); - console.log("Ans_GetAllActive_0300 getAllCallbackThree data============>"+JSON.stringify(data)); - expect(data.length).assertEqual(1); - var i; - for (i = 0; i < data.length; i++) { - expect(data[i].content.normal.title).assertEqual("test_title_otherApp"); - console.log("==========Ans_GetAllActive_0300 getCallback title=========>"+data[i].content.normal.title) - expect(data[i].content.normal.text).assertEqual("test_text_otherApp"); - console.log("==========Ans_GetAllActive_0300 getCallback text============>"+data[i].content.normal.text) - expect(data[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp"); - console.log("======Ans_GetAllActive_0300 getCallback text=======>"+data[i].content.normal.additionalText) - expect(data[i].id).assertEqual(2); - console.log("============Ans_GetAllActive_0300 getCallback id============>"+data[i].id) - expect(data[i].label).assertEqual("otherApp"); - console.log("============Ans_GetAllActive_0300 getCallback label=====>"+data[i].label) - } - } - - /* - * @tc.number: Ans_GetAllActive_xts_0300 - * @tc.name: getAllActiveNotifications(callback: AsyncCallback>): void; - * @tc.desc: Verify: After the current app and other apps publish two notifications, cancel the notifications - of the current app, get all active notifications in the system(callback) - */ - it('Ans_GetAllActive_xts_0300', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0300 start==================>"); - await notify.cancelAll(); - var notificationRequestOfOtherApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_otherApp", - text: "test_text_otherApp", - additionalText: "test_additionalText_otherApp" - }, - }, - id: 2, - label: "otherApp", - } - await notify.publish(notificationRequestOfOtherApp); - console.debug("===============Ans_GetAllActive_0300 publish OtherApp notify end==================>"); - var notificationRequestOfCurrentApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_currentApp", - text: "test_text_currentApp", - additionalText: "test_additionalText_currentApp" - }, - }, - id: 1, - label: "currentApp_0300", - } - await notify.publish(notificationRequestOfCurrentApp); - console.debug("===============Ans_GetAllActive_0300 publish CurrentApp notify end==================>"); - await notify.cancel(1, "currentApp_0300"); - notify.getAllActiveNotifications(getAllCallbackThree); - console.debug("===============Ans_GetAllActive_0300 getAllActiveNotifications end==================>"); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0300 setTimeout==================>"); - done(); - }, time); - }) - - /* - * @tc.number: Ans_GetAllActive_xts_0400 - * @tc.name: getAllActiveNotifications(): Promise>; - * @tc.desc: Verify: after publishing two notifications, - cancel one of the notifications, get all active notifications info(promise) - */ - it('Ans_GetAllActive_xts_0400', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0400 start==================>"); - await notify.cancelAll(); - var notificationRequestOfOtherApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_otherApp", - text: "test_text_otherApp", - additionalText: "test_additionalText_otherApp" - }, - }, - id: 2, - label: "otherApp", - } - await notify.publish(notificationRequestOfOtherApp); - console.debug("===============Ans_GetAllActive_0400 publish OtherApp notify end==================>"); - var notificationRequestOfCurrentApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_currentApp", - text: "test_text_currentApp", - additionalText: "test_additionalText_currentApp" - }, - }, - id: 1, - label: "currentApp_0400", - } - await notify.publish(notificationRequestOfCurrentApp); - console.debug("===============Ans_GetAllActive_0400 publish CurrentApp notify end==================>"); - await notify.cancel(1, "currentApp_0400"); - console.debug("===============Ans_GetAllActive_0400 cancel end==================>"); - var promiseData = await notify.getAllActiveNotifications(); - var i; - for (i = 0; i < promiseData.length; i++) { - expect(promiseData[i].content.normal.title).assertEqual("test_title_otherApp"); - console.log("=======Ans_GetAllActive_0400 title=====>"+promiseData[i].content.normal.title) - expect(promiseData[i].content.normal.text).assertEqual("test_text_otherApp"); - console.log("=======Ans_GetAllActive_0400 text========>"+promiseData[i].content.normal.text) - expect(promiseData[i].content.normal.additionalText).assertEqual("test_additionalText_otherApp"); - console.log("===Ans_GetAllActive_0400 text====>"+promiseData[i].content.normal.additionalText) - expect(promiseData[i].id).assertEqual(2); - console.log("============Ans_GetAllActive_0400 id============>"+promiseData[i].id) - expect(promiseData[i].label).assertEqual("otherApp"); - console.log("============Ans_GetAllActive_0400 label=====>"+promiseData[i].label) - } - console.debug("===============Ans_GetAllActive_0400 getAllActiveNotifications end==================>"); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0400 setTimeout==================>"); - done(); - }, time); - }) - - function getAllCallbackFive(err, data){ - console.log("Ans_GetAllActive_0500 getAllCallbackFive data.length============>"+data.length); - console.log("Ans_GetAllActive_0500 getAllCallbackFive data============>"+JSON.stringify(data)); - expect(data.length).assertEqual(0); - } - - /* - * @tc.number: Ans_GetAllActive_xts_0500 - * @tc.name: getAllActiveNotifications(callback: AsyncCallback>): void; - * @tc.desc: Verify: After the current app and other apps publish two notifications, remove all the notifications - of the system, get all active notifications in the system(callback) - */ - it('Ans_GetAllActive_xts_0500', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0500 start==================>"); - await notify.cancelAll(); - var notificationRequestOfOtherApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_otherApp", - text: "test_text_otherApp", - additionalText: "test_additionalText_otherApp" - }, - }, - id: 2, - label: "otherApp", - } - await notify.publish(notificationRequestOfOtherApp); - console.debug("===============Ans_GetAllActive_0500 publish OtherApp notify end==================>"); - var notificationRequestOfCurrentApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_currentApp", - text: "test_text_currentApp", - additionalText: "test_additionalText_currentApp" - }, - }, - id: 1, - label: "currentApp_0500", - } - await notify.publish(notificationRequestOfCurrentApp); - console.debug("===============Ans_GetAllActive_0500 publish CurrentApp notify end==================>"); - await notify.removeAll(); - notify.getAllActiveNotifications(getAllCallbackFive); - console.debug("===============Ans_GetAllActive_0500 getAllActiveNotifications end==================>"); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0500 setTimeout==================>"); - done(); - }, time); - }) - - /* - * @tc.number: Ans_GetAllActive_xts_0600 - * @tc.name: getAllActiveNotifications(): Promise>; - * @tc.desc: Verify: After the current app and other apps publish two notifications, remove all the notifications - of the system, get all active notifications in the system(promise) - */ - it('Ans_GetAllActive_xts_0600', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0600 start==================>"); - await notify.cancelAll(); - var notificationRequestOfOtherApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_otherApp", - text: "test_text_otherApp", - additionalText: "test_additionalText_otherApp" - }, - }, - id: 2, - label: "otherApp", - } - await notify.publish(notificationRequestOfOtherApp); - console.debug("===============Ans_GetAllActive_0600 publish OtherApp notify end==================>"); - var notificationRequestOfCurrentApp = { - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title_currentApp", - text: "test_text_currentApp", - additionalText: "test_additionalText_currentApp" - }, - }, - id: 1, - label: "currentApp_0600", - } - await notify.publish(notificationRequestOfCurrentApp); - console.debug("==========Ans_GetAllActive_0600 publish CurrentApp notify end==================>"); - await notify.removeAll(); - var promiseData = await notify.getAllActiveNotifications(); - expect(promiseData.length).assertEqual(0); - console.debug("=======Ans_GetAllActive_0600 promiseData.length==========>"+promiseData.length); - console.debug("=======Ans_GetAllActive_0600 promiseData==========>"+JSON.stringify(promiseData)); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0600 setTimeout==================>"); - done(); - }, time); - }) - - function getAllCallbackSeven(err, data){ - console.log("Ans_GetAllActive_0700 getAllCallbackSeven data.length============>"+data.length); - console.log("Ans_GetAllActive_0700 getAllCallbackSeven data============>"+JSON.stringify(data)); - expect(data.length).assertEqual(0); - } - - /* - * @tc.number: Ans_GetAllActive_xts_0700 - * @tc.name: getAllActiveNotifications(callback: AsyncCallback>): void; - * @tc.desc: Verify:No active notifications in the system, get all active notifications in the system(callback) - */ - it('Ans_GetAllActive_xts_0700', 0, async function (done) { - console.debug("===============Ans_GetAllActive_0700 start==================>"); - await notify.removeAll(); - notify.getAllActiveNotifications(getAllCallbackSeven); - console.debug("===============Ans_GetAllActive_0700 getAllActiveNotifications end==================>"); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0700 setTimeout==================>"); - done(); - }, time); - }) - - /* - * @tc.number: Ans_GetAllActive_xts_0800 - * @tc.name: getAllActiveNotifications(): Promise>; - * @tc.desc: Verify: No active notifications in the system, get all active notifications in the system(promise) - */ - it('Ans_GetAllActive_xts_0800', 0, async function (done) { - console.debug("==========Ans_GetAllActive_0800 start==================>"); - await notify.removeAll(); - var promiseData = await notify.getAllActiveNotifications(); - console.debug("=========Ans_GetAllActive_0800 promiseData.length=============>"+promiseData.length); - expect(promiseData.length).assertEqual(0); - setTimeout(function(){ - console.debug("===============Ans_GetAllActive_0800 setTimeout==================>"); - done(); - }, time); - }) }) diff --git a/notification/ans_standard/publish_test/badgedisplayed/badgedisplay/entry/src/main/js/test/BadgeDisplay.js b/notification/ans_standard/publish_test/badgedisplayed/badgedisplay/entry/src/main/js/test/BadgeDisplay.js index be0e7835dff98a1aed0b49029d5cb4b3fa2df12c..c0264f1f0b4661b989033567baf6b2c2473c7b43 100644 --- a/notification/ans_standard/publish_test/badgedisplayed/badgedisplay/entry/src/main/js/test/BadgeDisplay.js +++ b/notification/ans_standard/publish_test/badgedisplayed/badgedisplay/entry/src/main/js/test/BadgeDisplay.js @@ -32,22 +32,7 @@ describe('ActsAnsBadgeDisplayTest', function () { done(); }) }) - /* - * @tc.number: ActsGetDisplay_test_0200 - * @tc.name: isBadgeDisplayed() - * @tc.desc: verify the function of isBadgeDisplayed - */ - it('ActsGetDisplay_test_0200', 0, async function (done) { - notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - }).then((promise)=>{ - console.log("===>ActsGetDisplay_test_0200 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - done()} - ).catch((err)=>{ - console.log("===>ActsGetDisplay_test_0200 err===>"+err.code) - }) - }) + /* * @tc.number: ActsGetDisplay_test_0300 * @tc.name: isBadgeDisplayed() @@ -122,45 +107,7 @@ describe('ActsAnsBadgeDisplayTest', function () { expect(promise).assertEqual(undefined) done(); }) - /* - * @tc.number: ActsGetDisplay_test_0900 - * @tc.name: isBadgeDisplayed() - * @tc.desc: verify the function of isBadgeDisplayed - */ - it('ActsGetDisplay_test_0900', 0, async function (done) { - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },true,async(err) => { - console.log("===>ActsGetDisplay_test_0900 success===>"+err) - await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - },(err,data) => { - console.log("===>ActsGetDisplay_test_0900 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(true) - done(); - }) - }) - }) - /* - * @tc.number: ActsGetDisplay_test_1000 - * @tc.name: isBadgeDisplayed() - * @tc.desc: verify the function of isBadgeDisplayed - */ - it('ActsGetDisplay_test_1000', 0, async function (done) { - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },true,async(err) => { - console.log("===>ActsGetDisplay_test_1000 success===>"+err) - var promise = await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - }) - console.log("===>ActsGetDisplay_test_1000 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - }) + /* * @tc.number: ActsSetDisplay_test_0100 * @tc.name: displayBadge() @@ -214,43 +161,7 @@ describe('ActsAnsBadgeDisplayTest', function () { done(); }) }) - /* - * @tc.number: ActsSetDisplay_test_0500 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDisplay_test_0500', 0, async function (done) { - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },true,async(err) => { - await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - },(err,data) => { - console.log("===>ActsSetDisplay_test_0500 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(true) - done(); - }) - }) - }) - /* - * @tc.number: ActsSetDisplay_test_0600 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDisplay_test_0600', 0, async function (done) { - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },true).then(async(err) => { - var promise = await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - }) - console.log("===>ActsSetDisplay_test_0600 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - }) + /* * @tc.number: ActsSetDisplay_test_0700 * @tc.name: displayBadge() @@ -270,49 +181,6 @@ describe('ActsAnsBadgeDisplayTest', function () { }) }) }) - /* - * @tc.number: ActsSetDisplay_test_0800 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDisplay_test_0800', 0, async function (done) { - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },false).then(async(err) => { - var promise = await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - }) - console.log("===>ActsSetDisplay_test_0800 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(false) - done(); - }) - }) - /* - * @tc.number: ActsSetDisplay_test_0900 - * @tc.name: enableNotification() - * @tc.desc: verify the function of enableNotification - */ - it('ActsSetDisplay_test_0900', 0, async function (done) { - await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - },(err,data) => { - console.log("===>ActsSetDisplay_test_0900 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(false) - }) - await notify.displayBadge({ - bundle:"com.example.actsanslocalcandisplaytest" - },true).then(async(err) => { - var promise = await notify.isBadgeDisplayed({ - bundle:"com.example.actsanslocalcandisplaytest", - }) - console.log("===>ActsSetDisplay_test_0900 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - }) }) diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/doNotDisturbTest.js b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/doNotDisturbTest.js index 906d1d30b9f6bb8daadb3059ad07b25f73773ede..285953c3fb501e69b5f3e4ac89edf6faafa7ebce 100644 --- a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/doNotDisturbTest.js +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/doNotDisturbTest.js @@ -41,610 +41,6 @@ describe('ActsAnsDoNotDisturbTest', function () { expect(err.code).assertEqual(0); } - /* - * @tc.number: ActsGetDoNotDisturbTest_test_0100 - * @tc.name: getDoNotDisturbDate() - * @tc.desc: verify the function of getDoNotDisturbDate - */ - it('ActsGetDoNotDisturbTest_test_0100', 0, async function (done) { - await notify.getDoNotDisturbDate((err,data) => { - console.log("===>ActsGetDoNotDisturbTest_test_0100 success===>"+JSON.stringify(data)) - expect(data.type).assertEqual(0); - expect(data.begin.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - expect(data.end.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - done(); - }) - }) - - /* - * @tc.number: ActsGetDoNotDisturbTest_test_0200 - * @tc.name: getDoNotDisturbDate() - * @tc.desc: verify the function of getDoNotDisturbDate - */ - it('ActsGetDoNotDisturbTest_test_0200', 0, async function (done) { - notify.getDoNotDisturbDate().then((promise)=>{ - console.log("===>test_0200 success===>"+JSON.stringify(promise)) - expect(promise.type).assertEqual(0); - expect(promise.begin.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - expect(promise.end.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - done()} - ).catch((err)=>{ - console.log("===>ActsGetDoNotDisturbTest_test_0200 err===>"+JSON.stringify(err)) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0300 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0300', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+8, - beginDate.getMinutes()) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>test_0300 success===>"+err.code) - await notify.getDoNotDisturbDate((err,data)=>{ - console.log("===>test_0300 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) - expect(data.type).assertEqual(0); - expect(data.begin.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - expect(data.end.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0400 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0400', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+8, - beginDate.getMinutes()+20) - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate().then((data)=>{ - console.log("===>test_0400 getDoNotDisturbDate===>"+JSON.stringify(data)); - expect(data.type).assertEqual(0); - expect(data.begin.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - expect(data.end.toString()).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000"); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0500 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0500', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+8, - beginDate.getMinutes()) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_ONCE, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>test_0500 success===>"+err.code); - await notify.getDoNotDisturbDate(async (err,data)=>{ - console.log("===>test_0500 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) - expect(data.type).assertEqual(1); - var DoNotDateE = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>getDoNotDisturbDate DoNotDateE===>"+DoNotDateE) - console.log("===>getDoNotDisturbDate beginDate===>"+data.begin) - console.log("===>getDoNotDisturbDate endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateE.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0600 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0600', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+6, - beginDate.getMinutes()) - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_ONCE, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate().then(async(data)=>{ - console.log("===>test_0600 success===>"+JSON.stringify(data)) - expect(data.type).assertEqual(1); - var DoNotDateF = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>test_0600 begin===>"+DoNotDateF) - console.log("===>test_0600 beginDate===>"+data.begin) - console.log("===>test_0600 endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateF.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0700 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0700', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+7, - beginDate.getMinutes()+36) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>test_0700 success===>"+err.code) - await notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_0700 getDoNotDisturbDate===>"+JSON.stringify(data)) - expect(data.type).assertEqual(2); - var DoNotDateG = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>0700 begin===>"+DoNotDateG) - console.log("===>0700 beginDate===>"+data.begin) - console.log("===>0700 endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateG.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0800 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDoNotDisturbTest_test_0800', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+13, - beginDate.getMinutes()+48) - console.log("===>ActsSetDoNotDisturbTest_test_0800 beginDate ===>"+beginDate) - console.log("===>ActsSetDoNotDisturbTest_test_0800 endDate ===>"+endDate) - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate().then(async(data)=>{ - console.log("===>test_0800 success===>"+JSON.stringify(data)) - expect(data.type).assertEqual(2); - var DoNotDateH = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>0800 begin===>"+DoNotDateH) - console.log("===>0800 beginDate===>"+data.begin) - console.log("===>0800 endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateH.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_0900 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_0900', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+4, - beginDate.getMinutes()) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>ActsSetDoNotDisturbTest_test_0900 success===>"+err.code) - await notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_0900 getDoNotDisturbDate===>"+JSON.stringify(data)) - expect(data.type).assertEqual(3); - var DoNotDateI = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>test_0900 begin===>"+DoNotDateI) - console.log("===>test_0900 beginDate===>"+data.begin) - console.log("===>test_0900 endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateI.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1000 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDoNotDisturbTest_test_1000', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+6, - beginDate.getMinutes()+32) - console.log("===>test_1000 beginDate ===>"+beginDate) - console.log("===>test_1000 endDate ===>"+endDate) - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate().then(async(data)=>{ - console.log("===>test_1000 getDoNotDisturbDate===>"+JSON.stringify(data)) - expect(data.type).assertEqual(3); - var DoNotDateJ = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - console.log("===>test_1000 begin===>"+DoNotDateJ) - console.log("===>test_1000 beginDate===>"+data.begin) - console.log("===>test_1000 endDate===>"+data.end) - expect(data.begin.toString()).assertEqual(DoNotDateJ.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1100 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1100', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date() - console.log("===>test_1100 beginDate ===>"+beginDate) - console.log("===>test_1100 endDate ===>"+endDate) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>test_1100 success===>"+err.code) - await notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_1100 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) - expect(data.type).assertEqual(2); - var DoNotDateK = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateK.toString()); - expect(data.end.toString()).assertEqual(DoNotDateK.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1100 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1200', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date() - console.log("===>test_1200 beginDate ===>"+beginDate) - console.log("===>test_1200 endDate ===>"+endDate) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_1200 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)); - expect(data.type).assertEqual(2); - var DoNotDateL = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateL.toString()); - expect(data.end.toString()).assertEqual(DoNotDateL.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }).catch(async(err)=>{ - console.log("===>test_1200 getDoNotDisturbDate fail===>"+JSON.stringify(err)) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1300 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1300', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate()-2, - beginDate.getHours()+6, - beginDate.getMinutes()+32) - console.log("===>test_1300 beginDate ===>"+beginDate) - console.log("===>test_1300 endDate ===>"+endDate) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>test_1300 success===>"+err.code) - await notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_1300 getDoNotDisturbDate success===>"+err.code+JSON.stringify(data)) - expect(data.type).assertEqual(2); - var DoNotDateM = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateM.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1400 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1400', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate()-1, - beginDate.getHours()+6, - beginDate.getMinutes()+32) - console.log("===>test_1400 beginDate ===>"+beginDate) - console.log("===>test_1400 endDate ===>"+endDate) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - }).then(()=>{ - notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_1400 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) - expect(data.type).assertEqual(2); - var DoNotDateN = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateN.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }).catch(async(err)=>{ - console.log("===>test_1400 getDoNotDisturbDate fail===>"+JSON.stringify(err)) - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1500 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1500', 0, async function (done) { - var beginDate = new Date(2021,11,22,12,18); - var endDate = new Date(2021,11,22,12,18); - console.log("===>test_1500 beginDate ===>"+beginDate); - console.log("===>test_1500 endDate ===>"+endDate); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - },async(err) => { - console.log("===>ActsSetDoNotDisturbTest_test_1500 success===>"+err.code); - expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1600 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_1600', 0, async function (done) { - var beginDate = new Date(2021,11,22,12,18); - var endDate = new Date(2021,11,22,12,18); - console.log("===>test_1600 beginDate ===>"+beginDate); - console.log("===>test_1600 endDate ===>"+endDate); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - }).then().catch(async(err)=>{ - console.log("===>test_1600 fail===>"+JSON.stringify(err)); - expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1700 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDoNotDisturbTest_test_1700', 0, async function (done) { - var beginDate = new Date(2021,11,22,20,18); - var endDate = new Date(2021,11,22,2,18); - console.log("===>test_1700 beginDate ===>"+beginDate); - console.log("===>test_1700 endDate ===>"+endDate); - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - },async(err)=>{ - console.log("===>test_1700 setDoNotDisturbDate===>"+JSON.stringify(err)); - expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_1800 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDoNotDisturbTest_test_1800', 0, async function (done) { - var beginDate = new Date(2021,11,22,20,18); - var endDate = new Date(2021,11,22,2,18); - console.log("===>test_1800 beginDate ===>"+beginDate); - console.log("===>test_1800 endDate ===>"+endDate); - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - }).then().catch(async(err)=>{ - console.log("===>test_1800 setDoNotDisturbDate fail===>"+JSON.stringify(err)) - expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }) - /* * @tc.number: ActsSetDoNotDisturbTest_test_1900 * @tc.name: setDoNotDisturbDate() @@ -679,542 +75,6 @@ describe('ActsAnsDoNotDisturbTest', function () { expect(promise).assertEqual(undefined); done(); }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2100 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_2100', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+11, - beginDate.getMinutes()+26) - var subInfo ={ - onConnect:connectCallbacka, - onDoNotDisturbDateChange:async(data)=>{ - console.debug("==>disturbModeCallbacka data==>" +JSON.stringify(data)); - expect(data.type).assertEqual(3); - var DoNotDateO = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateO.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.getDoNotDisturbDate(async(err,data)=>{ - console.log("===>test_2100 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) - notify.unsubscribe(subInfo, unSubscribeCallbacka); - expect(data.type).assertEqual(3); - var DoNotDateP = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateP.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }, - } - await notify.subscribe(subInfo,subscribeCallbacka); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - },async (err) => { - console.log("===>test_2100 success===>"+err.code); - }) - }) - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2200 - * @tc.name: displayBadge() - * @tc.desc: verify the function of displayBadge - */ - it('ActsSetDoNotDisturbTest_test_2200', 0, async function (done) { - var beginDate = new Date() - var endDate = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours()+16, - beginDate.getMinutes()+45) - var subInfo ={ - onConnect:connectCallbackb, - onDoNotDisturbDateChange:async(data)=>{ - console.debug("==>disturbModeCallbackb data==>" +JSON.stringify(data)); - expect(data.type).assertEqual(3); - var DoNotDateQ = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateQ.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.getDoNotDisturbDate().then(async(data)=>{ - console.log("===>test_2200 getDoNotDisturbDate===>"+JSON.stringify(data)); - notify.unsubscribe(subInfo, unSubscribeCallbackb); - expect(data.type).assertEqual(3); - var DoNotDateR = new Date(beginDate.getFullYear(), - beginDate.getMonth(), - beginDate.getDate(), - beginDate.getHours(), - beginDate.getMinutes()) - expect(data.begin.toString()).assertEqual(DoNotDateR.toString()); - expect(data.end.toString()).assertEqual(endDate.toString()); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }) - }, - } - await notify.subscribe(subInfo,subscribeCallbackb); - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY, - begin:beginDate, - end:endDate - }).then(()=>{ - console.log("===>test_2200 setDoNotDisturbDate===>") - }) - }) - - /* - * @tc.number: ActsGetDoNotDisturbTest_test_2300 - * @tc.name: supportDoNotDisturbMode() - * @tc.desc: verify the function of supportDoNotDisturbMode - */ - it('ActsGetDoNotDisturbTest_test_2300', 0, async function (done) { - await notify.supportDoNotDisturbMode((err,data) => { - console.log("===>test_2300 success===>"+JSON.stringify(err)+data); - expect(data).assertEqual(true); - done(); - }) - }) - - /* - * @tc.number: ActsGetDoNotDisturbTest_test_2400 - * @tc.name: supportDoNotDisturbMode() - * @tc.desc: verify the function of supportDoNotDisturbMode - */ - it('ActsGetDoNotDisturbTest_test_2400', 0, async function (done) { - notify.supportDoNotDisturbMode().then((promise)=>{ - console.log("===>ActsGetDoNotDisturbTest_test_2400 success===>"+promise); - expect(promise).assertEqual(true); - done()} - ).catch((err)=>{ - console.log("===>test_2400 err===>"+err.code); - }) - }) - - function addSlotCallback(err){ - console.log("addSlotCallback err==>"+JSON.stringify(err)); - } - - function onDoNotDisturbDateChange(mode){ - console.log("===test_2500 onDisturbModeChange mode===>"+JSON.stringify(mode)); - expect(mode.type).assertEqual(2); - } - - function onConsume(data){ - console.log("===test_2500 onConsume===>"+JSON.stringify(data)); - var hashCode = data.request.hashCode - var sound = data.sortingMap.sortings[hashCode].slot.sound - console.log("===test_2500 onConsume sound===>"+sound); - expect(sound).assertEqual("normalSocialMusic"); - var vibra = data.sortingMap.sortings[hashCode].slot.vibrationValues - console.log("===test_2500 onConsume vibra===>"+vibra); - expect(JSON.stringify(vibra)).assertEqual(JSON.stringify([1,0,1,0,1,0])); - console.log("===test_2500 onConsume end===>"); - } - function publishCallback(err){ - console.log("===publishCallback===>"+JSON.stringify(err)); - } - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2500 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_2500', 0, async function (done) { - notify.addSlot({ - type:notify.SlotType.SOCIAL_COMMUNICATION, - level:notify.SlotLevel.LEVEL_NONE, - desc:"SOCIAL_COMMUNICATION_desc", - badgeFlag:true, - bypassDnd:false, - lightEnabled:true, - lightColor:1, - vibrationValues:[1,0,1,0,1,0], - sound:"normalSocialMusic", - },addSlotCallback); - - var subscriber ={ - onConsume:onConsume, - onDoNotDisturbDateChange:onDoNotDisturbDateChange, - } - - await notify.subscribe(subscriber); - - var beginDate = new Date(2021,11,23,0,0); - var endDate = new Date(2021,11,23,23,59); - - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - },(err) => { - console.log("===test_2500 setDoNotDisturbDate===>"+err.code) - }) - - await notify.publish({ - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - }, - }, - id: 21, - slotType : notify.SlotType.SOCIAL_COMMUNICATION, - isOngoing : true, - isUnremovable : false, - deliveryTime : 1624950453, - tapDismissed : true, - autoDeletedTime: 1625036817, - color: 2, - colorEnabled: true, - isAlertOnce: true, - isStopwatch: true, - isCountDown: true, - progressValue: 12, - progressMaxValue: 100, - isIndeterminate: true, - statusBarText: "normalSocialVibra_statusBarText", - isFloatingIcon : true, - label: "normalSocialVibra_label", - badgeIconStyle: 1, - showDeliveryTime: true, - },publishCallback); - setTimeout((async function(){ - console.info("===test_2500 setTimeout===>"); - await notify.unsubscribe(subscriber); - console.info("===test_2500 setTimeout unsubscribe===>"); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - console.info("====test_2500 setDoNotDisturbDate removeSlot============>"); - await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); - console.info("====test_2500 setTimeout removeSlot============>"); - done(); - }),500); - }) - - function onDoNotDisturbDateChange2600(mode){ - console.log("===test_2600 onDisturbModeChange mode===>"+JSON.stringify(mode)); - expect(mode.type).assertEqual(2); - } - - function onConsume2600(data){ - console.log("===test_2600 onConsume===>"+JSON.stringify(data)); - var hashCode = data.request.hashCode - var sound = data.sortingMap.sortings[hashCode].slot.sound - console.log("===test_2600 onConsume sound===>"+sound); - expect(sound).assertEqual("normalSocialMusic"); - var vibra = data.sortingMap.sortings[hashCode].slot.vibrationValues - console.log("===test_2600 onConsume vibra===>"+vibra); - expect(JSON.stringify(vibra)).assertEqual(JSON.stringify([1,0,1,0,1,0])); - console.log("===test_2600 onConsume end===>"); - } - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2600 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_2600', 0, async function (done) { - notify.addSlot({ - type:notify.SlotType.SOCIAL_COMMUNICATION, - level:notify.SlotLevel.LEVEL_NONE, - desc:"SOCIAL_COMMUNICATION_desc", - badgeFlag:true, - bypassDnd:false, - lightEnabled:true, - lightColor:1, - vibrationValues:[1,0,1,0,1,0], - sound:"normalSocialMusic", - },addSlotCallback); - - var subscriber ={ - onConsume:onConsume2600, - onDoNotDisturbDateChange:onDoNotDisturbDateChange2600, - } - - await notify.subscribe(subscriber); - - var beginDate = new Date(2021,11,23,0,0); - var endDate = new Date(2021,11,23,23,59); - - notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_DAILY, - begin:beginDate, - end:endDate - },(err)=>{ - console.log("===test_2600 setDoNotDisturbDate===>"+err.code) - }) - - await notify.publish({ - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - }, - }, - id: 22, - slotType : notify.SlotType.SOCIAL_COMMUNICATION, - isOngoing : true, - isUnremovable : false, - deliveryTime : 1624950453, - tapDismissed : true, - autoDeletedTime: 1625036817, - color: 2, - colorEnabled: true, - isAlertOnce: true, - isStopwatch: true, - isCountDown: true, - progressValue: 12, - progressMaxValue: 100, - isIndeterminate: true, - statusBarText: "normalSocialVibra_statusBarText", - isFloatingIcon : true, - label: "normalSocialVibra_label", - badgeIconStyle: 1, - showDeliveryTime: true, - },publishCallback); - setTimeout((async function(){ - console.info("====test_2600 setTimeout====>"); - await notify.unsubscribe(subscriber); - console.info("====test_2600 setTimeout unsubscribe====>"); - await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); - console.info("====test_2600 setTimeout removeSlot============>"); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - console.info("====test_2600 setTimeout setDoNotDisturbDate============>"); - done(); - }),500); - }) - - function onDoNotDisturbDateChange2700(mode){ - console.log("===test_2700 onDisturbModeChange mode===>"+JSON.stringify(mode)); - expect(mode.type).assertEqual(3); - } - - function onConsume2700(data){ - console.log("===test_2700 onConsume===>"+JSON.stringify(data)); - var hashCode = data.request.hashCode - var sound = data.sortingMap.sortings[hashCode].slot.sound - console.log("===test_2700 onConsume sound===>"+sound); - expect(sound).assertEqual("normalSocialMusic"); - var vibra = data.sortingMap.sortings[hashCode].slot.vibrationValues - console.log("===test_2700 onConsume vibra===>"+vibra); - expect(JSON.stringify(vibra)).assertEqual(JSON.stringify([1,0,1,0,1,0])); - console.log("===test_2700 onConsume end===>"); - } - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2700 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_2700', 0, async function (done) { - notify.addSlot({ - type:notify.SlotType.SOCIAL_COMMUNICATION, - level:notify.SlotLevel.LEVEL_NONE, - desc:"SOCIAL_COMMUNICATION_desc", - badgeFlag:true, - bypassDnd:false, - lightEnabled:true, - lightColor:1, - vibrationValues:[1,0,1,0,1,0], - sound:"normalSocialMusic", - },addSlotCallback); - - var subscriber ={ - onConsume:onConsume2700, - onDoNotDisturbDateChange:onDoNotDisturbDateChange2700, - } - - await notify.subscribe(subscriber); - - var beginDate = new Date(2020,1,1,0,0); - var endDate = new Date(2099,12,31,23,59); - - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY , - begin:beginDate, - end:endDate - },(err) => { - console.log("===test_2700 setDoNotDisturbDate===>"+err.code) - }) - - await notify.publish({ - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - }, - }, - id: 23, - slotType : notify.SlotType.SOCIAL_COMMUNICATION, - isOngoing : true, - isUnremovable : false, - deliveryTime : 1624950453, - tapDismissed : true, - autoDeletedTime: 1625036817, - color: 2, - colorEnabled: true, - isAlertOnce: true, - isStopwatch: true, - isCountDown: true, - progressValue: 12, - progressMaxValue: 100, - isIndeterminate: true, - statusBarText: "normalSocialVibra_statusBarText", - isFloatingIcon : true, - label: "normalSocialVibra_label", - badgeIconStyle: 1, - showDeliveryTime: true, - },publishCallback); - setTimeout((async function(){ - console.info("====test_2700 setTimeout====>"); - await notify.unsubscribe(subscriber); - console.info("====test_2700 setTimeout unsubscribe============>"); - await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); - console.info("====test_2700 setTimeout removeSlot============>"); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }),500); - }) - - function onDoNotDisturbDateChange2800(mode){ - console.log("===test_2800 onDisturbModeChange mode===>"+JSON.stringify(mode)); - expect(mode.type).assertEqual(3); - } - - function onConsume2800(data){ - console.log("===test_2800 onConsume===>"+JSON.stringify(data)); - var hashCode = data.request.hashCode - var sound = data.sortingMap.sortings[hashCode].slot.sound - console.log("===test_2800 onConsume sound===>"+sound); - expect(sound).assertEqual("normalSocialMusic"); - var vibra = data.sortingMap.sortings[hashCode].slot.vibrationValues - console.log("===test_2800 onConsume vibra===>"+vibra); - expect(JSON.stringify(vibra)).assertEqual(JSON.stringify([1,0,1,0,1,0])); - console.log("===test_2800 onConsume end===>"); - } - - /* - * @tc.number: ActsSetDoNotDisturbTest_test_2800 - * @tc.name: setDoNotDisturbDate() - * @tc.desc: verify the function of setDoNotDisturbDate - */ - it('ActsSetDoNotDisturbTest_test_2800', 0, async function (done) { - notify.addSlot({ - type:notify.SlotType.SOCIAL_COMMUNICATION, - level:notify.SlotLevel.LEVEL_NONE, - desc:"SOCIAL_COMMUNICATION_desc", - badgeFlag:true, - bypassDnd:false, - lightEnabled:true, - lightColor:1, - vibrationValues:[1,0,1,0,1,0], - sound:"normalSocialMusic", - },addSlotCallback); - - var subscriber ={ - onConsume:onConsume2800, - onDoNotDisturbDateChange:onDoNotDisturbDateChange2800, - } - - await notify.subscribe(subscriber); - - var beginDate = new Date(2021,11,23,0,0); - var endDate = new Date(2021,11,23,23,59); - - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_CLEARLY , - begin:beginDate, - end:endDate - },(err) => { - console.log("===test_2800 setDoNotDisturbDate===>"+err.code) - }) - - await notify.publish({ - content:{ - contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, - normal: { - title: "test_title", - text: "test_text", - additionalText: "test_additionalText" - }, - }, - id: 24, - slotType : notify.SlotType.SOCIAL_COMMUNICATION, - isOngoing : true, - isUnremovable : false, - deliveryTime : 1624950453, - tapDismissed : true, - autoDeletedTime: 1625036817, - color: 2, - colorEnabled: true, - isAlertOnce: true, - isStopwatch: true, - isCountDown: true, - progressValue: 12, - progressMaxValue: 100, - isIndeterminate: true, - statusBarText: "normalSocialVibra_statusBarText", - isFloatingIcon : true, - label: "normalSocialVibra_label", - badgeIconStyle: 1, - showDeliveryTime: true, - },publishCallback); - setTimeout((async function(){ - console.info("======test_2800 setTimeout============>"); - await notify.unsubscribe(subscriber); - console.info("======test_2800 setTimeout unsubscribe============>"); - await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); - await notify.setDoNotDisturbDate({ - type:notify.DoNotDisturbType.TYPE_NONE, - begin:beginDate, - end:endDate - }); - done(); - }),500); - }) }) diff --git a/notification/ans_standard/publish_test/enablenotification/enablenotification/entry/src/main/js/test/EnableNotification.js b/notification/ans_standard/publish_test/enablenotification/enablenotification/entry/src/main/js/test/EnableNotification.js index f06977573d0035b2f6e227a3774fe3c10da48fb2..1992d1ccd3d15deb13e879c71c35f8345eebce55 100644 --- a/notification/ans_standard/publish_test/enablenotification/enablenotification/entry/src/main/js/test/EnableNotification.js +++ b/notification/ans_standard/publish_test/enablenotification/enablenotification/entry/src/main/js/test/EnableNotification.js @@ -18,41 +18,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' var time = 1000 describe('ActsAnsEnableNotificationTest', function () { console.info("===========ActsAnsEnableNotificationTest start====================>"); - /* - * @tc.number: ActsGetEnable_test_0100 - * @tc.name: isNotificationEnabled() - * @tc.desc: verify the function of isNotificationEnabled - */ - it('ActsGetEnable_test_0100', 0, async function (done) { - await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - },(err,data) => { - console.log("===>ActsGetEnable_test_0100 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(true) - done(); - }) - setTimeout(function(){ - console.debug("====>time out ActsGetEnable_test_0100====>"); - }, time); - }) - /* - * @tc.number: ActsGetEnable_test_0200 - * @tc.name: isNotificationEnabled() - * @tc.desc: verify the function of isNotificationEnabled - */ - it('ActsGetEnable_test_0200', 0, async function (done) { - var promise = await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - }) - console.log("===>ActsGetEnable_test_0200 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - setTimeout(function(){ - console.debug("====>time out ActsGetEnable_test_0200====>"); - }, time); - }) + /* * @tc.number: ActsGetEnable_test_0300 * @tc.name: isNotificationEnabled() @@ -129,45 +95,7 @@ describe('ActsAnsEnableNotificationTest', function () { expect(promise).assertEqual(undefined) done(); }) - /* - * @tc.number: ActsGetEnable_test_0900 - * @tc.name: isNotificationEnabled() - * @tc.desc: verify the function of isNotificationEnabled - */ - it('ActsGetEnable_test_0900', 0, async function (done) { - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },true,async(err) => { - console.log("===>ActsGetEnable_test_0900 success===>"+err) - await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - },(err,data) => { - console.log("===>ActsGetEnable_test_0900 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(true) - done(); - }) - }) - }) - /* - * @tc.number: ActsGetEnable_test_1000 - * @tc.name: isNotificationEnabled() - * @tc.desc: verify the function of isNotificationEnabled - */ - it('ActsGetEnable_test_1000', 0, async function (done) { - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },true,async(err) => { - console.log("===>ActsGetEnable_test_1000 success===>"+err) - var promise = await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - }) - console.log("===>ActsGetEnable_test_1000 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - }) + /* * @tc.number: ActsGetEnable_test_1100 * @tc.name: isNotificationEnabled() @@ -180,17 +108,7 @@ describe('ActsAnsEnableNotificationTest', function () { }) done(); }) - /* - * @tc.number: ActsGetEnable_test_1200 - * @tc.name: isNotificationEnabled() - * @tc.desc: verify the function of isNotificationEnabled - */ - it('ActsGetEnable_test_1200', 0, async function (done) { - var promise = await notify.isNotificationEnabled() - console.log("==========================>ActsGetEnable_test_1200 success=======================>"+promise) - expect(typeof(promise)).assertEqual('boolean') - done(); - }) + /* * @tc.number: ActsSetEnable_test_0100 * @tc.name: enableNotification() @@ -244,49 +162,7 @@ describe('ActsAnsEnableNotificationTest', function () { done(); }) }) - /* - * @tc.number: ActsSetEnable_test_0500 - * @tc.name: enableNotification() - * @tc.desc: verify the function of enableNotification - */ - it('ActsSetEnable_test_0500', 0, async function (done) { - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },true,async(err) => { - await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - },(err,data) => { - console.log("===>ActsSetEnable_test_0500 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(true) - done(); - }) - }) - setTimeout(function(){ - console.debug("====>time out ActsGetDisplay_test_0900====>"); - }, time); - }) - /* - * @tc.number: ActsSetEnable_test_0600 - * @tc.name: enableNotification() - * @tc.desc: verify the function of enableNotification - */ - it('ActsSetEnable_test_0600', 0, async function (done) { - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },true).then(async(err) => { - var promise = await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - }) - console.log("===>ActsSetEnable_test_0600 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - setTimeout(function(){ - console.debug("===>time out ActsSetEnable_test_0600===>"); - }, time); - }) + /* * @tc.number: ActsSetEnable_test_0700 * @tc.name: enableNotification() @@ -309,54 +185,5 @@ describe('ActsAnsEnableNotificationTest', function () { console.debug("====>time out ActsSetEnable_test_0700====>"); }, time); }) - /* - * @tc.number: ActsSetEnable_test_0800 - * @tc.name: enableNotification() - * @tc.desc: verify the function of enableNotification - */ - it('ActsSetEnable_test_0800', 0, async function (done) { - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },false).then(async(err) => { - var promise = await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - }) - console.log("===>ActsSetEnable_test_0800 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(false) - done(); - }) - setTimeout(function(){ - console.debug("===>time out ActsSetEnable_test_0800===>"); - }, time); - }) - /* - * @tc.number: ActsSetEnable_test_0900 - * @tc.name: enableNotification() - * @tc.desc: verify the function of enableNotification - */ - it('ActsSetEnable_test_0900', 0, async function (done) { - await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - },(err,data) => { - console.log("===>ActsSetEnable_test_0900 success===>"+err+data) - expect(typeof(data)).assertEqual('boolean') - expect(data).assertEqual(false) - }) - await notify.enableNotification({ - bundle:"com.example.actsanslocalnotificationtest" - },true).then(async(err) => { - var promise = await notify.isNotificationEnabled({ - bundle:"com.example.actsanslocalnotificationtest", - }) - console.log("===>ActsSetEnable_test_0900 success===>"+promise) - expect(typeof(promise)).assertEqual('boolean') - expect(promise).assertEqual(true) - done(); - }) - setTimeout(function(){ - console.debug("===>time out ActsSetEnable_test_0900===>"); - }, time); - }) }) diff --git a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/UnSubscriber.js b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/UnSubscriber.js index 218291c289631103b9ae4d830e36e67f8b071211..4d7d86830f28a37efa031181dc879fb9d9f77136 100644 --- a/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/UnSubscriber.js +++ b/notification/ans_standard/publish_test/unsubscribe/entry/src/main/js/test/UnSubscriber.js @@ -24,300 +24,6 @@ describe('ActsAnsUnSubscriberTest', function () { console.debug("===============Ans_UnSubscriber_0100 onDisconnect=================>"); } - /* - * @tc.number: Ans_UnSubscriber_0100 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; - * @tc.desc: Verify that the subscription can be successfully unsubscribed(callback) - */ - it('Ans_UnSubscriber_0100', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0100 start=============>"); - var subscriber ={ - onConnect:onConnecteOne, - onDisconnect:onDisconnectOne - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0100 subscribe=============>"); - notify.unsubscribe(subscriber, (err)=>{ - console.debug("===========Ans_UnSubscriber_0100 unsubscribe err.code=================>"+err.code); - expect(err.code).assertEqual(0); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0100 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteTwo() { - console.debug("============Ans_UnSubscriber_0200 onConnecteTwo=================>"); - } - function onDisconnectTwo() { - console.debug("============Ans_UnSubscriber_0200 onDisconnectTwo=================>"); - } - - /* - * @tc.number: Ans_UnSubscriber_0200 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber): Promise; - * @tc.desc: Verify that the subscription can be successfully unsubscribed(promise) - */ - it('Ans_UnSubscriber_0200', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0200 start=============>"); - var subscriber ={ - onConnect:onConnecteTwo, - onDisconnect:onDisconnectTwo - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0200 subscribe=============>"); - notify.unsubscribe(subscriber).then(()=>{ - console.debug("=======Ans_UnSubscriber_0200 subscribe then==========>"); - }).catch((err)=>{ - console.debug("=======Ans_UnSubscriber_0200 subscribe catch err==========>"+err.code); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0200 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteThree() { - console.debug("=======Ans_UnSubscriber_0300 onConnecteThree=================>"); - } - function onDisconnectThree() { - console.debug("=======Ans_UnSubscriber_0300 onDisconnectThree=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_0300 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; - * @tc.desc: Verify the use of the wrong subscriber to unsubscribe(callback) - */ - it('Ans_UnSubscriber_0300', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0300 start=============>"); - var subscriber ={ - onConnect:onConnecteThree, - onDisconnect:onDisconnectThree - } - var subscriberErr ={ - onConnect:"", - onDisconnect:"" - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0300 subscribe=============>"); - notify.unsubscribe(subscriberErr,(err)=>{ - console.debug("Ans_UnSubscriber_0300 unsubscribe callback err=========>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0300 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteFour() { - console.debug("=======Ans_UnSubscriber_0400 onConnecteFour=================>"); - } - function onDisconnectFour() { - console.debug("=======Ans_UnSubscriber_0400 onDisconnectFour=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_0400 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber): Promise; - * @tc.desc: Verify the use of the wrong subscriber to unsubscribe(promise) - */ - it('Ans_UnSubscriber_0400', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0400 start=============>"); - var subscriber ={ - onConnect:onConnecteFour, - onDisconnect:onDisconnectFour - } - var subscriberErr ={ - onConnect:"", - onDisconnect:"" - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0400 subscribe=============>"); - notify.unsubscribe(subscriberErr).then().catch((err)=>{ - console.debug("=======Ans_UnSubscriber_0400 subscribe catch err==========>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0400 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteFive() { - console.debug("=======Ans_UnSubscriber_0500 onConnecteFive=================>"); - } - function onDisconnectFive() { - console.debug("=======Ans_UnSubscriber_0500 onDisconnectFive=================>"); - expect().assertFail(); - } - function onConnecteTest() { - console.debug("=======Ans_UnSubscriber_0500 onConnecteTest=================>"); - expect().assertFail(); - } - function onDisconnectTest() { - console.debug("=======Ans_UnSubscriber_0500 onDisconnectTest=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_0500 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; - * @tc.desc: Verify that inconsistent subscriber is used to unsubscribe(callback) - */ - it('Ans_UnSubscriber_0500', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0500 start=============>"); - var subscriber ={ - onConnect:onConnecteFive, - onDisconnect:onDisconnectFive - } - var subscriberTest ={ - onConnect:onConnecteTest, - onDisconnect:onDisconnectTest - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0500 subscribe=============>"); - notify.unsubscribe(subscriberTest,(err)=>{ - console.debug("Ans_UnSubscriber_0500 unsubscribe err.code=================>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - console.info("===========Ans_UnSubscriber_0500 unsubscribe=============>"); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0500 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteSix() { - console.debug("=======Ans_UnSubscriber_0600 onConnecteSix =================>"); - } - function onDisconnectSix() { - console.debug("=======Ans_UnSubscriber_0600 onDisconnectSix=================>"); - expect().assertFail(); - } - function onConnecteTestTwo() { - console.debug("=======Ans_UnSubscriber_0600 onConnecteTestTwo=================>"); - expect().assertFail(); - } - function onDisconnectTestTwo() { - console.debug("=======Ans_UnSubscriber_0600 onDisconnectTestTwo=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_0600 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber): Promise; - * @tc.desc: Verify that inconsistent subscriber is used to unsubscribe(promise) - */ - it('Ans_UnSubscriber_0600', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0600 start=============>"); - var subscriber ={ - onConnect:onConnecteSix, - onDisconnect:onDisconnectSix - } - var subscriberTest ={ - onConnect:onConnecteTestTwo, - onDisconnect:onDisconnectTestTwo - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0600 subscribe=============>"); - notify.unsubscribe(subscriberTest).then().catch((err)=>{ - console.debug("=======Ans_UnSubscriber_0600 unsubscribe catch err=================>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0600 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteSeven() { - console.debug("=======Ans_UnSubscriber_0700 onConnecteSeven=================>"); - } - var timesOfOnDis - function onDisconnectSeven() { - console.debug("=======Ans_UnSubscriber_0700 onDisconnectSeven=================>"); - timesOfOnDis ++; - if(timesOfOnDis == 2){ - expect().assertFail(); - } - } - - /* - * @tc.number: Ans_UnSubscriber_0700 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; - * @tc.desc:Verification: After the subscription is successful, unsubscribe twice in a row.(callback) - */ - it('Ans_UnSubscriber_0700', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0700 start=============>"); - timesOfOnDis = 0 - var subscriber ={ - onConnect:onConnecteSeven, - onDisconnect:onDisconnectSeven - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0700 subscribe=============>"); - notify.unsubscribe(subscriber, (err)=>{ - console.debug("Ans_UnSubscriber_0700 unsubscribe first err.code=================>"+err.code); - expect(err.code).assertEqual(0); - notify.unsubscribe(subscriber, (err)=>{ - console.debug("Ans_UnSubscriber_0700 unsubscribe Second err.code=================>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0700 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteEight() { - console.debug("=======Ans_UnSubscriber_0800 onConnecteEight=================>"); - } - var timesOfOnDisTwo - function onDisconnectEight() { - console.debug("=======Ans_UnSubscriber_0800 onDisconnectEight err.code=================>"); - timesOfOnDisTwo ++; - if(timesOfOnDisTwo == 2){ - expect().assertFail(); - } - } - - /* - * @tc.number: Ans_UnSubscriber_0800 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber): Promise; - * @tc.desc: Verification: After the subscription is successful, unsubscribe twice in a row.(promise) - */ - it('Ans_UnSubscriber_0800', 0, async function (done) { - console.info("===========Ans_UnSubscriber_0800 start=============>"); - timesOfOnDisTwo = 0 - var subscriber ={ - onConnect:onConnecteEight, - onDisconnect:onDisconnectEight - } - await notify.subscribe(subscriber); - console.info("===========Ans_UnSubscriber_0800 subscribe=============>"); - notify.unsubscribe(subscriber).then((err)=>{ - console.debug("=======Ans_UnSubscriber_0800 subscribe first then err=================>"+err.code); - notify.unsubscribe(subscriber).then((err)=>{ - console.debug("=======Ans_UnSubscriber_0800 subscribe second then err=================>"+err.code); - }).catch((err)=>{ - console.debug("=======Ans_UnSubscriber_0800 subscribe second catch err=================>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - }).catch((err)=>{ - console.debug("=======Ans_UnSubscriber_0800 subscribe first catch err=================>"+err.code); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_0800 setTimeout=============>"); - done(); - }, time); - }) - function onDisconnectTestNine() { console.debug("=======Ans_UnSubscriber_0900 onDisconnectTestNine =================>"); expect().assertFail(); @@ -377,76 +83,5 @@ describe('ActsAnsUnSubscriberTest', function () { done(); }, time); }) - - function onConnecteEleven() { - console.debug("============Ans_UnSubscriber_1100 onConnecteEleven=================>"); - } - function onDisconnectEleven() { - console.debug("============Ans_UnSubscriber_1100 onDisconnectEleven=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_1100 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber, callback: AsyncCallback): void; - * @tc.desc: Verify: After the subscription with anonymous Subscribers is successful, - unsubscribing with anonymous subscribers will fail(callback) - */ - it('Ans_UnSubscriber_1100', 0, async function (done) { - console.info("===========Ans_UnSubscriber_1100 start=============>"); - await notify.subscribe({ - onConnect:onConnecteEleven, - onDisconnect:onDisconnectEleven - }); - notify.unsubscribe( - { - onConnect:onConnecteOne, - onDisconnect:onDisconnectOne - }, - (err)=>{ - console.debug("Ans_UnSubscriber_1100 unSubscribeCallbackEleven err.code=================>"+err.code); - expect(err.code != 0).assertEqual(true); - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_1100 setTimeout=============>"); - done(); - }, time); - }) - - function onConnecteTwelve() { - console.debug("============Ans_UnSubscriber_1200 onConnecteTwelve=================>"); - } - function onDisconnectTwelve() { - console.debug("============Ans_UnSubscriber_1200 onDisconnectTwelve=================>"); - expect().assertFail(); - } - - /* - * @tc.number: Ans_UnSubscriber_1200 - * @tc.name: unsubscribe(subscriber: NotificationSubscriber): Promise; - * @tc.desc: Verify: After the subscription with anonymous Subscribers is successful, - unsubscribing with anonymous subscribers will fail(promise) - */ - it('Ans_UnSubscriber_1200', 0, async function (done) { - console.info("===========Ans_UnSubscriber_1200 start=============>"); - await notify.subscribe({ - onConnect:onConnecteTwelve, - onDisconnect:onConnecteTwelve - }); - notify.unsubscribe({ - onConnect:onConnecteTwelve, - onDisconnect:onDisconnectTwelve - }).then((err)=>{ - console.info("===========Ans_UnSubscriber_1200 unsubscribe then err=============>"+err.code); - }).catch((err)=>{ - console.info("===========Ans_UnSubscriber_1200 unsubscribe catch err=============>"+err.code); - expect(err.code != 0).assertEqual(true); - - }); - setTimeout(function(){ - console.debug("===========Ans_UnSubscriber_1200 setTimeout=============>"); - done(); - }, time); - }); })