From 889778b636ab18bd784a5f31e89f5993deb23cf2 Mon Sep 17 00:00:00 2001 From: yanglifeng1217 Date: Sat, 18 Jun 2022 18:21:52 +0800 Subject: [PATCH] Signed-off-by: yanglifeng1217 --- .../test/RdbStoreDistributedJsunit.test.js | 57 +++++++++++++++++++ .../default/test/StorageHelperJsunit.test.js | 43 ++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreDistributedJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreDistributedJsunit.test.js index 19a3b0996..262a4f7ad 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreDistributedJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbStoreDistributedJsunit.test.js @@ -309,6 +309,27 @@ describe('rdbStoreDistributedTest', function () { done(); console.log(TAG + "************* testRdbStoreDistributed0011 end *************"); }) + + /** + * @tc.name sync Callback test + * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_Callback_011 + * @tc.desc sync Callback test + */ + it('testRdbStoreDistributedCallback0011', 0, async function (done) { + console.log(TAG + "************* testRdbStoreDistributedCallback0011 start *************"); + let predicates = new dataRdb.RdbPredicates("employee") + predicates = predicates.inDevices("12345678abcd"); + rdbStore.sync(dataRdb.SyncMode.SYNC_MODE_PUSH, predicates,(err,ret)=>{ + console.log(TAG + "sync push success"); + expect(rdbStore).assertEqual(rdbStore); + }); + rdbStore.sync(dataRdb.SyncMode.SYNC_MODE_PULL, predicates,(err,ret)=>{ + console.log(TAG + "sync push success"); + expect(rdbStore).assertEqual(rdbStore); + }); + done(); + console.log(TAG + "************* testRdbStoreDistributedCallback0011 end *************"); + }) /** * @tc.name subscribe test @@ -341,5 +362,41 @@ describe('rdbStoreDistributedTest', function () { done() console.log(TAG + "************* testRdbStoreDistributed0013 end *************"); }) + + /** + * @tc.name obtainDistributedTableName Callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_014 + * @tc.desc obtainDistributedTableName test + */ + it('testRdbStoreDistributed0014', 0, async function (done){ + await rdbStore.obtainDistributedTableName("deviceId", "EMPLOYEE", function (err, tableName) { + expect(err != null).assertTrue(); + console.info('ObtainDistributedTableName failed, Unauthorized.' + err) + }) + done(); + }) + + /** + * @tc.name obtainDistributedTableName Promise interface test + * @tc.number SUB_DDM_AppDataFWK_JSRDB_Distributed_015 + * @tc.desc obtainDistributedTableName test + */ + it('testRdbStoreDistributed0015',0,async function (done){ + await dataRdb.deleteRdbStore(STORE_NAME); + const config = { + "name": STORE_NAME, + } + rdbStore = await dataRdb.getRdbStore(config, 1); + let promise = rdbStore.obtainDistributedTableName("deviceId", "EMPLOYEE") + promise.then((tableName)=>{ + expect(tableName != "EMPLOYEE").assertTrue(); + console.info('ObtainDistributedTableName') + }).catch((err)=>{ + expect(null).assertFail(); + console.info('ObtainDistributedTableName failed, Unauthorized.' + err) + }) + done(); + }) + console.log(TAG + "*************Unit Test End*************"); }) diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js index 48aa29543..24108fe6d 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageHelperJsunit.test.js @@ -61,6 +61,21 @@ describe('storageTest', function () { await promise; done(); }) + + /** + * @tc.name getStorage callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Callback_0020 + * @tc.desc getStorage callback interface test + */ + it('testGetStorageCallback0020', 0, async function (done) { + storage.getStorage(PATH,(err,pref)=>{ + pref.putSync('test', 2); + pref.flushSync(); + var value = mPref.getSync('test', 0); + expect(value).assertEqual(2); + }); + done(); + }) /** * @tc.name removeStorageFromCacheSync interface test @@ -95,6 +110,20 @@ describe('storageTest', function () { await promise; done(); }) + + /** + * @tc.name removeStorageFromCache callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Helper_0042 + * @tc.desc removeStorageFromCache callback interface test + */ + it('testRemoveStorageFromCache004', 0, async function (done) { + let perf = storage.getStorageSync('/data/test_storage2'); + perf = null; + storage.removeStorageFromCache('/data/test_storage2',(err,pref)=>{ + expect(err == null).assertTrue(); + }); + done(); + }) /** * @tc.name removeStorageFromCache callback interface test @@ -152,4 +181,18 @@ describe('storageTest', function () { await promise; done(); }) + + /** + * @tc.name deleteStorag callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_Callback_0070 + * @tc.desc deleteStorage interface test + */ + it('testDeleteStoragCallback0070', 0, async function (done) { + let perf = storage.getStorageSync('/data/test_storage4'); + perf = null; + storage.deleteStorage('/data/test_storage4',(err)=>{ + expect(err == null).assertTrue(); + }); + done(); + }) }) \ No newline at end of file -- GitLab