From 30e3b0d53a85801363ee7177ffb080f1fe7686b7 Mon Sep 17 00:00:00 2001 From: fangyun Date: Sun, 9 Oct 2022 14:47:44 +0800 Subject: [PATCH] add new testcase about new interface Signed-off-by: fangyun --- .../entry/src/main/ets/test/commom.ets | 5 +- .../src/main/ets/test/edmCallback.test.ets | 293 ++++++++++++++---- .../src/main/ets/test/edmPromise.test.ets | 279 +++++++++++++---- 3 files changed, 456 insertions(+), 121 deletions(-) diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets b/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets index 097589f6a..a6540fcd9 100644 --- a/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets +++ b/customization/edm_xts_stage/entry/src/main/ets/test/commom.ets @@ -39,7 +39,10 @@ const DEFAULT_USER_ID = 100; const TEST_USER_ID = 101; const ERR_USER_ID = 102; +const SUBSCRIBE_EVENTS: Array = [0,1]; +const SUBSCRIBE_INVALID_EVENTS: Array = [20,21]; + export { WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2, - DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID + DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID, SUBSCRIBE_EVENTS, SUBSCRIBE_INVALID_EVENTS } \ No newline at end of file diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets b/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets index 070788296..c410e441b 100644 --- a/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets +++ b/customization/edm_xts_stage/entry/src/main/ets/test/edmCallback.test.ets @@ -16,7 +16,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index" import { WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, - ENTINFO2, DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID + ENTINFO2, DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID, SUBSCRIBE_EVENTS, SUBSCRIBE_INVALID_EVENTS } from "./commom.ets"; import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' @@ -28,20 +28,19 @@ export default function edmCallbackTest() { * @tc.name test enableAdmin method in callback mode without user id * @tc.desc enable admin in callback mode */ - it('enableAdmin_test_002', 0, async function (done) { + it('enableAdmin_test_002', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - var retValue = await enterpriseDeviceManager.disableAdmin(WANT1); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -58,17 +57,16 @@ export default function edmCallbackTest() { it('enableAdmin_test_004', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin : ' + retValue); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled); expect(isEnabled).assertTrue(); - var retValue = await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); - console.log('enterpriseDeviceManager.disableSuperAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin.'); isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin : ' + isEnabled); @@ -86,17 +84,16 @@ export default function edmCallbackTest() { console.log(' enableAdmin()'); await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - var retValue = await enterpriseDeviceManager.disableAdmin(WANT1); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -113,17 +110,16 @@ export default function edmCallbackTest() { it('enableAdmin_test_008', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - var retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -140,17 +136,16 @@ export default function edmCallbackTest() { it('enableAdmin_test_012', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - var retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -167,17 +162,16 @@ export default function edmCallbackTest() { it('enableAdmin_test_013', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertFalse(); - var retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -194,9 +188,9 @@ export default function edmCallbackTest() { it('enableAdmin_test_014', 0, async function (done) { await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); @@ -214,9 +208,8 @@ export default function edmCallbackTest() { console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -231,26 +224,24 @@ export default function edmCallbackTest() { * @tc.desc set enterprise info in callback mode */ it('setEnterpriseInfo_test_002', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT); expect(isEnabled).assertTrue(); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); await enterpriseDeviceManager.setEnterpriseInfo(SELFWANT, ENTINFO2, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.setEnterpriseInfo : ' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.setEnterpriseInfo.'); + expect(err == null).assertTrue(); var entInfo = await enterpriseDeviceManager.getEnterpriseInfo(SELFWANT); expect(entInfo.name).assertEqual(COMPANYNAME2); expect(entInfo.description).assertEqual(DESCRIPTION2); - retValue = await enterpriseDeviceManager.disableAdmin(SELFWANT); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -283,11 +274,201 @@ export default function edmCallbackTest() { let dsmgr = await enterpriseDeviceManager.getDeviceSettingsManager(); expect(dsmgr !== null).assertTrue(); console.log('before setDateTime'); - await dsmgr.setDateTime(SELFWANT, 1526003846000, (error, data) => { - console.log("setDateTime ===data: " + data); - console.log("setDateTime ===error: " + error); + await dsmgr.setDateTime(SELFWANT, 1526003846000, OnReceiveEvent); + async function OnReceiveEvent() { + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + done(); + } + }) + + /** + * @tc.number subscribeManagedEvent_test_001 + * @tc.desc Test subscribeManagedEvent method in callback mode. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_001', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_001 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error == null).assertTrue(); + console.log('enterpriseDeviceManager.subscribeManagedEvent. null 1'); + resolve(0); + }); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_003 + * @tc.desc Test subscribeManagedEvent method in callback mode and subscribe invalid managed events. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_003', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_003 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_INVALID_EVENTS, error => { + expect(error.code == 9200008).assertTrue(); + console.log('enterpriseDeviceManager.subscribeManagedEvent. 9200008'); + resolve(0); + }); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_005 + * @tc.desc Test subscribeManagedEvent method in callback mode subscribe when disable admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_005', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_005 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error.code == 9200001).assertTrue(); + console.log('enterpriseDeviceManager.subscribeManagedEvent. 9200001'); + resolve(0); + }); + }); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_007 + * @tc.desc Test subscribeManagedEvent method in callback mode and subscribe when enable super admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_007', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_007 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error == null).assertTrue(); + console.log('enterpriseDeviceManager.subscribeManagedEvent. null 2'); + resolve(0); + }); + }); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin ADMIN_TYPE_SUPER.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_001 + * @tc.desc Test unsubscribeManagedEvent method in callback mode. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_001', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_001 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error == null).assertTrue(); + console.log('enterpriseDeviceManager.unsubscribeManagedEvent. null 1'); + resolve(0); + }); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_003 + * @tc.desc Test unsubscribeManagedEvent method in callback mode and unsubscribe invalid managed events. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_003', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_003 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_INVALID_EVENTS, error => { + expect(error.code == 9200008).assertTrue(); + console.log('enterpriseDeviceManager.unsubscribeManagedEvent. 9200008'); + resolve(0); + }); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_001 + * @tc.desc Test unsubscribeManagedEvent method in callback mode and unsubscribe when disable admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_001', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_001 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error.code == 9200001).assertTrue(); + console.log('enterpriseDeviceManager.unsubscribeManagedEvent. 9200001'); + resolve(0); + }); + }); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_001 + * @tc.desc Test unsubscribeManagedEvent method in callback mode and unsubscribe when enable super admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_001', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_001 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); + await new Promise((resolve, reject) => { + enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => { + expect(error == null).assertTrue(); + console.log('enterpriseDeviceManager.unsubscribeManagedEvent. null 2'); + resolve(0); + }); }); await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin ADMIN_TYPE_SUPER.'); done(); }) }) diff --git a/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets b/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets index f3a4810b6..9a00ae526 100644 --- a/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets +++ b/customization/edm_xts_stage/entry/src/main/ets/test/edmPromise.test.ets @@ -15,7 +15,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "hypium/index" import { WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2, - DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID + DEFAULT_USER_ID, TEST_USER_ID, ERR_USER_ID, SUBSCRIBE_EVENTS, SUBSCRIBE_INVALID_EVENTS } from "./commom.ets"; import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' @@ -26,19 +26,17 @@ export default function edmPromiseTest() { * @tc.name test enableAdmin method in promise mode without user id * @tc.desc enable admin in promise mode */ - it('enableAdmin_test_001', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + it('enableAdmin_test_001', 0, async function (done) { + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -53,18 +51,16 @@ export default function edmPromiseTest() { */ it('enableAdmin_test_003', 0, async function (done) { console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER'); - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); - console.log('enterpriseDeviceManager.disableSuperAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin.'); isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin : ' + isEnabled); @@ -78,18 +74,16 @@ export default function edmPromiseTest() { * @tc.desc enable admin in promise mode */ it('enableAdmin_test_005', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -104,19 +98,17 @@ export default function edmPromiseTest() { * @tc.desc enable admin in multi-user */ it('enableAdmin_test_007', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -130,9 +122,9 @@ export default function edmPromiseTest() { * @tc.desc enable admin in multi-user */ it('enableAdmin_test_009', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, TEST_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { + async function OnReceiveEvent(err) { expect(err != null).assertTrue(); if (err) { // user exsit but super admin can only be enabled in user 100 @@ -148,9 +140,9 @@ export default function edmPromiseTest() { * @tc.desc enable admin in multi-user */ it('enableAdmin_test_010', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, ERR_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { + async function OnReceiveEvent(err) { expect(err != null).assertTrue(); if (err) { // user does not exsit @@ -166,19 +158,17 @@ export default function edmPromiseTest() { * @tc.desc enable admin in multi-user */ it('enableAdmin_test_011', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -192,13 +182,13 @@ export default function edmPromiseTest() { * @tc.desc enable admin in multi-user */ it('enableAdmin_test_015', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); await enterpriseDeviceManager.enableAdmin(WANT1, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID, OnReceiveEvent); - async function OnReceiveEvent(err, datainfo) { - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL :' + datainfo); - expect(datainfo).assertTrue(); + async function OnReceiveEvent(err) { + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + expect(err == null).assertTrue(); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); @@ -208,9 +198,8 @@ export default function edmPromiseTest() { console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, DEFAULT_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -220,9 +209,8 @@ export default function edmPromiseTest() { console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); expect(isEnabled).assertTrue(); - retValue = await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(WANT1, TEST_USER_ID); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(WANT1, TEST_USER_ID); console.log('enterpriseDeviceManager.isAdminEnabled :' + isEnabled); @@ -237,17 +225,16 @@ export default function edmPromiseTest() { * @tc.desc enable and disable admin in multi-user */ it('enableAdmin_test_0016', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); var isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin :' + isEnabled); expect(isEnabled).assertTrue(); try { - retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, TEST_USER_ID); } catch (error) { expect(error != null).assertTrue(); @@ -258,9 +245,8 @@ export default function edmPromiseTest() { console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); expect(isEnabled).assertFalse(); - retValue = await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); - console.log('enterpriseDeviceManager.disableSuperAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin.'); isEnabled = await enterpriseDeviceManager.isSuperAdmin(SELFHAPNAME); console.log('enterpriseDeviceManager.isSuperAdmin : ' + isEnabled); @@ -274,26 +260,23 @@ export default function edmPromiseTest() { * @tc.desc set enterprise info in promise mode */ it('setEnterpriseInfo_test_001', 0, async function (done) { - var retValue = await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL); - console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL : ' + retValue); - expect(retValue).assertTrue(); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); var isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT); expect(isEnabled).assertTrue(); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); - retValue = await enterpriseDeviceManager.setEnterpriseInfo(SELFWANT, ENTINFO2); - console.log('enterpriseDeviceManager.setEnterpriseInfo : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.setEnterpriseInfo(SELFWANT, ENTINFO2); + console.log('enterpriseDeviceManager.setEnterpriseInfo.'); var entInfo = await enterpriseDeviceManager.getEnterpriseInfo(SELFWANT); expect(entInfo.name).assertEqual(COMPANYNAME2); expect(entInfo.description).assertEqual(DESCRIPTION2); - retValue = await enterpriseDeviceManager.disableAdmin(SELFWANT); - console.log('enterpriseDeviceManager.disableAdmin : ' + retValue); - expect(retValue).assertTrue(); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); isEnabled = await enterpriseDeviceManager.isAdminEnabled(SELFWANT); console.log('enterpriseDeviceManager.isAdminEnabled : ' + isEnabled); @@ -325,9 +308,177 @@ export default function edmPromiseTest() { let dsmgr = await enterpriseDeviceManager.getDeviceSettingsManager(); expect(dsmgr !== null).assertTrue(); console.log('before setDateTime'); - var setSuccess = await dsmgr.setDateTime(SELFWANT, 1526003846000); - expect(setSuccess).assertTrue(); + await dsmgr.setDateTime(SELFWANT, 1526003846000); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_002 + * @tc.desc Test subscribeManagedEvent method in promise mode. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_002', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_002 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error == null).assertTrue(); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_004 + * @tc.desc Test subscribeManagedEvent method in promise mode and subscribe invalid managed events. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_004', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_004 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_INVALID_EVENTS).then(() => { + }).catch((error) => { + expect(error.code == 9200008).assertTrue(); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_006 + * @tc.desc Test subscribeManagedEvent method in promise mode and subscribe when disable admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_006', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_006 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + await enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error.code == 9200001).assertTrue(); + }); + done(); + }) + + /** + * @tc.number subscribeManagedEvent_test_008 + * @tc.desc Test subscribeManagedEvent method in promise mode and subscribe when enable super admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('subscribeManagedEvent_test_008', 0, async function (done) { + console.info('-----------subscribeManagedEvent_test_008 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); + await enterpriseDeviceManager.subscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error == null).assertTrue(); + }); + await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin ADMIN_TYPE_SUPER.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_002 + * @tc.desc Test subscribeManagedEvent method in promise mode. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_002', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_002 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + + await enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error == null).assertTrue(); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_004 + * @tc.desc Test subscribeManagedEvent method in promise mode and unsubscribe invalid managed events. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_004', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_004 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_INVALID_EVENTS).then(() => { + }).catch((error) => { + expect(error.code == 9200008).assertTrue(); + }); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_006 + * @tc.desc Test subscribeManagedEvent method in promise mode and unsubscribe when disable admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_006', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_006 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_NORMAL.'); + await enterpriseDeviceManager.disableAdmin(SELFWANT); + console.log('enterpriseDeviceManager.disableAdmin.'); + await enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error.code == 9200001).assertTrue(); + }); + done(); + }) + + /** + * @tc.number unsubscribeManagedEvent_test_008 + * @tc.desc Test subscribeManagedEvent method in promise mode and unsubscribe when enable super admin. + * @tc.size : MEDIUM + * @tc.type : Function + * @tc.level : Level 1 + */ + it('unsubscribeManagedEvent_test_008', 0, async function (done) { + console.info('-----------unsubscribeManagedEvent_test_008 start-------------'); + await enterpriseDeviceManager.enableAdmin(SELFWANT, ENTINFO1, + enterpriseDeviceManager.AdminType.ADMIN_TYPE_SUPER, DEFAULT_USER_ID); + console.log('enterpriseDeviceManager.enableAdmin ADMIN_TYPE_SUPER.'); + await enterpriseDeviceManager.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS).then(() => { + }).catch((error) => { + expect(error == null).assertTrue(); + }); await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); + console.log('enterpriseDeviceManager.disableSuperAdmin ADMIN_TYPE_SUPER.'); done(); }) }) -- GitLab