From 89c5d5fc060356b2e28fe5d367efdb3b77125419 Mon Sep 17 00:00:00 2001 From: 18834416147 Date: Sat, 14 May 2022 09:44:31 +0800 Subject: [PATCH] Signed-off-by: 18834416147 --- .../test/StorageCallBackJsunit.test.js | 47 ++++++++++++++++++- .../default/test/StorageHelperJsunit.test.js | 2 +- .../default/test/StoragePromiseJsunit.test.js | 2 +- .../js/default/test/StorageSyncJsunit.test.js | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageCallBackJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageCallBackJsunit.test.js index 0c93ad637..1e4257b8b 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageCallBackJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageCallBackJsunit.test.js @@ -15,7 +15,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import storage from '@ohos.data.storage' -const PATH = '/data/test_storage'; +const PATH = '/data/storage/el2/database/test_storage'; const KEY_TEST_INT_ELEMENT = 'key_test_int'; const KEY_TEST_LONG_ELEMENT = 'key_test_long'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; @@ -272,4 +272,49 @@ describe('storageTest', function () { done(); }); }) + + + /** + * @tc.name clear、put、get、flush String callback interface test + * @tc.number SUB_DDM_AppDataFWK_JSPreferences_CallBack_0120 + * @tc.desc flush String callback interface test + */ + it('testCallback0172', 0, function (done) { + console.log("*******************testCallback0172 begin."); + mPref.clear(function (err, val) { + if(err){ + console.log("*******************clear error: " + err); + expect(false).assertTrue(); + } + mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) { + if(err){ + console.log("*******************put error: " + err); + expect(false).assertTrue(); + } + console.log("*******************put done."); + mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, pre) { + if(err){ + console.log("*******************get error: " + err); + expect(false).assertTrue(); + } + expect('').assertEqual(pre); + mPref.flush(function (err, val) { + if(err){ + console.log("*******************flush error: " + err); + expect(false).assertTrue(); + } + mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, pre2) { + if(err){ + console.log("*******************get error: " + err); + expect(false).assertTrue(); + } + expect('').assertEqual(pre2); + done(); + console.log("*******************testCallback0172 end."); + }) + }); + }) + }); + }); + }) }) \ No newline at end of file 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 fdaa2dc93..b10044ac1 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 @@ -16,7 +16,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import storage from '@ohos.data.storage' -const PATH = '/data/test_storage'; +const PATH = '/data/storage/el2/database/test_storage'; var mPref; describe('storageTest', function () { 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 cd88b2e58..26dc2a260 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 @@ -15,7 +15,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import storage from '@ohos.data.storage' -const PATH = '/data/test_storage'; +const PATH = '/data/storage/el2/database/test_storage'; const KEY_TEST_INT_ELEMENT = 'key_test_int'; const KEY_TEST_LONG_ELEMENT = 'key_test_long'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageSyncJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageSyncJsunit.test.js index c40deafa4..b6d78104f 100755 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageSyncJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/default/test/StorageSyncJsunit.test.js @@ -15,7 +15,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import storage from '@ohos.data.storage' -const PATH = '/data/test_storage'; +const PATH = '/data/storage/el2/database/test_storage'; const KEY_TEST_INT_ELEMENT = 'key_test_int'; const KEY_TEST_LONG_ELEMENT = 'key_test_long'; const KEY_TEST_FLOAT_ELEMENT = 'key_test_float'; -- GitLab