diff --git a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js index dd77efee3ea8f5eb870542a233af12689cc132f4..83a6f05ad71203801cd4d9f9d14fd421e6285164 100644 --- a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbStoreDistributedJsunit.test.js @@ -61,6 +61,10 @@ try { expect(null).assertFail() } } +function storeObserver(devices) { + console.info(TAG + devices + " dataChange"); + expect(devices).assertEqual(null) +} export default function rdbStoreDistributedTest() { describe('rdbStoreDistributedTest', function () { @@ -341,13 +345,15 @@ describe('rdbStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_012 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0012', 0, async function (done) { + it('testRdbStoreDistributed0012', 0, async function (done) { console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); - rdbStore.on("dataChange", (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "on dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.on("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "on dataChange success "); + }catch(err){ + console.info(TAG + "on dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); }) @@ -357,13 +363,15 @@ describe('rdbStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_013 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0013', 0, async function (done) { + it('testRdbStoreDistributed0013', 0, function (done) { console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); - rdbStore.off("dataChange", (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "off dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.off("dataChange", dataRdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "off dataChange success "); + }catch(err){ + console.info(TAG + "off dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); }) diff --git a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js index 57338fe921149490f71a76a2b300e01ca8768bc6..113b1da5d9eb1f86f03cc1a14a966134d9d6108f 100644 --- a/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/RdbJstest/hap/src/main/js/test/RdbstoreEncryptionJsunit.test.js @@ -168,16 +168,20 @@ describe('rdbEncryptTest', function () { * @tc.number SUB_DDM_RDB_JS_RdbEncryptTest_0040 * @tc.desc RDB Encrypt function test */ - it('RdbEncryptTest_0040', 0, async function (done) { + it('RdbEncryptTest_0040', 0, async function (done) { console.info(TAG + "************* RdbEncryptTest_0040 start *************") context = ability_featureAbility.getContext() rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = null - rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) - expect(rdbStore).assertNull - - done() - console.info(TAG + "************* RdbEncryptTest_0040 end *************") + try { + rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) + expect(rdbStore !== null).assertFalse() + } catch (err) { + console.info(TAG + `catch err: ` + err) + expect(rdbStore).assertEqual(null) + done() + console.info(TAG + "************* RdbEncryptTest_0040 end *************") + } }) console.info(TAG + "*************Unit Test End*************") } diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js index 01127658d510b0fd914a00818b106d0ae6a817dd..e9c5accd45eb8bea33f3ec6e8188cba827188876 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js @@ -64,6 +64,11 @@ try { } } +function storeObserver(devices) { + console.info(TAG + devices + " dataChange"); + expect(devices).assertEqual(null) +} + export default function relationalStoreDistributedTest() { describe('relationalStoreDistributedTest', function () { beforeAll(async function () { @@ -343,13 +348,15 @@ describe('relationalStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_012 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0012', 0, async function (done) { + it('testRdbStoreDistributed0012', 0, async function (done) { console.info(TAG + "************* testRdbStoreDistributed0012 start *************"); - rdbStore.on("dataChange", (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "on dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.on("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "on dataChange success "); + }catch(err){ + console.info(TAG + "on dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0012 end *************"); }) @@ -359,13 +366,15 @@ describe('relationalStoreDistributedTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_013 * @tc.desc subscribe test */ - it('testRdbStoreDistributed0013', 0, async function (done) { + it('testRdbStoreDistributed0013', 0, function (done) { console.info(TAG + "************* testRdbStoreDistributed0013 start *************"); - rdbStore.off("dataChange", (device) => { - console.info(TAG + device + " dataChange"); - }); - console.info(TAG + "off dataChange success"); - expect(rdbStore).assertEqual(rdbStore); + try{ + rdbStore.off("dataChange", data_Rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); + console.info(TAG + "off dataChange success "); + }catch(err){ + console.info(TAG + "off dataChange " + err); + expect(err !== null).assertFalse(); + } done() console.info(TAG + "************* testRdbStoreDistributed0013 end *************"); }) diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js index 1777b0ad3fa7f99de4ef4a5368ae96c0b11b8281..618bf0da34425936e24e505b5fae7954e407c113 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js +++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreEncryptionJsunit.test.js @@ -171,16 +171,20 @@ describe('relationalStoreEncryptTest', function () { * @tc.number SUB_DDM_RelationalStore_JS_RdbEncryptTest_0040 * @tc.desc RelationalStore Encrypt function test */ - it('RdbEncryptTest_0040', 0, async function (done) { + it('RdbEncryptTest_0040', 0, async function (done) { console.info(TAG + "************* RdbEncryptTest_0040 start *************") context = ability_featureAbility.getContext() rdbStore = await CreatRdbStore(context, STORE_CONFIG_ENCRYPT) rdbStore = null - rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) - expect(rdbStore).assertNull - - done() - console.info(TAG + "************* RdbEncryptTest_0040 end *************") + try { + rdbStore = await CreatRdbStore(context, STORE_CONFIG_WRONG) + expect(rdbStore !== null).assertFalse() + } catch (err) { + console.info(TAG + `catch err: err.code= ${err.code}, message = ${err.message}`) + expect(err.code).assertEqual(14800000); + done() + console.info(TAG + "************* RdbEncryptTest_0040 end *************") + } }) console.info(TAG + "*************Unit Test End*************") }