未验证 提交 1eae1003 编写于 作者: O openharmony_ci 提交者: Gitee

!5804 【EDM】新增接口xts测试用例

Merge pull request !5804 from 方昀/master
...@@ -39,7 +39,10 @@ const DEFAULT_USER_ID = 100; ...@@ -39,7 +39,10 @@ const DEFAULT_USER_ID = 100;
const TEST_USER_ID = 101; const TEST_USER_ID = 101;
const ERR_USER_ID = 102; const ERR_USER_ID = 102;
const SUBSCRIBE_EVENTS: Array<number> = [0,1];
const SUBSCRIBE_INVALID_EVENTS: Array<number> = [20,21];
export { export {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2, 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
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import { import {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, 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"; } from "./commom.ets";
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'
...@@ -253,5 +253,196 @@ export default function edmCallbackTest() { ...@@ -253,5 +253,196 @@ export default function edmCallbackTest() {
done(); 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_005
* @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_005', 0, async function (done) {
console.info('-----------unsubscribeManagedEvent_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.unsubscribeManagedEvent(SELFWANT, SUBSCRIBE_EVENTS, error => {
expect(error.code == 9200001).assertTrue();
console.log('enterpriseDeviceManager.unsubscribeManagedEvent. 9200001');
resolve(0);
});
});
done();
})
/**
* @tc.number unsubscribeManagedEvent_test_007
* @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_007', 0, async function (done) {
console.info('-----------unsubscribeManagedEvent_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.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();
})
}) })
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"
import { import {
WANT1, ENTINFO1, SELFWANT, SELFHAPNAME, COMPANYNAME2, DESCRIPTION2, ENTINFO2, 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"; } from "./commom.ets";
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager' import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager'
...@@ -288,5 +288,174 @@ export default function edmPromiseTest() { ...@@ -288,5 +288,174 @@ export default function edmPromiseTest() {
await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME); await enterpriseDeviceManager.disableSuperAdmin(SELFHAPNAME);
done(); 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();
})
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册