diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js index e2632dc9bc7fe62b3a7b23da3d424da44bbc11dd..8b1402c895fb3452540b7957e5483cfbcbd1b5e7 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/RdbstoreRdbstoreJsunit.test.js @@ -169,63 +169,6 @@ describe('rdbStoreTest', function () { done(); console.log(TAG + "************* testRdbStore0005 end *************"); }) - - /** - * @tc.name rdb store deleteRdbStore - * @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0060 - * @tc.desc rdb store deleteRdbStore - */ -// it('testRdbStore0006', 0, async function (done) { -// console.log(TAG + "************* testRdbStore0006 start *************"); -// -// let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 4); -// storePromise.then(async (store) => { -// try { -// await store.executeSql(CREATE_TABLE_TEST); -// let deletePromise = dataRdb.deleteRdbStore("rdbstore.db") -// deletePromise.then(()=>{ -// console.log(TAG + "deleteRdbStore promise done" + store); -// expect(true).assertTrue(); -// }) -// } catch (e) { -// expect(null).assertFail(); -// } -// }).catch((err) => { -// expect(null).assertFail(); -// }) -// await storePromise -// storePromise = null -// done(); -// console.log(TAG + "************* testRdbStore0006 end *************"); -// }) - - /** - * @tc.name rdb store deleteRdbStore - * @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0070 - * @tc.desc rdb store deleteRdbStore - */ - it('testRdbStore0007', 0, async function (done) { - console.log(TAG + "************* testRdbStore0007 start *************"); - - let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6); - storePromise.then(async (store) => { - try { - await store.executeSql(CREATE_TABLE_TEST); - let deletePromise = dataRdb.deleteRdbStore("rdbstore.db") - deletePromise.then(()=>{ - console.log(TAG + "deleteRdbStore promise done" + store); - expect(true).assertTrue(); - }) - } catch (e) { - expect(null).assertFail(); - } - }).catch((err) => { - expect(null).assertFail(); - }) - await storePromise - storePromise = null - done(); - console.log(TAG + "************* testRdbStore0007 end *************"); - }) + console.log(TAG + "*************Unit Test End*************"); }) \ No newline at end of file diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js index d1d41c6db1c73c83e0fb522b0f679e09d37349a1..b12d65f4b538c051f36456306bed7e69380fe6fe 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StoragePromiseJsunit.test.js @@ -21,6 +21,8 @@ const KEY_TEST_LONG_ELEMENT = 'key_test_long'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; const KEY_TEST_BOOLEAN_ELEMENT = 'key_test_boolean'; const KEY_TEST_STRING_ELEMENT = 'key_test_string'; +const MAX_KEY_LENGTH = 'X'.repeat(32) +const MAX_VALUE_LENGTH = 'y'.repeat(8191) var mPref; describe('storageTest', function () { @@ -380,7 +382,7 @@ describe('storageTest', function () { * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0200 * @tc.desc Maximum length of key test */ - it('testMaxLengthofKety0200', 0, async function(done){ + it('testMaxLengthofKey0200', 0, async function(done){ mPref.clearSync(); const promise = mPref.put(MAX_KEY_LENGTH,"value1") promise.then((ret)=>{ @@ -449,4 +451,43 @@ describe('storageTest', function () { await promise; done(); }) + + /** + * @tc.name Maximum length of key test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0240 + * @tc.desc Maximum length of key test + */ + it('testMaxLengthofKey0240', 0, async function(done){ + mPref.putSync(MAX_KEY_LENGTH, "value1"); + expect("value1").assertEqual(mPref.getSync(MAX_KEY_LENGTH, "default")); + const promise = mPref.delete(MAX_KEY_LENGTH); + promise.then((ret)=>{ + expect("default").assertEqual(mPref.getSync(MAX_KEY_LENGTH,"default")); + }).catch((err)=>{ + expect(null).assertFail(); + }); + await promise; + done(); + }) + + /** + * @tc.name Maximum length of value test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_Storage_0250 + * @tc.desc Maximum length of value test + */ + + it('testMaxLengthofValue0250', 0, async function (done) { + mPref.clearSync(); + mPref.putSync("test",MAX_VALUE_LENGTH) + const promise = mPref.put("test", "y".repeat(8192)); + promise.then((ret) => { + expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue")); + }).catch((err) => { + expect(null).assertFail(); + }); + await promise; + mPref.putSync("test",MAX_VALUE_LENGTH) + expect(MAX_VALUE_LENGTH).assertEqual(mPref.getSync("test", "defaultvalue")); + done(); + }) }) diff --git a/distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js b/distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js index c03af377c822012bc4fc6f03e907c34e3000bcc4..82884219039ffd2c5657355036af906cb68510d4 100644 --- a/distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js +++ b/distributeddatamgr/distributeddataObjectjstest/hap/src/main/js/default/test/ObjectStoreJsunit.test.js @@ -57,8 +57,8 @@ function statusCallback3(sessionId, networkId, status) { } function sleep(delay) { var start = (new Date()).getTime(); - while((new Date()).getTime() - start < delay) { - continue; + while((new Date()).getTime() - start >= delay) { + break; } } @@ -72,10 +72,10 @@ describe('objectStoreTest', function () { console.info("====>beforeAll start===="); var appInfo = await bundle.getApplicationInfo('ohos.acts.distributeddataObject', 0, 100); tokenID = appInfo.accessTokenId; - console.info("accessTokenId" + appInfo.accessTokenId + " bundleName:" + appInfo.name); + console.info(" bundleName:" + appInfo.name); var atManager = abilityAccessCtrl.createAtManager(); var result = await atManager.grantUserGrantedPermission(tokenID, PERMISSION_USER_NAME, PERMISSION_USER_SET); - console.info("tokenId" + tokenID + " result:" + result); + console.info(" result:" + result); sleep(TIMEOUT); console.debug("====>beforeAll end===="); done();