From 4bbc855c9fc2022c6be76466cc3d1abb95582e29 Mon Sep 17 00:00:00 2001 From: inter515 Date: Thu, 31 Mar 2022 16:16:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83=E4=BF=AE?= =?UTF-8?q?=E6=94=B9-=E7=A7=BB=E9=99=A4clean=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: inter515 --- .../js/test/ActsBmsCleanCacheTest.test.js | 163 ------------------ .../js/test/ActsBmsGetBackGroundModes.test.js | 74 ++++---- .../js/test/ActsBmsQueryAbilityByWant.test.js | 38 ++++ .../entry/src/main/js/test/List.test.js | 1 - 4 files changed, 71 insertions(+), 205 deletions(-) delete mode 100644 appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js deleted file mode 100644 index 0a8dc42b9..000000000 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsCleanCacheTest.test.js +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import bundle from '@ohos.bundle' -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit' - -const BUNDLE_PATH1 = '/data/test/bmsThirdBundleTest1.hap'; -const BUNDLE_NAME1 = 'com.example.third1'; - -describe('ActsCleancache', function () { - - /* - * @tc.number: bms_cleancache_0200 - * @tc.name: cleancache callback by other callback - * @tc.desc: 1.cleancache callback - * 2.cleancache for right input - */ - it('bms_cleancache_0100', 0, async function (done){ - console.info('=====================bms_cleancache_0100=================='); - - let bundlePath = [BUNDLE_PATH1] - bundle.getBundleInstaller().then(installer => { - function onReceiveinstallEvent(err, data) { - console.log('bms_cleancache_0100 install called: ' + data) - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - - bundle.cleanBundleCacheFiles('com.example.third1', (err) => { - if (err) { - console.log('bms_cleancache_0100 test query system app err is ' + err) - expect(err).assertEqual(1); - } - expect(err).assertEqual(undefined); - installer.uninstall(BUNDLE_NAME1, - { - userId: 100, - installFlag: 1, - isKeepData: false - } - , (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - ) - } - installer.install(['/data/test/bmsThirdBundleTest1.hap'], - { - userId: 100, - installFlag: 1, - isKeepData: false, - }, onReceiveinstallEvent); - }) - }) - - /* - * @tc.number: bms_cleancache_0200 - * @tc.name: cleancache callback by other callback - * @tc.desc: 1.cleancache callback - * 2.cleancache for null input - */ - it('bms_cleancache_0200', 0, async function (done){ - console.info('=====================bms_cleancache_0100=================='); - - let bundlePath = [BUNDLE_PATH1] - bundle.getBundleInstaller().then(installer => { - function onReceiveinstallEvent(err, data) { - console.log('bms_cleancache_0100 install called: ' + data) - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - - bundle.cleanBundleCacheFiles(null, (err) => { - if (err) { - console.log('bms_cleancache_0200 test query system app err is ' + err) - expect(err).assertEqual(2); - } - installer.uninstall(BUNDLE_NAME1, - { - userId: 100, - installFlag: 1, - isKeepData: false - } - , (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - ) - } - installer.install(['/data/test/bmsThirdBundleTest1.hap'], - { - userId: 100, - installFlag: 1, - isKeepData: false, - }, onReceiveinstallEvent); - }) - }) - - /* - * @tc.number: bms_cleancache_0300 - * @tc.name: cleancache callback by other callback - * @tc.desc: 1.cleancache callback - * 2.cleancache for wrong input - */ - it('bms_cleancache_0300', 0, async function (done){ - console.info('=====================bms_cleancache_0100=================='); - - let bundlePath = [BUNDLE_PATH1] - bundle.getBundleInstaller().then(installer => { - function onReceiveinstallEvent(err, data) { - console.log('bms_cleancache_0300 install called: ' + data) - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - - bundle.cleanBundleCacheFiles("wrong bundle name", (err) => { - if (err) { - console.log('bms_cleancache_0300 test query system app err is ' + err) - expect(err).assertEqual(1); - } - installer.uninstall(BUNDLE_NAME1, - { - userId: 100, - installFlag: 1, - isKeepData: false - } - , (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - ) - } - installer.install(['/data/test/bmsThirdBundleTest1.hap'], - { - userId: 100, - installFlag: 1, - isKeepData: false, - }, onReceiveinstallEvent); - }) - }) - -}) \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js index 250962209..625c859f7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsGetBackGroundModes.test.js @@ -40,15 +40,15 @@ const NUM_THREE = 3; const NUM_FOUR = 4; const NUM_NINE = 9; const USERID = 100; -let dataTransfer = 1; -let audioPlayback = 2; -let audioRecording = 4; -let location = 8; -let bluetoothInteraction = 16; -let multiDeviceConnection = 32; -let wifiInteraction = 64; -let voip = 128; -let taskKeeping = 256; +const DATATRANSFER = 1; +const AUDIOPLAYBACK = 2; +const AUDIORECORDING = 4; +const LOCATION = 8; +const BLUETOOTHINTERACTION = 16; +const MULTIDEVICECONNECTION = 32; +const WIFIINTERACTION = 64; +const VOIP = 128; +const TASKKEEPING = 256; let installParam = { userId: USERID, installFlag: 1, @@ -79,33 +79,29 @@ describe('ActsBmsGetBackGroundModes', function () { expect(dataInfos.length).assertEqual(NUM_FOUR); if (dataInfos.length == NUM_FOUR) { expect(dataInfos[NUM_TWO].name).assertEqual(ABILITIY_NAME1); - expect(dataInfos[NUM_TWO].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping); + expect(dataInfos[NUM_TWO].backgroundModes).assertEqual(DATATRANSFER | AUDIOPLAYBACK | AUDIORECORDING | + LOCATION | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); expect(dataInfos[NUM_THREE].name).assertEqual(ABILITIY_NAME2); - expect(dataInfos[NUM_THREE].backgroundModes).assertEqual(dataTransfer | voip); + expect(dataInfos[NUM_THREE].backgroundModes).assertEqual(DATATRANSFER | VOIP); } let bundleInfos = await bundle.getAllBundleInfo(bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, USERID); for (let i = 0; i < bundleInfos.length; i++) { if (bundleInfos[i].name == BUNDLE_NAME5) { for (let j = 0; j < bundleInfos[i].abilityInfos.length; j++) { if (bundleInfos[i].abilityInfos[j].name == ABILITIY_NAME1) { - expect(bundleInfos[i].abilityInfos[j].backgroundModes).assertEqual(dataTransfer | - audioPlayback | audioRecording | location | bluetoothInteraction | - multiDeviceConnection | wifiInteraction | voip | taskKeeping); + expect(bundleInfos[i].abilityInfos[j].backgroundModes).assertEqual(DATATRANSFER | + AUDIOPLAYBACK | AUDIORECORDING | LOCATION | BLUETOOTHINTERACTION | + MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); } else if (bundleInfos[i].abilityInfos[j].name == ABILITIY_NAME2) { - expect(bundleInfos[i].abilityInfos[j].backgroundModes).assertEqual(dataTransfer | voip); + expect(bundleInfos[i].abilityInfos[j].backgroundModes).assertEqual(DATATRANSFER | VOIP); } } } } let data3 = await bundle.getBundleInfo(BUNDLE_NAME5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(data3.abilityInfos[2].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping); - expect(data3.abilityInfos[3].backgroundModes).assertEqual(dataTransfer | voip); - let data5 = await bundle.getBundleArchiveInfo(BUNDLE_PATH5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(data5.abilityInfos[2].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping); - expect(data5.abilityInfos[3].backgroundModes).assertEqual(dataTransfer | voip); + expect(data3.abilityInfos[2].backgroundModes).assertEqual(DATATRANSFER | AUDIOPLAYBACK | AUDIORECORDING | + LOCATION | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); + expect(data3.abilityInfos[3].backgroundModes).assertEqual(DATATRANSFER | VOIP); installer.uninstall(BUNDLE_NAME5, installParam, (err, data) => { checkInstallOrUninstall(err, data); done(); @@ -166,8 +162,8 @@ describe('ActsBmsGetBackGroundModes', function () { expect(dataInfos.length).assertEqual(NUM_TWO); if (dataInfos.length == NUM_TWO) { expect(dataInfos[1].name).assertEqual(ABILITIY_NAME3) - expect(dataInfos[1].backgroundModes).assertEqual(audioPlayback | audioRecording | location - | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping) + expect(dataInfos[1].backgroundModes).assertEqual(AUDIOPLAYBACK | AUDIORECORDING | LOCATION + | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING) } bundle.getAllBundleInfo(bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, USERID, (err, bundleInfos) => { for (let i = 0; i < bundleInfos.length; i++) { @@ -175,20 +171,16 @@ describe('ActsBmsGetBackGroundModes', function () { for (let j = 0; j < bundleInfos[i].abilityInfos.length; j++) { if (bundleInfos[i].abilityInfos[j].name == ABILITIY_NAME3) { expect(bundleInfos[i].abilityInfos[j].backgroundModes).assertEqual( - audioPlayback | audioRecording | location | bluetoothInteraction - | multiDeviceConnection | wifiInteraction | voip | taskKeeping); + AUDIOPLAYBACK | AUDIORECORDING | LOCATION | BLUETOOTHINTERACTION + | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); } } } } }); bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (err, data3) => { - expect(data3.abilityInfos[1].backgroundModes).assertEqual(audioPlayback | audioRecording | location - | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping) - }); - bundle.getBundleArchiveInfo(BUNDLE_PATH2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (err, data5) => { - expect(data5.abilityInfos[1].backgroundModes).assertEqual(audioPlayback | audioRecording | location - | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping) + expect(data3.abilityInfos[1].backgroundModes).assertEqual(AUDIOPLAYBACK | AUDIORECORDING | LOCATION + | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING) }); installer.uninstall(BUNDLE_NAME2, installParam, (err, data) => { checkInstallOrUninstall(err, data); @@ -250,11 +242,11 @@ describe('ActsBmsGetBackGroundModes', function () { expect(dataInfos.length).assertEqual(NUM_FOUR); if (dataInfos.length == NUM_FOUR) { expect(dataInfos[1].name).assertEqual(ABILITIY_NAME5) - expect(dataInfos[1].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping) + expect(dataInfos[1].backgroundModes).assertEqual(DATATRANSFER | AUDIOPLAYBACK | AUDIORECORDING | + LOCATION | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING) expect(dataInfos[3].name).assertEqual(ABILITIY_NAME6) - expect(dataInfos[3].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping) + expect(dataInfos[3].backgroundModes).assertEqual(DATATRANSFER | AUDIOPLAYBACK | AUDIORECORDING | + LOCATION | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING) } installer.uninstall(BUNDLE_NAME1, installParam, (err, data) => { checkInstallOrUninstall(err, data); @@ -286,8 +278,8 @@ describe('ActsBmsGetBackGroundModes', function () { expect(dataInfos.length).assertEqual(NUM_TWO); if (dataInfos.length == NUM_TWO) { expect(dataInfos[1].name).assertEqual(ABILITIY_NAME5); - expect(dataInfos[1].backgroundModes).assertEqual(dataTransfer | audioPlayback | audioRecording | - location | bluetoothInteraction | multiDeviceConnection | wifiInteraction | voip | taskKeeping); + expect(dataInfos[1].backgroundModes).assertEqual(DATATRANSFER | AUDIOPLAYBACK | AUDIORECORDING | + LOCATION | BLUETOOTHINTERACTION | MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); } installer.install(bundlePath2, installParam, async (err, data) => { checkInstallOrUninstall(err, data); @@ -303,8 +295,8 @@ describe('ActsBmsGetBackGroundModes', function () { expect(dataInfos.length).assertEqual(NUM_TWO); if (dataInfos.length == NUM_TWO) { expect(dataInfos[1].name).assertEqual(ABILITIY_NAME7); - expect(dataInfos[1].backgroundModes).assertEqual(audioRecording | location | bluetoothInteraction | - multiDeviceConnection | wifiInteraction | voip | taskKeeping); + expect(dataInfos[1].backgroundModes).assertEqual(AUDIORECORDING | LOCATION | BLUETOOTHINTERACTION | + MULTIDEVICECONNECTION | WIFIINTERACTION | VOIP | TASKKEEPING); } installer.uninstall(BUNDLE_NAME1, installParam, (err, data) => { checkInstallOrUninstall(err, data); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js index ef82b0c84..775d7000f 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/ActsBmsQueryAbilityByWant.test.js @@ -28,6 +28,7 @@ let installParam = { }; describe('ActsBmsQueryAbilityByWant', function () { + /* * @tc.number: bms_queryAbilityByWant_0100 * @tc.name: queryAbilityByWant callback by other callback @@ -108,8 +109,45 @@ describe('ActsBmsQueryAbilityByWant', function () { abilityName: '', }, }, bundle.BundleFlag.GET_BUNDLE_DEFAULT, USERID); + for(let i = 0; i < dataInfos.length ; i ++){ + console.info ('dataInfos============='+ i); + for (const item in dataInfos[0]) { + const a = dataInfos[0][item]; + console.info(item+":"+ JSON.stringify(a)); + }; + }; expect(dataInfos.length).assertEqual(1); expect(dataInfos[0].name).assertEqual(ABILITIY_NAME8); + expect(dataInfos[0].label).assertEqual('$string:app_name'); + expect(dataInfos[0].description).assertEqual('$string:mainability_description'); + expect(dataInfos[0].icon).assertEqual("$media:icon"); + expect(dataInfos[0].srcPath).assertEqual(""); + expect(dataInfos[0].srcLanguage).assertEqual("js"); + expect(dataInfos[0].isVisible).assertEqual(false); + expect(dataInfos[0].permissions.length).assertEqual(0); + expect(dataInfos[0].deviceCapabilities.length).assertEqual(0); + expect(dataInfos[0].deviceTypes[0]).assertEqual('phone'); + expect(dataInfos[0].process).assertEqual(''); + expect(dataInfos[0].uri).assertEqual(''); + expect(dataInfos[0].bundleName).assertEqual(SYSTEM_NAME); + expect(dataInfos[0].moduleName).assertEqual("entry"); + expect(Object.keys(dataInfos[0].applicationInfo).length).assertLarger(0); + expect(dataInfos[0].type).assertEqual(1); + expect(dataInfos[0].orientation).assertEqual(0); + expect(dataInfos[0].launchMode).assertEqual(1); + expect(dataInfos[0].backgroundModes).assertEqual(0); + expect(dataInfos[0].descriptionId).assertLarger(0); + expect(dataInfos[0].formEnabled).assertEqual(false); + expect(dataInfos[0].iconId).assertLarger(0); + expect(dataInfos[0].labelId).assertLarger(0); + expect(dataInfos[0].subType).assertEqual(0); + expect(dataInfos[0].readPermission).assertEqual(""); + expect(dataInfos[0].writePermission).assertEqual(""); + expect(dataInfos[0].targetAbility).assertEqual(""); + expect(dataInfos[0].theme).assertEqual(""); + expect(dataInfos[0].metaData.length).assertEqual(0); + expect(dataInfos[0].metadata.length).assertEqual(0); + expect(dataInfos[0].enabled).assertEqual(true); installer.uninstall(SYSTEM_NAME, installParam, (err, data) => { checkInstallOrUninstall(err, data); done(); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js index 66b0438f5..cd266196c 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsgetinfostest/entry/src/main/js/test/List.test.js @@ -13,5 +13,4 @@ * limitations under the License. */ require('./ActsBmsQueryAbilityByWant.test.js') -require('./ActsBmsCleanCacheTest.test.js') require('./ActsBmsGetBackGroundModes.test.js') -- GitLab