diff --git a/notification/ans_standard/BUILD.gn b/notification/ans_standard/BUILD.gn index 9c176177fab3bf855c80998e8b44d3f5c9135d86..c7665fac45ec4a0b3bc560a582185e11943b34fb 100644 --- a/notification/ans_standard/BUILD.gn +++ b/notification/ans_standard/BUILD.gn @@ -16,8 +16,8 @@ group("ans_standard") { testonly = true if (is_standard_system) { deps = [ - #"actsansnotificationcancel:ActsAnsNotificationCancel", - #"actsansnotificationremove:ActsAnsNotificationRemove", + "actsansnotificationcancel:ActsAnsNotificationCancel", + "actsansnotificationremove:ActsAnsNotificationRemove", "actsansslottest:ActsAnsSlotTest", "publish_test:publish_test", ] diff --git a/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js b/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js index 35d5b954b0409904468cb14fb7df541254430cd6..7f2438de09cca23ca3887d394aef1c81bc224ec8 100644 --- a/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js +++ b/notification/ans_standard/actsansnotificationcancel/entry/src/main/js/test/ActsAnsNotificationCancel.test.js @@ -19,12 +19,12 @@ var timeout = 500; describe('ActsAnsNotificationCancel', function () { console.info("===========ActsAnsNotificationCancel start====================>"); var timesOfOnConsume - async function onConsumeCancelAll(data) { + function onConsumeCancelAll(data) { console.info("================ANS_Cancel_0100 onConsume start=======================>"); console.info("================ANS_Cancel_0100 onConsume data:=================>" + JSON.stringify(data)); timesOfOnConsume = timesOfOnConsume + 1 if (timesOfOnConsume == 2){ - await notify.cancelAll(cancelAllCallBack); + notify.cancelAll(cancelAllCallBack); console.info("================ANS_Cancel_0100 onConsume cancelAll=======================>"); } console.info("================ANS_Cancel_0100 onConsume end=======================>"); @@ -40,8 +40,6 @@ describe('ActsAnsNotificationCancel', function () { expect(data.request.id).assertEqual(2); } console.info("================ANS_Cancel_0100 onCancel end=======================>"); - console.info("===========ANS_Cancel_0100 onCancel unsubscribe promise========>"); - } function cancelAllCallBack(err, data){ console.info("========ANS_Cancel_0100 cancelAllCallBack start==============>"); @@ -124,15 +122,15 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===========ANS_Cancel_0100 subscribe promise=======>"); - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Cancel_0100 publish1 promise=======>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("===========ANS_Cancel_0100 publish2 promise=======>"); setTimeout((async function(){ console.info("======ANS_Cancel_0100 setTimeout==================>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0100 setTimeout unsubscribe==================>"); done(); }),timeout); @@ -176,7 +174,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAllPromise, onCancel:onCancelCancelAllPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Cancel_0200 subscribe promise==================>"); var notificationRequest = { content:{ @@ -238,12 +236,12 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Cancel_0200 publish1 promise==================>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("==========ANS_Cancel_0200 publish2 promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0200 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -283,12 +281,12 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAllNoNotify, onCancel:onCancelCancelAllNoNotify, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Cancel_0300 subscribe promise===============>"); - await notify.cancelAll(cancelAllCallBackNoNotify); + notify.cancelAll(cancelAllCallBackNoNotify); console.info("===============ANS_Cancel_0300 cancelAll promise===============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0300 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -322,12 +320,12 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAllNoNotifyPromise, onCancel:onCancelCancelAllNoNotifyPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_0400 subscribe promise=============>"); - await notify.cancelAll(); + notify.cancelAll(); console.info("================ANS_Cancel_0400 cancelAll promise=============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0400 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -380,7 +378,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAll2Times, onCancel:onCancelCancelAll2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Cancel_0500 subscribe promise======>"); var notificationRequest = { content:{ @@ -412,10 +410,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Cancel_0500 publish promise end==============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0500 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -455,7 +453,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAll2TimesPromise, onCancel:onCancelCancelAll2TimesPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Cancel_0600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -487,10 +485,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Cancel_0600 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0600 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -529,7 +527,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAllIsUnremovable, onCancel:onCancelCancelAllIsUnremovable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("========ANS_Cancel_0700 subscribe promise==================>"); var notificationRequest = { content:{ @@ -561,10 +559,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Cancel_0700 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0700 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -597,7 +595,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelAllIsUnremovablPromise, onCancel:onCancelCancelAllIsUnremovablePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Cancel_0800 subscribe promsie==================>"); var notificationRequest = { content:{ @@ -629,10 +627,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=========ANS_Cancel_0800 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0800 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -669,7 +667,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancel, onCancel:onCancelCancel, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Cancel_0900 subscribe promise==================>"); var notificationRequest = { content:{ @@ -700,10 +698,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Cancel_0900 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_0900 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -743,7 +741,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelWrongId, onCancel:onCancelCancelWrongId, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_1000 subscribe promise==================>"); var notificationRequest = { content:{ @@ -775,10 +773,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Cancel_1000 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1000 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -818,7 +816,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelIsUnremovable, onCancel:onCancelCancelIsUnremovable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Cancel_1100 subscribe promise=============>"); var notificationRequest = { content:{ @@ -849,10 +847,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Cancel_1100 publish promise===========>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1100 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -893,6 +891,7 @@ describe('ActsAnsNotificationCancel', function () { function cancelCallBackCancel2Times2(err){ console.info("===========ANS_Cancel_1200 cancelCallBack2 start===========>"); console.info("===========ANS_Cancel_1200 cancelCallBack2 err:============>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); console.info("===========ANS_Cancel_1200 cancelCallBack2 end============>"); } @@ -909,7 +908,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancel2Times, onCancel:onCancelCancel2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=============ANS_Cancel_1200 subscribe promise==================>"); var notificationRequest = { content:{ @@ -940,10 +939,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("========ANS_Cancel_1200 publish promise=================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1200 setTimeout unsubscribe end==================>"); done(); }),1500); @@ -986,7 +985,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabel, onCancel:onCancelCancelLabel, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_1300 subscribe promise==============>"); var notificationRequest = { content:{ @@ -1018,10 +1017,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Cancel_1300 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1300 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1058,7 +1057,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabelPromise, onCancel:onCancelCancelLabelPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==========ANS_Cancel_1400 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1090,10 +1089,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===============ANS_Cancel_1400 publish promise==============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1400 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1135,7 +1134,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabelIsUnremoveable, onCancel:onCancelCancelLabelIsUnremoveable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=======ANS_Cancel_1500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1167,10 +1166,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Cancel_1500 publish promise=============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1500 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1207,7 +1206,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabelIsUnremoveablePromise, onCancel:onCancelCancelLabelIsUnremoveablePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Cancel_1600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1239,10 +1238,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Cancel_1600 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1600 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1281,7 +1280,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelWrongLabel, onCancel:onCancelCancelWrongLabel, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Cancel_1700 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1313,10 +1312,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Cancel_1700 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1700 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1327,7 +1326,12 @@ describe('ActsAnsNotificationCancel', function () { console.info("=========ANS_Cancel_1800 onConsume data:================>" + JSON.stringify(data)); console.info("=========ANS_Cancel_1800 onConsume label:===============>" + data.request.label); console.info("=========ANS_Cancel_1800 onConsume id:==================>" + data.request.id); - notify.cancel(data.request.id, "9999"); + notify.cancel(data.request.id, "9999").then(()=>{ + console.info("=========ANS_Cancel_1800 onConsume cancel then======>"); + }).catch((err)=>{ + console.info("=========ANS_Cancel_1800 onConsume cancel catch err======>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("=========ANS_Cancel_1800 onConsume end=======================>"); } function onCancelCancelWrongLabelPromise(data) { @@ -1349,7 +1353,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelWrongLabelPromise, onCancel:onCancelCancelWrongLabelPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Cancel_1800 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1381,10 +1385,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Cancel_1800 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1800 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1424,7 +1428,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabelNullCharacter, onCancel:onCancelCancelLabelNullCharacter, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=============ANS_Cancel_1900 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1456,10 +1460,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Cancel_1900 publish promise==============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_1900 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1470,7 +1474,12 @@ describe('ActsAnsNotificationCancel', function () { console.info("==========ANS_Cancel_2000 onConsume data:=================>" + JSON.stringify(data)); console.info("==========ANS_Cancel_2000 onConsume label:================>" + data.request.label); console.info("==========ANS_Cancel_2000 onConsume id:===================>" + data.request.id); - notify.cancel(data.request.id, ""); + notify.cancel(data.request.id, "").then(()=>{ + console.info("=========ANS_Cancel_2000 onConsume cancel then======>"); + }).catch((err)=>{ + console.info("=========ANS_Cancel_2000 onConsume cancel catch err======>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("==========ANS_Cancel_2000 onConsume cancel end==========>"); console.info("==========ANS_Cancel_2000 onConsume end=================>"); } @@ -1493,7 +1502,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelNullCharacter, onCancel:onCancelCancelNullCharacter, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=========ANS_Cancel_2000 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1525,10 +1534,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Cancel_2000 publish promise===============>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2000 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1587,7 +1596,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabel2Times, onCancel:onCancelCancelLabel2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=============ANS_Cancel_2100 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1619,10 +1628,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Cancel_2100 publish promise================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2100 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1639,7 +1648,12 @@ describe('ActsAnsNotificationCancel', function () { label2200 = data.request.label notify.cancel(id2200, label2200); console.info("===========ANS_Cancel_2200 onConsume cancel1==========>"); - notify.cancel(id2200, label2200) + notify.cancel(id2200, label2200).then(()=>{ + console.info("=========ANS_Cancel_2200 onConsume cancel2 then======>"); + }).catch((err)=>{ + console.info("=========ANS_Cancel_2200 onConsume cancel2 catch err======>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("===========ANS_Cancel_2200 onConsume cancel2==========>"); console.info("===========ANS_Cancel_2200 onConsume end==============>"); } @@ -1669,7 +1683,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelLabelPromise2Times, onCancel:onCancelCancelLabelPromise2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_2200 subscribe_2200_promise=============>"); var notificationRequest = { content:{ @@ -1701,10 +1715,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("================ANS_Cancel_2200 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2200 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1744,7 +1758,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelRightLabelWrongId, onCancel:onCancelCancelRightLabelWrongId, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_2300 promise==================>"); var notificationRequest = { content:{ @@ -1776,10 +1790,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Cancel_2300 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2300 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1790,7 +1804,12 @@ describe('ActsAnsNotificationCancel', function () { console.info("============ANS_Cancel_2400 onConsume data:==============>" + JSON.stringify(data)); console.info("============ANS_Cancel_2400 onConsume label:=============>" + data.request.label); console.info("============ANS_Cancel_2400 onConsume id:================>" + data.request.id); - notify.cancel(11111, data.request.label) + notify.cancel(11111, data.request.label).then(()=>{ + console.info("=========ANS_Cancel_2400 onConsume cancel then======>"); + }).catch((err)=>{ + console.info("=========ANS_Cancel_2400 onConsume cancel catch err======>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("============ANS_Cancel_2400 onConsume cancel==========>"); console.info("============ANS_Cancel_2400 onConsume end=============>"); } @@ -1813,7 +1832,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelRightLabelWrongIdPromise, onCancel:onCancelCancelRightLabelWrongIdPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Cancel_2400 subscribe promise========>"); var notificationRequest = { content:{ @@ -1845,10 +1864,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Cancel_2400 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2400 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1888,7 +1907,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelWrongLabelWrongId, onCancel:onCancelCancelWrongLabelWrongId, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Cancel_2500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1920,10 +1939,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Cancel_2500 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2500 setTimeout unsubscribe end==================>"); done(); }),timeout); @@ -1934,7 +1953,12 @@ describe('ActsAnsNotificationCancel', function () { console.info("========ANS_Cancel_2600 onConsume data:==============>" + JSON.stringify(data)); console.info("========ANS_Cancel_2600 onConsume label:=============>" + data.request.label); console.info("========ANS_Cancel_2600 onConsume id:================>" + data.request.id); - notify.cancel(6666, "6666") + notify.cancel(6666, "6666").then(()=>{ + console.info("=========ANS_Cancel_2600 onConsume cancel then======>"); + }).catch((err)=>{ + console.info("=========ANS_Cancel_2600 onConsume cancel catch err======>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("========ANS_Cancel_2600 onConsume end================>"); console.info("========ANS_Cancel_2600 onConsume end================>"); } @@ -1957,7 +1981,7 @@ describe('ActsAnsNotificationCancel', function () { onConsume:onConsumeCancelWrongLabelWrongIdPromise, onCancel:onCancelCancelWrongLabelWrongIdPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Cancel_2600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1989,10 +2013,10 @@ describe('ActsAnsNotificationCancel', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===============ANS_Cancel_2600 publish promise==================>"); setTimeout((async function(){ - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Cancel_2600 setTimeout unsubscribe end==================>"); done(); }),timeout); diff --git a/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js b/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js index abe9d2196842f1e07901c833156461526859f900..d2d5894337353b225d8ebee4851ae1a796cefe93 100644 --- a/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js +++ b/notification/ans_standard/actsansnotificationremove/entry/src/main/js/test/ActsAnsNotificationRemove.test.js @@ -15,7 +15,7 @@ import notify from '@ohos.notification' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' -var timeout = 500; +var timeout = 300; describe('ActsAnsNotificationRemove', function () { console.info("===========ActsAnsNotificationRemove start====================>"); var subscriber; @@ -68,7 +68,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemove, onCancel:onCancelRemove, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Remove_0100 subscribe promise==================>"); var notificationRequest = { content:{ @@ -100,13 +100,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Remove_0100 publish promise===========>"); setTimeout((async function(){ console.info("======ANS_Remove_0100 setTimeout==================>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0100 setTimeout unsubscribe==================>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); @@ -144,7 +144,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemovePromise, onCancel:onCancelRemovePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_0200 subscribe promise==================>"); var notificationRequest = { content:{ @@ -176,13 +176,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("======ANS_Remove_0200 publish==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0200 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0200 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -199,10 +199,9 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("================ANS_Remove_0300 onCancel end=======================>"); } - function removeErrHashCodeCallBack(err,data) { + function removeErrHashCodeCallBack(err) { console.info("==========ANS_Remove_0300 removeCallBack start==============>"); console.info("==========ANS_Remove_0300 removeCallBack err====================>" + JSON.stringify(err)); - console.info("==========ANS_Remove_0300 removeCallBack data===============>" + JSON.stringify(data)); expect(err.code != 0).assertEqual(true); console.info("==========ANS_Remove_0300 removeCallBack end=======================>"); } @@ -219,7 +218,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveErrHashCode, onCancel:onCancelRemoveErrHashCode, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Remove_0300 subscribe promise==================>"); var notificationRequest = { content:{ @@ -251,13 +250,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_0300 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0300 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0300 setTimeout unsubscribe============>"); - await notify.cancelAll() + notify.cancelAll() done(); }),timeout); }) @@ -265,9 +264,13 @@ describe('ActsAnsNotificationRemove', function () { function onConsumeRemoveErrHashCodePromise(data) { console.info("===========ANS_Remove_0400 onConsume start:===========>"); console.info("===========ANS_Remove_0400 onConsume data:===========>" + JSON.stringify(data)); - notify.remove("errorHashCode"); - console.info("===========ANS_Remove_0400 onConsume remove:===========>"); - console.info("===========ANS_Remove_0400 onConsume end:===========>"); + notify.remove("errorHashCode").then((data)=>{ + console.info("===========ANS_Remove_0400 onConsume remove data:===========>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("===========ANS_Remove_0400 onConsume remove err:============>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("===========ANS_Remove_0400 onConsume end:===================>"); + }); } function onCancelRemoveErrHashCodePromise() { @@ -288,7 +291,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveErrHashCodePromise, onCancel:onCancelRemoveErrHashCodePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_0400 subscribe promise==================>"); var notificationRequest = { content:{ @@ -320,13 +323,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_0400 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0400 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0400 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -366,7 +369,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveUseEmptyCharacter, onCancel:onCancelRemoveUseEmptyCharacter, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Remove_0500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -398,23 +401,28 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_0500 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0500 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0500 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) function OnConsumeRemoveUseEmptyCharacterPromise(data) { - console.info("================ANS_Remove_0600 onConsume start=======================>"); - console.info("================ANS_Remove_0600 onConsume data:==================>" + JSON.stringify(data)); - notify.remove('',removeCallBackUseEmptyCharacter); - console.info("================ANS_Remove_0600 onConsume remove=======================>"); - console.info("================ANS_Remove_0600 onConsume end=======================>"); + console.info("===============ANS_Remove_0600 onConsume start==================>"); + console.info("===============ANS_Remove_0600 onConsume data:==================>" + JSON.stringify(data)); + notify.remove('').then((data)=>{ + console.info("===========ANS_Remove_0600 onConsume remove data:============>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("===========ANS_Remove_0600 onConsume remove err:=============>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("===========ANS_Remove_0600 onConsume end=====================>"); + }); + } function OnCancelRemoveUseEmptyCharacterPromise(data) { @@ -436,7 +444,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:OnConsumeRemoveUseEmptyCharacterPromise, onCancel:OnCancelRemoveUseEmptyCharacterPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Remove_0600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -468,13 +476,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_0600 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0600 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0600 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -514,7 +522,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveNotExistHashCode, onCancel:onCancelRemoveNotExistHashCode, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_0700 subscribe promise=======>"); var notificationRequest = { content:{ @@ -546,23 +554,28 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_0700 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0700 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0700 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) function onConsumeRemoveNotExistHashCodePromise(data) { - console.info("================ANS_Remove_0800 onConsume start=======================>"); + console.info("================ANS_Remove_0800 onConsume start===============>"); console.info("================ANS_Remove_0800 onConsume data:===============>" + JSON.stringify(data)); - notify.remove("9999_9999_9"); - console.info("================ANS_Remove_0800 onConsume remove====================>"); - console.info("================ANS_Remove_0800 onConsume end=======================>"); + notify.remove("9999_9999_9").then((data)=>{ + console.info("===========ANS_Remove_0800 onConsume remove data:=========>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("===========ANS_Remove_0800 onConsume remove err:==========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("===========ANS_Remove_0800 onConsume end==================>"); + }); + } function onCancelRemoveNotExistHashCodePromise(data) { @@ -584,7 +597,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveNotExistHashCodePromise, onCancel:onCancelRemoveNotExistHashCodePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_0800 subscribe promise=======>"); var notificationRequest = { content:{ @@ -616,13 +629,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Remove_0800 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0800 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0800 setTimeout unsubscribe============>"); - await notify.cancelAll() + notify.cancelAll() done(); }),timeout); }) @@ -662,7 +675,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveNonComplianceHashCode, onCancel:onCancelRemoveNonComplianceHashCode, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Remove_0900 subscribe promise==================>"); var notificationRequest = { content:{ @@ -694,13 +707,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_0900 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_0900 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_0900 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -708,9 +721,13 @@ describe('ActsAnsNotificationRemove', function () { function onConsumeRemoveNonComplianceHashCodePromise(data) { console.info("================ANS_Remove_1000 onConsume start===========>"); console.info("================ANS_Remove_1000 onConsume data:===========>" + JSON.stringify(data)); - notify.remove("哈希码"); - console.info("================ANS_Remove_1000 onConsume remove==========>"); - console.info("================ANS_Remove_1000 onConsume end=============>"); + notify.remove("哈希码").then((data)=>{ + console.info("===========ANS_Remove_1000 onConsume remove data:===========>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("===========ANS_Remove_1000 onConsume remove err:===========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("===========ANS_Remove_1000 onConsume end===================>"); + }); } function onCancelRemoveNonComplianceHashCodePromise(data) { @@ -732,7 +749,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveNonComplianceHashCodePromise, onCancel:onCancelRemoveNonComplianceHashCodePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_1000 subscribe promise==================>"); var notificationRequest = { content:{ @@ -764,13 +781,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("================ANS_Remove_1000 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1000 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1000 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -824,7 +841,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeCallbackRemove2Times, onCancel:onCancelCallbackRemove2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_1100 subscribe promise==================>"); var notificationRequest = { content:{ @@ -856,33 +873,42 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Remove_1100 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1100 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1100 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) function onConsumeCallbackRemove2TimesPromise(data) { - console.info("================ANS_Remove_1200 onConsume start=================>"); - console.info("================ANS_Remove_1200 onConsume data:==========>" + JSON.stringify(data)); - notify.remove(data.request.hashCode); - console.info("================ANS_Remove_1200 onConsume remove_2times1===========>"); - notify.remove(data.request.hashCode); - console.info("================ANS_Remove_1200 onConsume remove_2times2===========>"); - console.info("================ANS_Remove_1200 onConsume end=================>"); + console.info("=======ANS_Remove_1200 onConsume start=============>"); + console.info("=======ANS_Remove_1200 onConsume data:=============>" + JSON.stringify(data)); + notify.remove(data.request.hashCode).then(()=>{ + console.info("=======ANS_Remove_1200 onConsume remove_2times1:=======>"); + }).catch((err)=>{ + console.info("=======ANS_Remove_1200 onConsume remove_2times1 err:========>" + JSON.stringify(err)); + expect(err.code = 0).assertEqual(true); + }); + notify.remove(data.request.hashCode).then((data)=>{ + console.info("=======ANS_Remove_1200 onConsume remove_2times2 data:=======>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("=======ANS_Remove_1200 onConsume remove_2times2 err:========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("================ANS_Remove_1200 onConsume end=================>"); + }); } var timesOfOnCancelCallbackRemove2TimesPromise function onCancelCallbackRemove2TimesPromise(data) { timesOfOnCancelCallbackRemove2TimesPromise = timesOfOnCancelCallbackRemove2TimesPromise + 1 - console.info("================ANS_Remove_1200 onCancel start==========>"); + console.info("================ANS_Remove_1200 onCancel start=========>"); console.info("================ANS_Remove_1200 onCancel data:=========>" + JSON.stringify(data)); if (timesOfOnCancelCallbackRemove2TimesPromise == 1){ expect(data.request.id).assertEqual(12); + console.info("============ANS_Remove_1200 onCancel id:===========>" + JSON.stringify(data.request.id)); } else if (timesOfOnCancelCallbackRemove2TimesPromise == 2){ expect().assertFail(); } @@ -902,7 +928,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeCallbackRemove2TimesPromise, onCancel:onCancelCallbackRemove2TimesPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_1200 subscribe promise=============>"); var notificationRequest = { content:{ @@ -934,13 +960,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_1200 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1200 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1200 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -949,23 +975,22 @@ describe('ActsAnsNotificationRemove', function () { console.info("==========ANS_Remove_1300 onConsume start=================>"); console.info("==========ANS_Remove_1300 onConsume data:=================>" + JSON.stringify(data)); notify.remove(data.request.hashCode,removeIsUnremovableCallBack); - console.info("==========ANS_Remove_1300 onConsume remove=============>"); + console.info("==========ANS_Remove_1300 onConsume remove==============>"); console.info("==========ANS_Remove_1300 onConsume end=================>"); } function onCancelRemoveIsUnremovable(data) { console.info("==========ANS_Remove_1300 onCancel start================>"); - console.info("==========ANS_Remove_1300 onCancel data:===========>" + JSON.stringify(data)); + console.info("==========ANS_Remove_1300 onCancel data:================>" + JSON.stringify(data)); expect().assertFail(); console.info("==========ANS_Remove_1300 onCancel end================>"); } - function removeIsUnremovableCallBack(err, data) { - console.info("==========ANS_Remove_1300 removeCallBack start=======================>"); + function removeIsUnremovableCallBack(err) { + console.info("==========ANS_Remove_1300 removeCallBack start===================>"); console.info("==========ANS_Remove_1300 removeCallBack err=====================>" + JSON.stringify(err)); expect(err.code != 0).assertEqual(true); - console.info("==========ANS_Remove_1300 removeCallBack data=====================>" + JSON.stringify(data)); - console.info("==========ANS_Remove_1300 removeCallBack end=======================>"); + console.info("==========ANS_Remove_1300 removeCallBack end=====================>"); } /* @@ -980,7 +1005,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveIsUnremovable, onCancel:onCancelRemoveIsUnremovable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_1300 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1012,13 +1037,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("================ANS_Remove_1300 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1300 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1300 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1026,9 +1051,13 @@ describe('ActsAnsNotificationRemove', function () { function OnConsumeRemoveIsUnremovablePromise(data) { console.info("==============ANS_Remove_1400 onConsume start==============>"); console.info("==============ANS_Remove_1400 onConsume data:==============>" + JSON.stringify(data)); - notify.remove(data.request.hashCode); - console.info("==============ANS_Remove_1400 onConsume remove=============>"); - console.info("==============ANS_Remove_1400 onConsume end================>"); + notify.remove(data.request.hashCode).then((data)=>{ + console.info("=======ANS_Remove_1400 onConsume remove data:=======>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("=======ANS_Remove_1400 onConsume remove err:========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("=======ANS_Remove_1400 onConsume end================>"); + }); } function OnCancelRemoveIsUnremovablePromise(data) { @@ -1050,7 +1079,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:OnConsumeRemoveIsUnremovablePromise, onCancel:OnCancelRemoveIsUnremovablePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_1400 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1082,13 +1111,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Remove_1400 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1400 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1400 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1140,7 +1169,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOption, onCancel:onCancelRemoveAllByBundleOption, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_1500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1202,15 +1231,15 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Remove_1500 publish1 promise==================>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("=============ANS_Remove_1500 publish2 promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1500 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1500 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1221,7 +1250,7 @@ describe('ActsAnsNotificationRemove', function () { console.info("===============ANS_Remove_1600 onConsume data:========>" + JSON.stringify(data)); var bundleOption = { bundle:data.request.creatorBundleName, - uid:data.request.creatorUid, + uid:0, } timesOfOnConsumeRemoveAllByBundleOptionNullUid = timesOfOnConsumeRemoveAllByBundleOptionNullUid + 1 if (timesOfOnConsumeRemoveAllByBundleOptionNullUid == 2){ @@ -1230,22 +1259,15 @@ describe('ActsAnsNotificationRemove', function () { } console.info("===============ANS_Remove_1600 onConsume end================>"); } - var timesOfOnCancelRemoveAllByBundleOptionNullUid function onCancelRemoveAllByBundleOptionNullUid(data) { - timesOfOnCancelRemoveAllByBundleOptionNullUid = timesOfOnCancelRemoveAllByBundleOptionNullUid + 1 console.info("===============ANS_Remove_1600 onCancel start===================>"); console.info("===============ANS_Remove_1600 onCancel data:===================>" + JSON.stringify(data)); - if (timesOfOnCancelRemoveAllByBundleOptionNullUid == 1){ - expect(data.request.label).assertEqual("1600_1"); - }else if (timesOfOnCancelRemoveAllByBundleOptionNullUid == 2){ - expect(data.request.label).assertEqual("1600_2"); - } + expect().assertFail(); console.info("===============ANS_Remove_1600 onCancel end====================>"); } - function removeAllByBundleOptionCallBackNullUid(err, data) { + function removeAllByBundleOptionCallBackNullUid(err) { console.info("=========ANS_Remove_1600 removeAllCallBack start=============>"); console.info("=========ANS_Remove_1600 removeAllCallBack err===============>" + JSON.stringify(err)); - console.info("=========ANS_Remove_1600 removeAllCallBack data==============>" + JSON.stringify(data)); console.info("=========ANS_Remove_1600 removeAllCallBack end===============>"); } @@ -1253,17 +1275,16 @@ describe('ActsAnsNotificationRemove', function () { * @tc.number: ANS_Remove_1600 * @tc.name: removeAll(bundle: BundleOption, callback: AsyncCallback):void; * @tc.desc: Verify that the calling interface removeAll(bundle: BundleOption, callback: AsyncCallback):void; - * deletes all notification information through BundleOption Correct bundle, null uid. + * deletes all notification information through BundleOption Correct bundle, 0 uid. */ it('ANS_Remove_1600', 0, async function (done) { console.info("===============ANS_Remove_1600==========================>"); timesOfOnConsumeRemoveAllByBundleOptionNullUid = 0 - timesOfOnCancelRemoveAllByBundleOptionNullUid = 0 var subscriber ={ onConsume:onConsumeRemoveAllByBundleOptionNullUid, onCancel:onCancelRemoveAllByBundleOptionNullUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==================ANS_Remove_1600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1325,15 +1346,15 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==================ANS_Remove_1600 publish1 promise==================>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("==================ANS_Remove_1600 publish2 promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1600 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1600 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1355,10 +1376,9 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("==========ANS_Remove_1700 onCancel end======================>"); } - function removeAllByBundleOptionCallBackWrongUid(err, data) { + function removeAllByBundleOptionCallBackWrongUid(err) { console.info("==========ANS_Remove_1700 removeAllCallBack start=============>"); console.info("==========ANS_Remove_1700 removeAllCallBack err===============>" + JSON.stringify(err)); - console.info("==========ANS_Remove_1700 removeAllCallBack data==============>" + JSON.stringify(data)); console.info("==========ANS_Remove_1700 removeAllCallBack end=======================>"); } @@ -1374,7 +1394,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionWrongUid, onCancel:onCancelRemoveAllByBundleOptionWrongUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=============ANS_Remove_1700 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1406,13 +1426,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===============ANS_Remove_1700 publish promise===============>"); setTimeout((async function(){ console.info("======ANS_Remove_1700 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1700 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); @@ -1438,7 +1458,6 @@ describe('ActsAnsNotificationRemove', function () { function removeAllByBundleOptionCallBackWrongBundleCorrectUid(err, data) { console.info("=========ANS_Remove_1800 removeAllCallBack start==========>"); console.info("=========ANS_Remove_1800 removeAllCallBack err============>" + JSON.stringify(err)); - console.info("=========ANS_Remove_1800 removeAllCallBack data===========>" + JSON.stringify(data)); console.info("=========ANS_Remove_1800 removeAllCallBack end==========>"); } @@ -1454,7 +1473,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionWrongBundleCorrectUid, onCancel:onCancelremoveAllByBundleOptionwrongBundleCorrectUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_1800 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1486,13 +1505,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_1800 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1800 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1800 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1514,11 +1533,11 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("===========ANS_Remove_1900 onCancel end===========>"); } - function removeAllByBundleOptionCallBackNullCharacterBundleCorrectUid(err, data) { + function removeAllByBundleOptionCallBackNullCharacterBundleCorrectUid(err) { console.info("========ANS_Remove_1900 removeAllCallback start===========>"); console.info("========ANS_Remove_1900 removeAllCallback err=============>" + JSON.stringify(err)); - console.info("========ANS_Remove_1900 removeAllCallback data=========>" + JSON.stringify(data)); - console.info("========ANS_Remove_1900 removeAllCallback end=======================>"); + expect(err.code != 0).assertEqual(true); + console.info("========ANS_Remove_1900 removeAllCallback end=============>"); } /* @@ -1533,7 +1552,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionNullCharacterBundleCorrectUid, onCancel:onCancelRemoveAllByBundleOptionNullCharacterBundleCorrectUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_1900 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1565,13 +1584,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===============ANS_Remove_1900 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_1900 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_1900 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1593,10 +1612,9 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("============ANS_Remove_2000 onCancel end==============>"); } - function removeAllByBundleOptionCallBackWrongBundleWrongUid(err, data) { + function removeAllByBundleOptionCallBackWrongBundleWrongUid(err) { console.info("============ANS_Remove_2000 removeAllCallBack start============>"); console.info("============ANS_Remove_2000 removeAllCallBack err==============>" + JSON.stringify(err)); - console.info("============ANS_Remove_2000 removeAllCallBack data=============>" + JSON.stringify(data)); console.info("============ANS_Remove_2000 removeAllCallBack end=============>"); } @@ -1612,7 +1630,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionWrongBundleWrongUid, onCancel:onCancelRemoveAllByBundleOptionWrongBundleWrongUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Remove_2000 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1644,13 +1662,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Remove_2000 publish promise==============>"); setTimeout((async function(){ console.info("======ANS_Remove_2000 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2000 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1672,10 +1690,10 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("=========ANS_Remove_2100 onCancel end============>"); } - function removeAllByBundleOptionCallBackNullCharacterBundleWrongUid(err, data) { + function removeAllByBundleOptionCallBackNullCharacterBundleWrongUid(err) { console.info("=========ANS_Remove_2100 removeAllCallBack start===============>"); console.info("=========ANS_Remove_2100 err=========>" + JSON.stringify(err)); - console.info("=========ANS_Remove_2100 data=========>" + JSON.stringify(data)); + expect(err.code != 0).assertEqual(true); console.info("=========ANS_Remove_2100 removeAllCallBack end===============>"); } @@ -1691,7 +1709,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionNullCharacterBundleWrongUid, onCancel:onCancelRemoveAllByBundleOptionNullCharacterBundleWrongUid, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Remove_2100 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1723,13 +1741,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=========ANS_Remove_2100 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2100 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2100 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1751,10 +1769,9 @@ describe('ActsAnsNotificationRemove', function () { expect().assertFail(); console.info("==========ANS_Remove_2200 onCancel end===================>"); } - function removeAllByBundleOptionCallBackIsUnremovable(err, data) { + function removeAllByBundleOptionCallBackIsUnremovable(err) { console.info("==========ANS_Remove_2200 removeAllCallBack start==========>"); console.info("==========ANS_Remove_2200 removeAllCallBack err============>" + JSON.stringify(err)); - console.info("==========ANS_Remove_2200 removeAllCallBack data===========>" + JSON.stringify(data)); console.info("==========ANS_Remove_2200 removeAllCallBack end============>"); } @@ -1770,7 +1787,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllByBundleOptionIsUnremovable, onCancel:onCancelRemoveAllByBundleOptionIsUnremovable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Remove_2200 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1802,13 +1819,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Remove_2200 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2200 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2200 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1861,7 +1878,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAll, onCancel:onCancelRemoveAll, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("=============ANS_Remove_2300 subscribe promise==================>"); var notificationRequest = { content:{ @@ -1923,15 +1940,15 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Remove_2300 publish1 promise================>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("============ANS_Remove_2300 publish2 promise===============>"); setTimeout((async function(){ console.info("======ANS_Remove_2300 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2300 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -1978,7 +1995,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllPromise, onCancel:onCancelRemoveAllPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Remove_2400 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2040,15 +2057,15 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===ANS_Remove_2400 publish1 promise============>"); - await notify.publish(notificationRequest1); + notify.publish(notificationRequest1); console.info("===ANS_Remove_2400 publish2 promise============>"); setTimeout((async function(){ console.info("======ANS_Remove_2400 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2400 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2067,6 +2084,7 @@ describe('ActsAnsNotificationRemove', function () { console.info("=========ANS_Remove_2500 onConsume end=============>"); } function onCancelCallbackRemoveAllIsUnremovable(data) { + expect().assertFail(); console.info("=========ANS_Remove_2500 onCancel start==============>"); console.info("=========ANS_Remove_2500 onCancel data:==============>" + JSON.stringify(data)); console.info("=========ANS_Remove_2500 onCancel end================>"); @@ -2084,7 +2102,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAllIsUnremovable, onCancel:onCancelCallbackRemoveAllIsUnremovable, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("======ANS_Remove_2500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2116,13 +2134,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_2500 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2500 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2500 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2152,7 +2170,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:OnConsumeRemoveAllIsUnremovablePromise, onCancel:OnCancelCallbackRemoveAllIsUnremovablePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Remove_2600 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2184,27 +2202,25 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==========ANS_Remove_2600 publish promise==============>"); setTimeout((async function(){ console.info("======ANS_Remove_2600 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2600 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) - function removeAllCallBack2TimesOf2(err,data) { + function removeAllCallBack2TimesOf2(err) { console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf2 start===========>"); console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf2 err=============>" + JSON.stringify(err)); - console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf2 data============>" + JSON.stringify(data)); console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf2 end=============>"); } - function removeAllCallBack2TimesOf1(err,data) { + function removeAllCallBack2TimesOf1(err) { console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf1 start==========>"); console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf1 err============>" + JSON.stringify(err)); - console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf1 data===========>" + JSON.stringify(data)); expect(err.code).assertEqual(0); notify.removeAll(removeAllCallBack2TimesOf2); console.info("=======ANS_Remove_2700 removeAllCallBack2TimesOf1 removeAll=====>"); @@ -2224,6 +2240,7 @@ describe('ActsAnsNotificationRemove', function () { console.info("=======ANS_Remove_2700 onCancel data:============>" + JSON.stringify(data)); if (timesOfOnCancelCallbackRemoveAll2Times == 1){ expect(data.request.id).assertEqual(27); + console.info("=======ANS_Remove_2700 onCancel id============>"); } else if (timesOfOnCancelCallbackRemoveAll2Times == 2){ expect().assertFail(); } @@ -2243,7 +2260,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveAll2Times, onCancel:onCancelRemoveAll2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Remove_2700 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2275,13 +2292,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=========ANS_Remove_2700 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2700 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2700 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2289,9 +2306,9 @@ describe('ActsAnsNotificationRemove', function () { function onConsumeCallbackRemoveAll2TimesPromise(data) { console.info("=============ANS_Remove_2800 onConsume start=============>"); console.info("=============ANS_Remove_2800 onConsume data: =======================>" + JSON.stringify(data)); - notify.removeAll() + notify.removeAll(); console.info("=============ANS_Remove_2800 onConsume removeAll1=======================>"); - notify.removeAll() + notify.removeAll(); console.info("=============ANS_Remove_2800 onConsume removeAll2=======================>"); console.info("=============ANS_Remove_2800 onConsume end=============>"); } @@ -2321,7 +2338,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeCallbackRemoveAll2TimesPromise, onCancel:onCancelCallbackRemoveAll2TimesPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_2800 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2353,13 +2370,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("================ANS_Remove_2800 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2800 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2800 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2412,7 +2429,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKey, onCancel:onCancelRemoveByNotificationKey, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_2900 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2444,13 +2461,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("==============ANS_Remove_2900 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_2900 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_2900 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2491,7 +2508,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKeyPromise, onCancel:onCancelRemoveByNotificationKeyPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_3000 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2523,13 +2540,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Remove_3000 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3000 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3000 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2576,7 +2593,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKeyWrongKey, onCancel:onCancelRemoveByNotificationKeyWrongKey, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("==============ANS_Remove_3100 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2608,13 +2625,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("=============ANS_Remove_3100 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3100 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3100 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2630,7 +2647,12 @@ describe('ActsAnsNotificationRemove', function () { id:0, label:"wrongLabel" } - notify.remove(bundleOption, notificationKey); + notify.remove(bundleOption, notificationKey).then((data)=>{ + console.info("=======ANS_Remove_3200 onConsume remove data:=======>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("=======ANS_Remove_3200 onConsume remove err:========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("===========ANS_Remove_3200 onConsume remove============>"); console.info("===========ANS_Remove_3200 onConsume end===============>"); } @@ -2654,7 +2676,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKeyWrongKeyPromise, onCancel:onCancelRemoveByNotificationKeyWrongKeyPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===============ANS_Remove_3200 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2686,13 +2708,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("===========ANS_Remove_3200 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3200 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3200 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2739,7 +2761,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:OnConsumeRemoveByNotificationKeyWrongBundle, onCancel:OnCancelRemoveByNotificationKeyWrongBundle, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("================ANS_Remove_3300 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2771,13 +2793,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("================ANS_Remove_3300 publish promise=================>"); setTimeout((async function(){ console.info("======ANS_Remove_3300 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3300 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2793,7 +2815,12 @@ describe('ActsAnsNotificationRemove', function () { id:34, label:"3400" } - notify.remove(bundleOption, notificationKey) + notify.remove(bundleOption, notificationKey).then((data)=>{ + console.info("=======ANS_Remove_3400 onConsume remove data:=======>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("=======ANS_Remove_3400 onConsume remove err:========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + }); console.info("===========ANS_Remove_3400 onConsume remove=========>"); console.info("===========ANS_Remove_3400 onConsume end============>"); } @@ -2817,7 +2844,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKeyWrongBundlePromise, onCancel:onCancelRemoveByNotificationKeyWrongBundlePromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("============ANS_Remove_3400 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2849,13 +2876,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_3400 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3400 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3400 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2872,16 +2899,6 @@ describe('ActsAnsNotificationRemove', function () { console.info("==========ANS_Remove_3500 removeCallback2Times1 err=============>" + JSON.stringify(err)); console.info("==========ANS_Remove_3500 removeCallback2Times1 data============>" + JSON.stringify(data)); expect(err.code).assertEqual(0); - var bundleOption = { - bundle:data.request.creatorBundleName, - uid:data.request.creatorUid, - } - var notificationKey = { - id:35, - label:"3500" - } - notify.remove(bundleOption,notificationKey,removeByNotificationKey2Times2CB); - console.info("==========ANS_Remove_3500 removeCallback2Times1 remove===========>"); console.info("==========ANS_Remove_3500 removeCallback2Times1 end==============>"); } function onConsumeRemoveByNotificationKey2Times(data) { @@ -2896,6 +2913,7 @@ describe('ActsAnsNotificationRemove', function () { label:"3500" } notify.remove(bundleOption,notificationKey,removeByNotificationKey2Times1CB); + notify.remove(bundleOption,notificationKey,removeByNotificationKey2Times2CB); console.info("=========ANS_Remove_3500 onConsume remove==============>"); console.info("=========ANS_Remove_3500 onConsume end=================>"); } @@ -2926,7 +2944,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKey2Times, onCancel:onCancelRemoveByNotificationKey2Times, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("===========ANS_Remove_3500 subscribe promise==================>"); var notificationRequest = { content:{ @@ -2958,13 +2976,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_3500 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3500 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3500 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) @@ -2982,9 +3000,13 @@ describe('ActsAnsNotificationRemove', function () { } notify.remove(bundleOption, notificationKey) console.info("=========ANS_Remove_3600 onConsume remove1===========>"); - notify.remove(bundleOption, notificationKey); - console.info("=========ANS_Remove_3600 onConsume remove2===========>"); - console.info("=========ANS_Remove_3600 onConsume end===========>"); + notify.remove(bundleOption, notificationKey).then((data)=>{ + console.info("=======ANS_Remove_3600 onConsume remove2 data:=======>" + JSON.stringify(data)); + }).catch((err)=>{ + console.info("=======ANS_Remove_3600 onConsume remove2 err:========>" + JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("=========ANS_Remove_3600 onConsume end===========>"); + }); } var timesOnCancelcbRemoveByKey2TimesPromise function onCancelRemoveByNotificationKey2TimesPromise(data) { @@ -3014,7 +3036,7 @@ describe('ActsAnsNotificationRemove', function () { onConsume:onConsumeRemoveByNotificationKey2TimesPromise, onCancel:onCancelRemoveByNotificationKey2TimesPromise, } - await notify.subscribe(subscriber); + notify.subscribe(subscriber); console.info("========ANS_Remove_3600 subscribe promise=============>"); var notificationRequest = { content:{ @@ -3046,13 +3068,13 @@ describe('ActsAnsNotificationRemove', function () { badgeIconStyle: 1, showDeliveryTime: true, } - await notify.publish(notificationRequest); + notify.publish(notificationRequest); console.info("============ANS_Remove_3600 publish promise==================>"); setTimeout((async function(){ console.info("======ANS_Remove_3600 setTimeout============>"); - await notify.unsubscribe(subscriber); + notify.unsubscribe(subscriber); console.info("======ANS_Remove_3600 setTimeout unsubscribe============>"); - await notify.cancelAll(); + notify.cancelAll(); done(); }),timeout); }) diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/BUILD.gn b/notification/ans_standard/publish_test/ansactscancelgroup/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c0d4268375ae5b581fea6ee350bbff5b7391c546 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsCancelGroup") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsCancelGroup" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/Test.json b/notification/ans_standard/publish_test/ansactscancelgroup/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..bb89e0d46f3f5e15b942de1ee5054f59fb77b910 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsansrcancelgroup", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsCancelGroup.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/.gitignore b/notification/ans_standard/publish_test/ansactscancelgroup/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3543521e9fef8e7322940a87c2b45dd0061b0f45 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/config.json b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..08c11fabfc9d966dedb5436af3ccf03fe4cf755b --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/config.json @@ -0,0 +1,71 @@ +{ + "app": { + "bundleName": "com.example.actsansrcancelgroup", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansrcancelgroup", + "name": ".actsansremovegroup", + "deviceType": [ + "phone" + ], + "reqPermissions": [{ + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "install bundle", + "usedScene": { + "ability": [ + "KitFramework" + ], + "when": "always" + } + }], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansrcancelgroup.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..4f1747a95c4acbb66db5351e826c31584356e11c --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..14abd6f1917d43b2d848510c1b48cf91924d2363 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + ActsAnsNotificationCancel + +
diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1054f8e514806795f3e96c7e5248b921f406ae03 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ + +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import file from '@system.file' +import app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } +} diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9b1656ab3824e70163bcdedf221b17cc184967de --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsansremovegroup" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/ActsAnsCancelGroup.js b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/ActsAnsCancelGroup.js new file mode 100644 index 0000000000000000000000000000000000000000..957eec875c8eabb38b1fbd7c37f8730cd1da66dc --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/ActsAnsCancelGroup.js @@ -0,0 +1,776 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var timeout = 500; +describe('ActsAnsCancelGroup', function () { + console.info("===========ActsAnsCancelGroup start====================>"); + + var bundleOption = { + bundle:"com.example.actsanscancelgroup", + }; + + function onConsumeCancelGroup(data) { + console.info("=========ANS_CancelGroup_0100 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0100 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_0100", CancelGroupCallbackOne); + console.info("=========ANS_CancelGroup_0100 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_0100 onConsume end================>"); + } + + function onCancelCancelGroup(data) { + console.info("========ANS_CancelGroup_0100 onCancel start===========>"); + console.info("========ANS_CancelGroup_0100 onCancel data:===========>" + JSON.stringify(data)); + expect(data.request.id).assertEqual(1); + console.info("========ANS_CancelGroup_0100 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0100"); + console.info("========ANS_CancelGroup_0100 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0100"); + console.info("========ANS_CancelGroup_0100 onCancel groupName:======>" + data.request.groupName); + console.info("========ANS_CancelGroup_0100 onCancel end=============>"); + } + + function CancelGroupCallbackOne(err){ + console.info("========ANS_CancelGroup_0100 CancelGroupCallbackOne start==>"); + console.info("========ANS_CancelGroup_0100 CancelGroupCallbackOne err====>"+JSON.stringify(err)); + console.info("========ANS_CancelGroup_0100 CancelGroupCallbackOne end====>"); + } + + /* + * @tc.number: ANS_CancelGroup_0100 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : one notification of the specified group can be successfully canceled(callback) + */ + it('ANS_CancelGroup_0100', 0, async function (done) { + console.info("==================ANS_CancelGroup_0100 start==================>"); + var subscriber = { + onConsume:onConsumeCancelGroup, + onCancel:onCancelCancelGroup + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0100", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0100", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0100 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0100 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0100 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0100 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeCancelGroupPromise(data) { + console.info("=========ANS_CancelGroup_0200 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0200 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_0200"); + console.info("=========ANS_CancelGroup_0200 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_0200 onConsume end================>"); + } + + function onCancelCancelGroupPromise(data) { + console.info("========ANS_CancelGroup_0200 onCancel start===========>"); + console.info("========ANS_CancelGroup_0200 onCancel data:===========>" + JSON.stringify(data)); + expect(data.request.id).assertEqual(2); + console.info("========ANS_CancelGroup_0200 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0200"); + console.info("========ANS_CancelGroup_0200 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0200"); + console.info("========ANS_CancelGroup_0200 onCancel groupName:======>" + data.request.groupName); + console.info("========ANS_CancelGroup_0200 onCancel end=============>"); + } + + /* + * @tc.number: ANS_CancelGroup_0200 + * @tc.name: cancelGroup(groupName: string): Promise; + * @tc.desc: Verify : one notification of the specified group can be successfully cancel(promise) + */ + it('ANS_CancelGroup_0200', 0, async function (done) { + console.info("==================ANS_CancelGroup_0200 start==================>"); + var subscriber ={ + onConsume:onConsumeCancelGroupPromise, + onCancel:onCancelCancelGroupPromise + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0200", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0200", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0200 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0200 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0200 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0200 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + var timesOfOnConsume + + function onConsumeCancelGroupTwo(data) { + console.info("=========ANS_CancelGroup_0300 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0300 onConsume data:==============>" + JSON.stringify(data)); + timesOfOnConsume = timesOfOnConsume + 1 + if (timesOfOnConsume == 2){ + notify.cancelGroup("group_0300", cancelGroupCallbackTwo); + console.info("=========ANS_CancelGroup_0300 onConsume cancelGroup======>"); + } + console.info("=========ANS_CancelGroup_0300 onConsume end================>"); + } + + var timesOfOnCancel + + function onCancelCancelGroupTwo(data) { + console.info("========ANS_CancelGroup_0300 onCancel start===========>"); + console.info("========ANS_CancelGroup_0300 onCancel data:===========>" + JSON.stringify(data)); + timesOfOnCancel = timesOfOnCancel + 1 + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(1); + } else if (timesOfOnCancel == 2){ + expect(data.request.id).assertEqual(2); + } + console.info("========ANS_CancelGroup_0300 onCancel end===========>"); + } + + function cancelGroupCallbackTwo(err){ + console.info("========ANS_CancelGroup_0300 cancelGroupCallbackTwo start====>"); + console.info("========ANS_CancelGroup_0300 cancelGroupCallbackTwo err======>" + JSON.stringify(err)); + console.info("========ANS_CancelGroup_0300 cancelGroupCallbackTwo end======>"); + } + + /* + * @tc.number: ANS_CancelGroup_0300 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : 2 notifications of the specified group can be successfully canceled(callback) + */ + it('ANS_CancelGroup_0300', 0, async function (done) { + console.info("==================ANS_CancelGroup_0300 start==================>"); + timesOfOnConsume = 0 + timesOfOnCancel = 0 + var subscriber ={ + onConsume:onConsumeCancelGroupTwo, + onCancel:onCancelCancelGroupTwo, + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0300", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300_1", + badgeIconStyle: 1, + showDeliveryTime: true, + } + var notificationRequest1 = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0300", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300_2", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0300 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0300 publish1 promise=======>"); + notify.publish(notificationRequest1); + console.info("===========ANS_CancelGroup_0300 publish2 promise=======>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0300 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0300 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeCancelGroupPromiseTwo(data) { + console.info("=========ANS_CancelGroup_0400 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0400 onConsume data:==============>" + JSON.stringify(data)); + timesOfOnConsume = timesOfOnConsume + 1 + if (timesOfOnConsume == 2){ + notify.cancelGroup("group_0400"); + console.info("=========ANS_CancelGroup_0400 onConsume cancelGroup Promise======>"); + } + console.info("=========ANS_CancelGroup_0400 onConsume end================>"); + } + + function onCancelCancelGroupPromiseTwo(data) { + console.info("========ANS_CancelGroup_0400 onCancel start===========>"); + console.info("========ANS_CancelGroup_0400 onCancel data:===========>" + JSON.stringify(data)); + timesOfOnCancel = timesOfOnCancel + 1 + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(1); + } else if (timesOfOnCancel == 2){ + expect(data.request.id).assertEqual(2); + } + console.info("========ANS_CancelGroup_0400 onCancel end===========>"); + } + + /* + * @tc.number: ANS_CancelGroup_0400 + * @tc.name: cancelGroup(groupName: string): Promise; + * @tc.desc: Verify : 2 notifications of the specified group can be successfully canceled(promise) + */ + it('ANS_CancelGroup_0400', 0, async function (done) { + console.info("===============ANS_CancelGroup_0400 start==================>"); + timesOfOnConsume = 0 + timesOfOnCancel = 0 + var subscriber ={ + onConsume:onConsumeCancelGroupPromiseTwo, + onCancel:onCancelCancelGroupPromiseTwo, + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0400", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400_1", + badgeIconStyle: 1, + showDeliveryTime: true, + } + var notificationRequest1 = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0400", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400_2", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0400 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0400 publish1 promise=======>"); + notify.publish(notificationRequest1); + console.info("===========ANS_CancelGroup_0400 publish2 promise=======>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0400 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0400 setTimeout unsubscribe==>"); + done(); + }),timeout); + }); + + function onConsumeCancelGroupThree(data) { + console.info("=========ANS_CancelGroup_0500 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0500 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_0500", cancelGroupByBundleCallbackThree); + console.info("=========ANS_CancelGroup_0500 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_0500 onConsume end================>"); + } + + function onCancelCancelGroupThree(data) { + timesOfOnCancel = timesOfOnCancel + 1; + console.info("========ANS_CancelGroup_0500 onCancel start===========>"); + console.info("========ANS_CancelGroup_0500 onCancel data:===========>" + JSON.stringify(data)); + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(5); + console.info("========ANS_CancelGroup_0500 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0500"); + console.info("========ANS_CancelGroup_0500 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0500"); + console.info("========ANS_CancelGroup_0500 onCancel groupName:======>" + data.request.groupName); + notify.cancelGroup("group_0500", cancelGroupByBundleCallbackThree2); + console.info("========ANS_CancelGroup_0500 onCancel cancelGroup:======>"); + } else if (timesOfOnCancel == 2){ + expect.assertFail(); + } + console.info("========ANS_CancelGroup_0500 onCancel end=============>"); + } + + function cancelGroupByBundleCallbackThree(err){ + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree start==>"); + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree err====>"+JSON.stringify(err)); + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree end====>"); + } + + function cancelGroupByBundleCallbackThree2(err){ + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree2 start==>"); + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree2 err====>"+JSON.stringify(err)); + console.info("========ANS_CancelGroup_0500 cancelGroupByBundleCallbackThree2 end====>"); + } + + /* + * @tc.number: ANS_CancelGroup_0500 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : After the notification of a specific group is successfully canceled, + cancel the notification of this group again(callback) + */ + it('ANS_CancelGroup_0500', 0, async function (done) { + console.info("==================ANS_CancelGroup_0500 start==================>"); + timesOfOnCancel = 0; + var subscriber ={ + onConsume:onConsumeCancelGroupThree, + onCancel:onCancelCancelGroupThree + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0500", + id: 5, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0500", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0500 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0500 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0500 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0500 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeCancelGroupPromiseThree(data) { + console.info("=========ANS_CancelGroup_0600 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0600 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_0600"); + console.info("=========ANS_CancelGroup_0600 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_0600 onConsume end================>"); + } + + function onCancelCancelGroupPromiseThree(data) { + timesOfOnCancel = timesOfOnCancel + 1; + console.info("========ANS_CancelGroup_0600 onCancel start===========>"); + console.info("========ANS_CancelGroup_0600 onCancel data:===========>" + JSON.stringify(data)); + if (timesOfOnCancel == 1) { + expect(data.request.id).assertEqual(6); + console.info("========ANS_CancelGroup_0600 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0600"); + console.info("========ANS_CancelGroup_0600 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0600"); + console.info("========ANS_CancelGroup_0600 onCancel groupName:======>" + data.request.groupName); + notify.cancelGroup("group_0600"); + console.info("========ANS_CancelGroup_0600 onCancel cancelGroup:==========>"); + }else if(timesOfOnCancel == 2){ + expect.assertFail(); + } + console.info("========ANS_CancelGroup_0600 onCancel end=============>"); + } + + /* + * @tc.number: ANS_CancelGroup_0600 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : After the notification of a specific group is successfully canceled, + cancel the notification of this group again(promise) + */ + it('ANS_CancelGroup_0600', 0, async function (done) { + console.info("==================ANS_CancelGroup_0700 start==================>"); + timesOfOnCancel = 0; + var subscriber ={ + onConsume:onConsumeCancelGroupPromiseThree, + onCancel:onCancelCancelGroupPromiseThree + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0600", + id: 6, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0600", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0600 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0600 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0600 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0600 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function cancelGroupCallbackFour(err){ + console.info("========ANS_CancelGroup_0700 cancelGroupCallbackFour start==>"); + console.info("========ANS_CancelGroup_0700 cancelGroupCallbackFour err====>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("========ANS_CancelGroup_0700 cancelGroupCallbackFour end====>"); + } + + /* + * @tc.number: ANS_CancelGroup_0700 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Call the interface with an empty groupName parameter(callback) + */ + it('ANS_CancelGroup_0700', 0, async function (done) { + console.info("==================ANS_CancelGroup_0700 start==================>"); + notify.cancelGroup("", cancelGroupCallbackFour); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0700 setTimeout==============>"); + done(); + }),timeout); + }) + + /* + * @tc.number: ANS_CancelGroup_0800 + * @tc.name: cancelGroup(groupName: string): Promise; + * @tc.desc: Verify : Call the interface with an empty groupName parameter(promise) + */ + it('ANS_CancelGroup_0800', 0, async function (done) { + console.info("==================ANS_CancelGroup_0800 start==================>"); + notify.cancelGroup("").then(()=>{ + console.info("==================ANS_CancelGroup_0800 cancelGroup then==================>"); + }).catch((err)=>{ + console.info("==================ANS_CancelGroup_0800 cancelGroup catch==================>"); + console.info("==================ANS_CancelGroup_0800 cancelGroup err==================>"+err.code); + expect(err.code != 0).assertEqual(true); + }); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0800 setTimeout==============>"); + done(); + }),timeout); + }) + + function onConsumCancelGroupFour(data) { + console.info("=========ANS_CancelGroup_0900 onConsume start==============>"); + console.info("=========ANS_CancelGroup_0900 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_wrong", cancelGroupCallbackFive); + console.info("=========ANS_CancelGroup_0900 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_0900 onConsume end================>"); + } + + function onCancelCancelGroupFour(data) { + expect().assertFail(); + console.info("========ANS_CancelGroup_0900 onCancel start===========>"); + console.info("========ANS_CancelGroup_0900 onCancel data:===========>" + JSON.stringify(data)); + console.info("========ANS_CancelGroup_0900 onCancel end=============>"); + } + + function cancelGroupCallbackFive(err){ + console.info("========ANS_CancelGroup_0900 cancelGroupCallbackFive start==>"); + console.info("========ANS_CancelGroup_0900 cancelGroupCallbackFive err====>"+JSON.stringify(err)); + console.info("========ANS_CancelGroup_0900 cancelGroupCallbackFive end====>"); + } + + /* + * @tc.number: ANS_CancelGroup_0900 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Call the interface with an wrong groupName parameter(callback) + */ + it('ANS_CancelGroup_0900', 0, async function (done) { + console.info("==================ANS_CancelGroup_0900 start==================>"); + var subscriber ={ + onConsume:onConsumCancelGroupFour, + onCancel:onCancelCancelGroupFour + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0900", + id: 9, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0900", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_0900 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_0900 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_0900 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_0900 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeCancelGroupPromiseFour(data) { + console.info("=========ANS_CancelGroup_1000 onConsume start==============>"); + console.info("=========ANS_CancelGroup_1000 onConsume data:==============>" + JSON.stringify(data)); + notify.cancelGroup("group_wrong"); + console.info("=========ANS_CancelGroup_1000 onConsume cancelGroup======>"); + console.info("=========ANS_CancelGroup_1000 onConsume end================>"); + } + + function onCancelCancelGroupPromiseFour(data) { + expect().assertFail(); + console.info("========ANS_CancelGroup_1000 onCancel start===========>"); + console.info("========ANS_CancelGroup_1000 onCancel data:===========>" + JSON.stringify(data)); + console.info("========ANS_CancelGroup_1000 onCancel end=============>"); + } + + /* + * @tc.number: ANS_CancelGroup_1000 + * @tc.name: cancelGroup(groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Verify : Call the interface with an wrong groupName parameter(promise) + */ + it('ANS_CancelGroup_1000', 0, async function (done) { + console.info("==================ANS_CancelGroup_1000 start==================>"); + var subscriber ={ + onConsume:onConsumeCancelGroupPromiseFour, + onCancel:onCancelCancelGroupPromiseFour + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_1000", + id: 10, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "1000", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_CancelGroup_1000 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_CancelGroup_1000 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_CancelGroup_1000 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_CancelGroup_1000 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..b00858e72af0d1b54088f073724c5090bf66fb05 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactscancelgroup/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +require('./ActsAnsCancelGroup.js') diff --git a/notification/ans_standard/publish_test/ansactscancelgroup/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/ansactscancelgroup/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/ansactscancelgroup/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/BUILD.gn b/notification/ans_standard/publish_test/ansactsremovegroup/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1dc5d1abb799f72faf8f636acda53d13e590738f --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsRemoveGroup") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsRemoveGroup" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/Test.json b/notification/ans_standard/publish_test/ansactsremovegroup/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..680879a261e1f88486b9555dea7281d23c698a76 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsansremovegroup", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsRemoveGroup.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/.gitignore b/notification/ans_standard/publish_test/ansactsremovegroup/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3543521e9fef8e7322940a87c2b45dd0061b0f45 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/.gitignore @@ -0,0 +1 @@ +/build diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/config.json b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..572437265c100ffa51704045555fd150da4bb328 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/config.json @@ -0,0 +1,71 @@ +{ + "app": { + "bundleName": "com.example.actsansremovegroup", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansremovegroup", + "name": ".actsansremovegroup", + "deviceType": [ + "phone" + ], + "reqPermissions": [{ + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "install bundle", + "usedScene": { + "ability": [ + "KitFramework" + ], + "when": "always" + } + }], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansremovegroup.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..4f1747a95c4acbb66db5351e826c31584356e11c --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..3f05098fe069dfef663b5adfc7dbeae50e24f9f9 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + AnsRemoveGroup + +
diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1054f8e514806795f3e96c7e5248b921f406ae03 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ + +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import file from '@system.file' +import app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } +} diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9b1656ab3824e70163bcdedf221b17cc184967de --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "actsansremovegroup" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/ActsAnsRemoveGroup.js b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/ActsAnsRemoveGroup.js new file mode 100644 index 0000000000000000000000000000000000000000..309e5931f0a68fb74eaedfa4008916e06c5103f3 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/ActsAnsRemoveGroup.js @@ -0,0 +1,776 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var timeout = 500; +describe('ActsAnsRemoveGroup', function () { + console.info("===========ActsAnsRemoveGroup start====================>"); + + var bundleOption = { + bundle:"com.example.actsansremovegroup", + }; + + function onConsumeRemoveGroup(data) { + console.info("=========ANS_RemoveGroup_0100 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0100 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_0100", removeGroupByBundleCallbackOne); + console.info("=========ANS_RemoveGroup_0100 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_0100 onConsume end================>"); + } + + function onCancelRemoveGroup(data) { + console.info("========ANS_RemoveGroup_0100 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0100 onCancel data:===========>" + JSON.stringify(data)); + expect(data.request.id).assertEqual(1); + console.info("========ANS_RemoveGroup_0100 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0100"); + console.info("========ANS_RemoveGroup_0100 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0100"); + console.info("========ANS_RemoveGroup_0100 onCancel groupName:======>" + data.request.groupName); + console.info("========ANS_RemoveGroup_0100 onCancel end=============>"); + } + + function removeGroupByBundleCallbackOne(err){ + console.info("========ANS_RemoveGroup_0100 removeGroupByBundleCallbackOne start==>"); + console.info("========ANS_RemoveGroup_0100 removeGroupByBundleCallbackOne err====>"+JSON.stringify(err)); + console.info("========ANS_RemoveGroup_0100 removeGroupByBundleCallbackOne end====>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0100 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : one notification of the specified group can be successfully removed(callback) + */ + it('ANS_RemoveGroup_0100', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0100 start==================>"); + var subscriber ={ + onConsume:onConsumeRemoveGroup, + onCancel:onCancelRemoveGroup + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0100", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0100", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0100 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0100 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0100 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0100 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeRemoveGroupPromise(data) { + console.info("=========ANS_RemoveGroup_0200 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0200 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_0200"); + console.info("=========ANS_RemoveGroup_0200 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_0200 onConsume end================>"); + } + + function onCancelRemoveGroupPromise(data) { + console.info("========ANS_RemoveGroup_0200 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0200 onCancel data:===========>" + JSON.stringify(data)); + expect(data.request.id).assertEqual(2); + console.info("========ANS_RemoveGroup_0200 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0200"); + console.info("========ANS_RemoveGroup_0200 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0200"); + console.info("========ANS_RemoveGroup_0200 onCancel groupName:======>" + data.request.groupName); + console.info("========ANS_RemoveGroup_0200 onCancel end=============>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0200 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : one notification of the specified group can be successfully removed(promise) + */ + it('ANS_RemoveGroup_0200', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0200 start==================>"); + var subscriber ={ + onConsume:onConsumeRemoveGroupPromise, + onCancel:onCancelRemoveGroupPromise + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0200", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0200", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0200 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0200 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0200 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0200 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + var timesOfOnConsume + + function onConsumeRemoveGroupTwo(data) { + console.info("=========ANS_RemoveGroup_0300 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0300 onConsume data:==============>" + JSON.stringify(data)); + timesOfOnConsume = timesOfOnConsume + 1 + if (timesOfOnConsume == 2){ + notify.removeGroupByBundle(bundleOption, "group_0300", removeGroupByBundleCallback); + console.info("=========ANS_RemoveGroup_0300 onConsume removeGroupByBundle======>"); + } + console.info("=========ANS_RemoveGroup_0300 onConsume end================>"); + } + + var timesOfOnCancel + + function onCancelRemoveGroupTwo(data) { + console.info("========ANS_RemoveGroup_0300 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0300 onCancel data:===========>" + JSON.stringify(data)); + timesOfOnCancel = timesOfOnCancel + 1 + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(1); + } else if (timesOfOnCancel == 2){ + expect(data.request.id).assertEqual(2); + } + console.info("========ANS_RemoveGroup_0300 onCancel end===========>"); + } + + function removeGroupByBundleCallback(err){ + console.info("========ANS_RemoveGroup_0300 removeGroupByBundleCallback start====>"); + console.info("========ANS_RemoveGroup_0300 removeGroupByBundleCallback err======>" + JSON.stringify(err)); + console.info("========ANS_RemoveGroup_0300 removeGroupByBundleCallback end======>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0300 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : 2 notifications of the specified group can be successfully removed(callback) + */ + it('ANS_RemoveGroup_0300', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0300 start==================>"); + timesOfOnConsume = 0 + timesOfOnCancel = 0 + var subscriber ={ + onConsume:onConsumeRemoveGroupTwo, + onCancel:onCancelRemoveGroupTwo, + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0300", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300_1", + badgeIconStyle: 1, + showDeliveryTime: true, + } + var notificationRequest1 = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0300", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300_2", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0300 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0300 publish1 promise=======>"); + notify.publish(notificationRequest1); + console.info("===========ANS_RemoveGroup_0300 publish2 promise=======>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0300 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0300 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeRemoveGroupPromiseTwo(data) { + console.info("=========ANS_RemoveGroup_0400 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0400 onConsume data:==============>" + JSON.stringify(data)); + timesOfOnConsume = timesOfOnConsume + 1 + if (timesOfOnConsume == 2){ + notify.removeGroupByBundle(bundleOption, "group_0400"); + console.info("=========ANS_RemoveGroup_0400 onConsume removeGroupByBundle Promise======>"); + } + console.info("=========ANS_RemoveGroup_0400 onConsume end================>"); + } + + function onCancelRemoveGroupPromiseTwo(data) { + console.info("========ANS_RemoveGroup_0400 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0400 onCancel data:===========>" + JSON.stringify(data)); + timesOfOnCancel = timesOfOnCancel + 1 + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(1); + } else if (timesOfOnCancel == 2){ + expect(data.request.id).assertEqual(2); + } + console.info("========ANS_RemoveGroup_0400 onCancel end===========>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0400 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string): Promise; + * @tc.desc: Verify : 2 notifications of the specified group can be successfully removed(promise) + */ + it('ANS_RemoveGroup_0400', 0, async function (done) { + console.info("===============ANS_RemoveGroup_0400 start==================>"); + timesOfOnConsume = 0 + timesOfOnCancel = 0 + var subscriber ={ + onConsume:onConsumeRemoveGroupPromiseTwo, + onCancel:onCancelRemoveGroupPromiseTwo, + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0400", + id: 1, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400_1", + badgeIconStyle: 1, + showDeliveryTime: true, + } + var notificationRequest1 = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0400", + id: 2, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400_2", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0400 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0400 publish1 promise=======>"); + notify.publish(notificationRequest1); + console.info("===========ANS_RemoveGroup_0400 publish2 promise=======>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0400 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0400 setTimeout unsubscribe==>"); + done(); + }),timeout); + }); + + function onConsumeRemoveGroupThree(data) { + console.info("=========ANS_RemoveGroup_0500 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0500 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_0500", removeGroupByBundleCallbackThree); + console.info("=========ANS_RemoveGroup_0500 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_0500 onConsume end================>"); + } + + function onCancelRemoveGroupThree(data) { + timesOfOnCancel = timesOfOnCancel + 1; + console.info("========ANS_RemoveGroup_0500 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0500 onCancel data:===========>" + JSON.stringify(data)); + if (timesOfOnCancel == 1){ + expect(data.request.id).assertEqual(5); + console.info("========ANS_RemoveGroup_0500 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0500"); + console.info("========ANS_RemoveGroup_0500 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0500"); + console.info("========ANS_RemoveGroup_0500 onCancel groupName:======>" + data.request.groupName); + notify.removeGroupByBundle(bundleOption, "group_0500", removeGroupByBundleCallbackThree2); + console.info("========ANS_RemoveGroup_0500 onCancel removeGroupByBundle:======>"); + } else if (timesOfOnCancel == 2){ + expect.assertFail(); + } + console.info("========ANS_RemoveGroup_0500 onCancel end=============>"); + } + + function removeGroupByBundleCallbackThree(err){ + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree start==>"); + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree err====>"+JSON.stringify(err)); + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree end====>"); + } + + function removeGroupByBundleCallbackThree2(err){ + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree2 start==>"); + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree2 err====>"+JSON.stringify(err)); + console.info("========ANS_RemoveGroup_0500 removeGroupByBundleCallbackThree2 end====>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0500 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : After the notification of a specific group is successfully removed, + remove the notification of this group again(callback) + */ + it('ANS_RemoveGroup_0500', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0500 start==================>"); + timesOfOnCancel = 0; + var subscriber ={ + onConsume:onConsumeRemoveGroupThree, + onCancel:onCancelRemoveGroupThree + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0500", + id: 5, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0500", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0500 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0500 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0500 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0500 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeRemoveGroupPromiseThree(data) { + console.info("=========ANS_RemoveGroup_0600 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0600 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_0600"); + console.info("=========ANS_RemoveGroup_0600 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_0600 onConsume end================>"); + } + + function onCancelRemoveGroupPromiseThree(data) { + timesOfOnCancel = timesOfOnCancel + 1; + console.info("========ANS_RemoveGroup_0600 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0600 onCancel data:===========>" + JSON.stringify(data)); + if (timesOfOnCancel == 1) { + expect(data.request.id).assertEqual(6); + console.info("========ANS_RemoveGroup_0600 onCancel id:=============>" + data.request.id); + expect(data.request.label).assertEqual("0600"); + console.info("========ANS_RemoveGroup_0600 onCancel label:==========>" + data.request.label); + expect(data.request.groupName).assertEqual("group_0600"); + console.info("========ANS_RemoveGroup_0600 onCancel groupName:======>" + data.request.groupName); + notify.removeGroupByBundle(bundleOption, "group_0600"); + console.info("========ANS_RemoveGroup_0600 onCancel removeGroupByBundle:==========>"); + }else if(timesOfOnCancel == 2){ + expect.assertFail(); + } + console.info("========ANS_RemoveGroup_0600 onCancel end=============>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0600 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : After the notification of a specific group is successfully removed, + remove the notification of this group again(promise) + */ + it('ANS_RemoveGroup_0600', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0600 start==================>"); + timesOfOnCancel = 0; + var subscriber ={ + onConsume:onConsumeRemoveGroupPromiseThree, + onCancel:onCancelRemoveGroupPromiseThree + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0600", + id: 6, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0600", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0600 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0600 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0600 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0600 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function removeGroupByBundleCallbackFour(err){ + console.info("========ANS_RemoveGroup_0700 removeGroupByBundleCallbackFour start==>"); + console.info("========ANS_RemoveGroup_0700 removeGroupByBundleCallbackFour err====>"+JSON.stringify(err)); + expect(err.code != 0).assertEqual(true); + console.info("========ANS_RemoveGroup_0700 removeGroupByBundleCallbackFour end====>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0700 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Call the interface with an empty groupName parameter(callback) + */ + it('ANS_RemoveGroup_0700', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0700 start==================>"); + notify.removeGroupByBundle(bundleOption, "", removeGroupByBundleCallbackFour); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0700 setTimeout==============>"); + done(); + }),timeout); + }) + + /* + * @tc.number: ANS_RemoveGroup_0800 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Call the interface with an empty groupName parameter(promise) + */ + it('ANS_RemoveGroup_0800', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0800 start==================>"); + notify.removeGroupByBundle(bundleOption, "").then(()=>{ + console.info("==================ANS_RemoveGroup_0800 removeGroupByBundle then==================>"); + }).catch((err)=>{ + console.info("==================ANS_RemoveGroup_0800 removeGroupByBundle catch==================>"); + console.info("==================ANS_RemoveGroup_0800 removeGroupByBundle err==================>"+err.code); + expect(err.code != 0).assertEqual(true); + }); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0800 setTimeout==============>"); + done(); + }),timeout); + }) + + function onConsumeRemoveGroupFour(data) { + console.info("=========ANS_RemoveGroup_0900 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_0900 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_wrong", removeGroupByBundleCallbackFive); + console.info("=========ANS_RemoveGroup_0900 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_0900 onConsume end================>"); + } + + function onCancelRemoveGroupFour(data) { + expect().assertFail(); + console.info("========ANS_RemoveGroup_0900 onCancel start===========>"); + console.info("========ANS_RemoveGroup_0900 onCancel data:===========>" + JSON.stringify(data)); + console.info("========ANS_RemoveGroup_0900 onCancel end=============>"); + } + + function removeGroupByBundleCallbackFive(err){ + console.info("========ANS_RemoveGroup_0900 removeGroupByBundleCallbackOne start==>"); + console.info("========ANS_RemoveGroup_0900 removeGroupByBundleCallbackOne err====>"+JSON.stringify(err)); + console.info("========ANS_RemoveGroup_0900 removeGroupByBundleCallbackOne end====>"); + } + + /* + * @tc.number: ANS_RemoveGroup_0900 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Verify : Call the interface with an wrong groupName parameter(callback) + */ + it('ANS_RemoveGroup_0900', 0, async function (done) { + console.info("==================ANS_RemoveGroup_0900 start==================>"); + var subscriber ={ + onConsume:onConsumeRemoveGroupFour, + onCancel:onCancelRemoveGroupFour + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_0900", + id: 9, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0900", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_0900 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_0900 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_0900 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_0900 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) + + function onConsumeRemoveGroupPromiseFour(data) { + console.info("=========ANS_RemoveGroup_1000 onConsume start==============>"); + console.info("=========ANS_RemoveGroup_1000 onConsume data:==============>" + JSON.stringify(data)); + notify.removeGroupByBundle(bundleOption, "group_wrong"); + console.info("=========ANS_RemoveGroup_1000 onConsume removeGroupByBundle======>"); + console.info("=========ANS_RemoveGroup_1000 onConsume end================>"); + } + + function onCancelRemoveGroupPromiseFour(data) { + expect().assertFail(); + console.info("========ANS_RemoveGroup_1000 onCancel start===========>"); + console.info("========ANS_RemoveGroup_1000 onCancel data:===========>" + JSON.stringify(data)); + console.info("========ANS_RemoveGroup_1000 onCancel end=============>"); + } + + /* + * @tc.number: ANS_RemoveGroup_1000 + * @tc.name: removeGroupByBundle(bundle: BundleOption, groupName: string, callback: AsyncCallback): void; + * @tc.desc: Verify : Verify : Call the interface with an wrong groupName parameter(promise) + */ + it('ANS_RemoveGroup_1000', 0, async function (done) { + console.info("==================ANS_RemoveGroup_1000 start==================>"); + var subscriber ={ + onConsume:onConsumeRemoveGroupPromiseFour, + onCancel:onCancelRemoveGroupPromiseFour + } + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + groupName:"group_1000", + id: 10, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "1000", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.subscribe(subscriber); + console.info("===========ANS_RemoveGroup_1000 subscribe promise======>"); + notify.publish(notificationRequest); + console.info("===========ANS_RemoveGroup_1000 publish promise========>"); + setTimeout((async function(){ + console.info("======ANS_RemoveGroup_1000 setTimeout==============>"); + notify.unsubscribe(subscriber); + console.info("======ANS_RemoveGroup_1000 setTimeout unsubscribe==>"); + done(); + }),timeout); + }) +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..f19a1b389e59679f6b2e88f2d84d7d35128a7490 --- /dev/null +++ b/notification/ans_standard/publish_test/ansactsremovegroup/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +require('./ActsAnsRemoveGroup.js') diff --git a/notification/ans_standard/publish_test/ansactsremovegroup/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/ansactsremovegroup/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/ansactsremovegroup/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/donotdisturbmode/BUILD.gn b/notification/ans_standard/publish_test/donotdisturbmode/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..4c0ecbdc97d8b4fe9ed403ac30f7b5da3b1007a8 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsDoNotDisturbTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsDoNotDisturbTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/donotdisturbmode/Test.json b/notification/ans_standard/publish_test/donotdisturbmode/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..889e625bc53fe054c1268c02446fe88ac2253378 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsansdonotdisturbtest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsDoNotDisturbTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/config.json b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..07b59997ec105b5100fa9760583e76554ac7b4de --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/config.json @@ -0,0 +1,62 @@ +{ + "app": { + "bundleName": "com.example.actsansdonotdisturbtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsansdonotdisturbtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsansdonotdisturbtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "visible": true + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..4ec775495a8403b6d6d50c89f1311b5d71028954 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 免打扰 + +
diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c3b6a96287aa8ad4c9bf0e44ccba5d69b68ae02c --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import file from '@system.file' +import {Core, ExpectExtend} from 'deccjsunit/index' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + core.init() + + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + }, + onReady() { + console.info('onReady'); + }, +} diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8f8cfa125472c55abb2f04d77e7dae018eb78be3 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DoNot" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..875896977dba3102b36aca8de6788ca0d0a08e06 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +require('./doNotDisturbTest.js') \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..de00b1c917a9fb117cecece5b8946e182f529379 --- /dev/null +++ b/notification/ans_standard/publish_test/donotdisturbmode/entry/src/main/js/test/doNotDisturbTest.js @@ -0,0 +1,949 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +var ERR_ANS_INVALID_PARAM = 67108867 +describe('ActsAnsDoNotDisturbTest', function () { + console.info("===ActsAnsDoNotDisturbTest start===>"); + function connectCallbacka() { + console.debug("==>connectCallbacka code==>"); + } + function subscribeCallbacka(err) { + console.debug("==>subscribeCallbacka code==>" +err.code); + expect(err.code).assertEqual(0); + } + function unSubscribeCallbacka(err){ + console.debug("==>unSubscribeCallbacka code==>" +err.code); + expect(err.code).assertEqual(0); + } + function connectCallbackb() { + console.debug("==>connectCallbackb code==>"); + } + function subscribeCallbackb(err) { + console.debug("==>subscribeCallbackb code==>" +err.code); + expect(err.code).assertEqual(0); + } + function unSubscribeCallbackb(err){ + console.debug("==>unSubscribeCallbackb code==>" +err.code); + 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).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000") + expect(data.end).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).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000") + expect(promise.end).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(2021,11,19,16,52) + var endDate = new Date(2021,11,22,18,33) + 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).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000") + expect(data.end).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(2021,11,19,10,6) + var endDate = new Date(2021,11,22,18,46) + notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_NONE, + begin:beginDate, + end:endDate + }).then( + await notify.getDoNotDisturbDate().then((data)=>{ + console.log("===>test_0400 getDoNotDisturbDate===>"+JSON.stringify(data)) + expect(data.type).assertEqual(0) + expect(data.begin).assertEqual("Thu Jan 01 1970 00:00:00 GMT+0000") + expect(data.end).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(2021,11,19,12,10) + var endDate = new Date(2021,11,22,18,42) + await notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_ONCE, + begin:beginDate, + end:endDate + },async(err) => { + console.log("===>test_0500 success===>"+err.code) + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_0500 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) + expect(data.type).assertEqual(1) + expect(data.begin).assertEqual("Thu Jan 01 1970 12:10:00 GMT+0000") + expect(data.end).assertEqual("Thu Jan 01 1970 18:42:00 GMT+0000") + 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(2021,11,19,8,13) + var endDate = new Date(2021,11,22,18,42) + notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_ONCE, + begin:beginDate, + end:endDate + }).then( + await notify.getDoNotDisturbDate().then((data)=>{ + console.log("===>test_0600 success===>"+JSON.stringify(data)) + expect(data.type).assertEqual(1) + expect(data.begin).assertEqual("Thu Jan 01 1970 08:13:00 GMT+0000") + expect(data.end).assertEqual("Thu Jan 01 1970 18:42:00 GMT+0000") + 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(2021,11,19,8,18) + var endDate = new Date(2021,11,22,24,46) + await notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_DAILY, + begin:beginDate, + end:endDate + },async(err) => { + console.log("===>test_0700 success===>"+err.code) + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_0700 getDoNotDisturbDate===>"+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Sun Dec 19 2021 08:18:00 GMT+0000") + expect(data.end).assertEqual("Thu Dec 23 2021 00:46:00 GMT+0000") + 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(2021,11,18,16,12) + var endDate = new Date(2021,11,19,16,12) + 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((data)=>{ + console.log("===>test_0800 success===>"+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Sat Dec 18 2021 16:12:00 GMT+0000") + expect(data.end).assertEqual("Sun Dec 19 2021 16:12:00 GMT+0000") + 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(2021,11,19,12,12) + var endDate = new Date(2021,11,19,16,12) + 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((err,data)=>{ + console.log("===>test_0900 getDoNotDisturbDate===>"+JSON.stringify(data)) + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 12:12:00 GMT+0000") + expect(data.end).assertEqual("Sun Dec 19 2021 16:12:00 GMT+0000") + 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(2021,11,19,8,18) + var endDate = new Date(2021,11,22,24,46) + console.log("===>test_1000 beginDate ===>"+beginDate) + console.log("===>test_1000 endDate ===>"+endDate) + notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_CLEARLY, + begin:beginDate, + end:endDate + }).then( + await notify.getDoNotDisturbDate().then((data)=>{ + console.log("===>test_1000 getDoNotDisturbDate===>"+JSON.stringify(data)) + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 08:18:00 GMT+0000") + expect(data.end).assertEqual("Thu Dec 23 2021 00:46:00 GMT+0000") + 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(2021,11,22,12,18) + var endDate = new Date(2021,11,22,12,18) + 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((err,data)=>{ + console.log("===>test_1100 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Wed Dec 22 2021 12:18:00 GMT+0000") + expect(data.end).assertEqual("Wed Dec 22 2021 12:18:00 GMT+0000") + 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(2021,11,22,12,18) + var endDate = new Date(2021,11,22,12,18) + 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( + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_1200 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Wed Dec 22 2021 12:18:00 GMT+0000") + expect(data.end).assertEqual("Wed Dec 22 2021 12:18:00 GMT+0000") + done(); + }) + ).catch((err)=>{ + console.log("===>test_1200 getDoNotDisturbDate fail===>"+JSON.stringify(err)) + 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(2021,11,23,12,18) + var endDate = new Date(2021,11,22,2,18) + 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((err,data)=>{ + console.log("===>test_1300 getDoNotDisturbDate success===>"+err.code+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Thu Dec 23 2021 12:18:00 GMT+0000") + expect(data.end).assertEqual("Wed Dec 22 2021 02:18:00 GMT+0000") + 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(2021,11,23,12,18) + var endDate = new Date(2021,11,22,2,18) + 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( + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_1400 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) + expect(data.type).assertEqual(2) + expect(data.begin).assertEqual("Thu Dec 23 2021 12:18:00 GMT+0000") + expect(data.end).assertEqual("Wed Dec 22 2021 02:18:00 GMT+0000") + done(); + }) + ).catch((err)=>{ + console.log("===>test_1400 getDoNotDisturbDate fail===>"+JSON.stringify(err)) + 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 + },(err) => { + console.log("===>ActsSetDoNotDisturbTest_test_1500 success===>"+err.code) + expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM) + 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((err)=>{ + console.log("===>test_1600 fail===>"+JSON.stringify(err)) + expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM) + 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) + 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((err)=>{ + console.log("===>test_1800 setDoNotDisturbDate fail===>"+JSON.stringify(err)) + expect(err.code).assertEqual(ERR_ANS_INVALID_PARAM) + done(); + }) + }) + + /* + * @tc.number: ActsSetDoNotDisturbTest_test_1900 + * @tc.name: setDoNotDisturbDate() + * @tc.desc: verify the function of setDoNotDisturbDate + */ + it('ActsSetDoNotDisturbTest_test_1900', 0, async function (done) { + await notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_CLEARLY, + begin:100, + end:100 + },async(err) => { + console.log("===>test_1900 success===>"+err.code) + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_1900 getDoNotDisturbDate success===>"+err.code+JSON.stringify(data)) + }) + }) + done(); + }) + + /* + * @tc.number: ActsSetDoNotDisturbTest_test_2000 + * @tc.name: displayBadge() + * @tc.desc: verify the function of displayBadge + */ + it('ActsSetDoNotDisturbTest_test_2000', 0, async function (done) { + var promise = notify.setDoNotDisturbDate({ + type:notify.DoNotDisturbType.TYPE_CLEARLY, + begin:100, + end:100 + }) + console.log("===>ActsSetDoNotDisturbTest_test_2000 promise===>"+promise) + 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(2021,11,19,9,34) + var endDate = new Date(2021,11,19,16,12) + var subInfo ={ + onConnect:connectCallbacka, + onDoNotDisturbDateChange:async(data)=>{ + console.debug("==>disturbModeCallbacka data==>" +JSON.stringify(data)); + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 09:34:00 GMT+0000") + expect(data.end).assertEqual("Sun Dec 19 2021 16:12:00 GMT+0000") + await notify.getDoNotDisturbDate((err,data)=>{ + console.log("===>test_2100 getDoNotDisturbDate===>"+err.code+JSON.stringify(data)) + notify.unsubscribe(subInfo, unSubscribeCallbacka); + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 09:34:00 GMT+0000") + expect(data.end).assertEqual("Sun Dec 19 2021 16:12:00 GMT+0000") + 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(2021,11,19,8,18) + var endDate = new Date(2021,11,22,24,46) + var subInfo ={ + onConnect:connectCallbackb, + onDoNotDisturbDateChange:async(data)=>{ + console.debug("==>disturbModeCallbackb data==>" +JSON.stringify(data)); + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 08:18:00 GMT+0000") + expect(data.end).assertEqual("Thu Dec 23 2021 00:46:00 GMT+0000") + await notify.getDoNotDisturbDate().then((data)=>{ + console.log("===>test_2200 getDoNotDisturbDate===>"+JSON.stringify(data)) + notify.unsubscribe(subInfo, unSubscribeCallbackb); + expect(data.type).assertEqual(3) + expect(data.begin).assertEqual("Sun Dec 19 2021 08:18:00 GMT+0000") + expect(data.end).assertEqual("Thu Dec 23 2021 00:46:00 GMT+0000") + 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)); + expect(data.sound).assertEqual("normalSocialMusic"); + console.log("===test_2500 onConsume sound===>"+data.sound); + expect(data.vibrationValues).assertEqual("1,0,1,0,1,0"); + console.log("===test_2500 onConsume vibrationValues===>"+data.vibrationValues); + } + 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===>"); + notify.unsubscribe(subscriber); + console.info("===test_2500 setTimeout unsubscribe===>"); + done(); + }),300); + }) + + 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)); + expect(data.sound).assertEqual("normalSocialMusic"); + console.log("===test_2600 onConsume sound===>"+data.sound); + expect(data.vibrationValues).assertEqual("1,0,1,0,1,0"); + console.log("===test_2600 onConsume vibrationValues===>"+data.vibrationValues); + } + + /* + * @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====>"); + notify.unsubscribe(subscriber); + console.info("====test_2600 setTimeout unsubscribe====>"); + done(); + }),300); + }) + + 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)); + expect(data.sound).assertEqual("normalSocialMusic"); + console.log("===test_2700 onConsume sound===>"+data.sound); + expect(data.vibrationValues).assertEqual("1,0,1,0,1,0"); + console.log("===test_2700 onConsume vibrationValues===>"+data.vibrationValues); + } + + /* + * @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====>"); + notify.unsubscribe(subscriber); + console.info("====test_2700 setTimeout unsubscribe============>"); + done(); + }),300); + }) + + 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)); + expect(data.sound).assertEqual("normalSocialMusic"); + console.log("===test_2800 onConsume sound===>"+data.sound); + expect(data.vibrationValues).assertEqual("1,0,1,0,1,0"); + console.log("===test_2800 onConsume vibrationValues===>"+data.vibrationValues); + } + + /* + * @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============>"); + notify.unsubscribe(subscriber); + console.info("======test_2800 setTimeout unsubscribe============>"); + done(); + }),300); + }) + }) +}) + + diff --git a/notification/ans_standard/publish_test/donotdisturbmode/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/donotdisturbmode/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/donotdisturbmode/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/publishsound/BUILD.gn b/notification/ans_standard/publish_test/publishsound/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9a586313cf9a0381812ddf5671a5239feacd92e0 --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsPublishSoundTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsPublishSoundTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/publishsound/Test.json b/notification/ans_standard/publish_test/publishsound/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..b081e81b498e39aba0bfd2fc40de431494820dfc --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsanspublishsoundtest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsPublishSoundTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/config.json b/notification/ans_standard/publish_test/publishsound/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d9ca19e6250d94c2d91b80d0c2f32d00932d88f2 --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/config.json @@ -0,0 +1,71 @@ +{ + "app": { + "bundleName": "com.example.actsanspublishsoundtest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsanspublishsoundtest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "reqPermissions": [{ + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "install bundle", + "usedScene": { + "ability": [ + "KitFramework" + ], + "when": "always" + } + }], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsanspublishsoundtest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..4f1747a95c4acbb66db5351e826c31584356e11c --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..e10d16a54be3c61abdbbd17d4f404a4f95098c55 --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 发布声音通知-normal + +
diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1054f8e514806795f3e96c7e5248b921f406ae03 --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ + +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import file from '@system.file' +import app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } +} diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c79c42dff3ec080ae23c096b23615e14285bda2e --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "pubSound" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..fe31588189eadfb4ef3f00a2c16a93fc77b2a411 --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,1024 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +describe('ActsAnsPublishSoundTest', function () { + console.info("===========ActsAnsPublishSoundTest start====================>"); + var timeout = 300 + var bundleoption = { + bundle: "com.example.actsanspublishsoundtest" + } + var timesOfOnConsume + function onConsume0100(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0100 onConsume start============>"); + console.info("=============Ans_PublishSound_0100 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0100 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("file://system/etc/Light.ogg"); + console.info("=============Ans_PublishSound_0100 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0100"); + console.info("=============Ans_PublishSound_0100 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0100 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0100 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SOCIAL_COMMUNICATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0100', 0,async function (done) { + console.info("===============Ans_PublishSound_0100================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0100 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0100 subscribe======>"); + notify.addSlot(notify.SlotType.SOCIAL_COMMUNICATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 1, + 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: "statusBarText", + isFloatingIcon : true, + label: "0100", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0100 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SOCIAL_COMMUNICATION, + sound:"sound_0100", + }).then(()=>{ + console.info("=======Ans_PublishSound_0100 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0100 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0100 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0100 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0100 setTimeout========>"); + notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0100 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0200(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0200 onConsume start============>"); + console.info("=============Ans_PublishSound_0200 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0200 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("file://system/etc/Light.ogg"); + console.info("=============Ans_PublishSound_0200 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0200"); + console.info("=============Ans_PublishSound_0200 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0200 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0200 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SERVICE_INFORMATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0200', 0,async function (done) { + console.info("===============Ans_PublishSound_0200================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0200 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0200 subscribe======>"); + notify.addSlot(notify.SlotType.SERVICE_INFORMATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 2, + slotType : notify.SlotType.SERVICE_INFORMATION , + 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: "statusBarText", + isFloatingIcon : true, + label: "0200", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0200 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SERVICE_INFORMATION , + sound:"sound_0200", + }).then(()=>{ + console.info("=======Ans_PublishSound_0200 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0200 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0200 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0200 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0200 setTimeout========>"); + notify.removeSlot(notify.SlotType.SERVICE_INFORMATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0200 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0300(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0300 onConsume start============>"); + console.info("=============Ans_PublishSound_0300 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0300 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual(""); + console.info("=========Ans_PublishSound_0300 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0300"); + console.info("=========Ans_PublishSound_0300 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0300 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0300 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a CONTENT_INFORMATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0300', 0,async function (done) { + console.info("===============Ans_PublishSound_0300================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0300 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0300 subscribe======>"); + notify.addSlot(notify.SlotType.CONTENT_INFORMATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 3, + slotType : notify.SlotType.CONTENT_INFORMATION, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0300 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.CONTENT_INFORMATION, + sound:"sound_0300", + }).then(()=>{ + console.info("=======Ans_PublishSound_0300 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0300 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0300 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0300 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishSound_0300 setTimeout========>"); + notify.removeSlot(notify.SlotType.CONTENT_INFORMATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0300 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0400(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0400 onConsume start============>"); + console.info("=============Ans_PublishSound_0400 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0400 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual(""); + console.info("=========Ans_PublishSound_0400 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0400"); + console.info("=========Ans_PublishSound_0400 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0400 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0400 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a OTHER_TYPES type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0400', 0,async function (done) { + console.info("===============Ans_PublishSound_0400================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0400 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0400 subscribe======>"); + notify.addSlot(notify.SlotType.OTHER_TYPES); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 4, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0400 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + sound:"sound_0400", + }).then(()=>{ + console.info("=======Ans_PublishSound_0400 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0400 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0400 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0400 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0400 setTimeout========>"); + notify.removeSlot(notify.SlotType.OTHER_TYPES); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0400 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0500(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0500 onConsume start============>"); + console.info("=============Ans_PublishSound_0500 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0500 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual(""); + console.info("=========Ans_PublishSound_0500 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0500"); + console.info("=========Ans_PublishSound_0500 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0500 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0500 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a UNKNOWN_TYPE type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0500', 0,async function (done) { + console.info("===============Ans_PublishSound_0500================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0500 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0500 subscribe======>"); + notify.addSlot(notify.SlotType.UNKNOWN_TYPE); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 5, + slotType : notify.SlotType.UNKNOWN_TYPE, + 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: "statusBarText", + isFloatingIcon : true, + label: "0500", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0500 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + sound:"sound_0500", + }).then(()=>{ + console.info("=======Ans_PublishSound_0500 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0500 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0500 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0500 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0500 setTimeout========>"); + notify.removeSlot(notify.SlotType.UNKNOWN_TYPE); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0500 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0600(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0600 onConsume start============>"); + console.info("=============Ans_PublishSound_0600 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0600 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_0600"); + console.info("=============Ans_PublishSound_0600 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0600_set"); + console.info("=============Ans_PublishSound_0600 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0600 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0600 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SOCIAL_COMMUNICATION type slot, set sound information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0600', 0,async function (done) { + console.info("===============Ans_PublishSound_0600================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0600 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0600 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.SOCIAL_COMMUNICATION, + sound:"sound_0600", + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 6, + 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: "statusBarText", + isFloatingIcon : true, + label: "0600", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0600 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SOCIAL_COMMUNICATION, + sound:"sound_0600_set", + }).then(()=>{ + console.info("=======Ans_PublishSound_0600 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0600 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0600 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0600 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0600 setTimeout========>"); + notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0600 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0700(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0700 onConsume start============>"); + console.info("=============Ans_PublishSound_0700 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0700 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_0700"); + console.info("=============Ans_PublishSound_0700 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0700_set"); + console.info("=============Ans_PublishSound_0700 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0700 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0700 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SERVICE_INFORMATION type slot, set sound information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0700', 0,async function (done) { + console.info("===============Ans_PublishSound_0700================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0700 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0700v subscribe======>"); + notify.addSlot({ + type:notify.SlotType.SERVICE_INFORMATION, + sound:"sound_0700", + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 7, + slotType : notify.SlotType.SERVICE_INFORMATION , + 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: "statusBarText", + isFloatingIcon : true, + label: "0700", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0700 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SERVICE_INFORMATION , + sound:"sound_0700_set", + }).then(()=>{ + console.info("=======Ans_PublishSound_0700 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0700 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0700 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0700 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0700 setTimeout========>"); + notify.removeSlot(notify.SlotType.SERVICE_INFORMATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0700 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0800(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0800 onConsume start============>"); + console.info("=============Ans_PublishSound_0800 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0800 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_0800"); + console.info("=========Ans_PublishSound_0800 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0800_set"); + console.info("=========Ans_PublishSound_0800 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0800 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0800 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a CONTENT_INFORMATION type slot, set sound information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0800', 0,async function (done) { + console.info("===============Ans_PublishSound_0800================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0800 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0800 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.CONTENT_INFORMATION, + sound:"sound_0800", + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 8, + slotType : notify.SlotType.CONTENT_INFORMATION, + 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: "statusBarText", + isFloatingIcon : true, + label: "0800", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0800 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.CONTENT_INFORMATION, + sound:"sound_0800_set", + }).then(()=>{ + console.info("=======Ans_PublishSound_0800 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0800 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0800 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0800 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishSound_0800 setTimeout========>"); + notify.removeSlot(notify.SlotType.CONTENT_INFORMATION); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0800 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0900(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_0900 onConsume start============>"); + console.info("=============Ans_PublishSound_0900 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_0900 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_0900"); + console.info("=========Ans_PublishSound_0900 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_0900_set"); + console.info("=========Ans_PublishSound_0900 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_0900 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_0900 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a OTHER_TYPES type slot, set sound information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_0900', 0,async function (done) { + console.info("===============Ans_PublishSound_0900================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0900 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_0900 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.OTHER_TYPES, + sound:"sound_0900", + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 3, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_0900 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + sound:"sound_0900_set", + }).then(()=>{ + console.info("=======Ans_PublishSound_0900 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_0900 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0900 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_0900 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishSound_0900 setTimeout========>"); + notify.removeSlot(notify.SlotType.OTHER_TYPES); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_0900 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume1000(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_1000 onConsume start============>"); + console.info("=============Ans_PublishSound_1000 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + console.info("=============Ans_PublishSound_1000 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_1000"); + console.info("=========Ans_PublishSound_1000 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_1000_set"); + console.info("=========Ans_PublishSound_1000 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_1000 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_1000 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a UNKNOWN_TYPE type slot, set sound information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_1000', 0,async function (done) { + console.info("===============Ans_PublishSound_1000================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume1000 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_1000 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.UNKNOWN_TYPE, + sound:"sound_1000", + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 10, + slotType : notify.SlotType.UNKNOWN_TYPE, + 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: "statusBarText", + isFloatingIcon : true, + label: "1000", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_1000 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.UNKNOWN_TYPE, + sound:"sound_1000_set", + }).then(()=>{ + console.info("=======Ans_PublishSound_1000 publish1 then setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_1000 publish1 then setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_1000 publish1 then setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_1000 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishSound_1000 setTimeout========>"); + notify.removeSlot(notify.SlotType.UNKNOWN_TYPE); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_1000 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume1100(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishSound_1100 onConsume start============>"); + console.info("=============Ans_PublishSound_1100 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var sound = data.sortingMap.sortings[hashCode].slot.sound + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishSound_1100 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishSound_1100 onConsume vibrationEnabled============>" + vibrationEnabled); + console.info("=============Ans_PublishSound_1100 onConsume sound============>" + sound); + if (timesOfOnConsume == 1){ + expect(sound).assertEqual("sound_1100"); + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([11,0,11,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=========Ans_PublishSound_1100 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(sound).assertEqual("sound_1100_set"); + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([11,11,11,11])); + expect(vibrationEnabled).assertEqual(true); + console.info("=========Ans_PublishSound_1100 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishSound_1100 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishSound_1100 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a UNKNOWN_TYPE type slot, set sound and vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishSound_1100', 0,async function (done) { + console.info("===============Ans_PublishSound_1100================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume1100 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishSound_1100 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.UNKNOWN_TYPE, + sound:"sound_1100", + vibrationValues:[11,0,11,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 10, + slotType : notify.SlotType.UNKNOWN_TYPE, + 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: "statusBarText", + isFloatingIcon : true, + label: "1000", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishSound_1100 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.UNKNOWN_TYPE, + sound:"sound_1100_set", + vibrationValues:[11,11,11,11], + }).then(()=>{ + console.info("=======Ans_PublishSound_1100 publish1 then setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishSound_1100 publish1 then setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishSound_1100 publish1 then setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishSound_1100 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishSound_1100 setTimeout========>"); + notify.removeSlot(notify.SlotType.UNKNOWN_TYPE); + notify.unsubscribe(subscriber); + console.info("======Ans_PublishSound_1100 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..8775e7bf80d2e36e8efcb59fb03c6784f00209fd --- /dev/null +++ b/notification/ans_standard/publish_test/publishsound/entry/src/main/js/test/List.test.js @@ -0,0 +1,16 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +require('./ExampleJsunit.test.js') + diff --git a/notification/ans_standard/publish_test/publishsound/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/publishsound/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/publishsound/signature/openharmony_sx.p7b differ diff --git a/notification/ans_standard/publish_test/publishvibra/BUILD.gn b/notification/ans_standard/publish_test/publishvibra/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..59a706ab8ba50f6b5dcf4d93d92607bcd6bb0708 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAnsPublishVibraTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsAnsPublishVibraTest" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/notification/ans_standard/publish_test/publishvibra/Test.json b/notification/ans_standard/publish_test/publishvibra/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..c60057722cd2613b9b5c97d85b511a346032b7c4 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "60000", + "package": "com.example.actsanspublishvibratest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAnsPublishVibraTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/config.json b/notification/ans_standard/publish_test/publishvibra/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..cb034820200eb584748eda4eb12fcb115b61dd97 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/config.json @@ -0,0 +1,73 @@ +{ + "app": { + "bundleName": "com.example.actsanspublishvibratest", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsanspublishvibratest", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "reqPermissions": [ + { + "name": "ohos.permission.NOTIFICATION_CONTROLLER", + "reason": "install bundle", + "usedScene": { + "ability": [ + "KitFramework" + ], + "when": "always" + } + } + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.actsanspublishvibratest.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/app.js b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..4f1747a95c4acbb66db5351e826c31584356e11c --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/en-US.json b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/zh-CN.json b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.css b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.hml b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..6de4b7adbda598b62ecc65bf8d50342c4cf02bdd --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + 发布震动通知-normal + +
diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.js b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.js new file mode 100644 index 0000000000000000000000000000000000000000..1054f8e514806795f3e96c7e5248b921f406ae03 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,45 @@ + +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +import file from '@system.file' +import app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import {Core, ExpectExtend, ReportExtend} from 'deccjsunit/index' + +export default { + data: { + title: "" + }, + onInit() { + this.title = this.$t('strings.world'); + }, + onShow() { + console.info('onShow finish') + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + const reportExtend = new ReportExtend(file) + core.addService('expect', expectExtend) + core.addService('report', reportExtend) + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + + require('../../../test/List.test') + core.execute() + } +} diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/element/string.json b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..668aea23626b9aae9740b272a76f88a3d877b735 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "PubVibra" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/media/icon.png b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/resources/base/media/icon.png differ diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/ExampleJsunit.test.js b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/ExampleJsunit.test.js new file mode 100644 index 0000000000000000000000000000000000000000..623bd52e8f7648e3b85c8c20fed66fefaa18339c --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/ExampleJsunit.test.js @@ -0,0 +1,1121 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import notify from '@ohos.notification' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +describe('ActsAnsPublishVibraTest', function () { + console.info("===========ActsAnsPublishVibraTest start====================>"); + var timeout = 200 + var bundleoption = { + bundle: "com.example.actsanspublishvibratest" + } + var timesOfOnConsume + function onConsume0100(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0100 onConsume start============>"); + console.info("=============Ans_PublishVibra_0100 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0100 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0200 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([200])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0100 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([1,0,1,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0100 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0100 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0100 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SOCIAL_COMMUNICATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0100', 0,async function (done) { + console.info("===============Ans_PublishVibra_0100================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0100 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0100 subscribe======>"); + await notify.addSlot(notify.SlotType.SOCIAL_COMMUNICATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 1, + 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: "statusBarText", + isFloatingIcon : true, + label: "0100", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0100 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SOCIAL_COMMUNICATION, + vibrationValues:[1,0,1,0], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0100 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0100 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0100 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0100 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0100 setTimeout========>"); + await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0100 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0200(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0200 onConsume start============>"); + console.info("=============Ans_PublishVibra_0200 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0200 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0200 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([200])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0200 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([2,0,2,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0200 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0200 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0200 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SERVICE_INFORMATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0200', 0,async function (done) { + console.info("===============Ans_PublishVibra_0200================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0200 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0200 subscribe======>"); + await notify.addSlot(notify.SlotType.SERVICE_INFORMATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 2, + slotType : notify.SlotType.SERVICE_INFORMATION , + 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: "statusBarText", + isFloatingIcon : true, + label: "0200", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0200 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SERVICE_INFORMATION , + vibrationValues:[2,0,2,0], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0200 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0200 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0200 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0200 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0200 setTimeout========>"); + await notify.removeSlot(notify.SlotType.SERVICE_INFORMATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0200 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0300(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0300 onConsume start============>"); + console.info("=============Ans_PublishVibra_0300 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0300 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0300 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([])); + expect(vibrationEnabled).assertEqual(false); + console.info("=============Ans_PublishVibra_0300 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([3,0,3,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0300 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0300 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0300 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a CONTENT_INFORMATION type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0300', 0,async function (done) { + console.info("===============Ans_PublishVibra_0300================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0300 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0300 subscribe======>"); + await notify.addSlot(notify.SlotType.CONTENT_INFORMATION); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 3, + slotType : notify.SlotType.CONTENT_INFORMATION, + 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: "statusBarText", + isFloatingIcon : true, + label: "0300", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0300 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.CONTENT_INFORMATION, + vibrationValues:[3,0,3,0], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0300 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0300 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0300 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0300 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0300 setTimeout========>"); + await notify.removeSlot(notify.SlotType.CONTENT_INFORMATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0300 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0400(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0400 onConsume start============>"); + console.info("=============Ans_PublishVibra_0400 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0400 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0400 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([])); + expect(vibrationEnabled).assertEqual(false); + console.info("=============Ans_PublishVibra_0400 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([4,0,4,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0400 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0400 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0400 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a OTHER_TYPES type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0400', 0,async function (done) { + console.info("===============Ans_PublishVibra_0400================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0400 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0400 subscribe======>"); + await notify.addSlot(notify.SlotType.OTHER_TYPES); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 4, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0400", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0400 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + vibrationValues:[4,0,4,0], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0400 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0400 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0400 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0400 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0400 setTimeout========>"); + await notify.removeSlot(notify.SlotType.OTHER_TYPES); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0400 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0500(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0500 onConsume start============>"); + console.info("=============Ans_PublishVibra_0500 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0500 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0500 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([])); + expect(vibrationEnabled).assertEqual(false); + console.info("=============Ans_PublishVibra_0500 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([5,0,5,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0500 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0500 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0500 + * @tc.name: addSlot(type: SlotType): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a UNKNOWN_TYPE type slot, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0500', 0,async function (done) { + console.info("===============Ans_PublishVibra_0500================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0500 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0500 subscribe======>"); + await notify.addSlot(notify.SlotType.UNKNOWN_TYPE); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 5, + slotType : notify.SlotType.UNKNOWN_TYPE, + 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: "statusBarText", + isFloatingIcon : true, + label: "0500", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0500 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + vibrationValues:[5,0,5,0], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0500 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0500 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0500 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0500 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0500 setTimeout========>"); + await notify.removeSlot(notify.SlotType.UNKNOWN_TYPE); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0500 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0600(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0600 onConsume start============>"); + console.info("=============Ans_PublishVibra_0600 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0600 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0600 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([6,0,6,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0600 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([6,6,6,6])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0600 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0600 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0600 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SOCIAL_COMMUNICATION type slot, set vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0600', 0,async function (done) { + console.info("===============Ans_PublishVibra_0600================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0600 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0600 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.SOCIAL_COMMUNICATION, + vibrationValues:[6,0,6,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 6, + 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: "statusBarText", + isFloatingIcon : true, + label: "0600", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0600 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SOCIAL_COMMUNICATION, + vibrationValues:[6,6,6,6], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0600 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0600 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0600 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0600 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0600 setTimeout========>"); + await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0600 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0700(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0700 onConsume start============>"); + console.info("=============Ans_PublishVibra_0700 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0700 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0700 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([7,0,7,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0700 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([7,7,7,7])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0700 onConsume timesOfOnConsume2============>"); + } + + console.info("=============Ans_PublishVibra_0700 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0700 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SERVICE_INFORMATION type slot, set vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0700', 0,async function (done) { + console.info("===============Ans_PublishVibra_0700================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0700 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0700 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.SERVICE_INFORMATION, + vibrationValues:[7,0,7,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 7, + slotType : notify.SlotType.SERVICE_INFORMATION , + 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: "statusBarText", + isFloatingIcon : true, + label: "0700", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0700 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.SERVICE_INFORMATION , + vibrationValues:[7,7,7,7], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0700 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0700 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0700 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0700 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0700 setTimeout========>"); + await notify.removeSlot(notify.SlotType.SERVICE_INFORMATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0700 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0800(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0800 onConsume start============>"); + console.info("=============Ans_PublishVibra_0800 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0800 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0800 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([8,0,8,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0800 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([8,8,8,8])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0800 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0800 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0800 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a CONTENT_INFORMATION type slot, set vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0800', 0,async function (done) { + console.info("===============Ans_PublishVibra_0800================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume0800 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0800 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.CONTENT_INFORMATION, + vibrationValues:[8,0,8,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 8, + slotType : notify.SlotType.CONTENT_INFORMATION, + 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: "statusBarText", + isFloatingIcon : true, + label: "0800", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0800 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.CONTENT_INFORMATION, + vibrationValues:[8,8,8,8], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0800 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0800 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0800 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0800 publish1 then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0800 setTimeout========>"); + await notify.removeSlot(notify.SlotType.CONTENT_INFORMATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0800 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume0900(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_0900 onConsume start============>"); + console.info("=============Ans_PublishVibra_0900 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_0900 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_0900 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([9,0,9,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0900 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([9,9,9,9])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_0900 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_0900 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_0900 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a OTHER_TYPES type slot, set vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_0900', 0,async function (done) { + console.info("===============Ans_PublishVibra_0900================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume0900 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_0900 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.OTHER_TYPES, + vibrationValues:[9,0,9,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 9, + slotType : notify.SlotType.OTHER_TYPES, + 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: "statusBarText", + isFloatingIcon : true, + label: "0900", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_0900 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.OTHER_TYPES, + vibrationValues:[9,9,9,9], + }).then(()=>{ + console.info("=======Ans_PublishVibra_0900 setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_0900 setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0900 setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_0900 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishVibra_0900 setTimeout========>"); + await notify.removeSlot(notify.SlotType.OTHER_TYPES); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_0900 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume1000(data){ + timesOfOnConsume ++; + console.info("=============Ans_PublishVibra_1000 onConsume start============>"); + console.info("=============Ans_PublishVibra_1000 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_1000 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_1000 onConsume vibrationEnabled============>" + vibrationEnabled); + if (timesOfOnConsume == 1){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([10,0,10,0])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_1000 onConsume timesOfOnConsume1============>"); + } else if (timesOfOnConsume == 2){ + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([10,10,10,10])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_1000 onConsume timesOfOnConsume2============>"); + } + console.info("=============Ans_PublishVibra_1000 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_1000 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a UNKNOWN_TYPE type slot, set vibra information, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_1000', 0,async function (done) { + console.info("===============Ans_PublishVibra_1000================>"); + timesOfOnConsume = 0; + var subscriber = { + onConsume:onConsume1000 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_1000 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.UNKNOWN_TYPE, + vibrationValues:[10,0,10,0], + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 10, + slotType : notify.SlotType.UNKNOWN_TYPE, + 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: "statusBarText", + isFloatingIcon : true, + label: "1000", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_1000 publish1 then======>"); + notify.setSlotByBundle(bundleoption, + { + type:notify.SlotType.UNKNOWN_TYPE, + vibrationValues:[10,10,10,10], + }).then(()=>{ + console.info("=======Ans_PublishVibra_1000 publish1 then setSlotByBundle then======>"); + notify.publish(notificationRequest); + console.info("=======Ans_PublishVibra_1000 publish1 then setSlotByBundle then publish2======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_1000 publish1 then setSlotByBundle catch err======>"+err); + }) + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_1000 publish1 then catch err======>"+err); + }) + + setTimeout((async function(){ + console.info("======Ans_PublishVibra_1000 setTimeout========>"); + await notify.removeSlot(notify.SlotType.UNKNOWN_TYPE); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_1000 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume1100(data){ + console.info("=============Ans_PublishVibra_1100 onConsume start============>"); + console.info("=============Ans_PublishVibra_1100 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_1100 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_1100 onConsume vibrationEnabled============>" + vibrationEnabled); + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([200])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_1100 onConsume timesOfOnConsume1============>"); + console.info("=============Ans_PublishVibra_1100 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_1100 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a SOCIAL_COMMUNICATION type slot, set vibra flag, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_1100', 0,async function (done) { + console.info("===============Ans_PublishVibra_1100================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume1100 + } + notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_1100 subscribe======>"); + notify.addSlot({ + type:notify.SlotType.SOCIAL_COMMUNICATION, + vibrationEnabled:true, + }).then(()=>{ + console.info("===============Ans_PublishVibra_1100 addSlot then======>"); + }).catch((err)=>{ + console.info("===============Ans_PublishVibra_1100 addSlot catch err======>"+err); + }); + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 11, + 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: "statusBarText", + isFloatingIcon : true, + label: "1100", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_1100 publish then======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_1100 publish then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_1100 setTimeout========>"); + await notify.removeSlot(notify.SlotType.SOCIAL_COMMUNICATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_1100 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); + + function onConsume1200(data){ + console.info("=============Ans_PublishVibra_1200 onConsume start============>"); + console.info("=============Ans_PublishVibra_1200 onConsume data:============>" + JSON.stringify(data)); + var hashCode = data.request.hashCode + var vibrationValues = data.sortingMap.sortings[hashCode].slot.vibrationValues + var vibrationEnabled = data.sortingMap.sortings[hashCode].slot.vibrationEnabled + console.info("=============Ans_PublishVibra_1200 onConsume vibrationValues============>" + vibrationValues); + console.info("=============Ans_PublishVibra_1200 onConsume vibrationEnabled============>" + vibrationEnabled); + expect(JSON.stringify(vibrationValues)).assertEqual(JSON.stringify([])); + expect(vibrationEnabled).assertEqual(true); + console.info("=============Ans_PublishVibra_1200 onConsume end==============>"); + } + + /* + * @tc.number: Ans_PublishVibra_1200 + * @tc.name: addSlot(slot: NotificationSlot): Promise; + setSlotByBundle(bundle: BundleOption, slot: NotificationSlot): Promise; + * @tc.desc: Create a CONTENT_INFORMATION type slot, set vibra flag, publish a notification and verify. + After changing the slot information, publish a notification again and verify. + */ + it('Ans_PublishVibra_1200', 0,async function (done) { + console.info("===============Ans_PublishVibra_1200================>"); + timesOfOnConsume = 0; + var subscriber ={ + onConsume:onConsume1200 + } + await notify.subscribe(subscriber); + console.info("===============Ans_PublishVibra_1200 subscribe======>"); + await notify.addSlot({ + type:notify.SlotType.CONTENT_INFORMATION, + vibrationEnabled:true, + }) + + var notificationRequest = { + content:{ + contentType: notify.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT, + normal: { + title: "test_title", + text: "test_text", + additionalText: "test_additionalText" + }, + }, + id: 12, + slotType : notify.SlotType.CONTENT_INFORMATION, + 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: "statusBarText", + isFloatingIcon : true, + label: "1200", + badgeIconStyle: 1, + showDeliveryTime: true, + } + notify.publish(notificationRequest).then(()=>{ + console.info("=======Ans_PublishVibra_1200 publish then======>"); + }).catch((err)=>{ + console.info("=======Ans_PublishVibra_1200 publish then catch err======>"+err); + }) + setTimeout((async function(){ + console.info("======Ans_PublishVibra_1200 setTimeout========>"); + await notify.removeSlot(notify.SlotType.CONTENT_INFORMATION); + await notify.unsubscribe(subscriber); + console.info("======Ans_PublishVibra_1200 setTimeout unsubscribe===>"); + done(); + }),timeout); + }); +}) \ No newline at end of file diff --git a/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/List.test.js b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/List.test.js new file mode 100644 index 0000000000000000000000000000000000000000..833219dd7abe166a664ce61aa1a104852ffdd413 --- /dev/null +++ b/notification/ans_standard/publish_test/publishvibra/entry/src/main/js/test/List.test.js @@ -0,0 +1,15 @@ +/* +* Copyright (c) 2021 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +require('./ExampleJsunit.test.js') diff --git a/notification/ans_standard/publish_test/publishvibra/signature/openharmony_sx.p7b b/notification/ans_standard/publish_test/publishvibra/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/notification/ans_standard/publish_test/publishvibra/signature/openharmony_sx.p7b differ