diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js index e4e38765cbd04470bebd2d7c2c84cf8b7ad2d704..21d33f6ba43c77b75b4440277eae7e57d07fa1a4 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js @@ -617,13 +617,14 @@ describe('ActsBundleManagerTest', function () { checkgetApplicationInfos(datainfo); done(); }) + function checkgetApplicationInfos(datainfo) { console.log("=============datainfo.length===============" + datainfo.length); expect(datainfo.length).assertLarger(0); for (let i = 0; i < datainfo.length; i++) { expect(datainfo[i].name.length).assertLarger(0); if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { + || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0); @@ -677,7 +678,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -691,14 +692,61 @@ describe('ActsBundleManagerTest', function () { /** * @tc.number getApplicationInfo_0100 * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with one hap. + * @tc.desc Test getApplicationInfo interfaces with one hap. (by promise) */ it('getApplicationInfo_0100', 0, async function (done) { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, USERID).then(datainfo => { + expect(typeof datainfo).assertEqual(OBJECT); + console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); + expect(datainfo.moduleInfos.length).assertLarger(0); + expect(datainfo.name).assertEqual(NAME1); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.descriptionId).assertLarger(0); + expect(parseInt(datainfo.iconId)).assertLarger(0); + expect(parseInt(datainfo.labelId)).assertLarger(0); + expect(datainfo.supportedModes).assertEqual(0); + expect(datainfo.process).assertEqual(""); + expect(datainfo.enabled).assertEqual(true); + expect(datainfo.flags).assertEqual(0); + expect(datainfo.metaData.entry[0].name).assertEqual("metaDataName"); + expect(datainfo.metaData.entry[0].value).assertEqual("metaDataValue"); + expect(datainfo.metaData.entry[0].extra).assertEqual("$string:app_name"); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); + for (let j = 0; j < datainfo.moduleInfos; j++) { + expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); + } + done(); + }).catch(err => { + console.info("getApplicationInfo fail:" + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + }) + + /** + * @tc.number getApplicationInfo_0200 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with one hap. (by callback) + */ + it('getApplicationInfo_0200', 0, async function (done) { + demo.getApplicationInfo(NAME1, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION | demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, + USERID, (error, datainfo) => { + if (error) { + console.info("getApplicationInfo_0200 fail:" + JSON.stringify(error)); + expect(error).assertFail(); + done(); + return; + } expect(typeof datainfo).assertEqual(OBJECT); - console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); + console.info("getApplicationInfo_0200 success:" + JSON.stringify(datainfo)); expect(datainfo.moduleSourceDirs.length).assertLarger(0); expect(datainfo.moduleInfos.length).assertLarger(0); expect(datainfo.name).assertEqual(NAME1); @@ -722,77 +770,217 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); } done(); - }).catch(err => { - console.info("getApplicationInfo fail:" + JSON.stringify(err)); - expect(err).assertFail(); - done(); }) }) /** - * @tc.number getBundleInfos_0600 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with one hap. + * @tc.number getApplicationInfo_0300 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with two haps. (by promise) */ - it('getBundleInfos_0600', 0, async function (done) { - await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => { - expect(typeof data).assertEqual(OBJECT); - for (let i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0); - expect(data[i].appInfo.name.length).assertLarger(0); - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0); - expect(data[i].appInfo.icon.length).assertLarger(0); - expect(data[i].appInfo.label.length).assertLarger(0); - } - expect(data[i].appInfo.supportedModes).assertEqual(0); - expect(data[i].appInfo.moduleInfos.length).assertLarger(0); - } - done(); - }); + it('getApplicationInfo_0300', 0, async function (done) { + let datainfo = await demo.getApplicationInfo(NAME2, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID); + console.info("getApplicationInfo_0300 result" + JSON.stringify(datainfo)); + expect(typeof datainfo).assertEqual(OBJECT); + expect(datainfo.name.length).assertLarger(0); + expect(datainfo.description.length).assertLarger(0); + expect(datainfo.icon.length).assertLarger(0); + expect(datainfo.label.length).assertLarger(0); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); + expect(datainfo.moduleInfos.length).assertLarger(0); + expect(datainfo.name).assertEqual(NAME2); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(datainfo.iconId >= 0).assertTrue(); + expect(datainfo.labelId >= 0).assertTrue(); + expect(datainfo.supportedModes).assertEqual(0); + expect(datainfo.process).assertEqual(""); + expect(datainfo.enabled).assertEqual(true); + expect(datainfo.flags).assertEqual(0); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); + for (let j = 0; j < datainfo.moduleInfos; j++) { + expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); + } + done(); }) /** - * @tc.number getApplicationInfo_0600 + * @tc.number getApplicationInfo_0400 * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with one hap. + * @tc.desc Test getApplicationInfo interfaces with two haps. (by callback) */ - it('getApplicationInfo_0600', 0, async function (done) { - await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, - (error, datainfo) => { - if (error) { - console.info("getApplicationInfo fail:" + JSON.stringify(error)); - expect(error).assertFail(); - } - console.info("getApplicationInfo success:" + JSON.stringify(datainfo)); + it('getApplicationInfo_0400', 0, async function (done) { + await demo.getApplicationInfo(NAME2, + demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, (error, datainfo) => { + console.info("getApplicationInfo_0400 result" + JSON.stringify(datainfo)); expect(typeof datainfo).assertEqual(OBJECT); - expect(datainfo.name).assertEqual(NAME1); - expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.name.length).assertLarger(0); + expect(datainfo.description.length).assertLarger(0); + expect(datainfo.icon.length).assertLarger(0); + expect(datainfo.label.length).assertLarger(0); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); + expect(datainfo.moduleInfos.length).assertLarger(0); + expect(datainfo.name).assertEqual(NAME2); expect(datainfo.description).assertEqual(DESCRIPTION); expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.descriptionId >= 0).assertTrue(); - expect(parseInt(datainfo.iconId)).assertLarger(0); - expect(parseInt(datainfo.labelId)).assertLarger(0); + expect(datainfo.label).assertEqual("$string:app_name"); expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(datainfo.iconId >= 0).assertTrue(); + expect(datainfo.labelId >= 0).assertTrue(); expect(datainfo.supportedModes).assertEqual(0); + expect(datainfo.process).assertEqual(""); expect(datainfo.enabled).assertEqual(true); + expect(datainfo.flags).assertEqual(0); + expect(datainfo.moduleSourceDirs.length).assertLarger(0); for (let j = 0; j < datainfo.moduleInfos; j++) { expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); + expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); + } + done(); + }) + }) + + /** + * @tc.number getApplicationInfo_0500 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with three haps. (by promise) + */ + it('getApplicationInfo_0500', 0, async function (done) { + let datainfo = demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + console.info("getApplicationInfo_0500 result" + JSON.stringify(datainfo)); + expect(datainfo.name).assertEqual(NAME3); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.name).assertEqual(NAME3); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.iconId >= 0).assertTrue(); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.labelId >= 0).assertTrue(); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.supportedModes).assertEqual(0); + done(); + }) + + /** + * @tc.number getApplicationInfo_0600 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with three haps. (by callback) + */ + it('getApplicationInfo_0600', 0, async function (done) { + await demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { + console.info("getApplicationInfo_0600 result" + JSON.stringify(datainfo)); + expect(datainfo.name).assertEqual(NAME3); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.name).assertEqual(NAME3); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.iconId >= 0).assertTrue(); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.labelId >= 0).assertTrue(); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.supportedModes).assertEqual(0); + done(); + }) + }) + + /** + * @tc.number getApplicationInfo_0700 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with error hap. (by promise) + */ + it('getApplicationInfo_0700', 0, async function (done) { + demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USERID).then(datainfo => { + console.info("getApplicationInfo_0700 success" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); + done(); + }).catch(err => { + console.info("getApplicationInfo_0700 err" + JSON.stringify(err)); + expect(err).assertEqual(1); + done(); + }); + }) + + /** + * @tc.number getApplicationInfo_0800 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with error hap. (by callback) + */ + it('getApplicationInfo_0800', 0, async function (done) { + demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USERID, (error, datainfo) => { + if (error) { + console.info("getApplicationInfo_0800 fail" + JSON.stringify(error)); + expect(error).assertEqual(1); + done(); + return; } + console.info("getApplicationInfo_0800 success" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); done(); }) }) + /** + * @tc.number getApplicationInfo_0900 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with none hap. (by promise) + */ + it('getApplicationInfo_0900', 0, async function (done) { + demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USERID).then(datainfo => { + console.info("getApplicationInfo_0900 success" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); + done(); + }).catch(error => { + console.info("getApplicationInfo_0900 err" + JSON.stringify(error)); + expect(error).assertEqual(1); + done(); + }); + }) + + /** + * @tc.number getApplicationInfo_1000 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with none hap. (by callback) + */ + it('getApplicationInfo_1000', 0, async function (done) { + demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + USERID, (error, datainfo) => { + if (error) { + console.info("getApplicationInfo_1000 fail" + JSON.stringify(error)); + expect(error).assertEqual(1); + done(); + return; + } + console.info("getApplicationInfo_1000 success" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); + done(); + }); + }) + /** * @tc.number getApplicationInfo_1100 * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with one hap and different param. + * @tc.desc Test getApplicationInfo interfaces with one hap and different param. (by promise) */ it('getApplicationInfo_1100', 0, async function (done) { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => { - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); + console.info("getApplicationInfo_1100 success" + JSON.stringify(datainfo)); expect(typeof datainfo).assertEqual(OBJECT); expect(datainfo.name).assertEqual(NAME1); expect(datainfo.label).assertEqual("$string:app_name"); @@ -803,25 +991,28 @@ describe('ActsBundleManagerTest', function () { expect(parseInt(datainfo.labelId)).assertLarger(0); expect(datainfo.systemApp).assertEqual(true); expect(datainfo.supportedModes).assertEqual(0); + done(); }).catch(err => { - console.info("getApplicationInfo fail" + JSON.stringify(err)); + console.info("getApplicationInfo_1100 fail" + JSON.stringify(err)); expect(err).assertFail(); + done(); }) - done(); }) /** * @tc.number getApplicationInfo_1200 * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with one hap and different param. + * @tc.desc Test getApplicationInfo interfaces with one hap and different param. (by callback) */ it('getApplicationInfo_1200', 0, async function (done) { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID, (error, datainfo) => { if (error) { - console.info("getApplicationInfo fail" + JSON.stringify(error)); + console.info("getApplicationInfo_1200 fail" + JSON.stringify(error)); expect(error).assertFail(); + done(); + return; } - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); + console.info("getApplicationInfo_1200 success" + JSON.stringify(datainfo)); expect(typeof datainfo).assertEqual(OBJECT); expect(datainfo.name).assertEqual(NAME1); expect(datainfo.label).assertEqual("$string:app_name"); @@ -836,6 +1027,95 @@ describe('ActsBundleManagerTest', function () { }) }) + /** + * @tc.number getApplicationInfo_1300 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with one hap. (by promise) + */ + it('getApplicationInfo_1300', 0, async function (done) { + await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID).then(datainfo => { + console.info("getApplicationInfo_1300 success:" + JSON.stringify(datainfo)); + expect(typeof datainfo).assertEqual(OBJECT); + expect(datainfo.name).assertEqual(NAME1); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(parseInt(datainfo.iconId)).assertLarger(0); + expect(parseInt(datainfo.labelId)).assertLarger(0); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.supportedModes).assertEqual(0); + expect(datainfo.enabled).assertEqual(true); + for (let j = 0; j < datainfo.moduleInfos; j++) { + expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); + } + done(); + }).catch(error => { + console.info("getApplicationInfo_1300 fail:" + JSON.stringify(error)); + expect(error).assertFail(); + done(); + }) + }) + + /** + * @tc.number getApplicationInfo_1400 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with one hap. (by callback) + */ + it('getApplicationInfo_1400', 0, async function (done) { + await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, + (error, datainfo) => { + if (error) { + console.info("getApplicationInfo_1400 fail:" + JSON.stringify(error)); + expect(error).assertFail(); + done(); + return; + } + console.info("getApplicationInfo_1400 success:" + JSON.stringify(datainfo)); + expect(typeof datainfo).assertEqual(OBJECT); + expect(datainfo.name).assertEqual(NAME1); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.descriptionId >= 0).assertTrue(); + expect(parseInt(datainfo.iconId)).assertLarger(0); + expect(parseInt(datainfo.labelId)).assertLarger(0); + expect(datainfo.systemApp).assertEqual(true); + expect(datainfo.supportedModes).assertEqual(0); + expect(datainfo.enabled).assertEqual(true); + for (let j = 0; j < datainfo.moduleInfos; j++) { + expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); + } + done(); + }) + }) + + /** + * @tc.number getBundleInfos_0600 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with one hap. + */ + it('getBundleInfos_0600', 0, async function (done) { + await demo.getAllBundleInfo(demo.BundleFlag.GET_BUNDLE_DEFAULT, (error, data) => { + expect(typeof data).assertEqual(OBJECT); + for (let i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0); + expect(data[i].appInfo.name.length).assertLarger(0); + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0); + expect(data[i].appInfo.icon.length).assertLarger(0); + expect(data[i].appInfo.label.length).assertLarger(0); + } + expect(data[i].appInfo.supportedModes).assertEqual(0); + expect(data[i].appInfo.moduleInfos.length).assertLarger(0); + } + done(); + }); + }) + /** * @tc.number getApplicationInfos_0200 * @tc.name BUNDLE::getApplicationInfos @@ -871,7 +1151,7 @@ describe('ActsBundleManagerTest', function () { for (let i = 0; i < datainfo.length; i++) { expect(datainfo[i].name.length).assertLarger(0); if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { + || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0); @@ -899,7 +1179,7 @@ describe('ActsBundleManagerTest', function () { for (let i = 0; i < datainfo.length; i++) { expect(datainfo[i].name.length).assertLarger(0); if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { + || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0); @@ -927,7 +1207,7 @@ describe('ActsBundleManagerTest', function () { for (let i = 0; i < datainfo.length; i++) { expect(datainfo[i].name.length).assertLarger(0); if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { + || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { expect(datainfo[i].description.length).assertLarger(0); expect(datainfo[i].icon.length).assertLarger(0); expect(datainfo[i].label.length).assertLarger(0); @@ -957,7 +1237,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -980,7 +1260,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -991,41 +1271,6 @@ describe('ActsBundleManagerTest', function () { done(); }) - /** - * @tc.number getApplicationInfo_0200 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with two haps. - */ - it('getApplicationInfo_0200', 0, async function (done) { - let datainfo = await demo.getApplicationInfo(NAME2, - demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID); - console.info("getApplicationInfo result" + JSON.stringify(datainfo)); - expect(typeof datainfo).assertEqual(OBJECT); - expect(datainfo.name.length).assertLarger(0); - expect(datainfo.description.length).assertLarger(0); - expect(datainfo.icon.length).assertLarger(0); - expect(datainfo.label.length).assertLarger(0); - expect(datainfo.moduleSourceDirs.length).assertLarger(0); - expect(datainfo.moduleInfos.length).assertLarger(0); - expect(datainfo.name).assertEqual(NAME2); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.systemApp).assertEqual(true); - expect(datainfo.descriptionId >= 0).assertTrue(); - expect(datainfo.iconId >= 0).assertTrue(); - expect(datainfo.labelId >= 0).assertTrue(); - expect(datainfo.supportedModes).assertEqual(0); - expect(datainfo.process).assertEqual(""); - expect(datainfo.enabled).assertEqual(true); - expect(datainfo.flags).assertEqual(0); - expect(datainfo.moduleSourceDirs.length).assertLarger(0); - for (let j = 0; j < datainfo.moduleInfos; j++) { - expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); - } - done(); - }) /** * @tc.number getBundleInfos_0700 @@ -1039,7 +1284,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -1063,7 +1308,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -1075,38 +1320,6 @@ describe('ActsBundleManagerTest', function () { }) }) - - /** - * @tc.number getApplicationInfo_0700 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with two haps. - */ - it('getApplicationInfo_0700', 0, async function (done) { - await demo.getApplicationInfo(NAME2, - demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USERID, (error, datainfo) => { - if (error) { - console.info("getApplicationInfo error" + JSON.stringify(error)); - expect(error).assertFail(); - } - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); - expect(typeof datainfo).assertEqual(OBJECT); - expect(datainfo.name).assertEqual(NAME2); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.name).assertEqual(NAME2); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.descriptionId >= 0).assertTrue(); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.iconId >= 0).assertTrue(); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.labelId >= 0).assertTrue(); - expect(datainfo.systemApp).assertEqual(true); - expect(datainfo.supportedModes).assertEqual(0); - done(); - }) - }) - /** * @tc.number getBundleInfos_0300 * @tc.name BUNDLE::getBundleInfos @@ -1118,7 +1331,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -1140,7 +1353,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -1162,7 +1375,7 @@ describe('ActsBundleManagerTest', function () { expect(data[i].name.length).assertLarger(0); expect(data[i].appInfo.name.length).assertLarger(0); if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { expect(data[i].appInfo.description.length).assertLarger(0); expect(data[i].appInfo.icon.length).assertLarger(0); expect(data[i].appInfo.label.length).assertLarger(0); @@ -1175,112 +1388,6 @@ describe('ActsBundleManagerTest', function () { }) - /** - * @tc.number getApplicationInfo_0300 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with three haps. - */ - it('getApplicationInfo_0300', 0, async function (done) { - demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { - expect(datainfo.name).assertEqual(NAME3); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.name).assertEqual(NAME3); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.descriptionId >= 0).assertTrue(); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.iconId >= 0).assertTrue(); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.labelId >= 0).assertTrue(); - expect(datainfo.systemApp).assertEqual(true); - expect(datainfo.supportedModes).assertEqual(0); - }); - done(); - }) - - /** - * @tc.number getApplicationInfo_0400 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with error hap. - */ - it('getApplicationInfo_0400', 0, async function (done) { - demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USERID).then(datainfo => { - checkgetApplicationInfoe(datainfo); - }).catch(err => { - console.info("getApplicationInfo err" + JSON.stringify(err)); - expect(err).assertEqual(1); - done(); - }); - }) - function checkgetApplicationInfoe(datainfo) { - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); - expect(datainfo).assertFail(); - done(); - } - - /** - * @tc.number getApplicationInfo_0900 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with error hap. - */ - it('getApplicationInfo_0900', 0, async function (done) { - demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USERID, (error, datainfo) => { - if (error) { - console.info("getApplicationInfo fail" + JSON.stringify(error)); - expect(error).assertEqual(1); - done(); - return; - } - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); - expect(datainfo).assertFail(); - done(); - }) - }) - - /** - * @tc.number getApplicationInfo_0500 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with none hap. - */ - it('getApplicationInfo_0500', 0, async function (done) { - demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USERID, (error, datainfo) => { - if (error) { - console.info("getApplicationInfo err" + JSON.stringify(error)); - expect(error).assertEqual(1); - done(); - return; - } - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); - expect(datainfo).assertFail(); - done(); - }) - }) - - /** - * @tc.number getApplicationInfo_1000 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with none hap. - */ - it('getApplicationInfo_1000', 0, async function (done) { - demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USERID, (error, datainfo) => { - if (error) { - console.info("getApplicationInfo fail" + JSON.stringify(error)); - expect(error).assertEqual(1); - done(); - return; - } - console.info("getApplicationInfo success" + JSON.stringify(datainfo)); - expect(datainfo).assertFail(); - done(); - }); - }) - /** * @tc.number queryAbilityByWant_0100 * @tc.name BUNDLE::queryAbilityByWant @@ -1292,44 +1399,44 @@ describe('ActsBundleManagerTest', function () { "bundleName": "com.example.myapplication1", "abilityName": "com.example.myapplication1.MainAbility", }, demo.BundleFlag.GET_ABILITY_INFO_WITH_APPLICATION | - demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION | + demo.BundleFlag.GET_ABILITY_INFO_WITH_PERMISSION | demo.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(data => { - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - let datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility"); - expect(datainfo.label).assertEqual("$string:app_name"); - expect(datainfo.description).assertEqual(DESCRIPTION); - expect(datainfo.icon).assertEqual("$media:icon"); - expect(datainfo.moduleName).assertEqual("entry"); - expect(datainfo.bundleName).assertEqual(NAME1); - expect(datainfo.type).assertEqual(demo.AbilityType.PAGE); - expect(datainfo.subType).assertEqual(demo.AbilitySubType.UNSPECIFIED); - expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.UNSPECIFIED); - expect(datainfo.launchMode).assertEqual(demo.LaunchMode.STANDARD); - expect(datainfo.permissions[0]).assertEqual("com.permission.BMS_PERMISSION_CAMERA"); - expect(datainfo.applicationInfo.name).assertEqual(NAME1); - expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION); - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue(); - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon"); - expect(datainfo.applicationInfo.iconId >= 0).assertTrue(); - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name"); - expect(datainfo.applicationInfo.labelId >= 0).assertTrue(); - expect(datainfo.applicationInfo.systemApp).assertEqual(true); - expect(datainfo.applicationInfo.supportedModes).assertEqual(0); - expect(datainfo.applicationInfo.enabled).assertEqual(true); - expect(datainfo.metaData.length).assertLarger(0); - for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); - } + expect(data.length).assertLarger(0); + for (let i = 0, len = data.length; i < len; i++) { + let datainfo = data[i]; + expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility"); + expect(datainfo.label).assertEqual("$string:app_name"); + expect(datainfo.description).assertEqual(DESCRIPTION); + expect(datainfo.icon).assertEqual("$media:icon"); + expect(datainfo.moduleName).assertEqual("entry"); + expect(datainfo.bundleName).assertEqual(NAME1); + expect(datainfo.type).assertEqual(demo.AbilityType.PAGE); + expect(datainfo.subType).assertEqual(demo.AbilitySubType.UNSPECIFIED); + expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.UNSPECIFIED); + expect(datainfo.launchMode).assertEqual(demo.LaunchMode.STANDARD); + expect(datainfo.permissions[0]).assertEqual("com.permission.BMS_PERMISSION_CAMERA"); + expect(datainfo.applicationInfo.name).assertEqual(NAME1); + expect(datainfo.applicationInfo.description).assertEqual(DESCRIPTION); + expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue(); + expect(datainfo.applicationInfo.icon).assertEqual("$media:icon"); + expect(datainfo.applicationInfo.iconId >= 0).assertTrue(); + expect(datainfo.applicationInfo.label).assertEqual("$string:app_name"); + expect(datainfo.applicationInfo.labelId >= 0).assertTrue(); + expect(datainfo.applicationInfo.systemApp).assertEqual(true); + expect(datainfo.applicationInfo.supportedModes).assertEqual(0); + expect(datainfo.applicationInfo.enabled).assertEqual(true); + expect(datainfo.metaData.length).assertLarger(0); + for (let j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry"); + expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1); } - done(); - }).catch(err => { - expect(err).assertFail(); - done(); - }) + } + done(); + }).catch(err => { + expect(err).assertFail(); + done(); + }) }) /** @@ -1439,13 +1546,13 @@ describe('ActsBundleManagerTest', function () { "bundleName": "wrong name", "abilityName": "com.example.myapplication1.MainAbility" }, demo.BundleFlag.GET_BUNDLE_DEFAULT, USERID).then(datainfo => { - console.info("queryAbilityByWant_0400 dataInfo : ===========" + datainfo); - expect(datainfo).assertFail(); - }).catch(err => { - console.info("queryAbilityByWant_0400 err : ===========" + err); - expect(err).assertEqual(1); - done(); - }) + console.info("queryAbilityByWant_0400 dataInfo : ===========" + datainfo); + expect(datainfo).assertFail(); + }).catch(err => { + console.info("queryAbilityByWant_0400 err : ===========" + err); + expect(err).assertEqual(1); + done(); + }) }) /** @@ -1459,6 +1566,7 @@ describe('ActsBundleManagerTest', function () { bundleName: "wrong name", abilityName: "wrong name", }, 0, USERID, OnReceiveEvent); + function OnReceiveEvent(err, datainfo) { expect(err).assertEqual(1); expect(datainfo.length).assertLarger(0); diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js index cf00e8d2505f8474d2bbec87bbdc68638faee557..b204eb9faf81543c7888408606cdbe5150976d1b 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerCallbackJsunit.test.js @@ -21,7 +21,6 @@ const STORE_KEY = 'key_test_string'; const STORE_VALUE = 'value-test-string'; var kvManager = null; var kvStore = null; -var kvStoreNew = null; describe('KVManagerCallbackTest', function () { const config = { @@ -46,10 +45,7 @@ describe('KVManagerCallbackTest', function () { console.log('beforeAll'); await factory.createKVManager(config, function (err, manager) { kvManager = manager; - kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) { - kvStoreNew = store; - done(); - }); + done(); }); console.log('beforeAll end'); }) @@ -442,9 +438,10 @@ describe('KVManagerCallbackTest', function () { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { if (err == undefined) { console.log('testKVManagerGetKVStore113 getKVStore success'); - expect(null).assertFail(); + expect((err == undefined) && (store != null)).assertTrue(); } else { console.log('testKVManagerGetKVStore113 getKVStore fail'); + expect(null).assertFail(); } done(); }); @@ -483,7 +480,7 @@ describe('KVManagerCallbackTest', function () { done(); } }) - +F /** * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1150 * @tc.name [JS-API8]KVManager.GetKVStore. @@ -503,13 +500,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore115 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore115 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -533,13 +529,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore116 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore116 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -563,13 +558,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore117 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore117 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -593,13 +587,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore118 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore118 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -623,13 +616,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore119 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore119 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -653,13 +645,12 @@ describe('KVManagerCallbackTest', function () { try { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { console.log('testKVManagerGetKVStore120 getKVStore success'); - expect((err == undefined) && (store != null)).assertTrue(); - kvStore = store; + expect(null).assertFail(); done(); }); } catch (e) { console.log('testKVManagerGetKVStore119 getKVStore e ' + e); - expect(null).assertFail(); + expect(true).assertTrue(); done(); } }) @@ -923,100 +914,34 @@ describe('KVManagerCallbackTest', function () { it('testKVStorePut100', 0, async function (done) { console.log('testKVStorePut100'); try { - await kvStoreNew.put(STORE_KEY, STORE_VALUE, function (err, data) { - if (err != undefined){ - console.log('testKVStorePut100 put callback fail'); - } else { - console.log('testKVStorePut100 put callback success'); - expect(null).assertFail(); - } - done(); - }); - } catch (e) { - console.log('testKVStorePut100 callback e ' + e); - done(); - } - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_DELETE_1000 - * @tc.name [JS-API8]KVStore.Delete - * @tc.desc Test Js Api KVManager.Delete testcase 100 - */ - it('testKVStoreDelete100', 0, async function (done) { - console.log('testKVStoreDelete100'); - try { - await KVStoreNew.put(STORE_KEY, STORE_VALUE, async function (err,data) { - console.log('testKVStoreDelete100 put success'); - try { - kvStore.delete(STORE_KEY, function (err, data) { - if (err == undefined) { - console.log('testKVStoreDelete100 callback delete success'); - expect(null).assertFail(); + await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { + console.log('testKVStorePut100 getKVStore success'); + kvStore = store; + await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) { + if (err != undefined){ + console.log('testKVStorePut100 put callback fail'); } else { - console.log('testKVStoreDelete100 callback delete fail'); + console.log('testKVStorePut100 put callback success'); + expect(null).assertFail(); } done(); }); - } catch (e) { - console.log('testKVStoreDelete100 callback delete e ' + e); - done(); - } - }); - } catch (ee) { - console.log('testKVStoreDelete100 callback delete ee ' + ee); - expect(null).assertFail(); + }); + + } catch (e) { + console.log('testKVStorePut100 callback e ' + e); done(); } }) - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1000 - * @tc.name [JS-API8]KVStore.On - * @tc.desc Test Js Api KVManager.On testcase 100 - */ - it('testKVStoreOn100', 0, async function (done) { - kvStoreNew.on('dataChange', 0, function (data) { - console.log("testKVStoreOn100 callback call data: " + JSON.stringify(data)); - expect(true).assertTrue(); - }); - done(); - }) - /** * @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1100 * @tc.name [JS-API8]KVStore.On * @tc.desc Test Js Api KVManager.On testcase 101 */ it('testKVStoreOn101', 0, async function (done) { - kvStoreNew.on('dataChange', 1, function (data) { - console.log("testKVStoreOn101 callback call data: " + JSON.stringify(data)); - expect(true).assertTrue(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1200 - * @tc.name [JS-API8]KVStore.On - * @tc.desc Test Js Api KVManager.On testcase 102 - */ - it('testKVStoreOn102', 0, async function (done) { - kvStoreNew.on('dataChange', 2, function (data) { - console.log("testKVStoreOn102 callback call data: " + JSON.stringify(data)); - expect(true).assertTrue(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1300 - * @tc.name [JS-API8]KVStore.On - * @tc.desc Test Js Api KVManager.On testcase 103 - */ - it('testKVStoreOn103', 0, async function (done) { kvStoreNew.on('syncComplete', function (data) { - console.log("testKVStoreOn103 callback call data: " + data); + console.log("testKVStoreOn101 callback call data: " + data); expect(true).assertTrue(); }); done(); diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js index 4ca792e94452fd2244d6a0567aa7474dcb338813..240c20cf6268e1f24f97e24ce3293ea9940e8417 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/KvManagerPromiseJsunit.test.js @@ -441,11 +441,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore014 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore014 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -468,11 +467,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore015 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore015 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -495,11 +493,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore016 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore016 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -522,11 +519,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore017 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore017 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -549,11 +545,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore018 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore018 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -576,11 +571,10 @@ describe('KVManagerPromiseTest', function () { } await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => { console.log('testKVManagerGetKVStore019 getKVStore success'); - kvStore = store; - expect(store != null).assertTrue(); + expect(null).assertFail(); }).catch((err) => { console.log('testKVManagerGetKVStore019 getKVStore err ' + err); - expect(null).assertFail(); + expect(true).assertTrue(); }); done(); }) @@ -591,95 +585,18 @@ describe('KVManagerPromiseTest', function () { * @tc.desc Test Js Api KVManager.CloseKVStore testcase 001 */ it('testKVManagerCloseKVStore001', 0, async function (done) { - console.log('testKVManagerCloseKVStore001'); - await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => { - console.log('testKVManagerCloseKVStore001 getKVStore success'); - kvStore = store; - await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => { - console.log('testKVManagerCloseKVStore001 closeKVStore success'); - }).catch((err) => { - console.log('testKVManagerCloseKVStore001 closeKVStore err ' + err); - expect(null).assertFail(); - }); - }).catch((err) => { - console.log('testKVManagerCloseKVStore001 getKVStore err ' + err); - expect(null).assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0200 - * @tc.name [JS-API8]KVManager.CloseKVStore. - * @tc.desc Test Js Api KVManager.CloseKVStore testcase 002 - */ - it('testKVManagerCloseKVStore002', 0, async function (done) { - console.log('testKVManagerCloseKVStore002'); - await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => { - console.log('testKVManagerCloseKVStore002 getKVStore success'); - kvStore = store; - try { - await kvManager.closeKVStore(TEST_BUNDLE_NAME).then(() => { - console.log('testKVManagerCloseKVStore002 closeKVStore success'); - expect(null).assertFail(); - }).catch((err) => { - console.log('testKVManagerCloseKVStore002 closeKVStore err ' + err); - }); - } catch (e) { - console.log('testKVManagerCloseKVStore002 closeKVStore e ' + e); - } - }).catch((err) => { - console.log('testKVManagerCloseKVStore002 getKVStore err ' + err); - expect(null).assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0300 - * @tc.name [JS-API8]KVManager.CloseKVStore. - * @tc.desc Test Js Api KVManager.CloseKVStore testcase 003 - */ - it('testKVManagerCloseKVStore003', 0, async function (done) { - console.log('testKVManagerCloseKVStore003'); - await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => { - console.log('testKVManagerCloseKVStore003 getKVStore success'); - kvStore = store; - try { - await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { - console.log('testKVManagerCloseKVStore003 closeKVStore success'); - expect(null).assertFail(); - }).catch((err) => { - console.log('testKVManagerCloseKVStore003 closeKVStore err ' + err); - }); - } catch (e) { - console.log('testKVManagerCloseKVStore003 closeKVStore e ' + e); - } - }).catch((err) => { - console.log('testKVManagerCloseKVStore003 getKVStore err ' + err); - expect(null).assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0400 - * @tc.name [JS-API8]KVManager.CloseKVStore. - * @tc.desc Test Js Api KVManager.CloseKVStore testcase 004 - */ - it('testKVManagerCloseKVStore004', 0, async function (done) { console.log('testKVManagerCloseKVStore004'); await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { - console.log('testKVManagerCloseKVStore004 getKVStore success'); + console.log('testKVManagerCloseKVStore001 getKVStore success'); kvStore = store; await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore); }); - console.log('testKVManagerCloseKVStore104 closeKVStore redo.'); + console.log('testKVManagerCloseKVStore001 closeKVStore redo.'); await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => { - console.log('testKVManagerCloseKVStore004 closeKVStore twice'); + console.log('testKVManagerCloseKVStore001 closeKVStore twice'); expect(null).assertFail(); }).catch((err) => { - console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err); + console.log('testKVManagerCloseKVStore001 closeKVStore twice err ' + err); }); done(); }) @@ -691,61 +608,11 @@ describe('KVManagerPromiseTest', function () { */ it('testKVManagerDeleteKVStore001', 0, async function (done) { console.log('testKVManagerDeleteKVStore001'); - await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => { - console.log('testKVManagerDeleteKVStore001 getKVStore success'); - kvStore = store; - await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { - console.log('testKVManagerDeleteKVStore001 deleteKVStore success'); - }).catch((err) => { - console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err); - expect(null).assertFail(); - }); - }).catch((err) => { - console.log('testKVManagerDeleteKVStore001 getKVStore err ' + err); - expect(null).assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0200 - * @tc.name [JS-API8]KVManager.DeleteKVStore. - * @tc.desc Test Js Api KVManager.DeleteKVStore testcase 002 - */ - it('testKVManagerDeleteKVStore002', 0, async function (done) { - console.log('testKVManagerDeleteKVStore002'); - await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => { - console.log('testKVManagerDeleteKVStore002 getKVStore success'); - kvStore = store; - try { - await kvManager.deleteKVStore(TEST_BUNDLE_NAME).then(() => { - console.log('testKVManagerDeleteKVStore002 deleteKVStore success'); - expect(null).assertFail(); - }).catch((err) => { - console.log('testKVManagerDeleteKVStore002 deleteKVStore err ' + err); - }); - } catch (e) { - console.log('testKVManagerDeleteKVStore002 deleteKVStore e ' + e); - } - }).catch((err) => { - console.log('testKVManagerDeleteKVStore002 getKVStore err ' + err); - expect(null).assertFail(); - }); - done(); - }) - - /** - * @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0300 - * @tc.name [JS-API8]KVManager.DeleteKVStore. - * @tc.desc Test Js Api KVManager.DeleteKVStore testcase 003 - */ - it('testKVManagerDeleteKVStore003', 0, async function (done) { - console.log('testKVManagerDeleteKVStore003'); await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => { - console.log('testKVManagerDeleteKVStore003 deleteKVStore success'); + console.log('testKVManagerDeleteKVStore001 deleteKVStore success'); expect(null).assertFail(); }).catch((err) => { - console.log('testKVManagerDeleteKVStore003 deleteKVStore err ' + err); + console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err); }); done(); })