未验证 提交 8beb5e2b 编写于 作者: O openharmony_ci 提交者: Gitee

!8620 【Distributeddatamgr】【Master】

Merge pull request !8620 from yanglifeng/master
...@@ -61,6 +61,10 @@ try { ...@@ -61,6 +61,10 @@ try {
expect(null).assertFail() expect(null).assertFail()
} }
} }
function storeObserver(devices) {
console.info(TAG + devices + " dataChange");
expect(devices).assertEqual(null)
}
export default function rdbStoreDistributedTest() { export default function rdbStoreDistributedTest() {
describe('rdbStoreDistributedTest', function () { describe('rdbStoreDistributedTest', function () {
...@@ -343,11 +347,13 @@ describe('rdbStoreDistributedTest', function () { ...@@ -343,11 +347,13 @@ describe('rdbStoreDistributedTest', function () {
*/ */
it('testRdbStoreDistributed0012', 0, async function (done) { it('testRdbStoreDistributed0012', 0, async function (done) {
console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); console.info(TAG + "************* testRdbStoreDistributed0012 start *************");
rdbStore.on("dataChange", (device) => { try{
console.info(TAG + device + " dataChange"); rdbStore.on("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
}); console.info(TAG + "on dataChange success ");
console.info(TAG + "on dataChange success"); }catch(err){
expect(rdbStore).assertEqual(rdbStore); console.info(TAG + "on dataChange " + err);
expect(err !== null).assertFalse();
}
done() done()
console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); console.info(TAG + "************* testRdbStoreDistributed0012 end *************");
}) })
...@@ -357,13 +363,15 @@ describe('rdbStoreDistributedTest', function () { ...@@ -357,13 +363,15 @@ describe('rdbStoreDistributedTest', function () {
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_013 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_013
* @tc.desc subscribe test * @tc.desc subscribe test
*/ */
it('testRdbStoreDistributed0013', 0, async function (done) { it('testRdbStoreDistributed0013', 0, function (done) {
console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); console.info(TAG + "************* testRdbStoreDistributed0013 start *************");
rdbStore.off("dataChange", (device) => { try{
console.info(TAG + device + " dataChange"); rdbStore.off("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
}); console.info(TAG + "off dataChange success ");
console.info(TAG + "off dataChange success"); }catch(err){
expect(rdbStore).assertEqual(rdbStore); console.info(TAG + "off dataChange " + err);
expect(err !== null).assertFalse();
}
done() done()
console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); console.info(TAG + "************* testRdbStoreDistributed0013 end *************");
}) })
......
...@@ -173,11 +173,15 @@ describe('rdbEncryptTest', function () { ...@@ -173,11 +173,15 @@ describe('rdbEncryptTest', function () {
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT)
rdbStore = null rdbStore = null
try {
rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG)
expect(rdbStore).assertNull expect(rdbStore !== null).assertFalse()
} catch (err) {
console.info(TAG + `catch err: ` + err)
expect(rdbStore).assertEqual(null)
done() done()
console.info(TAG + "************* RdbEncryptTest_0040 end *************") console.info(TAG + "************* RdbEncryptTest_0040 end *************")
}
}) })
console.info(TAG + "*************Unit Test End*************") console.info(TAG + "*************Unit Test End*************")
} }
......
...@@ -64,6 +64,11 @@ try { ...@@ -64,6 +64,11 @@ try {
} }
} }
function storeObserver(devices) {
console.info(TAG + devices + " dataChange");
expect(devices).assertEqual(null)
}
export default function relationalStoreDistributedTest() { export default function relationalStoreDistributedTest() {
describe('relationalStoreDistributedTest', function () { describe('relationalStoreDistributedTest', function () {
beforeAll(async function () { beforeAll(async function () {
...@@ -345,11 +350,13 @@ describe('relationalStoreDistributedTest', function () { ...@@ -345,11 +350,13 @@ describe('relationalStoreDistributedTest', function () {
*/ */
it('testRdbStoreDistributed0012', 0, async function (done) { it('testRdbStoreDistributed0012', 0, async function (done) {
console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); console.info(TAG + "************* testRdbStoreDistributed0012 start *************");
rdbStore.on("dataChange", (device) => { try{
console.info(TAG + device + " dataChange"); rdbStore.on("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
}); console.info(TAG + "on dataChange success ");
console.info(TAG + "on dataChange success"); }catch(err){
expect(rdbStore).assertEqual(rdbStore); console.info(TAG + "on dataChange " + err);
expect(err !== null).assertFalse();
}
done() done()
console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); console.info(TAG + "************* testRdbStoreDistributed0012 end *************");
}) })
...@@ -359,13 +366,15 @@ describe('relationalStoreDistributedTest', function () { ...@@ -359,13 +366,15 @@ describe('relationalStoreDistributedTest', function () {
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_013 * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_013
* @tc.desc subscribe test * @tc.desc subscribe test
*/ */
it('testRdbStoreDistributed0013', 0, async function (done) { it('testRdbStoreDistributed0013', 0, function (done) {
console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); console.info(TAG + "************* testRdbStoreDistributed0013 start *************");
rdbStore.off("dataChange", (device) => { try{
console.info(TAG + device + " dataChange"); rdbStore.off("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver);
}); console.info(TAG + "off dataChange success ");
console.info(TAG + "off dataChange success"); }catch(err){
expect(rdbStore).assertEqual(rdbStore); console.info(TAG + "off dataChange " + err);
expect(err !== null).assertFalse();
}
done() done()
console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); console.info(TAG + "************* testRdbStoreDistributed0013 end *************");
}) })
......
...@@ -176,11 +176,15 @@ describe('relationalStoreEncryptTest', function () { ...@@ -176,11 +176,15 @@ describe('relationalStoreEncryptTest', function () {
context = ability_featureAbility.getContext() context = ability_featureAbility.getContext()
rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT)
rdbStore = null rdbStore = null
try {
rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG)
expect(rdbStore).assertNull expect(rdbStore !== null).assertFalse()
} catch (err) {
console.info(TAG + `catch err: err.code= ${err.code}, message = ${err.message}`)
expect(err.code).assertEqual(14800000);
done() done()
console.info(TAG + "************* RdbEncryptTest_0040 end *************") console.info(TAG + "************* RdbEncryptTest_0040 end *************")
}
}) })
console.info(TAG + "*************Unit Test End*************") console.info(TAG + "*************Unit Test End*************")
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册